From 5062800bdcd66377c4b2bc3e5d1da47b62b8d2f4 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 15 May 2021 09:30:24 -0400 Subject: [PATCH 1/3] chore: migrate to owl bot --- .github/.OwlBot.lock.yaml | 4 ++ .github/.OwlBot.yaml | 26 +++++++ synth.py => owlbot.py | 15 ++-- synth.metadata | 141 -------------------------------------- 4 files changed, 34 insertions(+), 152 deletions(-) create mode 100644 .github/.OwlBot.lock.yaml create mode 100644 .github/.OwlBot.yaml rename synth.py => owlbot.py (74%) delete mode 100644 synth.metadata diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml new file mode 100644 index 00000000..d49860b3 --- /dev/null +++ b/.github/.OwlBot.lock.yaml @@ -0,0 +1,4 @@ +docker: + digest: sha256:457583330eec64daa02aeb7a72a04d33e7be2428f646671ce4045dcbc0191b1e + image: gcr.io/repo-automation-bots/owlbot-python:latest + diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml new file mode 100644 index 00000000..5a71efc4 --- /dev/null +++ b/.github/.OwlBot.yaml @@ -0,0 +1,26 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +docker: + image: gcr.io/repo-automation-bots/owlbot-python:latest + +deep-remove-regex: + - /owl-bot-staging + +deep-copy-regex: + - source: /google/analytics/admin/(v.*)/.*-py/(.*) + dest: /owl-bot-staging/$1/$2 + +begin-after-commit-hash: ee56c3493ec6aeb237ff515ecea949710944a20f + diff --git a/synth.py b/owlbot.py similarity index 74% rename from synth.py rename to owlbot.py index 8aee0dad..b131a470 100644 --- a/synth.py +++ b/owlbot.py @@ -19,20 +19,14 @@ import synthtool.gcp as gcp from synthtool.languages import python -gapic = gcp.GAPICBazel() common = gcp.CommonTemplates() -# ---------------------------------------------------------------------------- -# Generate analytics admin GAPIC layer -# ---------------------------------------------------------------------------- -library = gapic.py_library( - service="admin", - version="v1alpha", - bazel_target="//google/analytics/admin/v1alpha:google-analytics-admin-v1alpha-py", +default_version = "v1alpha" -) +for library in s.get_staging_dirs(default_version): + s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"]) -s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"]) +s.remove_staging_dirs() # ---------------------------------------------------------------------------- # Add templated files @@ -48,4 +42,3 @@ '''"--cov=google.analytics",''') s.shell.run(["nox", "-s", "blacken"], hide_output=False) - diff --git a/synth.metadata b/synth.metadata deleted file mode 100644 index 9b786010..00000000 --- a/synth.metadata +++ /dev/null @@ -1,141 +0,0 @@ -{ - "sources": [ - { - "git": { - "name": ".", - "remote": "https://github.com/googleapis/python-analytics-admin.git", - "sha": "bf07ed75dc6d22fb52483212e914555194cab40f" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "8ff7d794576311d3d68d4df2ac6da93bbfcd7476", - "internalRef": "366472163" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "043cc620d6a6111816d9e09f2a97208565fde958" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "043cc620d6a6111816d9e09f2a97208565fde958" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "admin", - "apiVersion": "v1alpha", - "language": "python", - "generator": "bazel" - } - } - ], - "generatedFiles": [ - ".coveragerc", - ".flake8", - ".github/CONTRIBUTING.md", - ".github/ISSUE_TEMPLATE/bug_report.md", - ".github/ISSUE_TEMPLATE/feature_request.md", - ".github/ISSUE_TEMPLATE/support_request.md", - ".github/PULL_REQUEST_TEMPLATE.md", - ".github/header-checker-lint.yml", - ".github/release-please.yml", - ".github/snippet-bot.yml", - ".gitignore", - ".kokoro/build.sh", - ".kokoro/continuous/common.cfg", - ".kokoro/continuous/continuous.cfg", - ".kokoro/docker/docs/Dockerfile", - ".kokoro/docker/docs/fetch_gpg_keys.sh", - ".kokoro/docs/common.cfg", - ".kokoro/docs/docs-presubmit.cfg", - ".kokoro/docs/docs.cfg", - ".kokoro/populate-secrets.sh", - ".kokoro/presubmit/common.cfg", - ".kokoro/presubmit/presubmit.cfg", - ".kokoro/publish-docs.sh", - ".kokoro/release.sh", - ".kokoro/release/common.cfg", - ".kokoro/release/release.cfg", - ".kokoro/samples/lint/common.cfg", - ".kokoro/samples/lint/continuous.cfg", - ".kokoro/samples/lint/periodic.cfg", - ".kokoro/samples/lint/presubmit.cfg", - ".kokoro/samples/python3.6/common.cfg", - ".kokoro/samples/python3.6/continuous.cfg", - ".kokoro/samples/python3.6/periodic-head.cfg", - ".kokoro/samples/python3.6/periodic.cfg", - ".kokoro/samples/python3.6/presubmit.cfg", - ".kokoro/samples/python3.7/common.cfg", - ".kokoro/samples/python3.7/continuous.cfg", - ".kokoro/samples/python3.7/periodic-head.cfg", - ".kokoro/samples/python3.7/periodic.cfg", - ".kokoro/samples/python3.7/presubmit.cfg", - ".kokoro/samples/python3.8/common.cfg", - ".kokoro/samples/python3.8/continuous.cfg", - ".kokoro/samples/python3.8/periodic-head.cfg", - ".kokoro/samples/python3.8/periodic.cfg", - ".kokoro/samples/python3.8/presubmit.cfg", - ".kokoro/test-samples-against-head.sh", - ".kokoro/test-samples-impl.sh", - ".kokoro/test-samples.sh", - ".kokoro/trampoline.sh", - ".kokoro/trampoline_v2.sh", - ".pre-commit-config.yaml", - ".trampolinerc", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.rst", - "LICENSE", - "MANIFEST.in", - "docs/_static/custom.css", - "docs/_templates/layout.html", - "docs/admin_v1alpha/analytics_admin_service.rst", - "docs/admin_v1alpha/services.rst", - "docs/admin_v1alpha/types.rst", - "docs/conf.py", - "docs/multiprocessing.rst", - "google-analytics-admin-v1alpha-py.tar.gz", - "google/analytics/admin/__init__.py", - "google/analytics/admin/py.typed", - "google/analytics/admin_v1alpha/__init__.py", - "google/analytics/admin_v1alpha/py.typed", - "google/analytics/admin_v1alpha/services/__init__.py", - "google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py", - "google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py", - "google/analytics/admin_v1alpha/services/analytics_admin_service/client.py", - "google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py", - "google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py", - "google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py", - "google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py", - "google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py", - "google/analytics/admin_v1alpha/types/__init__.py", - "google/analytics/admin_v1alpha/types/analytics_admin.py", - "google/analytics/admin_v1alpha/types/resources.py", - "mypy.ini", - "noxfile.py", - "renovate.json", - "scripts/decrypt-secrets.sh", - "scripts/fixup_admin_v1alpha_keywords.py", - "scripts/readme-gen/readme_gen.py", - "scripts/readme-gen/templates/README.tmpl.rst", - "scripts/readme-gen/templates/auth.tmpl.rst", - "scripts/readme-gen/templates/auth_api_key.tmpl.rst", - "scripts/readme-gen/templates/install_deps.tmpl.rst", - "scripts/readme-gen/templates/install_portaudio.tmpl.rst", - "setup.cfg", - "testing/.gitignore", - "tests/unit/gapic/admin_v1alpha/__init__.py", - "tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py" - ] -} \ No newline at end of file From 6a6f995ae093361007850368484b0dce4a853632 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 15 May 2021 09:36:56 -0400 Subject: [PATCH 2/3] chore: copy files from googleapis-gen ee56c3493ec6aeb237ff515ecea949710944a20f --- owl-bot-staging/v1alpha/MANIFEST.in | 2 + owl-bot-staging/v1alpha/README.rst | 49 + .../admin_v1alpha/analytics_admin_service.rst | 11 + .../v1alpha/docs/admin_v1alpha/services.rst | 6 + .../v1alpha/docs/admin_v1alpha/types.rst | 7 + owl-bot-staging/v1alpha/docs/conf.py | 378 + owl-bot-staging/v1alpha/docs/index.rst | 7 + .../google/analytics/admin/__init__.py | 180 + .../v1alpha/google/analytics/admin/py.typed | 2 + .../analytics/admin_v1alpha/__init__.py | 179 + .../google/analytics/admin_v1alpha/py.typed | 2 + .../admin_v1alpha/services/__init__.py | 16 + .../analytics_admin_service/__init__.py | 24 + .../analytics_admin_service/async_client.py | 4014 +++++ .../analytics_admin_service/client.py | 4333 +++++ .../analytics_admin_service/pagers.py | 1241 ++ .../transports/__init__.py | 35 + .../transports/base.py | 790 + .../transports/grpc.py | 1567 ++ .../transports/grpc_asyncio.py | 1572 ++ .../analytics/admin_v1alpha/types/__init__.py | 180 + .../admin_v1alpha/types/analytics_admin.py | 1354 ++ .../admin_v1alpha/types/resources.py | 712 + owl-bot-staging/v1alpha/mypy.ini | 3 + owl-bot-staging/v1alpha/noxfile.py | 72 + .../scripts/fixup_admin_v1alpha_keywords.py | 226 + owl-bot-staging/v1alpha/setup.py | 55 + .../unit/gapic/admin_v1alpha/__init__.py | 17 + .../test_analytics_admin_service.py | 14201 ++++++++++++++++ 29 files changed, 31235 insertions(+) create mode 100644 owl-bot-staging/v1alpha/MANIFEST.in create mode 100644 owl-bot-staging/v1alpha/README.rst create mode 100644 owl-bot-staging/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst create mode 100644 owl-bot-staging/v1alpha/docs/admin_v1alpha/services.rst create mode 100644 owl-bot-staging/v1alpha/docs/admin_v1alpha/types.rst create mode 100644 owl-bot-staging/v1alpha/docs/conf.py create mode 100644 owl-bot-staging/v1alpha/docs/index.rst create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin/py.typed create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/py.typed create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py create mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py create mode 100644 owl-bot-staging/v1alpha/mypy.ini create mode 100644 owl-bot-staging/v1alpha/noxfile.py create mode 100644 owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py create mode 100644 owl-bot-staging/v1alpha/setup.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py diff --git a/owl-bot-staging/v1alpha/MANIFEST.in b/owl-bot-staging/v1alpha/MANIFEST.in new file mode 100644 index 00000000..0377d1d1 --- /dev/null +++ b/owl-bot-staging/v1alpha/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/analytics/admin *.py +recursive-include google/analytics/admin_v1alpha *.py diff --git a/owl-bot-staging/v1alpha/README.rst b/owl-bot-staging/v1alpha/README.rst new file mode 100644 index 00000000..890880fa --- /dev/null +++ b/owl-bot-staging/v1alpha/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Analytics Admin 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 Analytics Admin 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/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst b/owl-bot-staging/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst new file mode 100644 index 00000000..25d3cf20 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst @@ -0,0 +1,11 @@ +AnalyticsAdminService +--------------------------------------- + +.. automodule:: google.analytics.admin_v1alpha.services.analytics_admin_service + :members: + :inherited-members: + + +.. automodule:: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1alpha/docs/admin_v1alpha/services.rst b/owl-bot-staging/v1alpha/docs/admin_v1alpha/services.rst new file mode 100644 index 00000000..8d20fd9c --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/admin_v1alpha/services.rst @@ -0,0 +1,6 @@ +Services for Google Analytics Admin v1alpha API +=============================================== +.. toctree:: + :maxdepth: 2 + + analytics_admin_service diff --git a/owl-bot-staging/v1alpha/docs/admin_v1alpha/types.rst b/owl-bot-staging/v1alpha/docs/admin_v1alpha/types.rst new file mode 100644 index 00000000..30d49a78 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/admin_v1alpha/types.rst @@ -0,0 +1,7 @@ +Types for Google Analytics Admin v1alpha API +============================================ + +.. automodule:: google.analytics.admin_v1alpha.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha/docs/conf.py b/owl-bot-staging/v1alpha/docs/conf.py new file mode 100644 index 00000000..01d2cf47 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/conf.py @@ -0,0 +1,378 @@ +# -*- 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-analytics-admin 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-analytics-admin" +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 Analytics 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-analytics-admin-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-analytics-admin.tex", + u"google-analytics-admin 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-analytics-admin", + u"Google Analytics Admin 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-analytics-admin", + u"google-analytics-admin Documentation", + author, + "google-analytics-admin", + "GAPIC library for Google Analytics Admin 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/v1alpha/docs/index.rst b/owl-bot-staging/v1alpha/docs/index.rst new file mode 100644 index 00000000..f2ac5cfe --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + admin_v1alpha/services + admin_v1alpha/types diff --git a/owl-bot-staging/v1alpha/google/analytics/admin/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin/__init__.py new file mode 100644 index 00000000..323582ba --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin/__init__.py @@ -0,0 +1,180 @@ +# -*- 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.analytics.admin_v1alpha.services.analytics_admin_service.async_client import AnalyticsAdminServiceAsyncClient +from google.analytics.admin_v1alpha.services.analytics_admin_service.client import AnalyticsAdminServiceClient +from google.analytics.admin_v1alpha.types.analytics_admin import AuditUserLinksRequest +from google.analytics.admin_v1alpha.types.analytics_admin import AuditUserLinksResponse +from google.analytics.admin_v1alpha.types.analytics_admin import BatchCreateUserLinksRequest +from google.analytics.admin_v1alpha.types.analytics_admin import BatchCreateUserLinksResponse +from google.analytics.admin_v1alpha.types.analytics_admin import BatchDeleteUserLinksRequest +from google.analytics.admin_v1alpha.types.analytics_admin import BatchGetUserLinksRequest +from google.analytics.admin_v1alpha.types.analytics_admin import BatchGetUserLinksResponse +from google.analytics.admin_v1alpha.types.analytics_admin import BatchUpdateUserLinksRequest +from google.analytics.admin_v1alpha.types.analytics_admin import BatchUpdateUserLinksResponse +from google.analytics.admin_v1alpha.types.analytics_admin import CreateAndroidAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import CreateFirebaseLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import CreateGoogleAdsLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import CreateIosAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import CreatePropertyRequest +from google.analytics.admin_v1alpha.types.analytics_admin import CreateUserLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import CreateWebDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import DeleteAccountRequest +from google.analytics.admin_v1alpha.types.analytics_admin import DeleteAndroidAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import DeleteFirebaseLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import DeleteGoogleAdsLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import DeleteIosAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import DeletePropertyRequest +from google.analytics.admin_v1alpha.types.analytics_admin import DeleteUserLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import DeleteWebDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetAccountRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetAndroidAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetDataSharingSettingsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetEnhancedMeasurementSettingsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetGlobalSiteTagRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetIosAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetPropertyRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetUserLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetWebDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountSummariesRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountSummariesResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListAndroidAppDataStreamsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListAndroidAppDataStreamsResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListFirebaseLinksRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListFirebaseLinksResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListGoogleAdsLinksRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListGoogleAdsLinksResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListIosAppDataStreamsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListIosAppDataStreamsResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListPropertiesRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListPropertiesResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListUserLinksRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListUserLinksResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListWebDataStreamsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListWebDataStreamsResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ProvisionAccountTicketRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ProvisionAccountTicketResponse +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateAccountRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateAndroidAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateEnhancedMeasurementSettingsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateFirebaseLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateGoogleAdsLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateIosAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdatePropertyRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateUserLinkRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateWebDataStreamRequest +from google.analytics.admin_v1alpha.types.resources import Account +from google.analytics.admin_v1alpha.types.resources import AccountSummary +from google.analytics.admin_v1alpha.types.resources import AndroidAppDataStream +from google.analytics.admin_v1alpha.types.resources import AuditUserLink +from google.analytics.admin_v1alpha.types.resources import DataSharingSettings +from google.analytics.admin_v1alpha.types.resources import EnhancedMeasurementSettings +from google.analytics.admin_v1alpha.types.resources import FirebaseLink +from google.analytics.admin_v1alpha.types.resources import GlobalSiteTag +from google.analytics.admin_v1alpha.types.resources import GoogleAdsLink +from google.analytics.admin_v1alpha.types.resources import IndustryCategory +from google.analytics.admin_v1alpha.types.resources import IosAppDataStream +from google.analytics.admin_v1alpha.types.resources import MaximumUserAccess +from google.analytics.admin_v1alpha.types.resources import Property +from google.analytics.admin_v1alpha.types.resources import PropertySummary +from google.analytics.admin_v1alpha.types.resources import UserLink +from google.analytics.admin_v1alpha.types.resources import WebDataStream + +__all__ = ( + 'Account', + 'AccountSummary', + 'AnalyticsAdminServiceAsyncClient', + 'AnalyticsAdminServiceClient', + 'AndroidAppDataStream', + 'AuditUserLink', + 'AuditUserLinksRequest', + 'AuditUserLinksResponse', + 'BatchCreateUserLinksRequest', + 'BatchCreateUserLinksResponse', + 'BatchDeleteUserLinksRequest', + 'BatchGetUserLinksRequest', + 'BatchGetUserLinksResponse', + 'BatchUpdateUserLinksRequest', + 'BatchUpdateUserLinksResponse', + 'CreateAndroidAppDataStreamRequest', + 'CreateFirebaseLinkRequest', + 'CreateGoogleAdsLinkRequest', + 'CreateIosAppDataStreamRequest', + 'CreatePropertyRequest', + 'CreateUserLinkRequest', + 'CreateWebDataStreamRequest', + 'DataSharingSettings', + 'DeleteAccountRequest', + 'DeleteAndroidAppDataStreamRequest', + 'DeleteFirebaseLinkRequest', + 'DeleteGoogleAdsLinkRequest', + 'DeleteIosAppDataStreamRequest', + 'DeletePropertyRequest', + 'DeleteUserLinkRequest', + 'DeleteWebDataStreamRequest', + 'EnhancedMeasurementSettings', + 'FirebaseLink', + 'GetAccountRequest', + 'GetAndroidAppDataStreamRequest', + 'GetDataSharingSettingsRequest', + 'GetEnhancedMeasurementSettingsRequest', + 'GetGlobalSiteTagRequest', + 'GetIosAppDataStreamRequest', + 'GetPropertyRequest', + 'GetUserLinkRequest', + 'GetWebDataStreamRequest', + 'GlobalSiteTag', + 'GoogleAdsLink', + 'IndustryCategory', + 'IosAppDataStream', + 'ListAccountSummariesRequest', + 'ListAccountSummariesResponse', + 'ListAccountsRequest', + 'ListAccountsResponse', + 'ListAndroidAppDataStreamsRequest', + 'ListAndroidAppDataStreamsResponse', + 'ListFirebaseLinksRequest', + 'ListFirebaseLinksResponse', + 'ListGoogleAdsLinksRequest', + 'ListGoogleAdsLinksResponse', + 'ListIosAppDataStreamsRequest', + 'ListIosAppDataStreamsResponse', + 'ListPropertiesRequest', + 'ListPropertiesResponse', + 'ListUserLinksRequest', + 'ListUserLinksResponse', + 'ListWebDataStreamsRequest', + 'ListWebDataStreamsResponse', + 'MaximumUserAccess', + 'Property', + 'PropertySummary', + 'ProvisionAccountTicketRequest', + 'ProvisionAccountTicketResponse', + 'UpdateAccountRequest', + 'UpdateAndroidAppDataStreamRequest', + 'UpdateEnhancedMeasurementSettingsRequest', + 'UpdateFirebaseLinkRequest', + 'UpdateGoogleAdsLinkRequest', + 'UpdateIosAppDataStreamRequest', + 'UpdatePropertyRequest', + 'UpdateUserLinkRequest', + 'UpdateWebDataStreamRequest', + 'UserLink', + 'WebDataStream', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin/py.typed b/owl-bot-staging/v1alpha/google/analytics/admin/py.typed new file mode 100644 index 00000000..3b7eb147 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-analytics-admin package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py new file mode 100644 index 00000000..38cfae6f --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py @@ -0,0 +1,179 @@ +# -*- 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.analytics_admin_service import AnalyticsAdminServiceClient +from .types.analytics_admin import AuditUserLinksRequest +from .types.analytics_admin import AuditUserLinksResponse +from .types.analytics_admin import BatchCreateUserLinksRequest +from .types.analytics_admin import BatchCreateUserLinksResponse +from .types.analytics_admin import BatchDeleteUserLinksRequest +from .types.analytics_admin import BatchGetUserLinksRequest +from .types.analytics_admin import BatchGetUserLinksResponse +from .types.analytics_admin import BatchUpdateUserLinksRequest +from .types.analytics_admin import BatchUpdateUserLinksResponse +from .types.analytics_admin import CreateAndroidAppDataStreamRequest +from .types.analytics_admin import CreateFirebaseLinkRequest +from .types.analytics_admin import CreateGoogleAdsLinkRequest +from .types.analytics_admin import CreateIosAppDataStreamRequest +from .types.analytics_admin import CreatePropertyRequest +from .types.analytics_admin import CreateUserLinkRequest +from .types.analytics_admin import CreateWebDataStreamRequest +from .types.analytics_admin import DeleteAccountRequest +from .types.analytics_admin import DeleteAndroidAppDataStreamRequest +from .types.analytics_admin import DeleteFirebaseLinkRequest +from .types.analytics_admin import DeleteGoogleAdsLinkRequest +from .types.analytics_admin import DeleteIosAppDataStreamRequest +from .types.analytics_admin import DeletePropertyRequest +from .types.analytics_admin import DeleteUserLinkRequest +from .types.analytics_admin import DeleteWebDataStreamRequest +from .types.analytics_admin import GetAccountRequest +from .types.analytics_admin import GetAndroidAppDataStreamRequest +from .types.analytics_admin import GetDataSharingSettingsRequest +from .types.analytics_admin import GetEnhancedMeasurementSettingsRequest +from .types.analytics_admin import GetGlobalSiteTagRequest +from .types.analytics_admin import GetIosAppDataStreamRequest +from .types.analytics_admin import GetPropertyRequest +from .types.analytics_admin import GetUserLinkRequest +from .types.analytics_admin import GetWebDataStreamRequest +from .types.analytics_admin import ListAccountSummariesRequest +from .types.analytics_admin import ListAccountSummariesResponse +from .types.analytics_admin import ListAccountsRequest +from .types.analytics_admin import ListAccountsResponse +from .types.analytics_admin import ListAndroidAppDataStreamsRequest +from .types.analytics_admin import ListAndroidAppDataStreamsResponse +from .types.analytics_admin import ListFirebaseLinksRequest +from .types.analytics_admin import ListFirebaseLinksResponse +from .types.analytics_admin import ListGoogleAdsLinksRequest +from .types.analytics_admin import ListGoogleAdsLinksResponse +from .types.analytics_admin import ListIosAppDataStreamsRequest +from .types.analytics_admin import ListIosAppDataStreamsResponse +from .types.analytics_admin import ListPropertiesRequest +from .types.analytics_admin import ListPropertiesResponse +from .types.analytics_admin import ListUserLinksRequest +from .types.analytics_admin import ListUserLinksResponse +from .types.analytics_admin import ListWebDataStreamsRequest +from .types.analytics_admin import ListWebDataStreamsResponse +from .types.analytics_admin import ProvisionAccountTicketRequest +from .types.analytics_admin import ProvisionAccountTicketResponse +from .types.analytics_admin import UpdateAccountRequest +from .types.analytics_admin import UpdateAndroidAppDataStreamRequest +from .types.analytics_admin import UpdateEnhancedMeasurementSettingsRequest +from .types.analytics_admin import UpdateFirebaseLinkRequest +from .types.analytics_admin import UpdateGoogleAdsLinkRequest +from .types.analytics_admin import UpdateIosAppDataStreamRequest +from .types.analytics_admin import UpdatePropertyRequest +from .types.analytics_admin import UpdateUserLinkRequest +from .types.analytics_admin import UpdateWebDataStreamRequest +from .types.resources import Account +from .types.resources import AccountSummary +from .types.resources import AndroidAppDataStream +from .types.resources import AuditUserLink +from .types.resources import DataSharingSettings +from .types.resources import EnhancedMeasurementSettings +from .types.resources import FirebaseLink +from .types.resources import GlobalSiteTag +from .types.resources import GoogleAdsLink +from .types.resources import IndustryCategory +from .types.resources import IosAppDataStream +from .types.resources import MaximumUserAccess +from .types.resources import Property +from .types.resources import PropertySummary +from .types.resources import UserLink +from .types.resources import WebDataStream + + +__all__ = ( + 'Account', + 'AccountSummary', + 'AndroidAppDataStream', + 'AuditUserLink', + 'AuditUserLinksRequest', + 'AuditUserLinksResponse', + 'BatchCreateUserLinksRequest', + 'BatchCreateUserLinksResponse', + 'BatchDeleteUserLinksRequest', + 'BatchGetUserLinksRequest', + 'BatchGetUserLinksResponse', + 'BatchUpdateUserLinksRequest', + 'BatchUpdateUserLinksResponse', + 'CreateAndroidAppDataStreamRequest', + 'CreateFirebaseLinkRequest', + 'CreateGoogleAdsLinkRequest', + 'CreateIosAppDataStreamRequest', + 'CreatePropertyRequest', + 'CreateUserLinkRequest', + 'CreateWebDataStreamRequest', + 'DataSharingSettings', + 'DeleteAccountRequest', + 'DeleteAndroidAppDataStreamRequest', + 'DeleteFirebaseLinkRequest', + 'DeleteGoogleAdsLinkRequest', + 'DeleteIosAppDataStreamRequest', + 'DeletePropertyRequest', + 'DeleteUserLinkRequest', + 'DeleteWebDataStreamRequest', + 'EnhancedMeasurementSettings', + 'FirebaseLink', + 'GetAccountRequest', + 'GetAndroidAppDataStreamRequest', + 'GetDataSharingSettingsRequest', + 'GetEnhancedMeasurementSettingsRequest', + 'GetGlobalSiteTagRequest', + 'GetIosAppDataStreamRequest', + 'GetPropertyRequest', + 'GetUserLinkRequest', + 'GetWebDataStreamRequest', + 'GlobalSiteTag', + 'GoogleAdsLink', + 'IndustryCategory', + 'IosAppDataStream', + 'ListAccountSummariesRequest', + 'ListAccountSummariesResponse', + 'ListAccountsRequest', + 'ListAccountsResponse', + 'ListAndroidAppDataStreamsRequest', + 'ListAndroidAppDataStreamsResponse', + 'ListFirebaseLinksRequest', + 'ListFirebaseLinksResponse', + 'ListGoogleAdsLinksRequest', + 'ListGoogleAdsLinksResponse', + 'ListIosAppDataStreamsRequest', + 'ListIosAppDataStreamsResponse', + 'ListPropertiesRequest', + 'ListPropertiesResponse', + 'ListUserLinksRequest', + 'ListUserLinksResponse', + 'ListWebDataStreamsRequest', + 'ListWebDataStreamsResponse', + 'MaximumUserAccess', + 'Property', + 'PropertySummary', + 'ProvisionAccountTicketRequest', + 'ProvisionAccountTicketResponse', + 'UpdateAccountRequest', + 'UpdateAndroidAppDataStreamRequest', + 'UpdateEnhancedMeasurementSettingsRequest', + 'UpdateFirebaseLinkRequest', + 'UpdateGoogleAdsLinkRequest', + 'UpdateIosAppDataStreamRequest', + 'UpdatePropertyRequest', + 'UpdateUserLinkRequest', + 'UpdateWebDataStreamRequest', + 'UserLink', + 'WebDataStream', +'AnalyticsAdminServiceClient', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/py.typed b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/py.typed new file mode 100644 index 00000000..3b7eb147 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-analytics-admin package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__init__.py new file mode 100644 index 00000000..42ffdf2b --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__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/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py new file mode 100644 index 00000000..f5002cbc --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py @@ -0,0 +1,24 @@ +# -*- 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 AnalyticsAdminServiceClient +from .async_client import AnalyticsAdminServiceAsyncClient + +__all__ = ( + 'AnalyticsAdminServiceClient', + 'AnalyticsAdminServiceAsyncClient', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py new file mode 100644 index 00000000..0d1d0050 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py @@ -0,0 +1,4014 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers +from google.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import wrappers_pb2 as wrappers # type: ignore + +from .transports.base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport +from .client import AnalyticsAdminServiceClient + + +class AnalyticsAdminServiceAsyncClient: + """Service Interface for the Analytics Admin API (GA4).""" + + _client: AnalyticsAdminServiceClient + + DEFAULT_ENDPOINT = AnalyticsAdminServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = AnalyticsAdminServiceClient.DEFAULT_MTLS_ENDPOINT + + account_path = staticmethod(AnalyticsAdminServiceClient.account_path) + parse_account_path = staticmethod(AnalyticsAdminServiceClient.parse_account_path) + account_summary_path = staticmethod(AnalyticsAdminServiceClient.account_summary_path) + parse_account_summary_path = staticmethod(AnalyticsAdminServiceClient.parse_account_summary_path) + android_app_data_stream_path = staticmethod(AnalyticsAdminServiceClient.android_app_data_stream_path) + parse_android_app_data_stream_path = staticmethod(AnalyticsAdminServiceClient.parse_android_app_data_stream_path) + data_sharing_settings_path = staticmethod(AnalyticsAdminServiceClient.data_sharing_settings_path) + parse_data_sharing_settings_path = staticmethod(AnalyticsAdminServiceClient.parse_data_sharing_settings_path) + enhanced_measurement_settings_path = staticmethod(AnalyticsAdminServiceClient.enhanced_measurement_settings_path) + parse_enhanced_measurement_settings_path = staticmethod(AnalyticsAdminServiceClient.parse_enhanced_measurement_settings_path) + firebase_link_path = staticmethod(AnalyticsAdminServiceClient.firebase_link_path) + parse_firebase_link_path = staticmethod(AnalyticsAdminServiceClient.parse_firebase_link_path) + global_site_tag_path = staticmethod(AnalyticsAdminServiceClient.global_site_tag_path) + parse_global_site_tag_path = staticmethod(AnalyticsAdminServiceClient.parse_global_site_tag_path) + google_ads_link_path = staticmethod(AnalyticsAdminServiceClient.google_ads_link_path) + parse_google_ads_link_path = staticmethod(AnalyticsAdminServiceClient.parse_google_ads_link_path) + ios_app_data_stream_path = staticmethod(AnalyticsAdminServiceClient.ios_app_data_stream_path) + parse_ios_app_data_stream_path = staticmethod(AnalyticsAdminServiceClient.parse_ios_app_data_stream_path) + property_path = staticmethod(AnalyticsAdminServiceClient.property_path) + parse_property_path = staticmethod(AnalyticsAdminServiceClient.parse_property_path) + user_link_path = staticmethod(AnalyticsAdminServiceClient.user_link_path) + parse_user_link_path = staticmethod(AnalyticsAdminServiceClient.parse_user_link_path) + web_data_stream_path = staticmethod(AnalyticsAdminServiceClient.web_data_stream_path) + parse_web_data_stream_path = staticmethod(AnalyticsAdminServiceClient.parse_web_data_stream_path) + + common_billing_account_path = staticmethod(AnalyticsAdminServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(AnalyticsAdminServiceClient.parse_common_billing_account_path) + + common_folder_path = staticmethod(AnalyticsAdminServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(AnalyticsAdminServiceClient.parse_common_folder_path) + + common_organization_path = staticmethod(AnalyticsAdminServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(AnalyticsAdminServiceClient.parse_common_organization_path) + + common_project_path = staticmethod(AnalyticsAdminServiceClient.common_project_path) + parse_common_project_path = staticmethod(AnalyticsAdminServiceClient.parse_common_project_path) + + common_location_path = staticmethod(AnalyticsAdminServiceClient.common_location_path) + parse_common_location_path = staticmethod(AnalyticsAdminServiceClient.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: + AnalyticsAdminServiceAsyncClient: The constructed client. + """ + return AnalyticsAdminServiceClient.from_service_account_info.__func__(AnalyticsAdminServiceAsyncClient, 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: + AnalyticsAdminServiceAsyncClient: The constructed client. + """ + return AnalyticsAdminServiceClient.from_service_account_file.__func__(AnalyticsAdminServiceAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> AnalyticsAdminServiceTransport: + """Return the transport used by the client instance. + + Returns: + AnalyticsAdminServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(AnalyticsAdminServiceClient).get_transport_class, type(AnalyticsAdminServiceClient)) + + def __init__(self, *, + credentials: credentials.Credentials = None, + transport: Union[str, AnalyticsAdminServiceTransport] = 'grpc_asyncio', + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the analytics admin service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.AnalyticsAdminServiceTransport]): 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 = AnalyticsAdminServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def get_account(self, + request: analytics_admin.GetAccountRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Account: + r"""Lookup for a single Account. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetAccountRequest`): + The request object. Request message for GetAccount RPC. + name (:class:`str`): + Required. The name of the account to + lookup. Format: accounts/{account} + Example: "accounts/100" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.Account: + A resource message representing a + Google Analytics account. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = analytics_admin.GetAccountRequest(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_account, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_accounts(self, + request: analytics_admin.ListAccountsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAccountsAsyncPager: + r"""Returns all accounts accessible by the caller. + Note that these accounts might not currently have GA4 + properties. Soft-deleted (ie: "trashed") accounts are + excluded by default. Returns an empty list if no + relevant accounts are found. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListAccountsRequest`): + The request object. Request message for ListAccounts + RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsAsyncPager: + Request message for ListAccounts RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.ListAccountsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_accounts, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListAccountsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_account(self, + request: analytics_admin.DeleteAccountRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Marks target Account as soft-deleted (ie: "trashed") + and returns it. + This API does not have a method to restore soft-deleted + accounts. However, they can be restored using the Trash + Can UI. + If the accounts are not restored before the expiration + time, the account and all child resources (eg: + Properties, GoogleAdsLinks, Streams, UserLinks) will be + permanently purged. + https://support.google.com/analytics/answer/6154772 + Returns an error if the target is not found. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteAccountRequest`): + The request object. Request message for DeleteAccount + RPC. + name (:class:`str`): + Required. The name of the Account to + soft-delete. Format: accounts/{account} + Example: "accounts/100" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.DeleteAccountRequest(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_account, + 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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def update_account(self, + request: analytics_admin.UpdateAccountRequest = None, + *, + account: resources.Account = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Account: + r"""Updates an account. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateAccountRequest`): + The request object. Request message for UpdateAccount + RPC. + account (:class:`google.analytics.admin_v1alpha.types.Account`): + Required. The account to update. The account's ``name`` + field is used to identify the account. + + This corresponds to the ``account`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.Account: + A resource message representing a + Google Analytics account. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([account, 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 = analytics_admin.UpdateAccountRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if account is not None: + request.account = account + 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_account, + 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(( + ('account.name', request.account.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def provision_account_ticket(self, + request: analytics_admin.ProvisionAccountTicketRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.ProvisionAccountTicketResponse: + r"""Requests a ticket for creating an account. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ProvisionAccountTicketRequest`): + The request object. Request message for + ProvisionAccountTicket RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.ProvisionAccountTicketResponse: + Response message for + ProvisionAccountTicket RPC. + + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.ProvisionAccountTicketRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.provision_account_ticket, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_account_summaries(self, + request: analytics_admin.ListAccountSummariesRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAccountSummariesAsyncPager: + r"""Returns summaries of all accounts accessible by the + caller. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListAccountSummariesRequest`): + The request object. Request message for + ListAccountSummaries RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountSummariesAsyncPager: + Response message for + ListAccountSummaries RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.ListAccountSummariesRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_account_summaries, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListAccountSummariesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_property(self, + request: analytics_admin.GetPropertyRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Property: + r"""Lookup for a single "GA4" Property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetPropertyRequest`): + The request object. Request message for GetProperty RPC. + name (:class:`str`): + Required. The name of the property to lookup. Format: + properties/{property_id} Example: "properties/1000" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.Property: + A resource message representing a + Google Analytics GA4 property. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = analytics_admin.GetPropertyRequest(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_property, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_properties(self, + request: analytics_admin.ListPropertiesRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPropertiesAsyncPager: + r"""Returns child Properties under the specified parent + Account. + Only "GA4" properties will be returned. + Properties will be excluded if the caller does not have + access. Soft-deleted (ie: "trashed") properties are + excluded by default. Returns an empty list if no + relevant properties are found. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListPropertiesRequest`): + The request object. Request message for ListProperties + RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListPropertiesAsyncPager: + Response message for ListProperties + RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.ListPropertiesRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_properties, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListPropertiesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_property(self, + request: analytics_admin.CreatePropertyRequest = None, + *, + property: resources.Property = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Property: + r"""Creates an "GA4" property with the specified location + and attributes. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreatePropertyRequest`): + The request object. Request message for CreateProperty + RPC. + property (:class:`google.analytics.admin_v1alpha.types.Property`): + Required. The property to create. + Note: the supplied property must specify + its parent. + + This corresponds to the ``property`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.Property: + A resource message representing a + Google Analytics GA4 property. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([property]) + if request is 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 = analytics_admin.CreatePropertyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if property is not None: + request.property = property + + # 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_property, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_property(self, + request: analytics_admin.DeletePropertyRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Marks target Property as soft-deleted (ie: "trashed") + and returns it. + This API does not have a method to restore soft-deleted + properties. However, they can be restored using the + Trash Can UI. + If the properties are not restored before the expiration + time, the Property and all child resources (eg: + GoogleAdsLinks, Streams, UserLinks) will be permanently + purged. + https://support.google.com/analytics/answer/6154772 + Returns an error if the target is not found, or is not + an GA4 Property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeletePropertyRequest`): + The request object. Request message for DeleteProperty + RPC. + name (:class:`str`): + Required. The name of the Property to soft-delete. + Format: properties/{property_id} Example: + "properties/1000" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.DeletePropertyRequest(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_property, + 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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def update_property(self, + request: analytics_admin.UpdatePropertyRequest = None, + *, + property: resources.Property = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Property: + r"""Updates a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdatePropertyRequest`): + The request object. Request message for UpdateProperty + RPC. + property (:class:`google.analytics.admin_v1alpha.types.Property`): + Required. The property to update. The property's + ``name`` field is used to identify the property to be + updated. + + This corresponds to the ``property`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.Property: + A resource message representing a + Google Analytics GA4 property. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([property, 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 = analytics_admin.UpdatePropertyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if property is not None: + request.property = property + 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_property, + 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(( + ('property.name', request.property.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_user_link(self, + request: analytics_admin.GetUserLinkRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.UserLink: + r"""Gets information about a user's link to an account or + property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetUserLinkRequest`): + The request object. Request message for GetUserLink RPC. + name (:class:`str`): + Required. Example format: + accounts/1234/userLinks/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.UserLink: + A resource message representing a + user's permissions on an Account or + Property resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.GetUserLinkRequest(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_user_link, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def batch_get_user_links(self, + request: analytics_admin.BatchGetUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchGetUserLinksResponse: + r"""Gets information about multiple users' links to an + account or property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest`): + The request object. Request message for + BatchGetUserLinks RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse: + Response message for + BatchGetUserLinks RPC. + + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.BatchGetUserLinksRequest(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.batch_get_user_links, + 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, + ) + + # Done; return the response. + return response + + async def list_user_links(self, + request: analytics_admin.ListUserLinksRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListUserLinksAsyncPager: + r"""Lists all user links on an account or property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListUserLinksRequest`): + The request object. Request message for ListUserLinks + RPC. + parent (:class:`str`): + Required. Example format: + accounts/1234 + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListUserLinksAsyncPager: + Response message for ListUserLinks + RPC. + 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 = analytics_admin.ListUserLinksRequest(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_user_links, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListUserLinksAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def audit_user_links(self, + request: analytics_admin.AuditUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.AuditUserLinksAsyncPager: + r"""Lists all user links on an account or property, + including implicit ones that come from effective + permissions granted by groups or organization admin + roles. + + If a returned user link does not have direct + permissions, they cannot be removed from the account or + property directly with the DeleteUserLink command. They + have to be removed from the group/etc that gives them + permissions, which is currently only usable/discoverable + in the GA or GMP UIs. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.AuditUserLinksRequest`): + The request object. Request message for AuditUserLinks + RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.AuditUserLinksAsyncPager: + Response message for AuditUserLinks + RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.AuditUserLinksRequest(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.audit_user_links, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.AuditUserLinksAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_user_link(self, + request: analytics_admin.CreateUserLinkRequest = None, + *, + parent: str = None, + user_link: resources.UserLink = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.UserLink: + r"""Creates a user link on an account or property. + If the user with the specified email already has + permissions on the account or property, then the user's + existing permissions will be unioned with the + permissions specified in the new UserLink. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateUserLinkRequest`): + The request object. Request message for CreateUserLink + RPC. + Users can have multiple email addresses associated with + their Google account, and one of these email addresses + is the "primary" email address. Any of the email + addresses associated with a Google account may be used + for a new UserLink, but the returned UserLink will + always contain the "primary" email address. As a result, + the input and output email address for this request may + differ. + parent (:class:`str`): + Required. Example format: + accounts/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + user_link (:class:`google.analytics.admin_v1alpha.types.UserLink`): + Required. The user link to create. + This corresponds to the ``user_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.UserLink: + A resource message representing a + user's permissions on an Account or + Property resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, user_link]) + if request is 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 = analytics_admin.CreateUserLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if user_link is not None: + request.user_link = user_link + + # 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_user_link, + 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, + ) + + # Done; return the response. + return response + + async def batch_create_user_links(self, + request: analytics_admin.BatchCreateUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchCreateUserLinksResponse: + r"""Creates information about multiple users' links to an + account or property. + This method is transactional. If any UserLink cannot be + created, none of the UserLinks will be created. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest`): + The request object. Request message for + BatchCreateUserLinks RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse: + Response message for + BatchCreateUserLinks RPC. + + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.BatchCreateUserLinksRequest(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.batch_create_user_links, + 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, + ) + + # Done; return the response. + return response + + async def update_user_link(self, + request: analytics_admin.UpdateUserLinkRequest = None, + *, + user_link: resources.UserLink = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.UserLink: + r"""Updates a user link on an account or property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateUserLinkRequest`): + The request object. Request message for UpdateUserLink + RPC. + user_link (:class:`google.analytics.admin_v1alpha.types.UserLink`): + Required. The user link to update. + This corresponds to the ``user_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.UserLink: + A resource message representing a + user's permissions on an Account or + Property resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([user_link]) + if request is 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 = analytics_admin.UpdateUserLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if user_link is not None: + request.user_link = user_link + + # 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_user_link, + 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(( + ('user_link.name', request.user_link.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def batch_update_user_links(self, + request: analytics_admin.BatchUpdateUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchUpdateUserLinksResponse: + r"""Updates information about multiple users' links to an + account or property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest`): + The request object. Request message for + BatchUpdateUserLinks RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse: + Response message for + BatchUpdateUserLinks RPC. + + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.BatchUpdateUserLinksRequest(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.batch_update_user_links, + 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, + ) + + # Done; return the response. + return response + + async def delete_user_link(self, + request: analytics_admin.DeleteUserLinkRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a user link on an account or property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteUserLinkRequest`): + The request object. Request message for DeleteUserLink + RPC. + name (:class:`str`): + Required. Example format: + accounts/1234/userLinks/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.DeleteUserLinkRequest(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_user_link, + 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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def batch_delete_user_links(self, + request: analytics_admin.BatchDeleteUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes information about multiple users' links to an + account or property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest`): + The request object. Request message for + BatchDeleteUserLinks RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + + request = analytics_admin.BatchDeleteUserLinksRequest(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.batch_delete_user_links, + 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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def get_web_data_stream(self, + request: analytics_admin.GetWebDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.WebDataStream: + r"""Lookup for a single WebDataStream + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetWebDataStreamRequest`): + The request object. Request message for GetWebDataStream + RPC. + name (:class:`str`): + Required. The name of the web data stream to lookup. + Format: + properties/{property_id}/webDataStreams/{stream_id} + Example: "properties/123/webDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.WebDataStream: + A resource message representing a + Google Analytics web 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 = analytics_admin.GetWebDataStreamRequest(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_web_data_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, + ) + + # Done; return the response. + return response + + async def delete_web_data_stream(self, + request: analytics_admin.DeleteWebDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a web stream on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteWebDataStreamRequest`): + The request object. Request message for + DeleteWebDataStream RPC. + name (:class:`str`): + Required. The name of the web data stream to delete. + Format: + properties/{property_id}/webDataStreams/{stream_id} + Example: "properties/123/webDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.DeleteWebDataStreamRequest(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_web_data_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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def update_web_data_stream(self, + request: analytics_admin.UpdateWebDataStreamRequest = None, + *, + web_data_stream: resources.WebDataStream = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.WebDataStream: + r"""Updates a web stream on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateWebDataStreamRequest`): + The request object. Request message for + UpdateWebDataStream RPC. + web_data_stream (:class:`google.analytics.admin_v1alpha.types.WebDataStream`): + Required. The web stream to update. The ``name`` field + is used to identify the web stream to be updated. + + This corresponds to the ``web_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.WebDataStream: + A resource message representing a + Google Analytics web 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([web_data_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 = analytics_admin.UpdateWebDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if web_data_stream is not None: + request.web_data_stream = web_data_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_web_data_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(( + ('web_data_stream.name', request.web_data_stream.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_web_data_stream(self, + request: analytics_admin.CreateWebDataStreamRequest = None, + *, + parent: str = None, + web_data_stream: resources.WebDataStream = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.WebDataStream: + r"""Creates a web stream with the specified location and + attributes. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateWebDataStreamRequest`): + The request object. Request message for + CreateWebDataStream RPC. + parent (:class:`str`): + Required. The parent resource where + this web data stream will be created. + Format: properties/123 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + web_data_stream (:class:`google.analytics.admin_v1alpha.types.WebDataStream`): + Required. The web stream to create. + This corresponds to the ``web_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.WebDataStream: + A resource message representing a + Google Analytics web 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, web_data_stream]) + if request is 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 = analytics_admin.CreateWebDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if web_data_stream is not None: + request.web_data_stream = web_data_stream + + # 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_web_data_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, + ) + + # Done; return the response. + return response + + async def list_web_data_streams(self, + request: analytics_admin.ListWebDataStreamsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListWebDataStreamsAsyncPager: + r"""Returns child web data streams under the specified + parent property. + Web data streams will be excluded if the caller does not + have access. Returns an empty list if no relevant web + data streams are found. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest`): + The request object. Request message for + ListWebDataStreams RPC. + parent (:class:`str`): + Required. The name of the parent + property. For example, to list results + of web streams under the property with + Id 123: "properties/123" + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListWebDataStreamsAsyncPager: + Request message for + ListWebDataStreams RPC. + 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 = analytics_admin.ListWebDataStreamsRequest(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_web_data_streams, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListWebDataStreamsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_ios_app_data_stream(self, + request: analytics_admin.GetIosAppDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IosAppDataStream: + r"""Lookup for a single IosAppDataStream + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetIosAppDataStreamRequest`): + The request object. Request message for + GetIosAppDataStream RPC. + name (:class:`str`): + Required. The name of the iOS app data stream to lookup. + Format: + properties/{property_id}/iosAppDataStreams/{stream_id} + Example: "properties/123/iosAppDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.IosAppDataStream: + A resource message representing a + Google Analytics IOS app 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 = analytics_admin.GetIosAppDataStreamRequest(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_ios_app_data_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, + ) + + # Done; return the response. + return response + + async def delete_ios_app_data_stream(self, + request: analytics_admin.DeleteIosAppDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an iOS app stream on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteIosAppDataStreamRequest`): + The request object. Request message for + DeleteIosAppDataStream RPC. + name (:class:`str`): + Required. The name of the iOS app data stream to delete. + Format: + properties/{property_id}/iosAppDataStreams/{stream_id} + Example: "properties/123/iosAppDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.DeleteIosAppDataStreamRequest(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_ios_app_data_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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def update_ios_app_data_stream(self, + request: analytics_admin.UpdateIosAppDataStreamRequest = None, + *, + ios_app_data_stream: resources.IosAppDataStream = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IosAppDataStream: + r"""Updates an iOS app stream on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateIosAppDataStreamRequest`): + The request object. Request message for + UpdateIosAppDataStream RPC. + ios_app_data_stream (:class:`google.analytics.admin_v1alpha.types.IosAppDataStream`): + Required. The iOS app stream to update. The ``name`` + field is used to identify the iOS app stream to be + updated. + + This corresponds to the ``ios_app_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.IosAppDataStream: + A resource message representing a + Google Analytics IOS app 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([ios_app_data_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 = analytics_admin.UpdateIosAppDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if ios_app_data_stream is not None: + request.ios_app_data_stream = ios_app_data_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_ios_app_data_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(( + ('ios_app_data_stream.name', request.ios_app_data_stream.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_ios_app_data_stream(self, + request: analytics_admin.CreateIosAppDataStreamRequest = None, + *, + parent: str = None, + ios_app_data_stream: resources.IosAppDataStream = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IosAppDataStream: + r"""Creates an iOS app stream with the specified location + and attributes. + Note that an iOS app stream must be linked to a Firebase + app to receive traffic. + + To create a working app stream, make sure your property + is linked to a Firebase project. Then, use the Firebase + API to create a Firebase app, which will also create an + appropriate data stream in Analytics (may take up to 24 + hours). + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateIosAppDataStreamRequest`): + The request object. Request message for + CreateIosAppDataStream RPC. + parent (:class:`str`): + Required. The parent resource where + this ios app data stream will be + created. Format: properties/123 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + ios_app_data_stream (:class:`google.analytics.admin_v1alpha.types.IosAppDataStream`): + Required. The iOS app data stream to + create. + + This corresponds to the ``ios_app_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.IosAppDataStream: + A resource message representing a + Google Analytics IOS app 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, ios_app_data_stream]) + if request is 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 = analytics_admin.CreateIosAppDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if ios_app_data_stream is not None: + request.ios_app_data_stream = ios_app_data_stream + + # 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_ios_app_data_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, + ) + + # Done; return the response. + return response + + async def list_ios_app_data_streams(self, + request: analytics_admin.ListIosAppDataStreamsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListIosAppDataStreamsAsyncPager: + r"""Returns child iOS app data streams under the + specified parent property. + iOS app data streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + iOS app data streams are found. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest`): + The request object. Request message for + ListIosAppDataStreams RPC. + parent (:class:`str`): + Required. The name of the parent + property. For example, to list results + of app streams under the property with + Id 123: "properties/123" + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListIosAppDataStreamsAsyncPager: + Request message for + ListIosAppDataStreams RPC. + 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 = analytics_admin.ListIosAppDataStreamsRequest(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_ios_app_data_streams, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListIosAppDataStreamsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_android_app_data_stream(self, + request: analytics_admin.GetAndroidAppDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AndroidAppDataStream: + r"""Lookup for a single AndroidAppDataStream + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetAndroidAppDataStreamRequest`): + The request object. Request message for + GetAndroidAppDataStream RPC. + name (:class:`str`): + Required. The name of the android app data stream to + lookup. Format: + properties/{property_id}/androidAppDataStreams/{stream_id} + Example: "properties/123/androidAppDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: + A resource message representing a + Google Analytics Android app 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 = analytics_admin.GetAndroidAppDataStreamRequest(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_android_app_data_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, + ) + + # Done; return the response. + return response + + async def delete_android_app_data_stream(self, + request: analytics_admin.DeleteAndroidAppDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an android app stream on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteAndroidAppDataStreamRequest`): + The request object. Request message for + DeleteAndroidAppDataStream RPC. + name (:class:`str`): + Required. The name of the android app data stream to + delete. Format: + properties/{property_id}/androidAppDataStreams/{stream_id} + Example: "properties/123/androidAppDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.DeleteAndroidAppDataStreamRequest(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_android_app_data_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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def update_android_app_data_stream(self, + request: analytics_admin.UpdateAndroidAppDataStreamRequest = None, + *, + android_app_data_stream: resources.AndroidAppDataStream = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AndroidAppDataStream: + r"""Updates an android app stream on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateAndroidAppDataStreamRequest`): + The request object. Request message for + UpdateAndroidAppDataStream RPC. + android_app_data_stream (:class:`google.analytics.admin_v1alpha.types.AndroidAppDataStream`): + Required. The android app stream to update. The ``name`` + field is used to identify the android app stream to be + updated. + + This corresponds to the ``android_app_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.AndroidAppDataStream: + A resource message representing a + Google Analytics Android app 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([android_app_data_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 = analytics_admin.UpdateAndroidAppDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if android_app_data_stream is not None: + request.android_app_data_stream = android_app_data_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_android_app_data_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(( + ('android_app_data_stream.name', request.android_app_data_stream.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_android_app_data_stream(self, + request: analytics_admin.CreateAndroidAppDataStreamRequest = None, + *, + parent: str = None, + android_app_data_stream: resources.AndroidAppDataStream = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AndroidAppDataStream: + r"""Creates an Android app stream with the specified + location and attributes. + Note that an Android app stream must be linked to a + Firebase app to receive traffic. + + To create a working app stream, make sure your property + is linked to a Firebase project. Then, use the Firebase + API to create a Firebase app, which will also create an + appropriate data stream in Analytics (may take up to 24 + hours). + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateAndroidAppDataStreamRequest`): + The request object. Request message for + CreateAndroidAppDataStream RPC. + parent (:class:`str`): + Required. The parent resource where + this android app data stream will be + created. Format: properties/123 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + android_app_data_stream (:class:`google.analytics.admin_v1alpha.types.AndroidAppDataStream`): + Required. The android app stream to + create. + + This corresponds to the ``android_app_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: + A resource message representing a + Google Analytics Android app 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, android_app_data_stream]) + if request is 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 = analytics_admin.CreateAndroidAppDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if android_app_data_stream is not None: + request.android_app_data_stream = android_app_data_stream + + # 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_android_app_data_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, + ) + + # Done; return the response. + return response + + async def list_android_app_data_streams(self, + request: analytics_admin.ListAndroidAppDataStreamsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAndroidAppDataStreamsAsyncPager: + r"""Returns child android app streams under the specified + parent property. + Android app streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + android app streams are found. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest`): + The request object. Request message for + ListAndroidAppDataStreams RPC. + parent (:class:`str`): + Required. The name of the parent + property. For example, to limit results + to app streams under the property with + Id 123: "properties/123" + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAndroidAppDataStreamsAsyncPager: + Request message for + ListAndroidDataStreams RPC. + 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 = analytics_admin.ListAndroidAppDataStreamsRequest(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_android_app_data_streams, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListAndroidAppDataStreamsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_enhanced_measurement_settings(self, + request: analytics_admin.GetEnhancedMeasurementSettingsRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.EnhancedMeasurementSettings: + r"""Returns the singleton enhanced measurement settings + for this web stream. Note that the stream must enable + enhanced measurement for these settings to take effect. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest`): + The request object. Request message for + GetEnhancedMeasurementSettings RPC. + name (:class:`str`): + Required. The name of the settings to lookup. Format: + properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings + Example: + "properties/1000/webDataStreams/2000/enhancedMeasurementSettings" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: + Singleton resource under a + WebDataStream, configuring measurement + of additional site interactions and + content. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = analytics_admin.GetEnhancedMeasurementSettingsRequest(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_enhanced_measurement_settings, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_enhanced_measurement_settings(self, + request: analytics_admin.UpdateEnhancedMeasurementSettingsRequest = None, + *, + enhanced_measurement_settings: resources.EnhancedMeasurementSettings = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.EnhancedMeasurementSettings: + r"""Updates the singleton enhanced measurement settings + for this web stream. Note that the stream must enable + enhanced measurement for these settings to take effect. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateEnhancedMeasurementSettingsRequest`): + The request object. Request message for + UpdateEnhancedMeasurementSettings RPC. + enhanced_measurement_settings (:class:`google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings`): + Required. The settings to update. The ``name`` field is + used to identify the settings to be updated. + + This corresponds to the ``enhanced_measurement_settings`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: + Singleton resource under a + WebDataStream, configuring measurement + of additional site interactions and + content. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([enhanced_measurement_settings, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if enhanced_measurement_settings is not None: + request.enhanced_measurement_settings = enhanced_measurement_settings + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_enhanced_measurement_settings, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('enhanced_measurement_settings.name', request.enhanced_measurement_settings.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_firebase_link(self, + request: analytics_admin.CreateFirebaseLinkRequest = None, + *, + parent: str = None, + firebase_link: resources.FirebaseLink = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FirebaseLink: + r"""Creates a FirebaseLink. + Properties can have at most one FirebaseLink. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest`): + The request object. Request message for + CreateFirebaseLink RPC + parent (:class:`str`): + Required. Format: properties/{property_id} Example: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + firebase_link (:class:`google.analytics.admin_v1alpha.types.FirebaseLink`): + Required. The Firebase link to + create. + + This corresponds to the ``firebase_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.FirebaseLink: + A link between an GA4 property and a + Firebase project. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, firebase_link]) + if request is 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 = analytics_admin.CreateFirebaseLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if firebase_link is not None: + request.firebase_link = firebase_link + + # 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_firebase_link, + 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, + ) + + # Done; return the response. + return response + + async def update_firebase_link(self, + request: analytics_admin.UpdateFirebaseLinkRequest = None, + *, + firebase_link: resources.FirebaseLink = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FirebaseLink: + r"""Updates a FirebaseLink on a property + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateFirebaseLinkRequest`): + The request object. Request message for + UpdateFirebaseLink RPC + firebase_link (:class:`google.analytics.admin_v1alpha.types.FirebaseLink`): + Required. The Firebase link to + update. + + This corresponds to the ``firebase_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.FirebaseLink: + A link between an GA4 property and a + Firebase project. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([firebase_link, 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 = analytics_admin.UpdateFirebaseLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if firebase_link is not None: + request.firebase_link = firebase_link + 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_firebase_link, + 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(( + ('firebase_link.name', request.firebase_link.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_firebase_link(self, + request: analytics_admin.DeleteFirebaseLinkRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a FirebaseLink on a property + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteFirebaseLinkRequest`): + The request object. Request message for + DeleteFirebaseLink RPC + name (:class:`str`): + Required. Format: + properties/{property_id}/firebaseLinks/{firebase_link_id} + Example: properties/1234/firebaseLinks/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.DeleteFirebaseLinkRequest(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_firebase_link, + 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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def list_firebase_links(self, + request: analytics_admin.ListFirebaseLinksRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFirebaseLinksAsyncPager: + r"""Lists FirebaseLinks on a property. + Properties can have at most one FirebaseLink. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest`): + The request object. Request message for + ListFirebaseLinks RPC + parent (:class:`str`): + Required. Format: properties/{property_id} Example: + properties/1234 + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListFirebaseLinksAsyncPager: + Response message for + ListFirebaseLinks RPC + 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 = analytics_admin.ListFirebaseLinksRequest(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_firebase_links, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListFirebaseLinksAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_global_site_tag(self, + request: analytics_admin.GetGlobalSiteTagRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GlobalSiteTag: + r"""Returns the Site Tag for the specified web stream. + Site Tags are immutable singletons. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetGlobalSiteTagRequest`): + The request object. Request message for GetGlobalSiteTag + RPC. + name (:class:`str`): + Required. The name of the site tag to lookup. Note that + site tags are singletons and do not have unique IDs. + Format: + properties/{property_id}/webDataStreams/{stream_id}/globalSiteTag + Example: + "properties/123/webDataStreams/456/globalSiteTag" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.GlobalSiteTag: + Read-only resource with the tag for + sending data from a website to a + WebDataStream. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = analytics_admin.GetGlobalSiteTagRequest(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_global_site_tag, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_google_ads_link(self, + request: analytics_admin.CreateGoogleAdsLinkRequest = None, + *, + parent: str = None, + google_ads_link: resources.GoogleAdsLink = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleAdsLink: + r"""Creates a GoogleAdsLink. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest`): + The request object. Request message for + CreateGoogleAdsLink RPC + parent (:class:`str`): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + google_ads_link (:class:`google.analytics.admin_v1alpha.types.GoogleAdsLink`): + Required. The GoogleAdsLink to + create. + + This corresponds to the ``google_ads_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.GoogleAdsLink: + A link between an GA4 property and a + Google Ads account. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, google_ads_link]) + if request is 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 = analytics_admin.CreateGoogleAdsLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if google_ads_link is not None: + request.google_ads_link = google_ads_link + + # 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_google_ads_link, + 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, + ) + + # Done; return the response. + return response + + async def update_google_ads_link(self, + request: analytics_admin.UpdateGoogleAdsLinkRequest = None, + *, + google_ads_link: resources.GoogleAdsLink = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleAdsLink: + r"""Updates a GoogleAdsLink on a property + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateGoogleAdsLinkRequest`): + The request object. Request message for + UpdateGoogleAdsLink RPC + google_ads_link (:class:`google.analytics.admin_v1alpha.types.GoogleAdsLink`): + The GoogleAdsLink to update + This corresponds to the ``google_ads_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.GoogleAdsLink: + A link between an GA4 property and a + Google Ads account. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([google_ads_link, 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 = analytics_admin.UpdateGoogleAdsLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if google_ads_link is not None: + request.google_ads_link = google_ads_link + 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_google_ads_link, + 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(( + ('google_ads_link.name', request.google_ads_link.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_google_ads_link(self, + request: analytics_admin.DeleteGoogleAdsLinkRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a GoogleAdsLink on a property + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteGoogleAdsLinkRequest`): + The request object. Request message for + DeleteGoogleAdsLink RPC. + name (:class:`str`): + Required. Example format: + properties/1234/googleAdsLinks/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + request = analytics_admin.DeleteGoogleAdsLinkRequest(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_google_ads_link, + 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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def list_google_ads_links(self, + request: analytics_admin.ListGoogleAdsLinksRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListGoogleAdsLinksAsyncPager: + r"""Lists GoogleAdsLinks on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest`): + The request object. Request message for + ListGoogleAdsLinks RPC. + parent (:class:`str`): + Required. Example format: + properties/1234 + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListGoogleAdsLinksAsyncPager: + Response message for + ListGoogleAdsLinks RPC. + 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 = analytics_admin.ListGoogleAdsLinksRequest(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_google_ads_links, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListGoogleAdsLinksAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_data_sharing_settings(self, + request: analytics_admin.GetDataSharingSettingsRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.DataSharingSettings: + r"""Get data sharing settings on an account. + Data sharing settings are singletons. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetDataSharingSettingsRequest`): + The request object. Request message for + GetDataSharingSettings RPC. + name (:class:`str`): + Required. The name of the settings to + lookup. Format: + accounts/{account}/dataSharingSettings + Example: + "accounts/1000/dataSharingSettings" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.DataSharingSettings: + A resource message representing data + sharing settings of a Google Analytics + account. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = analytics_admin.GetDataSharingSettingsRequest(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_data_sharing_settings, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-analytics-admin', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + 'AnalyticsAdminServiceAsyncClient', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py new file mode 100644 index 00000000..3fac7ffd --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py @@ -0,0 +1,4333 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers +from google.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import wrappers_pb2 as wrappers # type: ignore + +from .transports.base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import AnalyticsAdminServiceGrpcTransport +from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport + + +class AnalyticsAdminServiceClientMeta(type): + """Metaclass for the AnalyticsAdminService 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[AnalyticsAdminServiceTransport]] + _transport_registry['grpc'] = AnalyticsAdminServiceGrpcTransport + _transport_registry['grpc_asyncio'] = AnalyticsAdminServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[AnalyticsAdminServiceTransport]: + """Return 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 AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta): + """Service Interface for the Analytics Admin API (GA4).""" + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Convert 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 = 'analyticsadmin.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: + AnalyticsAdminServiceClient: 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: + AnalyticsAdminServiceClient: 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) -> AnalyticsAdminServiceTransport: + """Return the transport used by the client instance. + + Returns: + AnalyticsAdminServiceTransport: The transport used by the client instance. + """ + return self._transport + + @staticmethod + def account_path(account: str,) -> str: + """Return a fully-qualified account string.""" + return "accounts/{account}".format(account=account, ) + + @staticmethod + def parse_account_path(path: str) -> Dict[str,str]: + """Parse a account path into its component segments.""" + m = re.match(r"^accounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def account_summary_path(account_summary: str,) -> str: + """Return a fully-qualified account_summary string.""" + return "accountSummaries/{account_summary}".format(account_summary=account_summary, ) + + @staticmethod + def parse_account_summary_path(path: str) -> Dict[str,str]: + """Parse a account_summary path into its component segments.""" + m = re.match(r"^accountSummaries/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def android_app_data_stream_path(property: str,android_app_data_stream: str,) -> str: + """Return a fully-qualified android_app_data_stream string.""" + return "properties/{property}/androidAppDataStreams/{android_app_data_stream}".format(property=property, android_app_data_stream=android_app_data_stream, ) + + @staticmethod + def parse_android_app_data_stream_path(path: str) -> Dict[str,str]: + """Parse a android_app_data_stream path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/androidAppDataStreams/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def data_sharing_settings_path(account: str,) -> str: + """Return a fully-qualified data_sharing_settings string.""" + return "accounts/{account}/dataSharingSettings".format(account=account, ) + + @staticmethod + def parse_data_sharing_settings_path(path: str) -> Dict[str,str]: + """Parse a data_sharing_settings path into its component segments.""" + m = re.match(r"^accounts/(?P.+?)/dataSharingSettings$", path) + return m.groupdict() if m else {} + + @staticmethod + def enhanced_measurement_settings_path(property: str,web_data_stream: str,) -> str: + """Return a fully-qualified enhanced_measurement_settings string.""" + return "properties/{property}/webDataStreams/{web_data_stream}/enhancedMeasurementSettings".format(property=property, web_data_stream=web_data_stream, ) + + @staticmethod + def parse_enhanced_measurement_settings_path(path: str) -> Dict[str,str]: + """Parse a enhanced_measurement_settings path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/webDataStreams/(?P.+?)/enhancedMeasurementSettings$", path) + return m.groupdict() if m else {} + + @staticmethod + def firebase_link_path(property: str,firebase_link: str,) -> str: + """Return a fully-qualified firebase_link string.""" + return "properties/{property}/firebaseLinks/{firebase_link}".format(property=property, firebase_link=firebase_link, ) + + @staticmethod + def parse_firebase_link_path(path: str) -> Dict[str,str]: + """Parse a firebase_link path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/firebaseLinks/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def global_site_tag_path(property: str,) -> str: + """Return a fully-qualified global_site_tag string.""" + return "properties/{property}/globalSiteTag".format(property=property, ) + + @staticmethod + def parse_global_site_tag_path(path: str) -> Dict[str,str]: + """Parse a global_site_tag path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/globalSiteTag$", path) + return m.groupdict() if m else {} + + @staticmethod + def google_ads_link_path(property: str,google_ads_link: str,) -> str: + """Return a fully-qualified google_ads_link string.""" + return "properties/{property}/googleAdsLinks/{google_ads_link}".format(property=property, google_ads_link=google_ads_link, ) + + @staticmethod + def parse_google_ads_link_path(path: str) -> Dict[str,str]: + """Parse a google_ads_link path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/googleAdsLinks/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def ios_app_data_stream_path(property: str,ios_app_data_stream: str,) -> str: + """Return a fully-qualified ios_app_data_stream string.""" + return "properties/{property}/iosAppDataStreams/{ios_app_data_stream}".format(property=property, ios_app_data_stream=ios_app_data_stream, ) + + @staticmethod + def parse_ios_app_data_stream_path(path: str) -> Dict[str,str]: + """Parse a ios_app_data_stream path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/iosAppDataStreams/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def property_path(property: str,) -> str: + """Return a fully-qualified property string.""" + return "properties/{property}".format(property=property, ) + + @staticmethod + def parse_property_path(path: str) -> Dict[str,str]: + """Parse a property path into its component segments.""" + m = re.match(r"^properties/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def user_link_path(account: str,user_link: str,) -> str: + """Return a fully-qualified user_link string.""" + return "accounts/{account}/userLinks/{user_link}".format(account=account, user_link=user_link, ) + + @staticmethod + def parse_user_link_path(path: str) -> Dict[str,str]: + """Parse a user_link path into its component segments.""" + m = re.match(r"^accounts/(?P.+?)/userLinks/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def web_data_stream_path(property: str,web_data_stream: str,) -> str: + """Return a fully-qualified web_data_stream string.""" + return "properties/{property}/webDataStreams/{web_data_stream}".format(property=property, web_data_stream=web_data_stream, ) + + @staticmethod + def parse_web_data_stream_path(path: str) -> Dict[str,str]: + """Parse a web_data_stream path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/webDataStreams/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_billing_account_path(billing_account: str, ) -> str: + """Return 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: + """Return 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: + """Return 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: + """Return 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: + """Return 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[credentials.Credentials] = None, + transport: Union[str, AnalyticsAdminServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the analytics admin service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, AnalyticsAdminServiceTransport]): 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() + client_cert_source_func = mtls.default_client_cert_source() if is_mtls else 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": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT if is_mtls else 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, AnalyticsAdminServiceTransport): + # transport is a AnalyticsAdminServiceTransport instance. + if credentials or client_options.credentials_file: + raise ValueError('When providing a transport instance, ' + 'provide its credentials directly.') + if client_options.scopes: + raise ValueError( + "When providing a transport instance, " + "provide its scopes directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + ) + + def get_account(self, + request: analytics_admin.GetAccountRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Account: + r"""Lookup for a single Account. + + Args: + request (google.analytics.admin_v1alpha.types.GetAccountRequest): + The request object. Request message for GetAccount RPC. + name (str): + Required. The name of the account to + lookup. Format: accounts/{account} + Example: "accounts/100" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.Account: + A resource message representing a + Google Analytics account. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 analytics_admin.GetAccountRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetAccountRequest): + request = analytics_admin.GetAccountRequest(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_account] + + # Certain fields should be 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_accounts(self, + request: analytics_admin.ListAccountsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAccountsPager: + r"""Returns all accounts accessible by the caller. + Note that these accounts might not currently have GA4 + properties. Soft-deleted (ie: "trashed") accounts are + excluded by default. Returns an empty list if no + relevant accounts are found. + + Args: + request (google.analytics.admin_v1alpha.types.ListAccountsRequest): + The request object. Request message for ListAccounts + RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsPager: + Request message for ListAccounts RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ListAccountsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListAccountsRequest): + request = analytics_admin.ListAccountsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_accounts] + + # 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.ListAccountsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_account(self, + request: analytics_admin.DeleteAccountRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Marks target Account as soft-deleted (ie: "trashed") + and returns it. + This API does not have a method to restore soft-deleted + accounts. However, they can be restored using the Trash + Can UI. + If the accounts are not restored before the expiration + time, the account and all child resources (eg: + Properties, GoogleAdsLinks, Streams, UserLinks) will be + permanently purged. + https://support.google.com/analytics/answer/6154772 + Returns an error if the target is not found. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteAccountRequest): + The request object. Request message for DeleteAccount + RPC. + name (str): + Required. The name of the Account to + soft-delete. Format: accounts/{account} + Example: "accounts/100" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteAccountRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteAccountRequest): + request = analytics_admin.DeleteAccountRequest(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_account] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def update_account(self, + request: analytics_admin.UpdateAccountRequest = None, + *, + account: resources.Account = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Account: + r"""Updates an account. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateAccountRequest): + The request object. Request message for UpdateAccount + RPC. + account (google.analytics.admin_v1alpha.types.Account): + Required. The account to update. The account's ``name`` + field is used to identify the account. + + This corresponds to the ``account`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.Account: + A resource message representing a + Google Analytics account. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([account, 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 analytics_admin.UpdateAccountRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateAccountRequest): + request = analytics_admin.UpdateAccountRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if account is not None: + request.account = account + 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_account] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('account.name', request.account.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def provision_account_ticket(self, + request: analytics_admin.ProvisionAccountTicketRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.ProvisionAccountTicketResponse: + r"""Requests a ticket for creating an account. + + Args: + request (google.analytics.admin_v1alpha.types.ProvisionAccountTicketRequest): + The request object. Request message for + ProvisionAccountTicket RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.ProvisionAccountTicketResponse: + Response message for + ProvisionAccountTicket RPC. + + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ProvisionAccountTicketRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ProvisionAccountTicketRequest): + request = analytics_admin.ProvisionAccountTicketRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.provision_account_ticket] + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_account_summaries(self, + request: analytics_admin.ListAccountSummariesRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAccountSummariesPager: + r"""Returns summaries of all accounts accessible by the + caller. + + Args: + request (google.analytics.admin_v1alpha.types.ListAccountSummariesRequest): + The request object. Request message for + ListAccountSummaries RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountSummariesPager: + Response message for + ListAccountSummaries RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ListAccountSummariesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListAccountSummariesRequest): + request = analytics_admin.ListAccountSummariesRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_account_summaries] + + # 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.ListAccountSummariesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_property(self, + request: analytics_admin.GetPropertyRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Property: + r"""Lookup for a single "GA4" Property. + + Args: + request (google.analytics.admin_v1alpha.types.GetPropertyRequest): + The request object. Request message for GetProperty RPC. + name (str): + Required. The name of the property to lookup. Format: + properties/{property_id} Example: "properties/1000" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.Property: + A resource message representing a + Google Analytics GA4 property. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 analytics_admin.GetPropertyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetPropertyRequest): + request = analytics_admin.GetPropertyRequest(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_property] + + # Certain fields should be 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_properties(self, + request: analytics_admin.ListPropertiesRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPropertiesPager: + r"""Returns child Properties under the specified parent + Account. + Only "GA4" properties will be returned. + Properties will be excluded if the caller does not have + access. Soft-deleted (ie: "trashed") properties are + excluded by default. Returns an empty list if no + relevant properties are found. + + Args: + request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): + The request object. Request message for ListProperties + RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListPropertiesPager: + Response message for ListProperties + RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ListPropertiesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListPropertiesRequest): + request = analytics_admin.ListPropertiesRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_properties] + + # 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.ListPropertiesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_property(self, + request: analytics_admin.CreatePropertyRequest = None, + *, + property: resources.Property = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Property: + r"""Creates an "GA4" property with the specified location + and attributes. + + Args: + request (google.analytics.admin_v1alpha.types.CreatePropertyRequest): + The request object. Request message for CreateProperty + RPC. + property (google.analytics.admin_v1alpha.types.Property): + Required. The property to create. + Note: the supplied property must specify + its parent. + + This corresponds to the ``property`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.Property: + A resource message representing a + Google Analytics GA4 property. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([property]) + if request is 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 analytics_admin.CreatePropertyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreatePropertyRequest): + request = analytics_admin.CreatePropertyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if property is not None: + request.property = property + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_property] + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_property(self, + request: analytics_admin.DeletePropertyRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Marks target Property as soft-deleted (ie: "trashed") + and returns it. + This API does not have a method to restore soft-deleted + properties. However, they can be restored using the + Trash Can UI. + If the properties are not restored before the expiration + time, the Property and all child resources (eg: + GoogleAdsLinks, Streams, UserLinks) will be permanently + purged. + https://support.google.com/analytics/answer/6154772 + Returns an error if the target is not found, or is not + an GA4 Property. + + Args: + request (google.analytics.admin_v1alpha.types.DeletePropertyRequest): + The request object. Request message for DeleteProperty + RPC. + name (str): + Required. The name of the Property to soft-delete. + Format: properties/{property_id} Example: + "properties/1000" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeletePropertyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeletePropertyRequest): + request = analytics_admin.DeletePropertyRequest(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_property] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def update_property(self, + request: analytics_admin.UpdatePropertyRequest = None, + *, + property: resources.Property = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Property: + r"""Updates a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdatePropertyRequest): + The request object. Request message for UpdateProperty + RPC. + property (google.analytics.admin_v1alpha.types.Property): + Required. The property to update. The property's + ``name`` field is used to identify the property to be + updated. + + This corresponds to the ``property`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.Property: + A resource message representing a + Google Analytics GA4 property. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([property, 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 analytics_admin.UpdatePropertyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdatePropertyRequest): + request = analytics_admin.UpdatePropertyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if property is not None: + request.property = property + 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_property] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('property.name', request.property.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_user_link(self, + request: analytics_admin.GetUserLinkRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.UserLink: + r"""Gets information about a user's link to an account or + property. + + Args: + request (google.analytics.admin_v1alpha.types.GetUserLinkRequest): + The request object. Request message for GetUserLink RPC. + name (str): + Required. Example format: + accounts/1234/userLinks/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.UserLink: + A resource message representing a + user's permissions on an Account or + Property resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.GetUserLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetUserLinkRequest): + request = analytics_admin.GetUserLinkRequest(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_user_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_get_user_links(self, + request: analytics_admin.BatchGetUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchGetUserLinksResponse: + r"""Gets information about multiple users' links to an + account or property. + + Args: + request (google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest): + The request object. Request message for + BatchGetUserLinks RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse: + Response message for + BatchGetUserLinks RPC. + + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.BatchGetUserLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.BatchGetUserLinksRequest): + request = analytics_admin.BatchGetUserLinksRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_get_user_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_user_links(self, + request: analytics_admin.ListUserLinksRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListUserLinksPager: + r"""Lists all user links on an account or property. + + Args: + request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): + The request object. Request message for ListUserLinks + RPC. + parent (str): + Required. Example format: + accounts/1234 + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListUserLinksPager: + Response message for ListUserLinks + RPC. + 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 analytics_admin.ListUserLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListUserLinksRequest): + request = analytics_admin.ListUserLinksRequest(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_user_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListUserLinksPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def audit_user_links(self, + request: analytics_admin.AuditUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.AuditUserLinksPager: + r"""Lists all user links on an account or property, + including implicit ones that come from effective + permissions granted by groups or organization admin + roles. + + If a returned user link does not have direct + permissions, they cannot be removed from the account or + property directly with the DeleteUserLink command. They + have to be removed from the group/etc that gives them + permissions, which is currently only usable/discoverable + in the GA or GMP UIs. + + Args: + request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): + The request object. Request message for AuditUserLinks + RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.AuditUserLinksPager: + Response message for AuditUserLinks + RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.AuditUserLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.AuditUserLinksRequest): + request = analytics_admin.AuditUserLinksRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.audit_user_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.AuditUserLinksPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_user_link(self, + request: analytics_admin.CreateUserLinkRequest = None, + *, + parent: str = None, + user_link: resources.UserLink = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.UserLink: + r"""Creates a user link on an account or property. + If the user with the specified email already has + permissions on the account or property, then the user's + existing permissions will be unioned with the + permissions specified in the new UserLink. + + Args: + request (google.analytics.admin_v1alpha.types.CreateUserLinkRequest): + The request object. Request message for CreateUserLink + RPC. + Users can have multiple email addresses associated with + their Google account, and one of these email addresses + is the "primary" email address. Any of the email + addresses associated with a Google account may be used + for a new UserLink, but the returned UserLink will + always contain the "primary" email address. As a result, + the input and output email address for this request may + differ. + parent (str): + Required. Example format: + accounts/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + user_link (google.analytics.admin_v1alpha.types.UserLink): + Required. The user link to create. + This corresponds to the ``user_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.UserLink: + A resource message representing a + user's permissions on an Account or + Property resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, user_link]) + if request is 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 analytics_admin.CreateUserLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateUserLinkRequest): + request = analytics_admin.CreateUserLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if user_link is not None: + request.user_link = user_link + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_user_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_create_user_links(self, + request: analytics_admin.BatchCreateUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchCreateUserLinksResponse: + r"""Creates information about multiple users' links to an + account or property. + This method is transactional. If any UserLink cannot be + created, none of the UserLinks will be created. + + Args: + request (google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest): + The request object. Request message for + BatchCreateUserLinks RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse: + Response message for + BatchCreateUserLinks RPC. + + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.BatchCreateUserLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.BatchCreateUserLinksRequest): + request = analytics_admin.BatchCreateUserLinksRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_create_user_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_user_link(self, + request: analytics_admin.UpdateUserLinkRequest = None, + *, + user_link: resources.UserLink = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.UserLink: + r"""Updates a user link on an account or property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateUserLinkRequest): + The request object. Request message for UpdateUserLink + RPC. + user_link (google.analytics.admin_v1alpha.types.UserLink): + Required. The user link to update. + This corresponds to the ``user_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.UserLink: + A resource message representing a + user's permissions on an Account or + Property resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([user_link]) + if request is 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 analytics_admin.UpdateUserLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateUserLinkRequest): + request = analytics_admin.UpdateUserLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if user_link is not None: + request.user_link = user_link + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_user_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('user_link.name', request.user_link.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_update_user_links(self, + request: analytics_admin.BatchUpdateUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchUpdateUserLinksResponse: + r"""Updates information about multiple users' links to an + account or property. + + Args: + request (google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest): + The request object. Request message for + BatchUpdateUserLinks RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse: + Response message for + BatchUpdateUserLinks RPC. + + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.BatchUpdateUserLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.BatchUpdateUserLinksRequest): + request = analytics_admin.BatchUpdateUserLinksRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_update_user_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_user_link(self, + request: analytics_admin.DeleteUserLinkRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a user link on an account or property. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteUserLinkRequest): + The request object. Request message for DeleteUserLink + RPC. + name (str): + Required. Example format: + accounts/1234/userLinks/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteUserLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteUserLinkRequest): + request = analytics_admin.DeleteUserLinkRequest(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_user_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def batch_delete_user_links(self, + request: analytics_admin.BatchDeleteUserLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes information about multiple users' links to an + account or property. + + Args: + request (google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest): + The request object. Request message for + BatchDeleteUserLinks RPC. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.BatchDeleteUserLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.BatchDeleteUserLinksRequest): + request = analytics_admin.BatchDeleteUserLinksRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.batch_delete_user_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def get_web_data_stream(self, + request: analytics_admin.GetWebDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.WebDataStream: + r"""Lookup for a single WebDataStream + + Args: + request (google.analytics.admin_v1alpha.types.GetWebDataStreamRequest): + The request object. Request message for GetWebDataStream + RPC. + name (str): + Required. The name of the web data stream to lookup. + Format: + properties/{property_id}/webDataStreams/{stream_id} + Example: "properties/123/webDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.WebDataStream: + A resource message representing a + Google Analytics web 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 analytics_admin.GetWebDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetWebDataStreamRequest): + request = analytics_admin.GetWebDataStreamRequest(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_web_data_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 delete_web_data_stream(self, + request: analytics_admin.DeleteWebDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a web stream on a property. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteWebDataStreamRequest): + The request object. Request message for + DeleteWebDataStream RPC. + name (str): + Required. The name of the web data stream to delete. + Format: + properties/{property_id}/webDataStreams/{stream_id} + Example: "properties/123/webDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteWebDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteWebDataStreamRequest): + request = analytics_admin.DeleteWebDataStreamRequest(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_web_data_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. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def update_web_data_stream(self, + request: analytics_admin.UpdateWebDataStreamRequest = None, + *, + web_data_stream: resources.WebDataStream = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.WebDataStream: + r"""Updates a web stream on a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateWebDataStreamRequest): + The request object. Request message for + UpdateWebDataStream RPC. + web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): + Required. The web stream to update. The ``name`` field + is used to identify the web stream to be updated. + + This corresponds to the ``web_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.WebDataStream: + A resource message representing a + Google Analytics web 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([web_data_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 analytics_admin.UpdateWebDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateWebDataStreamRequest): + request = analytics_admin.UpdateWebDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if web_data_stream is not None: + request.web_data_stream = web_data_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_web_data_stream] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('web_data_stream.name', request.web_data_stream.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_web_data_stream(self, + request: analytics_admin.CreateWebDataStreamRequest = None, + *, + parent: str = None, + web_data_stream: resources.WebDataStream = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.WebDataStream: + r"""Creates a web stream with the specified location and + attributes. + + Args: + request (google.analytics.admin_v1alpha.types.CreateWebDataStreamRequest): + The request object. Request message for + CreateWebDataStream RPC. + parent (str): + Required. The parent resource where + this web data stream will be created. + Format: properties/123 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): + Required. The web stream to create. + This corresponds to the ``web_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.WebDataStream: + A resource message representing a + Google Analytics web 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, web_data_stream]) + if request is 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 analytics_admin.CreateWebDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateWebDataStreamRequest): + request = analytics_admin.CreateWebDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if web_data_stream is not None: + request.web_data_stream = web_data_stream + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_web_data_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, + ) + + # Done; return the response. + return response + + def list_web_data_streams(self, + request: analytics_admin.ListWebDataStreamsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListWebDataStreamsPager: + r"""Returns child web data streams under the specified + parent property. + Web data streams will be excluded if the caller does not + have access. Returns an empty list if no relevant web + data streams are found. + + Args: + request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): + The request object. Request message for + ListWebDataStreams RPC. + parent (str): + Required. The name of the parent + property. For example, to list results + of web streams under the property with + Id 123: "properties/123" + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListWebDataStreamsPager: + Request message for + ListWebDataStreams RPC. + 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 analytics_admin.ListWebDataStreamsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListWebDataStreamsRequest): + request = analytics_admin.ListWebDataStreamsRequest(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_web_data_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.ListWebDataStreamsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_ios_app_data_stream(self, + request: analytics_admin.GetIosAppDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IosAppDataStream: + r"""Lookup for a single IosAppDataStream + + Args: + request (google.analytics.admin_v1alpha.types.GetIosAppDataStreamRequest): + The request object. Request message for + GetIosAppDataStream RPC. + name (str): + Required. The name of the iOS app data stream to lookup. + Format: + properties/{property_id}/iosAppDataStreams/{stream_id} + Example: "properties/123/iosAppDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.IosAppDataStream: + A resource message representing a + Google Analytics IOS app 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 analytics_admin.GetIosAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetIosAppDataStreamRequest): + request = analytics_admin.GetIosAppDataStreamRequest(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_ios_app_data_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 delete_ios_app_data_stream(self, + request: analytics_admin.DeleteIosAppDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an iOS app stream on a property. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteIosAppDataStreamRequest): + The request object. Request message for + DeleteIosAppDataStream RPC. + name (str): + Required. The name of the iOS app data stream to delete. + Format: + properties/{property_id}/iosAppDataStreams/{stream_id} + Example: "properties/123/iosAppDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteIosAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteIosAppDataStreamRequest): + request = analytics_admin.DeleteIosAppDataStreamRequest(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_ios_app_data_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. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def update_ios_app_data_stream(self, + request: analytics_admin.UpdateIosAppDataStreamRequest = None, + *, + ios_app_data_stream: resources.IosAppDataStream = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IosAppDataStream: + r"""Updates an iOS app stream on a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateIosAppDataStreamRequest): + The request object. Request message for + UpdateIosAppDataStream RPC. + ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): + Required. The iOS app stream to update. The ``name`` + field is used to identify the iOS app stream to be + updated. + + This corresponds to the ``ios_app_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.IosAppDataStream: + A resource message representing a + Google Analytics IOS app 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([ios_app_data_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 analytics_admin.UpdateIosAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateIosAppDataStreamRequest): + request = analytics_admin.UpdateIosAppDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if ios_app_data_stream is not None: + request.ios_app_data_stream = ios_app_data_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_ios_app_data_stream] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('ios_app_data_stream.name', request.ios_app_data_stream.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_ios_app_data_stream(self, + request: analytics_admin.CreateIosAppDataStreamRequest = None, + *, + parent: str = None, + ios_app_data_stream: resources.IosAppDataStream = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IosAppDataStream: + r"""Creates an iOS app stream with the specified location + and attributes. + Note that an iOS app stream must be linked to a Firebase + app to receive traffic. + + To create a working app stream, make sure your property + is linked to a Firebase project. Then, use the Firebase + API to create a Firebase app, which will also create an + appropriate data stream in Analytics (may take up to 24 + hours). + + Args: + request (google.analytics.admin_v1alpha.types.CreateIosAppDataStreamRequest): + The request object. Request message for + CreateIosAppDataStream RPC. + parent (str): + Required. The parent resource where + this ios app data stream will be + created. Format: properties/123 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): + Required. The iOS app data stream to + create. + + This corresponds to the ``ios_app_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.IosAppDataStream: + A resource message representing a + Google Analytics IOS app 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, ios_app_data_stream]) + if request is 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 analytics_admin.CreateIosAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateIosAppDataStreamRequest): + request = analytics_admin.CreateIosAppDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if ios_app_data_stream is not None: + request.ios_app_data_stream = ios_app_data_stream + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_ios_app_data_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, + ) + + # Done; return the response. + return response + + def list_ios_app_data_streams(self, + request: analytics_admin.ListIosAppDataStreamsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListIosAppDataStreamsPager: + r"""Returns child iOS app data streams under the + specified parent property. + iOS app data streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + iOS app data streams are found. + + Args: + request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): + The request object. Request message for + ListIosAppDataStreams RPC. + parent (str): + Required. The name of the parent + property. For example, to list results + of app streams under the property with + Id 123: "properties/123" + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListIosAppDataStreamsPager: + Request message for + ListIosAppDataStreams RPC. + 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 analytics_admin.ListIosAppDataStreamsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListIosAppDataStreamsRequest): + request = analytics_admin.ListIosAppDataStreamsRequest(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_ios_app_data_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.ListIosAppDataStreamsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_android_app_data_stream(self, + request: analytics_admin.GetAndroidAppDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AndroidAppDataStream: + r"""Lookup for a single AndroidAppDataStream + + Args: + request (google.analytics.admin_v1alpha.types.GetAndroidAppDataStreamRequest): + The request object. Request message for + GetAndroidAppDataStream RPC. + name (str): + Required. The name of the android app data stream to + lookup. Format: + properties/{property_id}/androidAppDataStreams/{stream_id} + Example: "properties/123/androidAppDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: + A resource message representing a + Google Analytics Android app 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 analytics_admin.GetAndroidAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetAndroidAppDataStreamRequest): + request = analytics_admin.GetAndroidAppDataStreamRequest(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_android_app_data_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 delete_android_app_data_stream(self, + request: analytics_admin.DeleteAndroidAppDataStreamRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an android app stream on a property. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteAndroidAppDataStreamRequest): + The request object. Request message for + DeleteAndroidAppDataStream RPC. + name (str): + Required. The name of the android app data stream to + delete. Format: + properties/{property_id}/androidAppDataStreams/{stream_id} + Example: "properties/123/androidAppDataStreams/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteAndroidAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteAndroidAppDataStreamRequest): + request = analytics_admin.DeleteAndroidAppDataStreamRequest(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_android_app_data_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. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def update_android_app_data_stream(self, + request: analytics_admin.UpdateAndroidAppDataStreamRequest = None, + *, + android_app_data_stream: resources.AndroidAppDataStream = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AndroidAppDataStream: + r"""Updates an android app stream on a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateAndroidAppDataStreamRequest): + The request object. Request message for + UpdateAndroidAppDataStream RPC. + android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): + Required. The android app stream to update. The ``name`` + field is used to identify the android app stream to be + updated. + + This corresponds to the ``android_app_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.AndroidAppDataStream: + A resource message representing a + Google Analytics Android app 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([android_app_data_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 analytics_admin.UpdateAndroidAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateAndroidAppDataStreamRequest): + request = analytics_admin.UpdateAndroidAppDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if android_app_data_stream is not None: + request.android_app_data_stream = android_app_data_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_android_app_data_stream] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('android_app_data_stream.name', request.android_app_data_stream.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_android_app_data_stream(self, + request: analytics_admin.CreateAndroidAppDataStreamRequest = None, + *, + parent: str = None, + android_app_data_stream: resources.AndroidAppDataStream = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AndroidAppDataStream: + r"""Creates an Android app stream with the specified + location and attributes. + Note that an Android app stream must be linked to a + Firebase app to receive traffic. + + To create a working app stream, make sure your property + is linked to a Firebase project. Then, use the Firebase + API to create a Firebase app, which will also create an + appropriate data stream in Analytics (may take up to 24 + hours). + + Args: + request (google.analytics.admin_v1alpha.types.CreateAndroidAppDataStreamRequest): + The request object. Request message for + CreateAndroidAppDataStream RPC. + parent (str): + Required. The parent resource where + this android app data stream will be + created. Format: properties/123 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): + Required. The android app stream to + create. + + This corresponds to the ``android_app_data_stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: + A resource message representing a + Google Analytics Android app 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, android_app_data_stream]) + if request is 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 analytics_admin.CreateAndroidAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateAndroidAppDataStreamRequest): + request = analytics_admin.CreateAndroidAppDataStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if android_app_data_stream is not None: + request.android_app_data_stream = android_app_data_stream + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_android_app_data_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, + ) + + # Done; return the response. + return response + + def list_android_app_data_streams(self, + request: analytics_admin.ListAndroidAppDataStreamsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAndroidAppDataStreamsPager: + r"""Returns child android app streams under the specified + parent property. + Android app streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + android app streams are found. + + Args: + request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): + The request object. Request message for + ListAndroidAppDataStreams RPC. + parent (str): + Required. The name of the parent + property. For example, to limit results + to app streams under the property with + Id 123: "properties/123" + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAndroidAppDataStreamsPager: + Request message for + ListAndroidDataStreams RPC. + 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 analytics_admin.ListAndroidAppDataStreamsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListAndroidAppDataStreamsRequest): + request = analytics_admin.ListAndroidAppDataStreamsRequest(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_android_app_data_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.ListAndroidAppDataStreamsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_enhanced_measurement_settings(self, + request: analytics_admin.GetEnhancedMeasurementSettingsRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.EnhancedMeasurementSettings: + r"""Returns the singleton enhanced measurement settings + for this web stream. Note that the stream must enable + enhanced measurement for these settings to take effect. + + Args: + request (google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest): + The request object. Request message for + GetEnhancedMeasurementSettings RPC. + name (str): + Required. The name of the settings to lookup. Format: + properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings + Example: + "properties/1000/webDataStreams/2000/enhancedMeasurementSettings" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: + Singleton resource under a + WebDataStream, configuring measurement + of additional site interactions and + content. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 analytics_admin.GetEnhancedMeasurementSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetEnhancedMeasurementSettingsRequest): + request = analytics_admin.GetEnhancedMeasurementSettingsRequest(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_enhanced_measurement_settings] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_enhanced_measurement_settings(self, + request: analytics_admin.UpdateEnhancedMeasurementSettingsRequest = None, + *, + enhanced_measurement_settings: resources.EnhancedMeasurementSettings = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.EnhancedMeasurementSettings: + r"""Updates the singleton enhanced measurement settings + for this web stream. Note that the stream must enable + enhanced measurement for these settings to take effect. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateEnhancedMeasurementSettingsRequest): + The request object. Request message for + UpdateEnhancedMeasurementSettings RPC. + enhanced_measurement_settings (google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings): + Required. The settings to update. The ``name`` field is + used to identify the settings to be updated. + + This corresponds to the ``enhanced_measurement_settings`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: + Singleton resource under a + WebDataStream, configuring measurement + of additional site interactions and + content. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([enhanced_measurement_settings, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.UpdateEnhancedMeasurementSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateEnhancedMeasurementSettingsRequest): + request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if enhanced_measurement_settings is not None: + request.enhanced_measurement_settings = enhanced_measurement_settings + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_enhanced_measurement_settings] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('enhanced_measurement_settings.name', request.enhanced_measurement_settings.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_firebase_link(self, + request: analytics_admin.CreateFirebaseLinkRequest = None, + *, + parent: str = None, + firebase_link: resources.FirebaseLink = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FirebaseLink: + r"""Creates a FirebaseLink. + Properties can have at most one FirebaseLink. + + Args: + request (google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest): + The request object. Request message for + CreateFirebaseLink RPC + parent (str): + Required. Format: properties/{property_id} Example: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): + Required. The Firebase link to + create. + + This corresponds to the ``firebase_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.FirebaseLink: + A link between an GA4 property and a + Firebase project. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, firebase_link]) + if request is 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 analytics_admin.CreateFirebaseLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateFirebaseLinkRequest): + request = analytics_admin.CreateFirebaseLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if firebase_link is not None: + request.firebase_link = firebase_link + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_firebase_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_firebase_link(self, + request: analytics_admin.UpdateFirebaseLinkRequest = None, + *, + firebase_link: resources.FirebaseLink = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.FirebaseLink: + r"""Updates a FirebaseLink on a property + + Args: + request (google.analytics.admin_v1alpha.types.UpdateFirebaseLinkRequest): + The request object. Request message for + UpdateFirebaseLink RPC + firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): + Required. The Firebase link to + update. + + This corresponds to the ``firebase_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.FirebaseLink: + A link between an GA4 property and a + Firebase project. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([firebase_link, 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 analytics_admin.UpdateFirebaseLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateFirebaseLinkRequest): + request = analytics_admin.UpdateFirebaseLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if firebase_link is not None: + request.firebase_link = firebase_link + 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_firebase_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('firebase_link.name', request.firebase_link.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_firebase_link(self, + request: analytics_admin.DeleteFirebaseLinkRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a FirebaseLink on a property + + Args: + request (google.analytics.admin_v1alpha.types.DeleteFirebaseLinkRequest): + The request object. Request message for + DeleteFirebaseLink RPC + name (str): + Required. Format: + properties/{property_id}/firebaseLinks/{firebase_link_id} + Example: properties/1234/firebaseLinks/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteFirebaseLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteFirebaseLinkRequest): + request = analytics_admin.DeleteFirebaseLinkRequest(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_firebase_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def list_firebase_links(self, + request: analytics_admin.ListFirebaseLinksRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFirebaseLinksPager: + r"""Lists FirebaseLinks on a property. + Properties can have at most one FirebaseLink. + + Args: + request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): + The request object. Request message for + ListFirebaseLinks RPC + parent (str): + Required. Format: properties/{property_id} Example: + properties/1234 + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListFirebaseLinksPager: + Response message for + ListFirebaseLinks RPC + 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 analytics_admin.ListFirebaseLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListFirebaseLinksRequest): + request = analytics_admin.ListFirebaseLinksRequest(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_firebase_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListFirebaseLinksPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_global_site_tag(self, + request: analytics_admin.GetGlobalSiteTagRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GlobalSiteTag: + r"""Returns the Site Tag for the specified web stream. + Site Tags are immutable singletons. + + Args: + request (google.analytics.admin_v1alpha.types.GetGlobalSiteTagRequest): + The request object. Request message for GetGlobalSiteTag + RPC. + name (str): + Required. The name of the site tag to lookup. Note that + site tags are singletons and do not have unique IDs. + Format: + properties/{property_id}/webDataStreams/{stream_id}/globalSiteTag + Example: + "properties/123/webDataStreams/456/globalSiteTag" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.GlobalSiteTag: + Read-only resource with the tag for + sending data from a website to a + WebDataStream. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 analytics_admin.GetGlobalSiteTagRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetGlobalSiteTagRequest): + request = analytics_admin.GetGlobalSiteTagRequest(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_global_site_tag] + + # Certain fields should be 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_google_ads_link(self, + request: analytics_admin.CreateGoogleAdsLinkRequest = None, + *, + parent: str = None, + google_ads_link: resources.GoogleAdsLink = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleAdsLink: + r"""Creates a GoogleAdsLink. + + Args: + request (google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest): + The request object. Request message for + CreateGoogleAdsLink RPC + parent (str): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): + Required. The GoogleAdsLink to + create. + + This corresponds to the ``google_ads_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.GoogleAdsLink: + A link between an GA4 property and a + Google Ads account. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, google_ads_link]) + if request is 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 analytics_admin.CreateGoogleAdsLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateGoogleAdsLinkRequest): + request = analytics_admin.CreateGoogleAdsLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if parent is not None: + request.parent = parent + if google_ads_link is not None: + request.google_ads_link = google_ads_link + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_google_ads_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_google_ads_link(self, + request: analytics_admin.UpdateGoogleAdsLinkRequest = None, + *, + google_ads_link: resources.GoogleAdsLink = None, + update_mask: field_mask.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleAdsLink: + r"""Updates a GoogleAdsLink on a property + + Args: + request (google.analytics.admin_v1alpha.types.UpdateGoogleAdsLinkRequest): + The request object. Request message for + UpdateGoogleAdsLink RPC + google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): + The GoogleAdsLink to update + This corresponds to the ``google_ads_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + 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.analytics.admin_v1alpha.types.GoogleAdsLink: + A link between an GA4 property and a + Google Ads account. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([google_ads_link, 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 analytics_admin.UpdateGoogleAdsLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateGoogleAdsLinkRequest): + request = analytics_admin.UpdateGoogleAdsLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + + if google_ads_link is not None: + request.google_ads_link = google_ads_link + 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_google_ads_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('google_ads_link.name', request.google_ads_link.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_google_ads_link(self, + request: analytics_admin.DeleteGoogleAdsLinkRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a GoogleAdsLink on a property + + Args: + request (google.analytics.admin_v1alpha.types.DeleteGoogleAdsLinkRequest): + The request object. Request message for + DeleteGoogleAdsLink RPC. + name (str): + Required. Example format: + properties/1234/googleAdsLinks/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteGoogleAdsLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteGoogleAdsLinkRequest): + request = analytics_admin.DeleteGoogleAdsLinkRequest(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_google_ads_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def list_google_ads_links(self, + request: analytics_admin.ListGoogleAdsLinksRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListGoogleAdsLinksPager: + r"""Lists GoogleAdsLinks on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): + The request object. Request message for + ListGoogleAdsLinks RPC. + parent (str): + Required. Example format: + properties/1234 + + 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListGoogleAdsLinksPager: + Response message for + ListGoogleAdsLinks RPC. + 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 analytics_admin.ListGoogleAdsLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListGoogleAdsLinksRequest): + request = analytics_admin.ListGoogleAdsLinksRequest(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_google_ads_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListGoogleAdsLinksPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_data_sharing_settings(self, + request: analytics_admin.GetDataSharingSettingsRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.DataSharingSettings: + r"""Get data sharing settings on an account. + Data sharing settings are singletons. + + Args: + request (google.analytics.admin_v1alpha.types.GetDataSharingSettingsRequest): + The request object. Request message for + GetDataSharingSettings RPC. + name (str): + Required. The name of the settings to + lookup. Format: + accounts/{account}/dataSharingSettings + Example: + "accounts/1000/dataSharingSettings" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.DataSharingSettings: + A resource message representing data + sharing settings of a Google Analytics + account. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 analytics_admin.GetDataSharingSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetDataSharingSettingsRequest): + request = analytics_admin.GetDataSharingSettingsRequest(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_data_sharing_settings] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-analytics-admin', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + 'AnalyticsAdminServiceClient', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py new file mode 100644 index 00000000..6f76b747 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py @@ -0,0 +1,1241 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional + +from google.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources + + +class ListAccountsPager: + """A pager for iterating through ``list_accounts`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``accounts`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAccounts`` requests and continue to iterate + through the ``accounts`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` + 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[..., analytics_admin.ListAccountsResponse], + request: analytics_admin.ListAccountsRequest, + response: analytics_admin.ListAccountsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListAccountsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAccountsResponse): + 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 = analytics_admin.ListAccountsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListAccountsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.Account]: + for page in self.pages: + yield from page.accounts + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAccountsAsyncPager: + """A pager for iterating through ``list_accounts`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``accounts`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAccounts`` requests and continue to iterate + through the ``accounts`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` + 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[analytics_admin.ListAccountsResponse]], + request: analytics_admin.ListAccountsRequest, + response: analytics_admin.ListAccountsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListAccountsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAccountsResponse): + 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 = analytics_admin.ListAccountsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListAccountsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.Account]: + async def async_generator(): + async for page in self.pages: + for response in page.accounts: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAccountSummariesPager: + """A pager for iterating through ``list_account_summaries`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``account_summaries`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAccountSummaries`` requests and continue to iterate + through the ``account_summaries`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` + 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[..., analytics_admin.ListAccountSummariesResponse], + request: analytics_admin.ListAccountSummariesRequest, + response: analytics_admin.ListAccountSummariesResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListAccountSummariesRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAccountSummariesResponse): + 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 = analytics_admin.ListAccountSummariesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListAccountSummariesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.AccountSummary]: + for page in self.pages: + yield from page.account_summaries + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAccountSummariesAsyncPager: + """A pager for iterating through ``list_account_summaries`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``account_summaries`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAccountSummaries`` requests and continue to iterate + through the ``account_summaries`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` + 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[analytics_admin.ListAccountSummariesResponse]], + request: analytics_admin.ListAccountSummariesRequest, + response: analytics_admin.ListAccountSummariesResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListAccountSummariesRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAccountSummariesResponse): + 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 = analytics_admin.ListAccountSummariesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListAccountSummariesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.AccountSummary]: + async def async_generator(): + async for page in self.pages: + for response in page.account_summaries: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPropertiesPager: + """A pager for iterating through ``list_properties`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``properties`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListProperties`` requests and continue to iterate + through the ``properties`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` + 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[..., analytics_admin.ListPropertiesResponse], + request: analytics_admin.ListPropertiesRequest, + response: analytics_admin.ListPropertiesResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListPropertiesResponse): + 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 = analytics_admin.ListPropertiesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListPropertiesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.Property]: + for page in self.pages: + yield from page.properties + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPropertiesAsyncPager: + """A pager for iterating through ``list_properties`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``properties`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListProperties`` requests and continue to iterate + through the ``properties`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` + 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[analytics_admin.ListPropertiesResponse]], + request: analytics_admin.ListPropertiesRequest, + response: analytics_admin.ListPropertiesResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListPropertiesResponse): + 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 = analytics_admin.ListPropertiesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListPropertiesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.Property]: + async def async_generator(): + async for page in self.pages: + for response in page.properties: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListUserLinksPager: + """A pager for iterating through ``list_user_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` object, and + provides an ``__iter__`` method to iterate through its + ``user_links`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListUserLinks`` requests and continue to iterate + through the ``user_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` + 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[..., analytics_admin.ListUserLinksResponse], + request: analytics_admin.ListUserLinksRequest, + response: analytics_admin.ListUserLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListUserLinksResponse): + 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 = analytics_admin.ListUserLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListUserLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.UserLink]: + for page in self.pages: + yield from page.user_links + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListUserLinksAsyncPager: + """A pager for iterating through ``list_user_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``user_links`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListUserLinks`` requests and continue to iterate + through the ``user_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` + 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[analytics_admin.ListUserLinksResponse]], + request: analytics_admin.ListUserLinksRequest, + response: analytics_admin.ListUserLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListUserLinksResponse): + 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 = analytics_admin.ListUserLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListUserLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.UserLink]: + async def async_generator(): + async for page in self.pages: + for response in page.user_links: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class AuditUserLinksPager: + """A pager for iterating through ``audit_user_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` object, and + provides an ``__iter__`` method to iterate through its + ``user_links`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``AuditUserLinks`` requests and continue to iterate + through the ``user_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` + 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[..., analytics_admin.AuditUserLinksResponse], + request: analytics_admin.AuditUserLinksRequest, + response: analytics_admin.AuditUserLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.AuditUserLinksResponse): + 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 = analytics_admin.AuditUserLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.AuditUserLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.AuditUserLink]: + for page in self.pages: + yield from page.user_links + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class AuditUserLinksAsyncPager: + """A pager for iterating through ``audit_user_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``user_links`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``AuditUserLinks`` requests and continue to iterate + through the ``user_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` + 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[analytics_admin.AuditUserLinksResponse]], + request: analytics_admin.AuditUserLinksRequest, + response: analytics_admin.AuditUserLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.AuditUserLinksResponse): + 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 = analytics_admin.AuditUserLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.AuditUserLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.AuditUserLink]: + async def async_generator(): + async for page in self.pages: + for response in page.user_links: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListWebDataStreamsPager: + """A pager for iterating through ``list_web_data_streams`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``web_data_streams`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListWebDataStreams`` requests and continue to iterate + through the ``web_data_streams`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` + 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[..., analytics_admin.ListWebDataStreamsResponse], + request: analytics_admin.ListWebDataStreamsRequest, + response: analytics_admin.ListWebDataStreamsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse): + 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 = analytics_admin.ListWebDataStreamsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListWebDataStreamsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.WebDataStream]: + for page in self.pages: + yield from page.web_data_streams + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListWebDataStreamsAsyncPager: + """A pager for iterating through ``list_web_data_streams`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``web_data_streams`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListWebDataStreams`` requests and continue to iterate + through the ``web_data_streams`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` + 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[analytics_admin.ListWebDataStreamsResponse]], + request: analytics_admin.ListWebDataStreamsRequest, + response: analytics_admin.ListWebDataStreamsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse): + 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 = analytics_admin.ListWebDataStreamsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListWebDataStreamsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.WebDataStream]: + async def async_generator(): + async for page in self.pages: + for response in page.web_data_streams: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListIosAppDataStreamsPager: + """A pager for iterating through ``list_ios_app_data_streams`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``ios_app_data_streams`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListIosAppDataStreams`` requests and continue to iterate + through the ``ios_app_data_streams`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` + 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[..., analytics_admin.ListIosAppDataStreamsResponse], + request: analytics_admin.ListIosAppDataStreamsRequest, + response: analytics_admin.ListIosAppDataStreamsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse): + 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 = analytics_admin.ListIosAppDataStreamsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListIosAppDataStreamsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.IosAppDataStream]: + for page in self.pages: + yield from page.ios_app_data_streams + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListIosAppDataStreamsAsyncPager: + """A pager for iterating through ``list_ios_app_data_streams`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``ios_app_data_streams`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListIosAppDataStreams`` requests and continue to iterate + through the ``ios_app_data_streams`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` + 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[analytics_admin.ListIosAppDataStreamsResponse]], + request: analytics_admin.ListIosAppDataStreamsRequest, + response: analytics_admin.ListIosAppDataStreamsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse): + 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 = analytics_admin.ListIosAppDataStreamsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListIosAppDataStreamsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.IosAppDataStream]: + async def async_generator(): + async for page in self.pages: + for response in page.ios_app_data_streams: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAndroidAppDataStreamsPager: + """A pager for iterating through ``list_android_app_data_streams`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``android_app_data_streams`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAndroidAppDataStreams`` requests and continue to iterate + through the ``android_app_data_streams`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` + 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[..., analytics_admin.ListAndroidAppDataStreamsResponse], + request: analytics_admin.ListAndroidAppDataStreamsRequest, + response: analytics_admin.ListAndroidAppDataStreamsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse): + 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 = analytics_admin.ListAndroidAppDataStreamsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListAndroidAppDataStreamsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.AndroidAppDataStream]: + for page in self.pages: + yield from page.android_app_data_streams + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAndroidAppDataStreamsAsyncPager: + """A pager for iterating through ``list_android_app_data_streams`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``android_app_data_streams`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAndroidAppDataStreams`` requests and continue to iterate + through the ``android_app_data_streams`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` + 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[analytics_admin.ListAndroidAppDataStreamsResponse]], + request: analytics_admin.ListAndroidAppDataStreamsRequest, + response: analytics_admin.ListAndroidAppDataStreamsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse): + 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 = analytics_admin.ListAndroidAppDataStreamsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListAndroidAppDataStreamsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.AndroidAppDataStream]: + async def async_generator(): + async for page in self.pages: + for response in page.android_app_data_streams: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListFirebaseLinksPager: + """A pager for iterating through ``list_firebase_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` object, and + provides an ``__iter__`` method to iterate through its + ``firebase_links`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFirebaseLinks`` requests and continue to iterate + through the ``firebase_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` + 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[..., analytics_admin.ListFirebaseLinksResponse], + request: analytics_admin.ListFirebaseLinksRequest, + response: analytics_admin.ListFirebaseLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse): + 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 = analytics_admin.ListFirebaseLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListFirebaseLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.FirebaseLink]: + for page in self.pages: + yield from page.firebase_links + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListFirebaseLinksAsyncPager: + """A pager for iterating through ``list_firebase_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``firebase_links`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFirebaseLinks`` requests and continue to iterate + through the ``firebase_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` + 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[analytics_admin.ListFirebaseLinksResponse]], + request: analytics_admin.ListFirebaseLinksRequest, + response: analytics_admin.ListFirebaseLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse): + 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 = analytics_admin.ListFirebaseLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListFirebaseLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.FirebaseLink]: + async def async_generator(): + async for page in self.pages: + for response in page.firebase_links: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListGoogleAdsLinksPager: + """A pager for iterating through ``list_google_ads_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` object, and + provides an ``__iter__`` method to iterate through its + ``google_ads_links`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListGoogleAdsLinks`` requests and continue to iterate + through the ``google_ads_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` + 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[..., analytics_admin.ListGoogleAdsLinksResponse], + request: analytics_admin.ListGoogleAdsLinksRequest, + response: analytics_admin.ListGoogleAdsLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse): + 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 = analytics_admin.ListGoogleAdsLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListGoogleAdsLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.GoogleAdsLink]: + for page in self.pages: + yield from page.google_ads_links + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListGoogleAdsLinksAsyncPager: + """A pager for iterating through ``list_google_ads_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``google_ads_links`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListGoogleAdsLinks`` requests and continue to iterate + through the ``google_ads_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` + 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[analytics_admin.ListGoogleAdsLinksResponse]], + request: analytics_admin.ListGoogleAdsLinksRequest, + response: analytics_admin.ListGoogleAdsLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse): + 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 = analytics_admin.ListGoogleAdsLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListGoogleAdsLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.GoogleAdsLink]: + async def async_generator(): + async for page in self.pages: + for response in page.google_ads_links: + 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/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py new file mode 100644 index 00000000..c11f91bc --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py @@ -0,0 +1,35 @@ +# -*- 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 AnalyticsAdminServiceTransport +from .grpc import AnalyticsAdminServiceGrpcTransport +from .grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[AnalyticsAdminServiceTransport]] +_transport_registry['grpc'] = AnalyticsAdminServiceGrpcTransport +_transport_registry['grpc_asyncio'] = AnalyticsAdminServiceGrpcAsyncIOTransport + +__all__ = ( + 'AnalyticsAdminServiceTransport', + 'AnalyticsAdminServiceGrpcTransport', + 'AnalyticsAdminServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py new file mode 100644 index 00000000..9570d80c --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py @@ -0,0 +1,790 @@ +# -*- 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 +import typing +import pkg_resources + +from google import auth # type: ignore +from google.api_core import exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials # type: ignore + +from google.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources +from google.protobuf import empty_pb2 as empty # type: ignore + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-analytics-admin', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +class AnalyticsAdminServiceTransport(abc.ABC): + """Abstract transport class for AnalyticsAdminService.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/analytics.edit', + 'https://www.googleapis.com/auth/analytics.manage.users', + 'https://www.googleapis.com/auth/analytics.manage.users.readonly', + 'https://www.googleapis.com/auth/analytics.readonly', + ) + + def __init__( + self, *, + host: str = 'analyticsadmin.googleapis.com', + credentials: credentials.Credentials = None, + credentials_file: typing.Optional[str] = None, + scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, + quota_project_id: typing.Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scope (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ':' not in host: + host += ':443' + self._host = host + + # Save the scopes. + self._scopes = scopes or self.AUTH_SCOPES + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = auth.load_credentials_from_file( + credentials_file, + scopes=self._scopes, + quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = auth.default(scopes=self._scopes, quota_project_id=quota_project_id) + + # Save the credentials. + self._credentials = credentials + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.get_account: gapic_v1.method.wrap_method( + self.get_account, + default_timeout=60.0, + client_info=client_info, + ), + self.list_accounts: gapic_v1.method.wrap_method( + self.list_accounts, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_account: gapic_v1.method.wrap_method( + self.delete_account, + default_timeout=60.0, + client_info=client_info, + ), + self.update_account: gapic_v1.method.wrap_method( + self.update_account, + default_timeout=60.0, + client_info=client_info, + ), + self.provision_account_ticket: gapic_v1.method.wrap_method( + self.provision_account_ticket, + default_timeout=60.0, + client_info=client_info, + ), + self.list_account_summaries: gapic_v1.method.wrap_method( + self.list_account_summaries, + default_timeout=None, + client_info=client_info, + ), + self.get_property: gapic_v1.method.wrap_method( + self.get_property, + default_timeout=60.0, + client_info=client_info, + ), + self.list_properties: gapic_v1.method.wrap_method( + self.list_properties, + default_timeout=60.0, + client_info=client_info, + ), + self.create_property: gapic_v1.method.wrap_method( + self.create_property, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_property: gapic_v1.method.wrap_method( + self.delete_property, + default_timeout=60.0, + client_info=client_info, + ), + self.update_property: gapic_v1.method.wrap_method( + self.update_property, + default_timeout=60.0, + client_info=client_info, + ), + self.get_user_link: gapic_v1.method.wrap_method( + self.get_user_link, + default_timeout=60.0, + client_info=client_info, + ), + self.batch_get_user_links: gapic_v1.method.wrap_method( + self.batch_get_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.list_user_links: gapic_v1.method.wrap_method( + self.list_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.audit_user_links: gapic_v1.method.wrap_method( + self.audit_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.create_user_link: gapic_v1.method.wrap_method( + self.create_user_link, + default_timeout=60.0, + client_info=client_info, + ), + self.batch_create_user_links: gapic_v1.method.wrap_method( + self.batch_create_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.update_user_link: gapic_v1.method.wrap_method( + self.update_user_link, + default_timeout=60.0, + client_info=client_info, + ), + self.batch_update_user_links: gapic_v1.method.wrap_method( + self.batch_update_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_user_link: gapic_v1.method.wrap_method( + self.delete_user_link, + default_timeout=60.0, + client_info=client_info, + ), + self.batch_delete_user_links: gapic_v1.method.wrap_method( + self.batch_delete_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.get_web_data_stream: gapic_v1.method.wrap_method( + self.get_web_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_web_data_stream: gapic_v1.method.wrap_method( + self.delete_web_data_stream, + default_timeout=None, + client_info=client_info, + ), + self.update_web_data_stream: gapic_v1.method.wrap_method( + self.update_web_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.create_web_data_stream: gapic_v1.method.wrap_method( + self.create_web_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.list_web_data_streams: gapic_v1.method.wrap_method( + self.list_web_data_streams, + default_timeout=60.0, + client_info=client_info, + ), + self.get_ios_app_data_stream: gapic_v1.method.wrap_method( + self.get_ios_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_ios_app_data_stream: gapic_v1.method.wrap_method( + self.delete_ios_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.update_ios_app_data_stream: gapic_v1.method.wrap_method( + self.update_ios_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.create_ios_app_data_stream: gapic_v1.method.wrap_method( + self.create_ios_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.list_ios_app_data_streams: gapic_v1.method.wrap_method( + self.list_ios_app_data_streams, + default_timeout=60.0, + client_info=client_info, + ), + self.get_android_app_data_stream: gapic_v1.method.wrap_method( + self.get_android_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_android_app_data_stream: gapic_v1.method.wrap_method( + self.delete_android_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.update_android_app_data_stream: gapic_v1.method.wrap_method( + self.update_android_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.create_android_app_data_stream: gapic_v1.method.wrap_method( + self.create_android_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.list_android_app_data_streams: gapic_v1.method.wrap_method( + self.list_android_app_data_streams, + default_timeout=60.0, + client_info=client_info, + ), + self.get_enhanced_measurement_settings: gapic_v1.method.wrap_method( + self.get_enhanced_measurement_settings, + default_timeout=60.0, + client_info=client_info, + ), + self.update_enhanced_measurement_settings: gapic_v1.method.wrap_method( + self.update_enhanced_measurement_settings, + default_timeout=60.0, + client_info=client_info, + ), + self.create_firebase_link: gapic_v1.method.wrap_method( + self.create_firebase_link, + default_timeout=60.0, + client_info=client_info, + ), + self.update_firebase_link: gapic_v1.method.wrap_method( + self.update_firebase_link, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_firebase_link: gapic_v1.method.wrap_method( + self.delete_firebase_link, + default_timeout=60.0, + client_info=client_info, + ), + self.list_firebase_links: gapic_v1.method.wrap_method( + self.list_firebase_links, + default_timeout=60.0, + client_info=client_info, + ), + self.get_global_site_tag: gapic_v1.method.wrap_method( + self.get_global_site_tag, + default_timeout=60.0, + client_info=client_info, + ), + self.create_google_ads_link: gapic_v1.method.wrap_method( + self.create_google_ads_link, + default_timeout=60.0, + client_info=client_info, + ), + self.update_google_ads_link: gapic_v1.method.wrap_method( + self.update_google_ads_link, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_google_ads_link: gapic_v1.method.wrap_method( + self.delete_google_ads_link, + default_timeout=60.0, + client_info=client_info, + ), + self.list_google_ads_links: gapic_v1.method.wrap_method( + self.list_google_ads_links, + default_timeout=60.0, + client_info=client_info, + ), + self.get_data_sharing_settings: gapic_v1.method.wrap_method( + self.get_data_sharing_settings, + default_timeout=None, + client_info=client_info, + ), + + } + + @property + def get_account(self) -> typing.Callable[ + [analytics_admin.GetAccountRequest], + typing.Union[ + resources.Account, + typing.Awaitable[resources.Account] + ]]: + raise NotImplementedError() + + @property + def list_accounts(self) -> typing.Callable[ + [analytics_admin.ListAccountsRequest], + typing.Union[ + analytics_admin.ListAccountsResponse, + typing.Awaitable[analytics_admin.ListAccountsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_account(self) -> typing.Callable[ + [analytics_admin.DeleteAccountRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def update_account(self) -> typing.Callable[ + [analytics_admin.UpdateAccountRequest], + typing.Union[ + resources.Account, + typing.Awaitable[resources.Account] + ]]: + raise NotImplementedError() + + @property + def provision_account_ticket(self) -> typing.Callable[ + [analytics_admin.ProvisionAccountTicketRequest], + typing.Union[ + analytics_admin.ProvisionAccountTicketResponse, + typing.Awaitable[analytics_admin.ProvisionAccountTicketResponse] + ]]: + raise NotImplementedError() + + @property + def list_account_summaries(self) -> typing.Callable[ + [analytics_admin.ListAccountSummariesRequest], + typing.Union[ + analytics_admin.ListAccountSummariesResponse, + typing.Awaitable[analytics_admin.ListAccountSummariesResponse] + ]]: + raise NotImplementedError() + + @property + def get_property(self) -> typing.Callable[ + [analytics_admin.GetPropertyRequest], + typing.Union[ + resources.Property, + typing.Awaitable[resources.Property] + ]]: + raise NotImplementedError() + + @property + def list_properties(self) -> typing.Callable[ + [analytics_admin.ListPropertiesRequest], + typing.Union[ + analytics_admin.ListPropertiesResponse, + typing.Awaitable[analytics_admin.ListPropertiesResponse] + ]]: + raise NotImplementedError() + + @property + def create_property(self) -> typing.Callable[ + [analytics_admin.CreatePropertyRequest], + typing.Union[ + resources.Property, + typing.Awaitable[resources.Property] + ]]: + raise NotImplementedError() + + @property + def delete_property(self) -> typing.Callable[ + [analytics_admin.DeletePropertyRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def update_property(self) -> typing.Callable[ + [analytics_admin.UpdatePropertyRequest], + typing.Union[ + resources.Property, + typing.Awaitable[resources.Property] + ]]: + raise NotImplementedError() + + @property + def get_user_link(self) -> typing.Callable[ + [analytics_admin.GetUserLinkRequest], + typing.Union[ + resources.UserLink, + typing.Awaitable[resources.UserLink] + ]]: + raise NotImplementedError() + + @property + def batch_get_user_links(self) -> typing.Callable[ + [analytics_admin.BatchGetUserLinksRequest], + typing.Union[ + analytics_admin.BatchGetUserLinksResponse, + typing.Awaitable[analytics_admin.BatchGetUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def list_user_links(self) -> typing.Callable[ + [analytics_admin.ListUserLinksRequest], + typing.Union[ + analytics_admin.ListUserLinksResponse, + typing.Awaitable[analytics_admin.ListUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def audit_user_links(self) -> typing.Callable[ + [analytics_admin.AuditUserLinksRequest], + typing.Union[ + analytics_admin.AuditUserLinksResponse, + typing.Awaitable[analytics_admin.AuditUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def create_user_link(self) -> typing.Callable[ + [analytics_admin.CreateUserLinkRequest], + typing.Union[ + resources.UserLink, + typing.Awaitable[resources.UserLink] + ]]: + raise NotImplementedError() + + @property + def batch_create_user_links(self) -> typing.Callable[ + [analytics_admin.BatchCreateUserLinksRequest], + typing.Union[ + analytics_admin.BatchCreateUserLinksResponse, + typing.Awaitable[analytics_admin.BatchCreateUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def update_user_link(self) -> typing.Callable[ + [analytics_admin.UpdateUserLinkRequest], + typing.Union[ + resources.UserLink, + typing.Awaitable[resources.UserLink] + ]]: + raise NotImplementedError() + + @property + def batch_update_user_links(self) -> typing.Callable[ + [analytics_admin.BatchUpdateUserLinksRequest], + typing.Union[ + analytics_admin.BatchUpdateUserLinksResponse, + typing.Awaitable[analytics_admin.BatchUpdateUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def delete_user_link(self) -> typing.Callable[ + [analytics_admin.DeleteUserLinkRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def batch_delete_user_links(self) -> typing.Callable[ + [analytics_admin.BatchDeleteUserLinksRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def get_web_data_stream(self) -> typing.Callable[ + [analytics_admin.GetWebDataStreamRequest], + typing.Union[ + resources.WebDataStream, + typing.Awaitable[resources.WebDataStream] + ]]: + raise NotImplementedError() + + @property + def delete_web_data_stream(self) -> typing.Callable[ + [analytics_admin.DeleteWebDataStreamRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def update_web_data_stream(self) -> typing.Callable[ + [analytics_admin.UpdateWebDataStreamRequest], + typing.Union[ + resources.WebDataStream, + typing.Awaitable[resources.WebDataStream] + ]]: + raise NotImplementedError() + + @property + def create_web_data_stream(self) -> typing.Callable[ + [analytics_admin.CreateWebDataStreamRequest], + typing.Union[ + resources.WebDataStream, + typing.Awaitable[resources.WebDataStream] + ]]: + raise NotImplementedError() + + @property + def list_web_data_streams(self) -> typing.Callable[ + [analytics_admin.ListWebDataStreamsRequest], + typing.Union[ + analytics_admin.ListWebDataStreamsResponse, + typing.Awaitable[analytics_admin.ListWebDataStreamsResponse] + ]]: + raise NotImplementedError() + + @property + def get_ios_app_data_stream(self) -> typing.Callable[ + [analytics_admin.GetIosAppDataStreamRequest], + typing.Union[ + resources.IosAppDataStream, + typing.Awaitable[resources.IosAppDataStream] + ]]: + raise NotImplementedError() + + @property + def delete_ios_app_data_stream(self) -> typing.Callable[ + [analytics_admin.DeleteIosAppDataStreamRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def update_ios_app_data_stream(self) -> typing.Callable[ + [analytics_admin.UpdateIosAppDataStreamRequest], + typing.Union[ + resources.IosAppDataStream, + typing.Awaitable[resources.IosAppDataStream] + ]]: + raise NotImplementedError() + + @property + def create_ios_app_data_stream(self) -> typing.Callable[ + [analytics_admin.CreateIosAppDataStreamRequest], + typing.Union[ + resources.IosAppDataStream, + typing.Awaitable[resources.IosAppDataStream] + ]]: + raise NotImplementedError() + + @property + def list_ios_app_data_streams(self) -> typing.Callable[ + [analytics_admin.ListIosAppDataStreamsRequest], + typing.Union[ + analytics_admin.ListIosAppDataStreamsResponse, + typing.Awaitable[analytics_admin.ListIosAppDataStreamsResponse] + ]]: + raise NotImplementedError() + + @property + def get_android_app_data_stream(self) -> typing.Callable[ + [analytics_admin.GetAndroidAppDataStreamRequest], + typing.Union[ + resources.AndroidAppDataStream, + typing.Awaitable[resources.AndroidAppDataStream] + ]]: + raise NotImplementedError() + + @property + def delete_android_app_data_stream(self) -> typing.Callable[ + [analytics_admin.DeleteAndroidAppDataStreamRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def update_android_app_data_stream(self) -> typing.Callable[ + [analytics_admin.UpdateAndroidAppDataStreamRequest], + typing.Union[ + resources.AndroidAppDataStream, + typing.Awaitable[resources.AndroidAppDataStream] + ]]: + raise NotImplementedError() + + @property + def create_android_app_data_stream(self) -> typing.Callable[ + [analytics_admin.CreateAndroidAppDataStreamRequest], + typing.Union[ + resources.AndroidAppDataStream, + typing.Awaitable[resources.AndroidAppDataStream] + ]]: + raise NotImplementedError() + + @property + def list_android_app_data_streams(self) -> typing.Callable[ + [analytics_admin.ListAndroidAppDataStreamsRequest], + typing.Union[ + analytics_admin.ListAndroidAppDataStreamsResponse, + typing.Awaitable[analytics_admin.ListAndroidAppDataStreamsResponse] + ]]: + raise NotImplementedError() + + @property + def get_enhanced_measurement_settings(self) -> typing.Callable[ + [analytics_admin.GetEnhancedMeasurementSettingsRequest], + typing.Union[ + resources.EnhancedMeasurementSettings, + typing.Awaitable[resources.EnhancedMeasurementSettings] + ]]: + raise NotImplementedError() + + @property + def update_enhanced_measurement_settings(self) -> typing.Callable[ + [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], + typing.Union[ + resources.EnhancedMeasurementSettings, + typing.Awaitable[resources.EnhancedMeasurementSettings] + ]]: + raise NotImplementedError() + + @property + def create_firebase_link(self) -> typing.Callable[ + [analytics_admin.CreateFirebaseLinkRequest], + typing.Union[ + resources.FirebaseLink, + typing.Awaitable[resources.FirebaseLink] + ]]: + raise NotImplementedError() + + @property + def update_firebase_link(self) -> typing.Callable[ + [analytics_admin.UpdateFirebaseLinkRequest], + typing.Union[ + resources.FirebaseLink, + typing.Awaitable[resources.FirebaseLink] + ]]: + raise NotImplementedError() + + @property + def delete_firebase_link(self) -> typing.Callable[ + [analytics_admin.DeleteFirebaseLinkRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def list_firebase_links(self) -> typing.Callable[ + [analytics_admin.ListFirebaseLinksRequest], + typing.Union[ + analytics_admin.ListFirebaseLinksResponse, + typing.Awaitable[analytics_admin.ListFirebaseLinksResponse] + ]]: + raise NotImplementedError() + + @property + def get_global_site_tag(self) -> typing.Callable[ + [analytics_admin.GetGlobalSiteTagRequest], + typing.Union[ + resources.GlobalSiteTag, + typing.Awaitable[resources.GlobalSiteTag] + ]]: + raise NotImplementedError() + + @property + def create_google_ads_link(self) -> typing.Callable[ + [analytics_admin.CreateGoogleAdsLinkRequest], + typing.Union[ + resources.GoogleAdsLink, + typing.Awaitable[resources.GoogleAdsLink] + ]]: + raise NotImplementedError() + + @property + def update_google_ads_link(self) -> typing.Callable[ + [analytics_admin.UpdateGoogleAdsLinkRequest], + typing.Union[ + resources.GoogleAdsLink, + typing.Awaitable[resources.GoogleAdsLink] + ]]: + raise NotImplementedError() + + @property + def delete_google_ads_link(self) -> typing.Callable[ + [analytics_admin.DeleteGoogleAdsLinkRequest], + typing.Union[ + empty.Empty, + typing.Awaitable[empty.Empty] + ]]: + raise NotImplementedError() + + @property + def list_google_ads_links(self) -> typing.Callable[ + [analytics_admin.ListGoogleAdsLinksRequest], + typing.Union[ + analytics_admin.ListGoogleAdsLinksResponse, + typing.Awaitable[analytics_admin.ListGoogleAdsLinksResponse] + ]]: + raise NotImplementedError() + + @property + def get_data_sharing_settings(self) -> typing.Callable[ + [analytics_admin.GetDataSharingSettingsRequest], + typing.Union[ + resources.DataSharingSettings, + typing.Awaitable[resources.DataSharingSettings] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'AnalyticsAdminServiceTransport', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py new file mode 100644 index 00000000..929e3ef6 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py @@ -0,0 +1,1567 @@ +# -*- 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 + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google import auth # type: ignore +from google.auth import credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources +from google.protobuf import empty_pb2 as empty # type: ignore + +from .base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO + + +class AnalyticsAdminServiceGrpcTransport(AnalyticsAdminServiceTransport): + """gRPC backend transport for AnalyticsAdminService. + + Service Interface for the Analytics Admin API (GA4). + + 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 = 'analyticsadmin.googleapis.com', + credentials: credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'analyticsadmin.googleapis.com', + credentials: 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. + """ + scopes = scopes or cls.AUTH_SCOPES + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def get_account(self) -> Callable[ + [analytics_admin.GetAccountRequest], + resources.Account]: + r"""Return a callable for the get account method over gRPC. + + Lookup for a single Account. + + Returns: + Callable[[~.GetAccountRequest], + ~.Account]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_account' not in self._stubs: + self._stubs['get_account'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccount', + request_serializer=analytics_admin.GetAccountRequest.serialize, + response_deserializer=resources.Account.deserialize, + ) + return self._stubs['get_account'] + + @property + def list_accounts(self) -> Callable[ + [analytics_admin.ListAccountsRequest], + analytics_admin.ListAccountsResponse]: + r"""Return a callable for the list accounts method over gRPC. + + Returns all accounts accessible by the caller. + Note that these accounts might not currently have GA4 + properties. Soft-deleted (ie: "trashed") accounts are + excluded by default. Returns an empty list if no + relevant accounts are found. + + Returns: + Callable[[~.ListAccountsRequest], + ~.ListAccountsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_accounts' not in self._stubs: + self._stubs['list_accounts'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccounts', + request_serializer=analytics_admin.ListAccountsRequest.serialize, + response_deserializer=analytics_admin.ListAccountsResponse.deserialize, + ) + return self._stubs['list_accounts'] + + @property + def delete_account(self) -> Callable[ + [analytics_admin.DeleteAccountRequest], + empty.Empty]: + r"""Return a callable for the delete account method over gRPC. + + Marks target Account as soft-deleted (ie: "trashed") + and returns it. + This API does not have a method to restore soft-deleted + accounts. However, they can be restored using the Trash + Can UI. + If the accounts are not restored before the expiration + time, the account and all child resources (eg: + Properties, GoogleAdsLinks, Streams, UserLinks) will be + permanently purged. + https://support.google.com/analytics/answer/6154772 + Returns an error if the target is not found. + + Returns: + Callable[[~.DeleteAccountRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_account' not in self._stubs: + self._stubs['delete_account'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccount', + request_serializer=analytics_admin.DeleteAccountRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_account'] + + @property + def update_account(self) -> Callable[ + [analytics_admin.UpdateAccountRequest], + resources.Account]: + r"""Return a callable for the update account method over gRPC. + + Updates an account. + + Returns: + Callable[[~.UpdateAccountRequest], + ~.Account]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_account' not in self._stubs: + self._stubs['update_account'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccount', + request_serializer=analytics_admin.UpdateAccountRequest.serialize, + response_deserializer=resources.Account.deserialize, + ) + return self._stubs['update_account'] + + @property + def provision_account_ticket(self) -> Callable[ + [analytics_admin.ProvisionAccountTicketRequest], + analytics_admin.ProvisionAccountTicketResponse]: + r"""Return a callable for the provision account ticket method over gRPC. + + Requests a ticket for creating an account. + + Returns: + Callable[[~.ProvisionAccountTicketRequest], + ~.ProvisionAccountTicketResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'provision_account_ticket' not in self._stubs: + self._stubs['provision_account_ticket'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ProvisionAccountTicket', + request_serializer=analytics_admin.ProvisionAccountTicketRequest.serialize, + response_deserializer=analytics_admin.ProvisionAccountTicketResponse.deserialize, + ) + return self._stubs['provision_account_ticket'] + + @property + def list_account_summaries(self) -> Callable[ + [analytics_admin.ListAccountSummariesRequest], + analytics_admin.ListAccountSummariesResponse]: + r"""Return a callable for the list account summaries method over gRPC. + + Returns summaries of all accounts accessible by the + caller. + + Returns: + Callable[[~.ListAccountSummariesRequest], + ~.ListAccountSummariesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_account_summaries' not in self._stubs: + self._stubs['list_account_summaries'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccountSummaries', + request_serializer=analytics_admin.ListAccountSummariesRequest.serialize, + response_deserializer=analytics_admin.ListAccountSummariesResponse.deserialize, + ) + return self._stubs['list_account_summaries'] + + @property + def get_property(self) -> Callable[ + [analytics_admin.GetPropertyRequest], + resources.Property]: + r"""Return a callable for the get property method over gRPC. + + Lookup for a single "GA4" Property. + + Returns: + Callable[[~.GetPropertyRequest], + ~.Property]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_property' not in self._stubs: + self._stubs['get_property'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetProperty', + request_serializer=analytics_admin.GetPropertyRequest.serialize, + response_deserializer=resources.Property.deserialize, + ) + return self._stubs['get_property'] + + @property + def list_properties(self) -> Callable[ + [analytics_admin.ListPropertiesRequest], + analytics_admin.ListPropertiesResponse]: + r"""Return a callable for the list properties method over gRPC. + + Returns child Properties under the specified parent + Account. + Only "GA4" properties will be returned. + Properties will be excluded if the caller does not have + access. Soft-deleted (ie: "trashed") properties are + excluded by default. Returns an empty list if no + relevant properties are found. + + Returns: + Callable[[~.ListPropertiesRequest], + ~.ListPropertiesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_properties' not in self._stubs: + self._stubs['list_properties'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListProperties', + request_serializer=analytics_admin.ListPropertiesRequest.serialize, + response_deserializer=analytics_admin.ListPropertiesResponse.deserialize, + ) + return self._stubs['list_properties'] + + @property + def create_property(self) -> Callable[ + [analytics_admin.CreatePropertyRequest], + resources.Property]: + r"""Return a callable for the create property method over gRPC. + + Creates an "GA4" property with the specified location + and attributes. + + Returns: + Callable[[~.CreatePropertyRequest], + ~.Property]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_property' not in self._stubs: + self._stubs['create_property'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateProperty', + request_serializer=analytics_admin.CreatePropertyRequest.serialize, + response_deserializer=resources.Property.deserialize, + ) + return self._stubs['create_property'] + + @property + def delete_property(self) -> Callable[ + [analytics_admin.DeletePropertyRequest], + empty.Empty]: + r"""Return a callable for the delete property method over gRPC. + + Marks target Property as soft-deleted (ie: "trashed") + and returns it. + This API does not have a method to restore soft-deleted + properties. However, they can be restored using the + Trash Can UI. + If the properties are not restored before the expiration + time, the Property and all child resources (eg: + GoogleAdsLinks, Streams, UserLinks) will be permanently + purged. + https://support.google.com/analytics/answer/6154772 + Returns an error if the target is not found, or is not + an GA4 Property. + + Returns: + Callable[[~.DeletePropertyRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_property' not in self._stubs: + self._stubs['delete_property'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteProperty', + request_serializer=analytics_admin.DeletePropertyRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_property'] + + @property + def update_property(self) -> Callable[ + [analytics_admin.UpdatePropertyRequest], + resources.Property]: + r"""Return a callable for the update property method over gRPC. + + Updates a property. + + Returns: + Callable[[~.UpdatePropertyRequest], + ~.Property]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_property' not in self._stubs: + self._stubs['update_property'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateProperty', + request_serializer=analytics_admin.UpdatePropertyRequest.serialize, + response_deserializer=resources.Property.deserialize, + ) + return self._stubs['update_property'] + + @property + def get_user_link(self) -> Callable[ + [analytics_admin.GetUserLinkRequest], + resources.UserLink]: + r"""Return a callable for the get user link method over gRPC. + + Gets information about a user's link to an account or + property. + + Returns: + Callable[[~.GetUserLinkRequest], + ~.UserLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_user_link' not in self._stubs: + self._stubs['get_user_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetUserLink', + request_serializer=analytics_admin.GetUserLinkRequest.serialize, + response_deserializer=resources.UserLink.deserialize, + ) + return self._stubs['get_user_link'] + + @property + def batch_get_user_links(self) -> Callable[ + [analytics_admin.BatchGetUserLinksRequest], + analytics_admin.BatchGetUserLinksResponse]: + r"""Return a callable for the batch get user links method over gRPC. + + Gets information about multiple users' links to an + account or property. + + Returns: + Callable[[~.BatchGetUserLinksRequest], + ~.BatchGetUserLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'batch_get_user_links' not in self._stubs: + self._stubs['batch_get_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchGetUserLinks', + request_serializer=analytics_admin.BatchGetUserLinksRequest.serialize, + response_deserializer=analytics_admin.BatchGetUserLinksResponse.deserialize, + ) + return self._stubs['batch_get_user_links'] + + @property + def list_user_links(self) -> Callable[ + [analytics_admin.ListUserLinksRequest], + analytics_admin.ListUserLinksResponse]: + r"""Return a callable for the list user links method over gRPC. + + Lists all user links on an account or property. + + Returns: + Callable[[~.ListUserLinksRequest], + ~.ListUserLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_user_links' not in self._stubs: + self._stubs['list_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListUserLinks', + request_serializer=analytics_admin.ListUserLinksRequest.serialize, + response_deserializer=analytics_admin.ListUserLinksResponse.deserialize, + ) + return self._stubs['list_user_links'] + + @property + def audit_user_links(self) -> Callable[ + [analytics_admin.AuditUserLinksRequest], + analytics_admin.AuditUserLinksResponse]: + r"""Return a callable for the audit user links method over gRPC. + + Lists all user links on an account or property, + including implicit ones that come from effective + permissions granted by groups or organization admin + roles. + + If a returned user link does not have direct + permissions, they cannot be removed from the account or + property directly with the DeleteUserLink command. They + have to be removed from the group/etc that gives them + permissions, which is currently only usable/discoverable + in the GA or GMP UIs. + + Returns: + Callable[[~.AuditUserLinksRequest], + ~.AuditUserLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'audit_user_links' not in self._stubs: + self._stubs['audit_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/AuditUserLinks', + request_serializer=analytics_admin.AuditUserLinksRequest.serialize, + response_deserializer=analytics_admin.AuditUserLinksResponse.deserialize, + ) + return self._stubs['audit_user_links'] + + @property + def create_user_link(self) -> Callable[ + [analytics_admin.CreateUserLinkRequest], + resources.UserLink]: + r"""Return a callable for the create user link method over gRPC. + + Creates a user link on an account or property. + If the user with the specified email already has + permissions on the account or property, then the user's + existing permissions will be unioned with the + permissions specified in the new UserLink. + + Returns: + Callable[[~.CreateUserLinkRequest], + ~.UserLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_user_link' not in self._stubs: + self._stubs['create_user_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateUserLink', + request_serializer=analytics_admin.CreateUserLinkRequest.serialize, + response_deserializer=resources.UserLink.deserialize, + ) + return self._stubs['create_user_link'] + + @property + def batch_create_user_links(self) -> Callable[ + [analytics_admin.BatchCreateUserLinksRequest], + analytics_admin.BatchCreateUserLinksResponse]: + r"""Return a callable for the batch create user links method over gRPC. + + Creates information about multiple users' links to an + account or property. + This method is transactional. If any UserLink cannot be + created, none of the UserLinks will be created. + + Returns: + Callable[[~.BatchCreateUserLinksRequest], + ~.BatchCreateUserLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'batch_create_user_links' not in self._stubs: + self._stubs['batch_create_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchCreateUserLinks', + request_serializer=analytics_admin.BatchCreateUserLinksRequest.serialize, + response_deserializer=analytics_admin.BatchCreateUserLinksResponse.deserialize, + ) + return self._stubs['batch_create_user_links'] + + @property + def update_user_link(self) -> Callable[ + [analytics_admin.UpdateUserLinkRequest], + resources.UserLink]: + r"""Return a callable for the update user link method over gRPC. + + Updates a user link on an account or property. + + Returns: + Callable[[~.UpdateUserLinkRequest], + ~.UserLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_user_link' not in self._stubs: + self._stubs['update_user_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateUserLink', + request_serializer=analytics_admin.UpdateUserLinkRequest.serialize, + response_deserializer=resources.UserLink.deserialize, + ) + return self._stubs['update_user_link'] + + @property + def batch_update_user_links(self) -> Callable[ + [analytics_admin.BatchUpdateUserLinksRequest], + analytics_admin.BatchUpdateUserLinksResponse]: + r"""Return a callable for the batch update user links method over gRPC. + + Updates information about multiple users' links to an + account or property. + + Returns: + Callable[[~.BatchUpdateUserLinksRequest], + ~.BatchUpdateUserLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'batch_update_user_links' not in self._stubs: + self._stubs['batch_update_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchUpdateUserLinks', + request_serializer=analytics_admin.BatchUpdateUserLinksRequest.serialize, + response_deserializer=analytics_admin.BatchUpdateUserLinksResponse.deserialize, + ) + return self._stubs['batch_update_user_links'] + + @property + def delete_user_link(self) -> Callable[ + [analytics_admin.DeleteUserLinkRequest], + empty.Empty]: + r"""Return a callable for the delete user link method over gRPC. + + Deletes a user link on an account or property. + + Returns: + Callable[[~.DeleteUserLinkRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_user_link' not in self._stubs: + self._stubs['delete_user_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteUserLink', + request_serializer=analytics_admin.DeleteUserLinkRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_user_link'] + + @property + def batch_delete_user_links(self) -> Callable[ + [analytics_admin.BatchDeleteUserLinksRequest], + empty.Empty]: + r"""Return a callable for the batch delete user links method over gRPC. + + Deletes information about multiple users' links to an + account or property. + + Returns: + Callable[[~.BatchDeleteUserLinksRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'batch_delete_user_links' not in self._stubs: + self._stubs['batch_delete_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteUserLinks', + request_serializer=analytics_admin.BatchDeleteUserLinksRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['batch_delete_user_links'] + + @property + def get_web_data_stream(self) -> Callable[ + [analytics_admin.GetWebDataStreamRequest], + resources.WebDataStream]: + r"""Return a callable for the get web data stream method over gRPC. + + Lookup for a single WebDataStream + + Returns: + Callable[[~.GetWebDataStreamRequest], + ~.WebDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: + self._stubs['get_web_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetWebDataStream', + request_serializer=analytics_admin.GetWebDataStreamRequest.serialize, + response_deserializer=resources.WebDataStream.deserialize, + ) + return self._stubs['get_web_data_stream'] + + @property + def delete_web_data_stream(self) -> Callable[ + [analytics_admin.DeleteWebDataStreamRequest], + empty.Empty]: + r"""Return a callable for the delete web data stream method over gRPC. + + Deletes a web stream on a property. + + Returns: + Callable[[~.DeleteWebDataStreamRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_web_data_stream' not in self._stubs: + self._stubs['delete_web_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteWebDataStream', + request_serializer=analytics_admin.DeleteWebDataStreamRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_web_data_stream'] + + @property + def update_web_data_stream(self) -> Callable[ + [analytics_admin.UpdateWebDataStreamRequest], + resources.WebDataStream]: + r"""Return a callable for the update web data stream method over gRPC. + + Updates a web stream on a property. + + Returns: + Callable[[~.UpdateWebDataStreamRequest], + ~.WebDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: + self._stubs['update_web_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateWebDataStream', + request_serializer=analytics_admin.UpdateWebDataStreamRequest.serialize, + response_deserializer=resources.WebDataStream.deserialize, + ) + return self._stubs['update_web_data_stream'] + + @property + def create_web_data_stream(self) -> Callable[ + [analytics_admin.CreateWebDataStreamRequest], + resources.WebDataStream]: + r"""Return a callable for the create web data stream method over gRPC. + + Creates a web stream with the specified location and + attributes. + + Returns: + Callable[[~.CreateWebDataStreamRequest], + ~.WebDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: + self._stubs['create_web_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateWebDataStream', + request_serializer=analytics_admin.CreateWebDataStreamRequest.serialize, + response_deserializer=resources.WebDataStream.deserialize, + ) + return self._stubs['create_web_data_stream'] + + @property + def list_web_data_streams(self) -> Callable[ + [analytics_admin.ListWebDataStreamsRequest], + analytics_admin.ListWebDataStreamsResponse]: + r"""Return a callable for the list web data streams method over gRPC. + + Returns child web data streams under the specified + parent property. + Web data streams will be excluded if the caller does not + have access. Returns an empty list if no relevant web + data streams are found. + + Returns: + Callable[[~.ListWebDataStreamsRequest], + ~.ListWebDataStreamsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_web_data_streams' not in self._stubs: + self._stubs['list_web_data_streams'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListWebDataStreams', + request_serializer=analytics_admin.ListWebDataStreamsRequest.serialize, + response_deserializer=analytics_admin.ListWebDataStreamsResponse.deserialize, + ) + return self._stubs['list_web_data_streams'] + + @property + def get_ios_app_data_stream(self) -> Callable[ + [analytics_admin.GetIosAppDataStreamRequest], + resources.IosAppDataStream]: + r"""Return a callable for the get ios app data stream method over gRPC. + + Lookup for a single IosAppDataStream + + Returns: + Callable[[~.GetIosAppDataStreamRequest], + ~.IosAppDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: + self._stubs['get_ios_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetIosAppDataStream', + request_serializer=analytics_admin.GetIosAppDataStreamRequest.serialize, + response_deserializer=resources.IosAppDataStream.deserialize, + ) + return self._stubs['get_ios_app_data_stream'] + + @property + def delete_ios_app_data_stream(self) -> Callable[ + [analytics_admin.DeleteIosAppDataStreamRequest], + empty.Empty]: + r"""Return a callable for the delete ios app data stream method over gRPC. + + Deletes an iOS app stream on a property. + + Returns: + Callable[[~.DeleteIosAppDataStreamRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_ios_app_data_stream' not in self._stubs: + self._stubs['delete_ios_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteIosAppDataStream', + request_serializer=analytics_admin.DeleteIosAppDataStreamRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_ios_app_data_stream'] + + @property + def update_ios_app_data_stream(self) -> Callable[ + [analytics_admin.UpdateIosAppDataStreamRequest], + resources.IosAppDataStream]: + r"""Return a callable for the update ios app data stream method over gRPC. + + Updates an iOS app stream on a property. + + Returns: + Callable[[~.UpdateIosAppDataStreamRequest], + ~.IosAppDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: + self._stubs['update_ios_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateIosAppDataStream', + request_serializer=analytics_admin.UpdateIosAppDataStreamRequest.serialize, + response_deserializer=resources.IosAppDataStream.deserialize, + ) + return self._stubs['update_ios_app_data_stream'] + + @property + def create_ios_app_data_stream(self) -> Callable[ + [analytics_admin.CreateIosAppDataStreamRequest], + resources.IosAppDataStream]: + r"""Return a callable for the create ios app data stream method over gRPC. + + Creates an iOS app stream with the specified location + and attributes. + Note that an iOS app stream must be linked to a Firebase + app to receive traffic. + + To create a working app stream, make sure your property + is linked to a Firebase project. Then, use the Firebase + API to create a Firebase app, which will also create an + appropriate data stream in Analytics (may take up to 24 + hours). + + Returns: + Callable[[~.CreateIosAppDataStreamRequest], + ~.IosAppDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: + self._stubs['create_ios_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateIosAppDataStream', + request_serializer=analytics_admin.CreateIosAppDataStreamRequest.serialize, + response_deserializer=resources.IosAppDataStream.deserialize, + ) + return self._stubs['create_ios_app_data_stream'] + + @property + def list_ios_app_data_streams(self) -> Callable[ + [analytics_admin.ListIosAppDataStreamsRequest], + analytics_admin.ListIosAppDataStreamsResponse]: + r"""Return a callable for the list ios app data streams method over gRPC. + + Returns child iOS app data streams under the + specified parent property. + iOS app data streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + iOS app data streams are found. + + Returns: + Callable[[~.ListIosAppDataStreamsRequest], + ~.ListIosAppDataStreamsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ios_app_data_streams' not in self._stubs: + self._stubs['list_ios_app_data_streams'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListIosAppDataStreams', + request_serializer=analytics_admin.ListIosAppDataStreamsRequest.serialize, + response_deserializer=analytics_admin.ListIosAppDataStreamsResponse.deserialize, + ) + return self._stubs['list_ios_app_data_streams'] + + @property + def get_android_app_data_stream(self) -> Callable[ + [analytics_admin.GetAndroidAppDataStreamRequest], + resources.AndroidAppDataStream]: + r"""Return a callable for the get android app data stream method over gRPC. + + Lookup for a single AndroidAppDataStream + + Returns: + Callable[[~.GetAndroidAppDataStreamRequest], + ~.AndroidAppDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: + self._stubs['get_android_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAndroidAppDataStream', + request_serializer=analytics_admin.GetAndroidAppDataStreamRequest.serialize, + response_deserializer=resources.AndroidAppDataStream.deserialize, + ) + return self._stubs['get_android_app_data_stream'] + + @property + def delete_android_app_data_stream(self) -> Callable[ + [analytics_admin.DeleteAndroidAppDataStreamRequest], + empty.Empty]: + r"""Return a callable for the delete android app data stream method over gRPC. + + Deletes an android app stream on a property. + + Returns: + Callable[[~.DeleteAndroidAppDataStreamRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_android_app_data_stream' not in self._stubs: + self._stubs['delete_android_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAndroidAppDataStream', + request_serializer=analytics_admin.DeleteAndroidAppDataStreamRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_android_app_data_stream'] + + @property + def update_android_app_data_stream(self) -> Callable[ + [analytics_admin.UpdateAndroidAppDataStreamRequest], + resources.AndroidAppDataStream]: + r"""Return a callable for the update android app data stream method over gRPC. + + Updates an android app stream on a property. + + Returns: + Callable[[~.UpdateAndroidAppDataStreamRequest], + ~.AndroidAppDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: + self._stubs['update_android_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAndroidAppDataStream', + request_serializer=analytics_admin.UpdateAndroidAppDataStreamRequest.serialize, + response_deserializer=resources.AndroidAppDataStream.deserialize, + ) + return self._stubs['update_android_app_data_stream'] + + @property + def create_android_app_data_stream(self) -> Callable[ + [analytics_admin.CreateAndroidAppDataStreamRequest], + resources.AndroidAppDataStream]: + r"""Return a callable for the create android app data stream method over gRPC. + + Creates an Android app stream with the specified + location and attributes. + Note that an Android app stream must be linked to a + Firebase app to receive traffic. + + To create a working app stream, make sure your property + is linked to a Firebase project. Then, use the Firebase + API to create a Firebase app, which will also create an + appropriate data stream in Analytics (may take up to 24 + hours). + + Returns: + Callable[[~.CreateAndroidAppDataStreamRequest], + ~.AndroidAppDataStream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: + self._stubs['create_android_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAndroidAppDataStream', + request_serializer=analytics_admin.CreateAndroidAppDataStreamRequest.serialize, + response_deserializer=resources.AndroidAppDataStream.deserialize, + ) + return self._stubs['create_android_app_data_stream'] + + @property + def list_android_app_data_streams(self) -> Callable[ + [analytics_admin.ListAndroidAppDataStreamsRequest], + analytics_admin.ListAndroidAppDataStreamsResponse]: + r"""Return a callable for the list android app data streams method over gRPC. + + Returns child android app streams under the specified + parent property. + Android app streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + android app streams are found. + + Returns: + Callable[[~.ListAndroidAppDataStreamsRequest], + ~.ListAndroidAppDataStreamsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_android_app_data_streams' not in self._stubs: + self._stubs['list_android_app_data_streams'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAndroidAppDataStreams', + request_serializer=analytics_admin.ListAndroidAppDataStreamsRequest.serialize, + response_deserializer=analytics_admin.ListAndroidAppDataStreamsResponse.deserialize, + ) + return self._stubs['list_android_app_data_streams'] + + @property + def get_enhanced_measurement_settings(self) -> Callable[ + [analytics_admin.GetEnhancedMeasurementSettingsRequest], + resources.EnhancedMeasurementSettings]: + r"""Return a callable for the get enhanced measurement + settings method over gRPC. + + Returns the singleton enhanced measurement settings + for this web stream. Note that the stream must enable + enhanced measurement for these settings to take effect. + + Returns: + Callable[[~.GetEnhancedMeasurementSettingsRequest], + ~.EnhancedMeasurementSettings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_enhanced_measurement_settings' not in self._stubs: + self._stubs['get_enhanced_measurement_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEnhancedMeasurementSettings', + request_serializer=analytics_admin.GetEnhancedMeasurementSettingsRequest.serialize, + response_deserializer=resources.EnhancedMeasurementSettings.deserialize, + ) + return self._stubs['get_enhanced_measurement_settings'] + + @property + def update_enhanced_measurement_settings(self) -> Callable[ + [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], + resources.EnhancedMeasurementSettings]: + r"""Return a callable for the update enhanced measurement + settings method over gRPC. + + Updates the singleton enhanced measurement settings + for this web stream. Note that the stream must enable + enhanced measurement for these settings to take effect. + + Returns: + Callable[[~.UpdateEnhancedMeasurementSettingsRequest], + ~.EnhancedMeasurementSettings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_enhanced_measurement_settings' not in self._stubs: + self._stubs['update_enhanced_measurement_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEnhancedMeasurementSettings', + request_serializer=analytics_admin.UpdateEnhancedMeasurementSettingsRequest.serialize, + response_deserializer=resources.EnhancedMeasurementSettings.deserialize, + ) + return self._stubs['update_enhanced_measurement_settings'] + + @property + def create_firebase_link(self) -> Callable[ + [analytics_admin.CreateFirebaseLinkRequest], + resources.FirebaseLink]: + r"""Return a callable for the create firebase link method over gRPC. + + Creates a FirebaseLink. + Properties can have at most one FirebaseLink. + + Returns: + Callable[[~.CreateFirebaseLinkRequest], + ~.FirebaseLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_firebase_link' not in self._stubs: + self._stubs['create_firebase_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateFirebaseLink', + request_serializer=analytics_admin.CreateFirebaseLinkRequest.serialize, + response_deserializer=resources.FirebaseLink.deserialize, + ) + return self._stubs['create_firebase_link'] + + @property + def update_firebase_link(self) -> Callable[ + [analytics_admin.UpdateFirebaseLinkRequest], + resources.FirebaseLink]: + r"""Return a callable for the update firebase link method over gRPC. + + Updates a FirebaseLink on a property + + Returns: + Callable[[~.UpdateFirebaseLinkRequest], + ~.FirebaseLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_firebase_link' not in self._stubs: + self._stubs['update_firebase_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateFirebaseLink', + request_serializer=analytics_admin.UpdateFirebaseLinkRequest.serialize, + response_deserializer=resources.FirebaseLink.deserialize, + ) + return self._stubs['update_firebase_link'] + + @property + def delete_firebase_link(self) -> Callable[ + [analytics_admin.DeleteFirebaseLinkRequest], + empty.Empty]: + r"""Return a callable for the delete firebase link method over gRPC. + + Deletes a FirebaseLink on a property + + Returns: + Callable[[~.DeleteFirebaseLinkRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_firebase_link' not in self._stubs: + self._stubs['delete_firebase_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteFirebaseLink', + request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_firebase_link'] + + @property + def list_firebase_links(self) -> Callable[ + [analytics_admin.ListFirebaseLinksRequest], + analytics_admin.ListFirebaseLinksResponse]: + r"""Return a callable for the list firebase links method over gRPC. + + Lists FirebaseLinks on a property. + Properties can have at most one FirebaseLink. + + Returns: + Callable[[~.ListFirebaseLinksRequest], + ~.ListFirebaseLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_firebase_links' not in self._stubs: + self._stubs['list_firebase_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListFirebaseLinks', + request_serializer=analytics_admin.ListFirebaseLinksRequest.serialize, + response_deserializer=analytics_admin.ListFirebaseLinksResponse.deserialize, + ) + return self._stubs['list_firebase_links'] + + @property + def get_global_site_tag(self) -> Callable[ + [analytics_admin.GetGlobalSiteTagRequest], + resources.GlobalSiteTag]: + r"""Return a callable for the get global site tag method over gRPC. + + Returns the Site Tag for the specified web stream. + Site Tags are immutable singletons. + + Returns: + Callable[[~.GetGlobalSiteTagRequest], + ~.GlobalSiteTag]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_global_site_tag' not in self._stubs: + self._stubs['get_global_site_tag'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGlobalSiteTag', + request_serializer=analytics_admin.GetGlobalSiteTagRequest.serialize, + response_deserializer=resources.GlobalSiteTag.deserialize, + ) + return self._stubs['get_global_site_tag'] + + @property + def create_google_ads_link(self) -> Callable[ + [analytics_admin.CreateGoogleAdsLinkRequest], + resources.GoogleAdsLink]: + r"""Return a callable for the create google ads link method over gRPC. + + Creates a GoogleAdsLink. + + Returns: + Callable[[~.CreateGoogleAdsLinkRequest], + ~.GoogleAdsLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_google_ads_link' not in self._stubs: + self._stubs['create_google_ads_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateGoogleAdsLink', + request_serializer=analytics_admin.CreateGoogleAdsLinkRequest.serialize, + response_deserializer=resources.GoogleAdsLink.deserialize, + ) + return self._stubs['create_google_ads_link'] + + @property + def update_google_ads_link(self) -> Callable[ + [analytics_admin.UpdateGoogleAdsLinkRequest], + resources.GoogleAdsLink]: + r"""Return a callable for the update google ads link method over gRPC. + + Updates a GoogleAdsLink on a property + + Returns: + Callable[[~.UpdateGoogleAdsLinkRequest], + ~.GoogleAdsLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_google_ads_link' not in self._stubs: + self._stubs['update_google_ads_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleAdsLink', + request_serializer=analytics_admin.UpdateGoogleAdsLinkRequest.serialize, + response_deserializer=resources.GoogleAdsLink.deserialize, + ) + return self._stubs['update_google_ads_link'] + + @property + def delete_google_ads_link(self) -> Callable[ + [analytics_admin.DeleteGoogleAdsLinkRequest], + empty.Empty]: + r"""Return a callable for the delete google ads link method over gRPC. + + Deletes a GoogleAdsLink on a property + + Returns: + Callable[[~.DeleteGoogleAdsLinkRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_google_ads_link' not in self._stubs: + self._stubs['delete_google_ads_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteGoogleAdsLink', + request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_google_ads_link'] + + @property + def list_google_ads_links(self) -> Callable[ + [analytics_admin.ListGoogleAdsLinksRequest], + analytics_admin.ListGoogleAdsLinksResponse]: + r"""Return a callable for the list google ads links method over gRPC. + + Lists GoogleAdsLinks on a property. + + Returns: + Callable[[~.ListGoogleAdsLinksRequest], + ~.ListGoogleAdsLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_google_ads_links' not in self._stubs: + self._stubs['list_google_ads_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListGoogleAdsLinks', + request_serializer=analytics_admin.ListGoogleAdsLinksRequest.serialize, + response_deserializer=analytics_admin.ListGoogleAdsLinksResponse.deserialize, + ) + return self._stubs['list_google_ads_links'] + + @property + def get_data_sharing_settings(self) -> Callable[ + [analytics_admin.GetDataSharingSettingsRequest], + resources.DataSharingSettings]: + r"""Return a callable for the get data sharing settings method over gRPC. + + Get data sharing settings on an account. + Data sharing settings are singletons. + + Returns: + Callable[[~.GetDataSharingSettingsRequest], + ~.DataSharingSettings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_data_sharing_settings' not in self._stubs: + self._stubs['get_data_sharing_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataSharingSettings', + request_serializer=analytics_admin.GetDataSharingSettingsRequest.serialize, + response_deserializer=resources.DataSharingSettings.deserialize, + ) + return self._stubs['get_data_sharing_settings'] + + +__all__ = ( + 'AnalyticsAdminServiceGrpcTransport', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py new file mode 100644 index 00000000..74aecae9 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py @@ -0,0 +1,1572 @@ +# -*- 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 + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google import auth # type: ignore +from google.auth import 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.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources +from google.protobuf import empty_pb2 as empty # type: ignore + +from .base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import AnalyticsAdminServiceGrpcTransport + + +class AnalyticsAdminServiceGrpcAsyncIOTransport(AnalyticsAdminServiceTransport): + """gRPC AsyncIO backend transport for AnalyticsAdminService. + + Service Interface for the Analytics Admin API (GA4). + + 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 = 'analyticsadmin.googleapis.com', + credentials: 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. + """ + scopes = scopes or cls.AUTH_SCOPES + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + **kwargs + ) + + def __init__(self, *, + host: str = 'analyticsadmin.googleapis.com', + credentials: credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def get_account(self) -> Callable[ + [analytics_admin.GetAccountRequest], + Awaitable[resources.Account]]: + r"""Return a callable for the get account method over gRPC. + + Lookup for a single Account. + + Returns: + Callable[[~.GetAccountRequest], + Awaitable[~.Account]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_account' not in self._stubs: + self._stubs['get_account'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccount', + request_serializer=analytics_admin.GetAccountRequest.serialize, + response_deserializer=resources.Account.deserialize, + ) + return self._stubs['get_account'] + + @property + def list_accounts(self) -> Callable[ + [analytics_admin.ListAccountsRequest], + Awaitable[analytics_admin.ListAccountsResponse]]: + r"""Return a callable for the list accounts method over gRPC. + + Returns all accounts accessible by the caller. + Note that these accounts might not currently have GA4 + properties. Soft-deleted (ie: "trashed") accounts are + excluded by default. Returns an empty list if no + relevant accounts are found. + + Returns: + Callable[[~.ListAccountsRequest], + Awaitable[~.ListAccountsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_accounts' not in self._stubs: + self._stubs['list_accounts'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccounts', + request_serializer=analytics_admin.ListAccountsRequest.serialize, + response_deserializer=analytics_admin.ListAccountsResponse.deserialize, + ) + return self._stubs['list_accounts'] + + @property + def delete_account(self) -> Callable[ + [analytics_admin.DeleteAccountRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the delete account method over gRPC. + + Marks target Account as soft-deleted (ie: "trashed") + and returns it. + This API does not have a method to restore soft-deleted + accounts. However, they can be restored using the Trash + Can UI. + If the accounts are not restored before the expiration + time, the account and all child resources (eg: + Properties, GoogleAdsLinks, Streams, UserLinks) will be + permanently purged. + https://support.google.com/analytics/answer/6154772 + Returns an error if the target is not found. + + Returns: + Callable[[~.DeleteAccountRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_account' not in self._stubs: + self._stubs['delete_account'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccount', + request_serializer=analytics_admin.DeleteAccountRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_account'] + + @property + def update_account(self) -> Callable[ + [analytics_admin.UpdateAccountRequest], + Awaitable[resources.Account]]: + r"""Return a callable for the update account method over gRPC. + + Updates an account. + + Returns: + Callable[[~.UpdateAccountRequest], + Awaitable[~.Account]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_account' not in self._stubs: + self._stubs['update_account'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccount', + request_serializer=analytics_admin.UpdateAccountRequest.serialize, + response_deserializer=resources.Account.deserialize, + ) + return self._stubs['update_account'] + + @property + def provision_account_ticket(self) -> Callable[ + [analytics_admin.ProvisionAccountTicketRequest], + Awaitable[analytics_admin.ProvisionAccountTicketResponse]]: + r"""Return a callable for the provision account ticket method over gRPC. + + Requests a ticket for creating an account. + + Returns: + Callable[[~.ProvisionAccountTicketRequest], + Awaitable[~.ProvisionAccountTicketResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'provision_account_ticket' not in self._stubs: + self._stubs['provision_account_ticket'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ProvisionAccountTicket', + request_serializer=analytics_admin.ProvisionAccountTicketRequest.serialize, + response_deserializer=analytics_admin.ProvisionAccountTicketResponse.deserialize, + ) + return self._stubs['provision_account_ticket'] + + @property + def list_account_summaries(self) -> Callable[ + [analytics_admin.ListAccountSummariesRequest], + Awaitable[analytics_admin.ListAccountSummariesResponse]]: + r"""Return a callable for the list account summaries method over gRPC. + + Returns summaries of all accounts accessible by the + caller. + + Returns: + Callable[[~.ListAccountSummariesRequest], + Awaitable[~.ListAccountSummariesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_account_summaries' not in self._stubs: + self._stubs['list_account_summaries'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccountSummaries', + request_serializer=analytics_admin.ListAccountSummariesRequest.serialize, + response_deserializer=analytics_admin.ListAccountSummariesResponse.deserialize, + ) + return self._stubs['list_account_summaries'] + + @property + def get_property(self) -> Callable[ + [analytics_admin.GetPropertyRequest], + Awaitable[resources.Property]]: + r"""Return a callable for the get property method over gRPC. + + Lookup for a single "GA4" Property. + + Returns: + Callable[[~.GetPropertyRequest], + Awaitable[~.Property]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_property' not in self._stubs: + self._stubs['get_property'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetProperty', + request_serializer=analytics_admin.GetPropertyRequest.serialize, + response_deserializer=resources.Property.deserialize, + ) + return self._stubs['get_property'] + + @property + def list_properties(self) -> Callable[ + [analytics_admin.ListPropertiesRequest], + Awaitable[analytics_admin.ListPropertiesResponse]]: + r"""Return a callable for the list properties method over gRPC. + + Returns child Properties under the specified parent + Account. + Only "GA4" properties will be returned. + Properties will be excluded if the caller does not have + access. Soft-deleted (ie: "trashed") properties are + excluded by default. Returns an empty list if no + relevant properties are found. + + Returns: + Callable[[~.ListPropertiesRequest], + Awaitable[~.ListPropertiesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_properties' not in self._stubs: + self._stubs['list_properties'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListProperties', + request_serializer=analytics_admin.ListPropertiesRequest.serialize, + response_deserializer=analytics_admin.ListPropertiesResponse.deserialize, + ) + return self._stubs['list_properties'] + + @property + def create_property(self) -> Callable[ + [analytics_admin.CreatePropertyRequest], + Awaitable[resources.Property]]: + r"""Return a callable for the create property method over gRPC. + + Creates an "GA4" property with the specified location + and attributes. + + Returns: + Callable[[~.CreatePropertyRequest], + Awaitable[~.Property]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_property' not in self._stubs: + self._stubs['create_property'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateProperty', + request_serializer=analytics_admin.CreatePropertyRequest.serialize, + response_deserializer=resources.Property.deserialize, + ) + return self._stubs['create_property'] + + @property + def delete_property(self) -> Callable[ + [analytics_admin.DeletePropertyRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the delete property method over gRPC. + + Marks target Property as soft-deleted (ie: "trashed") + and returns it. + This API does not have a method to restore soft-deleted + properties. However, they can be restored using the + Trash Can UI. + If the properties are not restored before the expiration + time, the Property and all child resources (eg: + GoogleAdsLinks, Streams, UserLinks) will be permanently + purged. + https://support.google.com/analytics/answer/6154772 + Returns an error if the target is not found, or is not + an GA4 Property. + + Returns: + Callable[[~.DeletePropertyRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_property' not in self._stubs: + self._stubs['delete_property'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteProperty', + request_serializer=analytics_admin.DeletePropertyRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_property'] + + @property + def update_property(self) -> Callable[ + [analytics_admin.UpdatePropertyRequest], + Awaitable[resources.Property]]: + r"""Return a callable for the update property method over gRPC. + + Updates a property. + + Returns: + Callable[[~.UpdatePropertyRequest], + Awaitable[~.Property]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_property' not in self._stubs: + self._stubs['update_property'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateProperty', + request_serializer=analytics_admin.UpdatePropertyRequest.serialize, + response_deserializer=resources.Property.deserialize, + ) + return self._stubs['update_property'] + + @property + def get_user_link(self) -> Callable[ + [analytics_admin.GetUserLinkRequest], + Awaitable[resources.UserLink]]: + r"""Return a callable for the get user link method over gRPC. + + Gets information about a user's link to an account or + property. + + Returns: + Callable[[~.GetUserLinkRequest], + Awaitable[~.UserLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_user_link' not in self._stubs: + self._stubs['get_user_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetUserLink', + request_serializer=analytics_admin.GetUserLinkRequest.serialize, + response_deserializer=resources.UserLink.deserialize, + ) + return self._stubs['get_user_link'] + + @property + def batch_get_user_links(self) -> Callable[ + [analytics_admin.BatchGetUserLinksRequest], + Awaitable[analytics_admin.BatchGetUserLinksResponse]]: + r"""Return a callable for the batch get user links method over gRPC. + + Gets information about multiple users' links to an + account or property. + + Returns: + Callable[[~.BatchGetUserLinksRequest], + Awaitable[~.BatchGetUserLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'batch_get_user_links' not in self._stubs: + self._stubs['batch_get_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchGetUserLinks', + request_serializer=analytics_admin.BatchGetUserLinksRequest.serialize, + response_deserializer=analytics_admin.BatchGetUserLinksResponse.deserialize, + ) + return self._stubs['batch_get_user_links'] + + @property + def list_user_links(self) -> Callable[ + [analytics_admin.ListUserLinksRequest], + Awaitable[analytics_admin.ListUserLinksResponse]]: + r"""Return a callable for the list user links method over gRPC. + + Lists all user links on an account or property. + + Returns: + Callable[[~.ListUserLinksRequest], + Awaitable[~.ListUserLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_user_links' not in self._stubs: + self._stubs['list_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListUserLinks', + request_serializer=analytics_admin.ListUserLinksRequest.serialize, + response_deserializer=analytics_admin.ListUserLinksResponse.deserialize, + ) + return self._stubs['list_user_links'] + + @property + def audit_user_links(self) -> Callable[ + [analytics_admin.AuditUserLinksRequest], + Awaitable[analytics_admin.AuditUserLinksResponse]]: + r"""Return a callable for the audit user links method over gRPC. + + Lists all user links on an account or property, + including implicit ones that come from effective + permissions granted by groups or organization admin + roles. + + If a returned user link does not have direct + permissions, they cannot be removed from the account or + property directly with the DeleteUserLink command. They + have to be removed from the group/etc that gives them + permissions, which is currently only usable/discoverable + in the GA or GMP UIs. + + Returns: + Callable[[~.AuditUserLinksRequest], + Awaitable[~.AuditUserLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'audit_user_links' not in self._stubs: + self._stubs['audit_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/AuditUserLinks', + request_serializer=analytics_admin.AuditUserLinksRequest.serialize, + response_deserializer=analytics_admin.AuditUserLinksResponse.deserialize, + ) + return self._stubs['audit_user_links'] + + @property + def create_user_link(self) -> Callable[ + [analytics_admin.CreateUserLinkRequest], + Awaitable[resources.UserLink]]: + r"""Return a callable for the create user link method over gRPC. + + Creates a user link on an account or property. + If the user with the specified email already has + permissions on the account or property, then the user's + existing permissions will be unioned with the + permissions specified in the new UserLink. + + Returns: + Callable[[~.CreateUserLinkRequest], + Awaitable[~.UserLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_user_link' not in self._stubs: + self._stubs['create_user_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateUserLink', + request_serializer=analytics_admin.CreateUserLinkRequest.serialize, + response_deserializer=resources.UserLink.deserialize, + ) + return self._stubs['create_user_link'] + + @property + def batch_create_user_links(self) -> Callable[ + [analytics_admin.BatchCreateUserLinksRequest], + Awaitable[analytics_admin.BatchCreateUserLinksResponse]]: + r"""Return a callable for the batch create user links method over gRPC. + + Creates information about multiple users' links to an + account or property. + This method is transactional. If any UserLink cannot be + created, none of the UserLinks will be created. + + Returns: + Callable[[~.BatchCreateUserLinksRequest], + Awaitable[~.BatchCreateUserLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'batch_create_user_links' not in self._stubs: + self._stubs['batch_create_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchCreateUserLinks', + request_serializer=analytics_admin.BatchCreateUserLinksRequest.serialize, + response_deserializer=analytics_admin.BatchCreateUserLinksResponse.deserialize, + ) + return self._stubs['batch_create_user_links'] + + @property + def update_user_link(self) -> Callable[ + [analytics_admin.UpdateUserLinkRequest], + Awaitable[resources.UserLink]]: + r"""Return a callable for the update user link method over gRPC. + + Updates a user link on an account or property. + + Returns: + Callable[[~.UpdateUserLinkRequest], + Awaitable[~.UserLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_user_link' not in self._stubs: + self._stubs['update_user_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateUserLink', + request_serializer=analytics_admin.UpdateUserLinkRequest.serialize, + response_deserializer=resources.UserLink.deserialize, + ) + return self._stubs['update_user_link'] + + @property + def batch_update_user_links(self) -> Callable[ + [analytics_admin.BatchUpdateUserLinksRequest], + Awaitable[analytics_admin.BatchUpdateUserLinksResponse]]: + r"""Return a callable for the batch update user links method over gRPC. + + Updates information about multiple users' links to an + account or property. + + Returns: + Callable[[~.BatchUpdateUserLinksRequest], + Awaitable[~.BatchUpdateUserLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'batch_update_user_links' not in self._stubs: + self._stubs['batch_update_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchUpdateUserLinks', + request_serializer=analytics_admin.BatchUpdateUserLinksRequest.serialize, + response_deserializer=analytics_admin.BatchUpdateUserLinksResponse.deserialize, + ) + return self._stubs['batch_update_user_links'] + + @property + def delete_user_link(self) -> Callable[ + [analytics_admin.DeleteUserLinkRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the delete user link method over gRPC. + + Deletes a user link on an account or property. + + Returns: + Callable[[~.DeleteUserLinkRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_user_link' not in self._stubs: + self._stubs['delete_user_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteUserLink', + request_serializer=analytics_admin.DeleteUserLinkRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_user_link'] + + @property + def batch_delete_user_links(self) -> Callable[ + [analytics_admin.BatchDeleteUserLinksRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the batch delete user links method over gRPC. + + Deletes information about multiple users' links to an + account or property. + + Returns: + Callable[[~.BatchDeleteUserLinksRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'batch_delete_user_links' not in self._stubs: + self._stubs['batch_delete_user_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteUserLinks', + request_serializer=analytics_admin.BatchDeleteUserLinksRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['batch_delete_user_links'] + + @property + def get_web_data_stream(self) -> Callable[ + [analytics_admin.GetWebDataStreamRequest], + Awaitable[resources.WebDataStream]]: + r"""Return a callable for the get web data stream method over gRPC. + + Lookup for a single WebDataStream + + Returns: + Callable[[~.GetWebDataStreamRequest], + Awaitable[~.WebDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: + self._stubs['get_web_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetWebDataStream', + request_serializer=analytics_admin.GetWebDataStreamRequest.serialize, + response_deserializer=resources.WebDataStream.deserialize, + ) + return self._stubs['get_web_data_stream'] + + @property + def delete_web_data_stream(self) -> Callable[ + [analytics_admin.DeleteWebDataStreamRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the delete web data stream method over gRPC. + + Deletes a web stream on a property. + + Returns: + Callable[[~.DeleteWebDataStreamRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_web_data_stream' not in self._stubs: + self._stubs['delete_web_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteWebDataStream', + request_serializer=analytics_admin.DeleteWebDataStreamRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_web_data_stream'] + + @property + def update_web_data_stream(self) -> Callable[ + [analytics_admin.UpdateWebDataStreamRequest], + Awaitable[resources.WebDataStream]]: + r"""Return a callable for the update web data stream method over gRPC. + + Updates a web stream on a property. + + Returns: + Callable[[~.UpdateWebDataStreamRequest], + Awaitable[~.WebDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: + self._stubs['update_web_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateWebDataStream', + request_serializer=analytics_admin.UpdateWebDataStreamRequest.serialize, + response_deserializer=resources.WebDataStream.deserialize, + ) + return self._stubs['update_web_data_stream'] + + @property + def create_web_data_stream(self) -> Callable[ + [analytics_admin.CreateWebDataStreamRequest], + Awaitable[resources.WebDataStream]]: + r"""Return a callable for the create web data stream method over gRPC. + + Creates a web stream with the specified location and + attributes. + + Returns: + Callable[[~.CreateWebDataStreamRequest], + Awaitable[~.WebDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: + self._stubs['create_web_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateWebDataStream', + request_serializer=analytics_admin.CreateWebDataStreamRequest.serialize, + response_deserializer=resources.WebDataStream.deserialize, + ) + return self._stubs['create_web_data_stream'] + + @property + def list_web_data_streams(self) -> Callable[ + [analytics_admin.ListWebDataStreamsRequest], + Awaitable[analytics_admin.ListWebDataStreamsResponse]]: + r"""Return a callable for the list web data streams method over gRPC. + + Returns child web data streams under the specified + parent property. + Web data streams will be excluded if the caller does not + have access. Returns an empty list if no relevant web + data streams are found. + + Returns: + Callable[[~.ListWebDataStreamsRequest], + Awaitable[~.ListWebDataStreamsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_web_data_streams' not in self._stubs: + self._stubs['list_web_data_streams'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListWebDataStreams', + request_serializer=analytics_admin.ListWebDataStreamsRequest.serialize, + response_deserializer=analytics_admin.ListWebDataStreamsResponse.deserialize, + ) + return self._stubs['list_web_data_streams'] + + @property + def get_ios_app_data_stream(self) -> Callable[ + [analytics_admin.GetIosAppDataStreamRequest], + Awaitable[resources.IosAppDataStream]]: + r"""Return a callable for the get ios app data stream method over gRPC. + + Lookup for a single IosAppDataStream + + Returns: + Callable[[~.GetIosAppDataStreamRequest], + Awaitable[~.IosAppDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: + self._stubs['get_ios_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetIosAppDataStream', + request_serializer=analytics_admin.GetIosAppDataStreamRequest.serialize, + response_deserializer=resources.IosAppDataStream.deserialize, + ) + return self._stubs['get_ios_app_data_stream'] + + @property + def delete_ios_app_data_stream(self) -> Callable[ + [analytics_admin.DeleteIosAppDataStreamRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the delete ios app data stream method over gRPC. + + Deletes an iOS app stream on a property. + + Returns: + Callable[[~.DeleteIosAppDataStreamRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_ios_app_data_stream' not in self._stubs: + self._stubs['delete_ios_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteIosAppDataStream', + request_serializer=analytics_admin.DeleteIosAppDataStreamRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_ios_app_data_stream'] + + @property + def update_ios_app_data_stream(self) -> Callable[ + [analytics_admin.UpdateIosAppDataStreamRequest], + Awaitable[resources.IosAppDataStream]]: + r"""Return a callable for the update ios app data stream method over gRPC. + + Updates an iOS app stream on a property. + + Returns: + Callable[[~.UpdateIosAppDataStreamRequest], + Awaitable[~.IosAppDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: + self._stubs['update_ios_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateIosAppDataStream', + request_serializer=analytics_admin.UpdateIosAppDataStreamRequest.serialize, + response_deserializer=resources.IosAppDataStream.deserialize, + ) + return self._stubs['update_ios_app_data_stream'] + + @property + def create_ios_app_data_stream(self) -> Callable[ + [analytics_admin.CreateIosAppDataStreamRequest], + Awaitable[resources.IosAppDataStream]]: + r"""Return a callable for the create ios app data stream method over gRPC. + + Creates an iOS app stream with the specified location + and attributes. + Note that an iOS app stream must be linked to a Firebase + app to receive traffic. + + To create a working app stream, make sure your property + is linked to a Firebase project. Then, use the Firebase + API to create a Firebase app, which will also create an + appropriate data stream in Analytics (may take up to 24 + hours). + + Returns: + Callable[[~.CreateIosAppDataStreamRequest], + Awaitable[~.IosAppDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: + self._stubs['create_ios_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateIosAppDataStream', + request_serializer=analytics_admin.CreateIosAppDataStreamRequest.serialize, + response_deserializer=resources.IosAppDataStream.deserialize, + ) + return self._stubs['create_ios_app_data_stream'] + + @property + def list_ios_app_data_streams(self) -> Callable[ + [analytics_admin.ListIosAppDataStreamsRequest], + Awaitable[analytics_admin.ListIosAppDataStreamsResponse]]: + r"""Return a callable for the list ios app data streams method over gRPC. + + Returns child iOS app data streams under the + specified parent property. + iOS app data streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + iOS app data streams are found. + + Returns: + Callable[[~.ListIosAppDataStreamsRequest], + Awaitable[~.ListIosAppDataStreamsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ios_app_data_streams' not in self._stubs: + self._stubs['list_ios_app_data_streams'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListIosAppDataStreams', + request_serializer=analytics_admin.ListIosAppDataStreamsRequest.serialize, + response_deserializer=analytics_admin.ListIosAppDataStreamsResponse.deserialize, + ) + return self._stubs['list_ios_app_data_streams'] + + @property + def get_android_app_data_stream(self) -> Callable[ + [analytics_admin.GetAndroidAppDataStreamRequest], + Awaitable[resources.AndroidAppDataStream]]: + r"""Return a callable for the get android app data stream method over gRPC. + + Lookup for a single AndroidAppDataStream + + Returns: + Callable[[~.GetAndroidAppDataStreamRequest], + Awaitable[~.AndroidAppDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: + self._stubs['get_android_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAndroidAppDataStream', + request_serializer=analytics_admin.GetAndroidAppDataStreamRequest.serialize, + response_deserializer=resources.AndroidAppDataStream.deserialize, + ) + return self._stubs['get_android_app_data_stream'] + + @property + def delete_android_app_data_stream(self) -> Callable[ + [analytics_admin.DeleteAndroidAppDataStreamRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the delete android app data stream method over gRPC. + + Deletes an android app stream on a property. + + Returns: + Callable[[~.DeleteAndroidAppDataStreamRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_android_app_data_stream' not in self._stubs: + self._stubs['delete_android_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAndroidAppDataStream', + request_serializer=analytics_admin.DeleteAndroidAppDataStreamRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_android_app_data_stream'] + + @property + def update_android_app_data_stream(self) -> Callable[ + [analytics_admin.UpdateAndroidAppDataStreamRequest], + Awaitable[resources.AndroidAppDataStream]]: + r"""Return a callable for the update android app data stream method over gRPC. + + Updates an android app stream on a property. + + Returns: + Callable[[~.UpdateAndroidAppDataStreamRequest], + Awaitable[~.AndroidAppDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: + self._stubs['update_android_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAndroidAppDataStream', + request_serializer=analytics_admin.UpdateAndroidAppDataStreamRequest.serialize, + response_deserializer=resources.AndroidAppDataStream.deserialize, + ) + return self._stubs['update_android_app_data_stream'] + + @property + def create_android_app_data_stream(self) -> Callable[ + [analytics_admin.CreateAndroidAppDataStreamRequest], + Awaitable[resources.AndroidAppDataStream]]: + r"""Return a callable for the create android app data stream method over gRPC. + + Creates an Android app stream with the specified + location and attributes. + Note that an Android app stream must be linked to a + Firebase app to receive traffic. + + To create a working app stream, make sure your property + is linked to a Firebase project. Then, use the Firebase + API to create a Firebase app, which will also create an + appropriate data stream in Analytics (may take up to 24 + hours). + + Returns: + Callable[[~.CreateAndroidAppDataStreamRequest], + Awaitable[~.AndroidAppDataStream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: + self._stubs['create_android_app_data_stream'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAndroidAppDataStream', + request_serializer=analytics_admin.CreateAndroidAppDataStreamRequest.serialize, + response_deserializer=resources.AndroidAppDataStream.deserialize, + ) + return self._stubs['create_android_app_data_stream'] + + @property + def list_android_app_data_streams(self) -> Callable[ + [analytics_admin.ListAndroidAppDataStreamsRequest], + Awaitable[analytics_admin.ListAndroidAppDataStreamsResponse]]: + r"""Return a callable for the list android app data streams method over gRPC. + + Returns child android app streams under the specified + parent property. + Android app streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + android app streams are found. + + Returns: + Callable[[~.ListAndroidAppDataStreamsRequest], + Awaitable[~.ListAndroidAppDataStreamsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_android_app_data_streams' not in self._stubs: + self._stubs['list_android_app_data_streams'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAndroidAppDataStreams', + request_serializer=analytics_admin.ListAndroidAppDataStreamsRequest.serialize, + response_deserializer=analytics_admin.ListAndroidAppDataStreamsResponse.deserialize, + ) + return self._stubs['list_android_app_data_streams'] + + @property + def get_enhanced_measurement_settings(self) -> Callable[ + [analytics_admin.GetEnhancedMeasurementSettingsRequest], + Awaitable[resources.EnhancedMeasurementSettings]]: + r"""Return a callable for the get enhanced measurement + settings method over gRPC. + + Returns the singleton enhanced measurement settings + for this web stream. Note that the stream must enable + enhanced measurement for these settings to take effect. + + Returns: + Callable[[~.GetEnhancedMeasurementSettingsRequest], + Awaitable[~.EnhancedMeasurementSettings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_enhanced_measurement_settings' not in self._stubs: + self._stubs['get_enhanced_measurement_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEnhancedMeasurementSettings', + request_serializer=analytics_admin.GetEnhancedMeasurementSettingsRequest.serialize, + response_deserializer=resources.EnhancedMeasurementSettings.deserialize, + ) + return self._stubs['get_enhanced_measurement_settings'] + + @property + def update_enhanced_measurement_settings(self) -> Callable[ + [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], + Awaitable[resources.EnhancedMeasurementSettings]]: + r"""Return a callable for the update enhanced measurement + settings method over gRPC. + + Updates the singleton enhanced measurement settings + for this web stream. Note that the stream must enable + enhanced measurement for these settings to take effect. + + Returns: + Callable[[~.UpdateEnhancedMeasurementSettingsRequest], + Awaitable[~.EnhancedMeasurementSettings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_enhanced_measurement_settings' not in self._stubs: + self._stubs['update_enhanced_measurement_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEnhancedMeasurementSettings', + request_serializer=analytics_admin.UpdateEnhancedMeasurementSettingsRequest.serialize, + response_deserializer=resources.EnhancedMeasurementSettings.deserialize, + ) + return self._stubs['update_enhanced_measurement_settings'] + + @property + def create_firebase_link(self) -> Callable[ + [analytics_admin.CreateFirebaseLinkRequest], + Awaitable[resources.FirebaseLink]]: + r"""Return a callable for the create firebase link method over gRPC. + + Creates a FirebaseLink. + Properties can have at most one FirebaseLink. + + Returns: + Callable[[~.CreateFirebaseLinkRequest], + Awaitable[~.FirebaseLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_firebase_link' not in self._stubs: + self._stubs['create_firebase_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateFirebaseLink', + request_serializer=analytics_admin.CreateFirebaseLinkRequest.serialize, + response_deserializer=resources.FirebaseLink.deserialize, + ) + return self._stubs['create_firebase_link'] + + @property + def update_firebase_link(self) -> Callable[ + [analytics_admin.UpdateFirebaseLinkRequest], + Awaitable[resources.FirebaseLink]]: + r"""Return a callable for the update firebase link method over gRPC. + + Updates a FirebaseLink on a property + + Returns: + Callable[[~.UpdateFirebaseLinkRequest], + Awaitable[~.FirebaseLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_firebase_link' not in self._stubs: + self._stubs['update_firebase_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateFirebaseLink', + request_serializer=analytics_admin.UpdateFirebaseLinkRequest.serialize, + response_deserializer=resources.FirebaseLink.deserialize, + ) + return self._stubs['update_firebase_link'] + + @property + def delete_firebase_link(self) -> Callable[ + [analytics_admin.DeleteFirebaseLinkRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the delete firebase link method over gRPC. + + Deletes a FirebaseLink on a property + + Returns: + Callable[[~.DeleteFirebaseLinkRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_firebase_link' not in self._stubs: + self._stubs['delete_firebase_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteFirebaseLink', + request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_firebase_link'] + + @property + def list_firebase_links(self) -> Callable[ + [analytics_admin.ListFirebaseLinksRequest], + Awaitable[analytics_admin.ListFirebaseLinksResponse]]: + r"""Return a callable for the list firebase links method over gRPC. + + Lists FirebaseLinks on a property. + Properties can have at most one FirebaseLink. + + Returns: + Callable[[~.ListFirebaseLinksRequest], + Awaitable[~.ListFirebaseLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_firebase_links' not in self._stubs: + self._stubs['list_firebase_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListFirebaseLinks', + request_serializer=analytics_admin.ListFirebaseLinksRequest.serialize, + response_deserializer=analytics_admin.ListFirebaseLinksResponse.deserialize, + ) + return self._stubs['list_firebase_links'] + + @property + def get_global_site_tag(self) -> Callable[ + [analytics_admin.GetGlobalSiteTagRequest], + Awaitable[resources.GlobalSiteTag]]: + r"""Return a callable for the get global site tag method over gRPC. + + Returns the Site Tag for the specified web stream. + Site Tags are immutable singletons. + + Returns: + Callable[[~.GetGlobalSiteTagRequest], + Awaitable[~.GlobalSiteTag]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_global_site_tag' not in self._stubs: + self._stubs['get_global_site_tag'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGlobalSiteTag', + request_serializer=analytics_admin.GetGlobalSiteTagRequest.serialize, + response_deserializer=resources.GlobalSiteTag.deserialize, + ) + return self._stubs['get_global_site_tag'] + + @property + def create_google_ads_link(self) -> Callable[ + [analytics_admin.CreateGoogleAdsLinkRequest], + Awaitable[resources.GoogleAdsLink]]: + r"""Return a callable for the create google ads link method over gRPC. + + Creates a GoogleAdsLink. + + Returns: + Callable[[~.CreateGoogleAdsLinkRequest], + Awaitable[~.GoogleAdsLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_google_ads_link' not in self._stubs: + self._stubs['create_google_ads_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateGoogleAdsLink', + request_serializer=analytics_admin.CreateGoogleAdsLinkRequest.serialize, + response_deserializer=resources.GoogleAdsLink.deserialize, + ) + return self._stubs['create_google_ads_link'] + + @property + def update_google_ads_link(self) -> Callable[ + [analytics_admin.UpdateGoogleAdsLinkRequest], + Awaitable[resources.GoogleAdsLink]]: + r"""Return a callable for the update google ads link method over gRPC. + + Updates a GoogleAdsLink on a property + + Returns: + Callable[[~.UpdateGoogleAdsLinkRequest], + Awaitable[~.GoogleAdsLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_google_ads_link' not in self._stubs: + self._stubs['update_google_ads_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleAdsLink', + request_serializer=analytics_admin.UpdateGoogleAdsLinkRequest.serialize, + response_deserializer=resources.GoogleAdsLink.deserialize, + ) + return self._stubs['update_google_ads_link'] + + @property + def delete_google_ads_link(self) -> Callable[ + [analytics_admin.DeleteGoogleAdsLinkRequest], + Awaitable[empty.Empty]]: + r"""Return a callable for the delete google ads link method over gRPC. + + Deletes a GoogleAdsLink on a property + + Returns: + Callable[[~.DeleteGoogleAdsLinkRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_google_ads_link' not in self._stubs: + self._stubs['delete_google_ads_link'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteGoogleAdsLink', + request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, + response_deserializer=empty.Empty.FromString, + ) + return self._stubs['delete_google_ads_link'] + + @property + def list_google_ads_links(self) -> Callable[ + [analytics_admin.ListGoogleAdsLinksRequest], + Awaitable[analytics_admin.ListGoogleAdsLinksResponse]]: + r"""Return a callable for the list google ads links method over gRPC. + + Lists GoogleAdsLinks on a property. + + Returns: + Callable[[~.ListGoogleAdsLinksRequest], + Awaitable[~.ListGoogleAdsLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_google_ads_links' not in self._stubs: + self._stubs['list_google_ads_links'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListGoogleAdsLinks', + request_serializer=analytics_admin.ListGoogleAdsLinksRequest.serialize, + response_deserializer=analytics_admin.ListGoogleAdsLinksResponse.deserialize, + ) + return self._stubs['list_google_ads_links'] + + @property + def get_data_sharing_settings(self) -> Callable[ + [analytics_admin.GetDataSharingSettingsRequest], + Awaitable[resources.DataSharingSettings]]: + r"""Return a callable for the get data sharing settings method over gRPC. + + Get data sharing settings on an account. + Data sharing settings are singletons. + + Returns: + Callable[[~.GetDataSharingSettingsRequest], + Awaitable[~.DataSharingSettings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_data_sharing_settings' not in self._stubs: + self._stubs['get_data_sharing_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataSharingSettings', + request_serializer=analytics_admin.GetDataSharingSettingsRequest.serialize, + response_deserializer=resources.DataSharingSettings.deserialize, + ) + return self._stubs['get_data_sharing_settings'] + + +__all__ = ( + 'AnalyticsAdminServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py new file mode 100644 index 00000000..25bc2282 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py @@ -0,0 +1,180 @@ +# -*- 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 .analytics_admin import ( + AuditUserLinksRequest, + AuditUserLinksResponse, + BatchCreateUserLinksRequest, + BatchCreateUserLinksResponse, + BatchDeleteUserLinksRequest, + BatchGetUserLinksRequest, + BatchGetUserLinksResponse, + BatchUpdateUserLinksRequest, + BatchUpdateUserLinksResponse, + CreateAndroidAppDataStreamRequest, + CreateFirebaseLinkRequest, + CreateGoogleAdsLinkRequest, + CreateIosAppDataStreamRequest, + CreatePropertyRequest, + CreateUserLinkRequest, + CreateWebDataStreamRequest, + DeleteAccountRequest, + DeleteAndroidAppDataStreamRequest, + DeleteFirebaseLinkRequest, + DeleteGoogleAdsLinkRequest, + DeleteIosAppDataStreamRequest, + DeletePropertyRequest, + DeleteUserLinkRequest, + DeleteWebDataStreamRequest, + GetAccountRequest, + GetAndroidAppDataStreamRequest, + GetDataSharingSettingsRequest, + GetEnhancedMeasurementSettingsRequest, + GetGlobalSiteTagRequest, + GetIosAppDataStreamRequest, + GetPropertyRequest, + GetUserLinkRequest, + GetWebDataStreamRequest, + ListAccountsRequest, + ListAccountsResponse, + ListAccountSummariesRequest, + ListAccountSummariesResponse, + ListAndroidAppDataStreamsRequest, + ListAndroidAppDataStreamsResponse, + ListFirebaseLinksRequest, + ListFirebaseLinksResponse, + ListGoogleAdsLinksRequest, + ListGoogleAdsLinksResponse, + ListIosAppDataStreamsRequest, + ListIosAppDataStreamsResponse, + ListPropertiesRequest, + ListPropertiesResponse, + ListUserLinksRequest, + ListUserLinksResponse, + ListWebDataStreamsRequest, + ListWebDataStreamsResponse, + ProvisionAccountTicketRequest, + ProvisionAccountTicketResponse, + UpdateAccountRequest, + UpdateAndroidAppDataStreamRequest, + UpdateEnhancedMeasurementSettingsRequest, + UpdateFirebaseLinkRequest, + UpdateGoogleAdsLinkRequest, + UpdateIosAppDataStreamRequest, + UpdatePropertyRequest, + UpdateUserLinkRequest, + UpdateWebDataStreamRequest, +) +from .resources import ( + Account, + AccountSummary, + AndroidAppDataStream, + AuditUserLink, + DataSharingSettings, + EnhancedMeasurementSettings, + FirebaseLink, + GlobalSiteTag, + GoogleAdsLink, + IosAppDataStream, + Property, + PropertySummary, + UserLink, + WebDataStream, + IndustryCategory, + MaximumUserAccess, +) + +__all__ = ( + 'AuditUserLinksRequest', + 'AuditUserLinksResponse', + 'BatchCreateUserLinksRequest', + 'BatchCreateUserLinksResponse', + 'BatchDeleteUserLinksRequest', + 'BatchGetUserLinksRequest', + 'BatchGetUserLinksResponse', + 'BatchUpdateUserLinksRequest', + 'BatchUpdateUserLinksResponse', + 'CreateAndroidAppDataStreamRequest', + 'CreateFirebaseLinkRequest', + 'CreateGoogleAdsLinkRequest', + 'CreateIosAppDataStreamRequest', + 'CreatePropertyRequest', + 'CreateUserLinkRequest', + 'CreateWebDataStreamRequest', + 'DeleteAccountRequest', + 'DeleteAndroidAppDataStreamRequest', + 'DeleteFirebaseLinkRequest', + 'DeleteGoogleAdsLinkRequest', + 'DeleteIosAppDataStreamRequest', + 'DeletePropertyRequest', + 'DeleteUserLinkRequest', + 'DeleteWebDataStreamRequest', + 'GetAccountRequest', + 'GetAndroidAppDataStreamRequest', + 'GetDataSharingSettingsRequest', + 'GetEnhancedMeasurementSettingsRequest', + 'GetGlobalSiteTagRequest', + 'GetIosAppDataStreamRequest', + 'GetPropertyRequest', + 'GetUserLinkRequest', + 'GetWebDataStreamRequest', + 'ListAccountsRequest', + 'ListAccountsResponse', + 'ListAccountSummariesRequest', + 'ListAccountSummariesResponse', + 'ListAndroidAppDataStreamsRequest', + 'ListAndroidAppDataStreamsResponse', + 'ListFirebaseLinksRequest', + 'ListFirebaseLinksResponse', + 'ListGoogleAdsLinksRequest', + 'ListGoogleAdsLinksResponse', + 'ListIosAppDataStreamsRequest', + 'ListIosAppDataStreamsResponse', + 'ListPropertiesRequest', + 'ListPropertiesResponse', + 'ListUserLinksRequest', + 'ListUserLinksResponse', + 'ListWebDataStreamsRequest', + 'ListWebDataStreamsResponse', + 'ProvisionAccountTicketRequest', + 'ProvisionAccountTicketResponse', + 'UpdateAccountRequest', + 'UpdateAndroidAppDataStreamRequest', + 'UpdateEnhancedMeasurementSettingsRequest', + 'UpdateFirebaseLinkRequest', + 'UpdateGoogleAdsLinkRequest', + 'UpdateIosAppDataStreamRequest', + 'UpdatePropertyRequest', + 'UpdateUserLinkRequest', + 'UpdateWebDataStreamRequest', + 'Account', + 'AccountSummary', + 'AndroidAppDataStream', + 'AuditUserLink', + 'DataSharingSettings', + 'EnhancedMeasurementSettings', + 'FirebaseLink', + 'GlobalSiteTag', + 'GoogleAdsLink', + 'IosAppDataStream', + 'Property', + 'PropertySummary', + 'UserLink', + 'WebDataStream', + 'IndustryCategory', + 'MaximumUserAccess', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py new file mode 100644 index 00000000..7507779d --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py @@ -0,0 +1,1354 @@ +# -*- 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.analytics.admin_v1alpha.types import resources +from google.protobuf import field_mask_pb2 as field_mask # type: ignore + + +__protobuf__ = proto.module( + package='google.analytics.admin.v1alpha', + manifest={ + 'GetAccountRequest', + 'ListAccountsRequest', + 'ListAccountsResponse', + 'DeleteAccountRequest', + 'UpdateAccountRequest', + 'ProvisionAccountTicketRequest', + 'ProvisionAccountTicketResponse', + 'GetPropertyRequest', + 'ListPropertiesRequest', + 'ListPropertiesResponse', + 'UpdatePropertyRequest', + 'CreatePropertyRequest', + 'DeletePropertyRequest', + 'GetUserLinkRequest', + 'BatchGetUserLinksRequest', + 'BatchGetUserLinksResponse', + 'ListUserLinksRequest', + 'ListUserLinksResponse', + 'AuditUserLinksRequest', + 'AuditUserLinksResponse', + 'CreateUserLinkRequest', + 'BatchCreateUserLinksRequest', + 'BatchCreateUserLinksResponse', + 'UpdateUserLinkRequest', + 'BatchUpdateUserLinksRequest', + 'BatchUpdateUserLinksResponse', + 'DeleteUserLinkRequest', + 'BatchDeleteUserLinksRequest', + 'GetWebDataStreamRequest', + 'DeleteWebDataStreamRequest', + 'UpdateWebDataStreamRequest', + 'CreateWebDataStreamRequest', + 'ListWebDataStreamsRequest', + 'ListWebDataStreamsResponse', + 'GetIosAppDataStreamRequest', + 'DeleteIosAppDataStreamRequest', + 'UpdateIosAppDataStreamRequest', + 'CreateIosAppDataStreamRequest', + 'ListIosAppDataStreamsRequest', + 'ListIosAppDataStreamsResponse', + 'GetAndroidAppDataStreamRequest', + 'DeleteAndroidAppDataStreamRequest', + 'UpdateAndroidAppDataStreamRequest', + 'CreateAndroidAppDataStreamRequest', + 'ListAndroidAppDataStreamsRequest', + 'ListAndroidAppDataStreamsResponse', + 'GetEnhancedMeasurementSettingsRequest', + 'UpdateEnhancedMeasurementSettingsRequest', + 'CreateFirebaseLinkRequest', + 'UpdateFirebaseLinkRequest', + 'DeleteFirebaseLinkRequest', + 'ListFirebaseLinksRequest', + 'ListFirebaseLinksResponse', + 'GetGlobalSiteTagRequest', + 'CreateGoogleAdsLinkRequest', + 'UpdateGoogleAdsLinkRequest', + 'DeleteGoogleAdsLinkRequest', + 'ListGoogleAdsLinksRequest', + 'ListGoogleAdsLinksResponse', + 'GetDataSharingSettingsRequest', + 'ListAccountSummariesRequest', + 'ListAccountSummariesResponse', + }, +) + + +class GetAccountRequest(proto.Message): + r"""Request message for GetAccount RPC. + + Attributes: + name (str): + Required. The name of the account to lookup. + Format: accounts/{account} + Example: "accounts/100". + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListAccountsRequest(proto.Message): + r"""Request message for ListAccounts RPC. + + Attributes: + page_size (int): + The maximum number of resources to return. + The service may return fewer than this value, + even if there are additional pages. If + unspecified, at most 50 resources will be + returned. The maximum value is 200; (higher + values will be coerced to the maximum) + page_token (str): + A page token, received from a previous ``ListAccounts`` + call. Provide this to retrieve the subsequent page. When + paginating, all other parameters provided to + ``ListAccounts`` must match the call that provided the page + token. + show_deleted (bool): + Whether to include soft-deleted (ie: + "trashed") Accounts in the results. Accounts can + be inspected to determine whether they are + deleted or not. + """ + + page_size = proto.Field(proto.INT32, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + show_deleted = proto.Field(proto.BOOL, number=3) + + +class ListAccountsResponse(proto.Message): + r"""Request message for ListAccounts RPC. + + Attributes: + accounts (Sequence[google.analytics.admin_v1alpha.types.Account]): + Results that were accessible to the caller. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + accounts = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.Account, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class DeleteAccountRequest(proto.Message): + r"""Request message for DeleteAccount RPC. + + Attributes: + name (str): + Required. The name of the Account to soft- + elete. Format: accounts/{account} + Example: "accounts/100". + """ + + name = proto.Field(proto.STRING, number=1) + + +class UpdateAccountRequest(proto.Message): + r"""Request message for UpdateAccount RPC. + + Attributes: + account (google.analytics.admin_v1alpha.types.Account): + Required. The account to update. The account's ``name`` + field is used to identify the account. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + account = proto.Field(proto.MESSAGE, number=1, + message=resources.Account, + ) + + update_mask = proto.Field(proto.MESSAGE, number=2, + message=field_mask.FieldMask, + ) + + +class ProvisionAccountTicketRequest(proto.Message): + r"""Request message for ProvisionAccountTicket RPC. + + Attributes: + account (google.analytics.admin_v1alpha.types.Account): + The account to create. + redirect_uri (str): + Redirect URI where the user will be sent + after accepting Terms of Service. Must be + configured in Developers Console as a Redirect + URI + """ + + account = proto.Field(proto.MESSAGE, number=1, + message=resources.Account, + ) + + redirect_uri = proto.Field(proto.STRING, number=2) + + +class ProvisionAccountTicketResponse(proto.Message): + r"""Response message for ProvisionAccountTicket RPC. + + Attributes: + account_ticket_id (str): + The param to be passed in the ToS link. + """ + + account_ticket_id = proto.Field(proto.STRING, number=1) + + +class GetPropertyRequest(proto.Message): + r"""Request message for GetProperty RPC. + + Attributes: + name (str): + Required. The name of the property to lookup. Format: + properties/{property_id} Example: "properties/1000". + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListPropertiesRequest(proto.Message): + r"""Request message for ListProperties RPC. + + Attributes: + filter (str): + Required. An expression for filtering the results of the + request. Fields eligible for filtering are: + ``parent:``\ (The resource name of the parent account) or + ``firebase_project:``\ (The id or number of the linked + firebase project). Some examples of filters: + + :: + + | Filter | Description | + |-----------------------------|-------------------------------------------| + | parent:accounts/123 | The account with account id: 123. | + | firebase_project:project-id | The firebase project with id: project-id. | + | firebase_project:123 | The firebase project with number: 123. | + page_size (int): + The maximum number of resources to return. + The service may return fewer than this value, + even if there are additional pages. If + unspecified, at most 50 resources will be + returned. The maximum value is 200; (higher + values will be coerced to the maximum) + page_token (str): + A page token, received from a previous ``ListProperties`` + call. Provide this to retrieve the subsequent page. When + paginating, all other parameters provided to + ``ListProperties`` must match the call that provided the + page token. + show_deleted (bool): + Whether to include soft-deleted (ie: + "trashed") Properties in the results. Properties + can be inspected to determine whether they are + deleted or not. + """ + + filter = proto.Field(proto.STRING, number=1) + + page_size = proto.Field(proto.INT32, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + show_deleted = proto.Field(proto.BOOL, number=4) + + +class ListPropertiesResponse(proto.Message): + r"""Response message for ListProperties RPC. + + Attributes: + properties (Sequence[google.analytics.admin_v1alpha.types.Property]): + Results that matched the filter criteria and + were accessible to the caller. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + properties = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.Property, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class UpdatePropertyRequest(proto.Message): + r"""Request message for UpdateProperty RPC. + + Attributes: + property (google.analytics.admin_v1alpha.types.Property): + Required. The property to update. The property's ``name`` + field is used to identify the property to be updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + property = proto.Field(proto.MESSAGE, number=1, + message=resources.Property, + ) + + update_mask = proto.Field(proto.MESSAGE, number=2, + message=field_mask.FieldMask, + ) + + +class CreatePropertyRequest(proto.Message): + r"""Request message for CreateProperty RPC. + + Attributes: + property (google.analytics.admin_v1alpha.types.Property): + Required. The property to create. + Note: the supplied property must specify its + parent. + """ + + property = proto.Field(proto.MESSAGE, number=1, + message=resources.Property, + ) + + +class DeletePropertyRequest(proto.Message): + r"""Request message for DeleteProperty RPC. + + Attributes: + name (str): + Required. The name of the Property to soft-delete. Format: + properties/{property_id} Example: "properties/1000". + """ + + name = proto.Field(proto.STRING, number=1) + + +class GetUserLinkRequest(proto.Message): + r"""Request message for GetUserLink RPC. + + Attributes: + name (str): + Required. Example format: + accounts/1234/userLinks/5678 + """ + + name = proto.Field(proto.STRING, number=1) + + +class BatchGetUserLinksRequest(proto.Message): + r"""Request message for BatchGetUserLinks RPC. + + Attributes: + parent (str): + Required. The account or property that all + user links in the request are for. The parent of + all provided values for the 'names' field must + match this field. + Example format: accounts/1234 + names (Sequence[str]): + Required. The names of the user links to + retrieve. A maximum of 1000 user links can be + retrieved in a batch. Format: + accounts/{accountId}/userLinks/{userLinkId} + """ + + parent = proto.Field(proto.STRING, number=1) + + names = proto.RepeatedField(proto.STRING, number=2) + + +class BatchGetUserLinksResponse(proto.Message): + r"""Response message for BatchGetUserLinks RPC. + + Attributes: + user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): + The requested user links. + """ + + user_links = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.UserLink, + ) + + +class ListUserLinksRequest(proto.Message): + r"""Request message for ListUserLinks RPC. + + Attributes: + parent (str): + Required. Example format: accounts/1234 + page_size (int): + The maximum number of user links to return. + The service may return fewer than this value. If + unspecified, at most 200 user links will be + returned. The maximum value is 500; values above + 500 will be coerced to 500. + page_token (str): + A page token, received from a previous ``ListUserLinks`` + call. Provide this to retrieve the subsequent page. When + paginating, all other parameters provided to + ``ListUserLinks`` must match the call that provided the page + token. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_size = proto.Field(proto.INT32, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + +class ListUserLinksResponse(proto.Message): + r"""Response message for ListUserLinks RPC. + + Attributes: + user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): + List of UserLinks. These will be ordered + stably, but in an arbitrary order. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + user_links = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.UserLink, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class AuditUserLinksRequest(proto.Message): + r"""Request message for AuditUserLinks RPC. + + Attributes: + parent (str): + Required. Example format: accounts/1234 + page_size (int): + The maximum number of user links to return. + The service may return fewer than this value. If + unspecified, at most 1000 user links will be + returned. The maximum value is 5000; values + above 5000 will be coerced to 5000. + page_token (str): + A page token, received from a previous ``AuditUserLinks`` + call. Provide this to retrieve the subsequent page. When + paginating, all other parameters provided to + ``AuditUserLinks`` must match the call that provided the + page token. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_size = proto.Field(proto.INT32, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + +class AuditUserLinksResponse(proto.Message): + r"""Response message for AuditUserLinks RPC. + + Attributes: + user_links (Sequence[google.analytics.admin_v1alpha.types.AuditUserLink]): + List of AuditUserLinks. These will be ordered + stably, but in an arbitrary order. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + user_links = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.AuditUserLink, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class CreateUserLinkRequest(proto.Message): + r"""Request message for CreateUserLink RPC. + Users can have multiple email addresses associated with their + Google account, and one of these email addresses is the + "primary" email address. Any of the email addresses associated + with a Google account may be used for a new UserLink, but the + returned UserLink will always contain the "primary" email + address. As a result, the input and output email address for + this request may differ. + + Attributes: + parent (str): + Required. Example format: accounts/1234 + notify_new_user (bool): + Optional. If set, then email the new user + notifying them that they've been granted + permissions to the resource. + user_link (google.analytics.admin_v1alpha.types.UserLink): + Required. The user link to create. + """ + + parent = proto.Field(proto.STRING, number=1) + + notify_new_user = proto.Field(proto.BOOL, number=2) + + user_link = proto.Field(proto.MESSAGE, number=3, + message=resources.UserLink, + ) + + +class BatchCreateUserLinksRequest(proto.Message): + r"""Request message for BatchCreateUserLinks RPC. + + Attributes: + parent (str): + Required. The account or property that all + user links in the request are for. This field is + required. The parent field in the + CreateUserLinkRequest messages must either be + empty or match this field. Example format: + accounts/1234 + notify_new_users (bool): + Optional. If set, then email the new users notifying them + that they've been granted permissions to the resource. + Regardless of whether this is set or not, notify_new_user + field inside each individual request is ignored. + requests (Sequence[google.analytics.admin_v1alpha.types.CreateUserLinkRequest]): + Required. The requests specifying the user + links to create. A maximum of 1000 user links + can be created in a batch. + """ + + parent = proto.Field(proto.STRING, number=1) + + notify_new_users = proto.Field(proto.BOOL, number=2) + + requests = proto.RepeatedField(proto.MESSAGE, number=3, + message='CreateUserLinkRequest', + ) + + +class BatchCreateUserLinksResponse(proto.Message): + r"""Response message for BatchCreateUserLinks RPC. + + Attributes: + user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): + The user links created. + """ + + user_links = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.UserLink, + ) + + +class UpdateUserLinkRequest(proto.Message): + r"""Request message for UpdateUserLink RPC. + + Attributes: + user_link (google.analytics.admin_v1alpha.types.UserLink): + Required. The user link to update. + """ + + user_link = proto.Field(proto.MESSAGE, number=1, + message=resources.UserLink, + ) + + +class BatchUpdateUserLinksRequest(proto.Message): + r"""Request message for BatchUpdateUserLinks RPC. + + Attributes: + parent (str): + Required. The account or property that all + user links in the request are for. The parent + field in the UpdateUserLinkRequest messages must + either be empty or match this field. + Example format: accounts/1234 + requests (Sequence[google.analytics.admin_v1alpha.types.UpdateUserLinkRequest]): + Required. The requests specifying the user + links to update. A maximum of 1000 user links + can be updated in a batch. + """ + + parent = proto.Field(proto.STRING, number=1) + + requests = proto.RepeatedField(proto.MESSAGE, number=2, + message='UpdateUserLinkRequest', + ) + + +class BatchUpdateUserLinksResponse(proto.Message): + r"""Response message for BatchUpdateUserLinks RPC. + + Attributes: + user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): + The user links updated. + """ + + user_links = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.UserLink, + ) + + +class DeleteUserLinkRequest(proto.Message): + r"""Request message for DeleteUserLink RPC. + + Attributes: + name (str): + Required. Example format: + accounts/1234/userLinks/5678 + """ + + name = proto.Field(proto.STRING, number=1) + + +class BatchDeleteUserLinksRequest(proto.Message): + r"""Request message for BatchDeleteUserLinks RPC. + + Attributes: + parent (str): + Required. The account or property that all + user links in the request are for. The parent of + all values for user link names to delete must + match this field. + Example format: accounts/1234 + requests (Sequence[google.analytics.admin_v1alpha.types.DeleteUserLinkRequest]): + Required. The requests specifying the user + links to update. A maximum of 1000 user links + can be updated in a batch. + """ + + parent = proto.Field(proto.STRING, number=1) + + requests = proto.RepeatedField(proto.MESSAGE, number=2, + message='DeleteUserLinkRequest', + ) + + +class GetWebDataStreamRequest(proto.Message): + r"""Request message for GetWebDataStream RPC. + + Attributes: + name (str): + Required. The name of the web data stream to lookup. Format: + properties/{property_id}/webDataStreams/{stream_id} Example: + "properties/123/webDataStreams/456". + """ + + name = proto.Field(proto.STRING, number=1) + + +class DeleteWebDataStreamRequest(proto.Message): + r"""Request message for DeleteWebDataStream RPC. + + Attributes: + name (str): + Required. The name of the web data stream to delete. Format: + properties/{property_id}/webDataStreams/{stream_id} Example: + "properties/123/webDataStreams/456". + """ + + name = proto.Field(proto.STRING, number=1) + + +class UpdateWebDataStreamRequest(proto.Message): + r"""Request message for UpdateWebDataStream RPC. + + Attributes: + web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): + Required. The web stream to update. The ``name`` field is + used to identify the web stream to be updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + web_data_stream = proto.Field(proto.MESSAGE, number=1, + message=resources.WebDataStream, + ) + + update_mask = proto.Field(proto.MESSAGE, number=2, + message=field_mask.FieldMask, + ) + + +class CreateWebDataStreamRequest(proto.Message): + r"""Request message for CreateWebDataStream RPC. + + Attributes: + web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): + Required. The web stream to create. + parent (str): + Required. The parent resource where this web + data stream will be created. Format: + properties/123 + """ + + web_data_stream = proto.Field(proto.MESSAGE, number=1, + message=resources.WebDataStream, + ) + + parent = proto.Field(proto.STRING, number=2) + + +class ListWebDataStreamsRequest(proto.Message): + r"""Request message for ListWebDataStreams RPC. + + Attributes: + parent (str): + Required. The name of the parent property. + For example, to list results of web streams + under the property with Id 123: "properties/123". + page_size (int): + The maximum number of resources to return. + If unspecified, at most 50 resources will be + returned. The maximum value is 200; (higher + values will be coerced to the maximum) + page_token (str): + A page token, received from a previous + ``ListWebDataStreams`` call. Provide this to retrieve the + subsequent page. When paginating, all other parameters + provided to ``ListWebDataStreams`` must match the call that + provided the page token. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_size = proto.Field(proto.INT32, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + +class ListWebDataStreamsResponse(proto.Message): + r"""Request message for ListWebDataStreams RPC. + + Attributes: + web_data_streams (Sequence[google.analytics.admin_v1alpha.types.WebDataStream]): + Results that matched the filter criteria and + were accessible to the caller. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + web_data_streams = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.WebDataStream, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class GetIosAppDataStreamRequest(proto.Message): + r"""Request message for GetIosAppDataStream RPC. + + Attributes: + name (str): + Required. The name of the iOS app data stream to lookup. + Format: + properties/{property_id}/iosAppDataStreams/{stream_id} + Example: "properties/123/iosAppDataStreams/456". + """ + + name = proto.Field(proto.STRING, number=1) + + +class DeleteIosAppDataStreamRequest(proto.Message): + r"""Request message for DeleteIosAppDataStream RPC. + + Attributes: + name (str): + Required. The name of the iOS app data stream to delete. + Format: + properties/{property_id}/iosAppDataStreams/{stream_id} + Example: "properties/123/iosAppDataStreams/456". + """ + + name = proto.Field(proto.STRING, number=1) + + +class UpdateIosAppDataStreamRequest(proto.Message): + r"""Request message for UpdateIosAppDataStream RPC. + + Attributes: + ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): + Required. The iOS app stream to update. The ``name`` field + is used to identify the iOS app stream to be updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + ios_app_data_stream = proto.Field(proto.MESSAGE, number=1, + message=resources.IosAppDataStream, + ) + + update_mask = proto.Field(proto.MESSAGE, number=2, + message=field_mask.FieldMask, + ) + + +class CreateIosAppDataStreamRequest(proto.Message): + r"""Request message for CreateIosAppDataStream RPC. + + Attributes: + ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): + Required. The iOS app data stream to create. + parent (str): + Required. The parent resource where this ios + app data stream will be created. Format: + properties/123 + """ + + ios_app_data_stream = proto.Field(proto.MESSAGE, number=1, + message=resources.IosAppDataStream, + ) + + parent = proto.Field(proto.STRING, number=2) + + +class ListIosAppDataStreamsRequest(proto.Message): + r"""Request message for ListIosAppDataStreams RPC. + + Attributes: + parent (str): + Required. The name of the parent property. + For example, to list results of app streams + under the property with Id 123: "properties/123". + page_size (int): + The maximum number of resources to return. + If unspecified, at most 50 resources will be + returned. The maximum value is 200; (higher + values will be coerced to the maximum) + page_token (str): + A page token, received from a previous + ``ListIosAppDataStreams`` call. Provide this to retrieve the + subsequent page. When paginating, all other parameters + provided to ``ListIosAppDataStreams`` must match the call + that provided the page token. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_size = proto.Field(proto.INT32, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + +class ListIosAppDataStreamsResponse(proto.Message): + r"""Request message for ListIosAppDataStreams RPC. + + Attributes: + ios_app_data_streams (Sequence[google.analytics.admin_v1alpha.types.IosAppDataStream]): + Results that matched the filter criteria and + were accessible to the caller. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + ios_app_data_streams = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.IosAppDataStream, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class GetAndroidAppDataStreamRequest(proto.Message): + r"""Request message for GetAndroidAppDataStream RPC. + + Attributes: + name (str): + Required. The name of the android app data stream to lookup. + Format: + properties/{property_id}/androidAppDataStreams/{stream_id} + Example: "properties/123/androidAppDataStreams/456". + """ + + name = proto.Field(proto.STRING, number=1) + + +class DeleteAndroidAppDataStreamRequest(proto.Message): + r"""Request message for DeleteAndroidAppDataStream RPC. + + Attributes: + name (str): + Required. The name of the android app data stream to delete. + Format: + properties/{property_id}/androidAppDataStreams/{stream_id} + Example: "properties/123/androidAppDataStreams/456". + """ + + name = proto.Field(proto.STRING, number=1) + + +class UpdateAndroidAppDataStreamRequest(proto.Message): + r"""Request message for UpdateAndroidAppDataStream RPC. + + Attributes: + android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): + Required. The android app stream to update. The ``name`` + field is used to identify the android app stream to be + updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + android_app_data_stream = proto.Field(proto.MESSAGE, number=1, + message=resources.AndroidAppDataStream, + ) + + update_mask = proto.Field(proto.MESSAGE, number=2, + message=field_mask.FieldMask, + ) + + +class CreateAndroidAppDataStreamRequest(proto.Message): + r"""Request message for CreateAndroidAppDataStream RPC. + + Attributes: + android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): + Required. The android app stream to create. + parent (str): + Required. The parent resource where this + android app data stream will be created. Format: + properties/123 + """ + + android_app_data_stream = proto.Field(proto.MESSAGE, number=1, + message=resources.AndroidAppDataStream, + ) + + parent = proto.Field(proto.STRING, number=2) + + +class ListAndroidAppDataStreamsRequest(proto.Message): + r"""Request message for ListAndroidAppDataStreams RPC. + + Attributes: + parent (str): + Required. The name of the parent property. + For example, to limit results to app streams + under the property with Id 123: "properties/123". + page_size (int): + The maximum number of resources to return. + If unspecified, at most 50 resources will be + returned. The maximum value is 200; (higher + values will be coerced to the maximum) + page_token (str): + A page token, received from a previous call. Provide this to + retrieve the subsequent page. When paginating, all other + parameters provided to ``ListAndroidAppDataStreams`` must + match the call that provided the page token. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_size = proto.Field(proto.INT32, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + +class ListAndroidAppDataStreamsResponse(proto.Message): + r"""Request message for ListAndroidDataStreams RPC. + + Attributes: + android_app_data_streams (Sequence[google.analytics.admin_v1alpha.types.AndroidAppDataStream]): + Results that matched the filter criteria and + were accessible to the caller. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + android_app_data_streams = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.AndroidAppDataStream, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class GetEnhancedMeasurementSettingsRequest(proto.Message): + r"""Request message for GetEnhancedMeasurementSettings RPC. + + Attributes: + name (str): + Required. The name of the settings to lookup. Format: + properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings + Example: + "properties/1000/webDataStreams/2000/enhancedMeasurementSettings". + """ + + name = proto.Field(proto.STRING, number=1) + + +class UpdateEnhancedMeasurementSettingsRequest(proto.Message): + r"""Request message for UpdateEnhancedMeasurementSettings RPC. + + Attributes: + enhanced_measurement_settings (google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings): + Required. The settings to update. The ``name`` field is used + to identify the settings to be updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + enhanced_measurement_settings = proto.Field(proto.MESSAGE, number=1, + message=resources.EnhancedMeasurementSettings, + ) + + update_mask = proto.Field(proto.MESSAGE, number=2, + message=field_mask.FieldMask, + ) + + +class CreateFirebaseLinkRequest(proto.Message): + r"""Request message for CreateFirebaseLink RPC + + Attributes: + parent (str): + Required. Format: properties/{property_id} Example: + properties/1234 + firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): + Required. The Firebase link to create. + """ + + parent = proto.Field(proto.STRING, number=1) + + firebase_link = proto.Field(proto.MESSAGE, number=2, + message=resources.FirebaseLink, + ) + + +class UpdateFirebaseLinkRequest(proto.Message): + r"""Request message for UpdateFirebaseLink RPC + + Attributes: + firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): + Required. The Firebase link to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + firebase_link = proto.Field(proto.MESSAGE, number=1, + message=resources.FirebaseLink, + ) + + update_mask = proto.Field(proto.MESSAGE, number=2, + message=field_mask.FieldMask, + ) + + +class DeleteFirebaseLinkRequest(proto.Message): + r"""Request message for DeleteFirebaseLink RPC + + Attributes: + name (str): + Required. Format: + properties/{property_id}/firebaseLinks/{firebase_link_id} + Example: properties/1234/firebaseLinks/5678 + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListFirebaseLinksRequest(proto.Message): + r"""Request message for ListFirebaseLinks RPC + + Attributes: + parent (str): + Required. Format: properties/{property_id} Example: + properties/1234 + page_size (int): + The maximum number of resources to return. + The service may return fewer than this value, + even if there are additional pages. If + unspecified, at most 50 resources will be + returned. The maximum value is 200; (higher + values will be coerced to the maximum) + page_token (str): + A page token, received from a previous ``ListFirebaseLinks`` + call. Provide this to retrieve the subsequent page. When + paginating, all other parameters provided to + ``ListProperties`` must match the call that provided the + page token. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_size = proto.Field(proto.INT32, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + +class ListFirebaseLinksResponse(proto.Message): + r"""Response message for ListFirebaseLinks RPC + + Attributes: + firebase_links (Sequence[google.analytics.admin_v1alpha.types.FirebaseLink]): + List of FirebaseLinks. This will have at most + one value. + 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. Currently, Google Analytics supports only one + FirebaseLink per property, so this will never be populated. + """ + + @property + def raw_page(self): + return self + + firebase_links = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.FirebaseLink, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class GetGlobalSiteTagRequest(proto.Message): + r"""Request message for GetGlobalSiteTag RPC. + + Attributes: + name (str): + Required. The name of the site tag to lookup. Note that site + tags are singletons and do not have unique IDs. Format: + properties/{property_id}/webDataStreams/{stream_id}/globalSiteTag + Example: "properties/123/webDataStreams/456/globalSiteTag". + """ + + name = proto.Field(proto.STRING, number=1) + + +class CreateGoogleAdsLinkRequest(proto.Message): + r"""Request message for CreateGoogleAdsLink RPC + + Attributes: + parent (str): + Required. Example format: properties/1234 + google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): + Required. The GoogleAdsLink to create. + """ + + parent = proto.Field(proto.STRING, number=1) + + google_ads_link = proto.Field(proto.MESSAGE, number=2, + message=resources.GoogleAdsLink, + ) + + +class UpdateGoogleAdsLinkRequest(proto.Message): + r"""Request message for UpdateGoogleAdsLink RPC + + Attributes: + google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): + The GoogleAdsLink to update + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + google_ads_link = proto.Field(proto.MESSAGE, number=1, + message=resources.GoogleAdsLink, + ) + + update_mask = proto.Field(proto.MESSAGE, number=2, + message=field_mask.FieldMask, + ) + + +class DeleteGoogleAdsLinkRequest(proto.Message): + r"""Request message for DeleteGoogleAdsLink RPC. + + Attributes: + name (str): + Required. Example format: + properties/1234/googleAdsLinks/5678 + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListGoogleAdsLinksRequest(proto.Message): + r"""Request message for ListGoogleAdsLinks RPC. + + Attributes: + parent (str): + Required. Example format: properties/1234 + page_size (int): + The maximum number of resources to return. + If unspecified, at most 50 resources will be + returned. The maximum value is 200 (higher + values will be coerced to the maximum). + page_token (str): + A page token, received from a previous + ``ListGoogleAdsLinks`` call. Provide this to retrieve the + subsequent page. + + When paginating, all other parameters provided to + ``ListGoogleAdsLinks`` must match the call that provided the + page token. + """ + + parent = proto.Field(proto.STRING, number=1) + + page_size = proto.Field(proto.INT32, number=2) + + page_token = proto.Field(proto.STRING, number=3) + + +class ListGoogleAdsLinksResponse(proto.Message): + r"""Response message for ListGoogleAdsLinks RPC. + + Attributes: + google_ads_links (Sequence[google.analytics.admin_v1alpha.types.GoogleAdsLink]): + List of GoogleAdsLinks. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + google_ads_links = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.GoogleAdsLink, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +class GetDataSharingSettingsRequest(proto.Message): + r"""Request message for GetDataSharingSettings RPC. + + Attributes: + name (str): + Required. The name of the settings to lookup. + Format: accounts/{account}/dataSharingSettings + Example: "accounts/1000/dataSharingSettings". + """ + + name = proto.Field(proto.STRING, number=1) + + +class ListAccountSummariesRequest(proto.Message): + r"""Request message for ListAccountSummaries RPC. + + Attributes: + page_size (int): + The maximum number of AccountSummary + resources to return. The service may return + fewer than this value, even if there are + additional pages. If unspecified, at most 50 + resources will be returned. The maximum value is + 200; (higher values will be coerced to the + maximum) + page_token (str): + A page token, received from a previous + ``ListAccountSummaries`` call. Provide this to retrieve the + subsequent page. When paginating, all other parameters + provided to ``ListAccountSummaries`` must match the call + that provided the page token. + """ + + page_size = proto.Field(proto.INT32, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + +class ListAccountSummariesResponse(proto.Message): + r"""Response message for ListAccountSummaries RPC. + + Attributes: + account_summaries (Sequence[google.analytics.admin_v1alpha.types.AccountSummary]): + Account summaries of all accounts the caller + has access to. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + account_summaries = proto.RepeatedField(proto.MESSAGE, number=1, + message=resources.AccountSummary, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py new file mode 100644 index 00000000..ad0d3296 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py @@ -0,0 +1,712 @@ +# -*- 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 timestamp_pb2 as timestamp # type: ignore +from google.protobuf import wrappers_pb2 as wrappers # type: ignore + + +__protobuf__ = proto.module( + package='google.analytics.admin.v1alpha', + manifest={ + 'MaximumUserAccess', + 'IndustryCategory', + 'Account', + 'Property', + 'AndroidAppDataStream', + 'IosAppDataStream', + 'WebDataStream', + 'UserLink', + 'AuditUserLink', + 'EnhancedMeasurementSettings', + 'FirebaseLink', + 'GlobalSiteTag', + 'GoogleAdsLink', + 'DataSharingSettings', + 'AccountSummary', + 'PropertySummary', + }, +) + + +class MaximumUserAccess(proto.Enum): + r"""Maximum access settings that Firebase user receive on the + linked Analytics property. + """ + MAXIMUM_USER_ACCESS_UNSPECIFIED = 0 + NO_ACCESS = 1 + READ_AND_ANALYZE = 2 + EDITOR_WITHOUT_LINK_MANAGEMENT = 3 + EDITOR_INCLUDING_LINK_MANAGEMENT = 4 + + +class IndustryCategory(proto.Enum): + r"""The category selected for this property, used for industry + benchmarking. + """ + INDUSTRY_CATEGORY_UNSPECIFIED = 0 + AUTOMOTIVE = 1 + BUSINESS_AND_INDUSTRIAL_MARKETS = 2 + FINANCE = 3 + HEALTHCARE = 4 + TECHNOLOGY = 5 + TRAVEL = 6 + OTHER = 7 + ARTS_AND_ENTERTAINMENT = 8 + BEAUTY_AND_FITNESS = 9 + BOOKS_AND_LITERATURE = 10 + FOOD_AND_DRINK = 11 + GAMES = 12 + HOBBIES_AND_LEISURE = 13 + HOME_AND_GARDEN = 14 + INTERNET_AND_TELECOM = 15 + LAW_AND_GOVERNMENT = 16 + NEWS = 17 + ONLINE_COMMUNITIES = 18 + PEOPLE_AND_SOCIETY = 19 + PETS_AND_ANIMALS = 20 + REAL_ESTATE = 21 + REFERENCE = 22 + SCIENCE = 23 + SPORTS = 24 + JOBS_AND_EDUCATION = 25 + SHOPPING = 26 + + +class Account(proto.Message): + r"""A resource message representing a Google Analytics account. + + Attributes: + name (str): + Output only. Resource name of this account. + Format: accounts/{account} + Example: "accounts/100". + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this account was + originally created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when account payload fields + were last updated. + display_name (str): + Required. Human-readable display name for + this account. + region_code (str): + Country of business. Must be a Unicode CLDR + region code. + deleted (bool): + Output only. Indicates whether this Account + is soft-deleted or not. Deleted accounts are + excluded from List results unless specifically + requested. + """ + + name = proto.Field(proto.STRING, number=1) + + create_time = proto.Field(proto.MESSAGE, number=2, + message=timestamp.Timestamp, + ) + + update_time = proto.Field(proto.MESSAGE, number=3, + message=timestamp.Timestamp, + ) + + display_name = proto.Field(proto.STRING, number=4) + + region_code = proto.Field(proto.STRING, number=5) + + deleted = proto.Field(proto.BOOL, number=6) + + +class Property(proto.Message): + r"""A resource message representing a Google Analytics GA4 + property. + + Attributes: + name (str): + Output only. Resource name of this property. Format: + properties/{property_id} Example: "properties/1000". + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when the entity was + originally created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when entity payload fields + were last updated. + parent (str): + Immutable. Resource name of this property's + logical parent. + Note: The Property-Moving UI can be used to + change the parent. Format: accounts/{account} + Example: "accounts/100". + display_name (str): + Required. Human-readable display name for + this property. + The max allowed display name length is 100 + UTF-16 code units. + industry_category (google.analytics.admin_v1alpha.types.IndustryCategory): + Industry associated with this property Example: AUTOMOTIVE, + FOOD_AND_DRINK + time_zone (str): + Reporting Time Zone, used as the day boundary for reports, + regardless of where the data originates. If the time zone + honors DST, Analytics will automatically adjust for the + changes. + + NOTE: Changing the time zone only affects data going + forward, and is not applied retroactively. + + Format: https://www.iana.org/time-zones Example: + "America/Los_Angeles". + currency_code (str): + The currency type used in reports involving monetary values. + + Format: https://en.wikipedia.org/wiki/ISO_4217 Examples: + "USD", "EUR", "JPY". + deleted (bool): + Output only. Indicates whether this Property + is soft-deleted or not. Deleted properties are + excluded from List results unless specifically + requested. + """ + + name = proto.Field(proto.STRING, number=1) + + create_time = proto.Field(proto.MESSAGE, number=3, + message=timestamp.Timestamp, + ) + + update_time = proto.Field(proto.MESSAGE, number=4, + message=timestamp.Timestamp, + ) + + parent = proto.Field(proto.STRING, number=2) + + display_name = proto.Field(proto.STRING, number=5) + + industry_category = proto.Field(proto.ENUM, number=6, + enum='IndustryCategory', + ) + + time_zone = proto.Field(proto.STRING, number=7) + + currency_code = proto.Field(proto.STRING, number=8) + + deleted = proto.Field(proto.BOOL, number=9) + + +class AndroidAppDataStream(proto.Message): + r"""A resource message representing a Google Analytics Android + app stream. + + Attributes: + name (str): + Output only. Resource name of this Data Stream. Format: + properties/{property_id}/androidAppDataStreams/{stream_id} + Example: "properties/1000/androidAppDataStreams/2000". + firebase_app_id (str): + Output only. ID of the corresponding Android + app in Firebase, if any. This ID can change if + the Android app is deleted and recreated. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this stream was + originally created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when stream payload fields + were last updated. + package_name (str): + Immutable. The package name for the app being + measured. Example: "com.example.myandroidapp". + display_name (str): + Human-readable display name for the Data + Stream. + The max allowed display name length is 255 + UTF-16 code units. + """ + + name = proto.Field(proto.STRING, number=1) + + firebase_app_id = proto.Field(proto.STRING, number=2) + + create_time = proto.Field(proto.MESSAGE, number=3, + message=timestamp.Timestamp, + ) + + update_time = proto.Field(proto.MESSAGE, number=4, + message=timestamp.Timestamp, + ) + + package_name = proto.Field(proto.STRING, number=5) + + display_name = proto.Field(proto.STRING, number=6) + + +class IosAppDataStream(proto.Message): + r"""A resource message representing a Google Analytics IOS app + stream. + + Attributes: + name (str): + Output only. Resource name of this Data Stream. Format: + properties/{property_id}/iosAppDataStreams/{stream_id} + Example: "properties/1000/iosAppDataStreams/2000". + firebase_app_id (str): + Output only. ID of the corresponding iOS app + in Firebase, if any. This ID can change if the + iOS app is deleted and recreated. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this stream was + originally created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when stream payload fields + were last updated. + bundle_id (str): + Required. Immutable. The Apple App Store + Bundle ID for the app Example: + "com.example.myiosapp". + display_name (str): + Human-readable display name for the Data + Stream. + The max allowed display name length is 255 + UTF-16 code units. + """ + + name = proto.Field(proto.STRING, number=1) + + firebase_app_id = proto.Field(proto.STRING, number=2) + + create_time = proto.Field(proto.MESSAGE, number=3, + message=timestamp.Timestamp, + ) + + update_time = proto.Field(proto.MESSAGE, number=4, + message=timestamp.Timestamp, + ) + + bundle_id = proto.Field(proto.STRING, number=5) + + display_name = proto.Field(proto.STRING, number=6) + + +class WebDataStream(proto.Message): + r"""A resource message representing a Google Analytics web + stream. + + Attributes: + name (str): + Output only. Resource name of this Data Stream. Format: + properties/{property_id}/webDataStreams/{stream_id} Example: + "properties/1000/webDataStreams/2000". + measurement_id (str): + Output only. Analytics "Measurement ID", + without the "G-" prefix. Example: "G-1A2BCD345E" + would just be "1A2BCD345E". + firebase_app_id (str): + Output only. ID of the corresponding web app + in Firebase, if any. This ID can change if the + web app is deleted and recreated. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this stream was + originally created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when stream payload fields + were last updated. + default_uri (str): + Immutable. Domain name of the web app being + measured, or empty. Example: + "http://www.google.com", + "https://www.google.com". + display_name (str): + Required. Human-readable display name for the + Data Stream. + The max allowed display name length is 100 + UTF-16 code units. + """ + + name = proto.Field(proto.STRING, number=1) + + measurement_id = proto.Field(proto.STRING, number=2) + + firebase_app_id = proto.Field(proto.STRING, number=3) + + create_time = proto.Field(proto.MESSAGE, number=4, + message=timestamp.Timestamp, + ) + + update_time = proto.Field(proto.MESSAGE, number=5, + message=timestamp.Timestamp, + ) + + default_uri = proto.Field(proto.STRING, number=6) + + display_name = proto.Field(proto.STRING, number=7) + + +class UserLink(proto.Message): + r"""A resource message representing a user's permissions on an + Account or Property resource. + + Attributes: + name (str): + Example format: + properties/1234/userLinks/5678 + email_address (str): + Email address of the user to link + direct_roles (Sequence[str]): + Roles directly assigned to this user for this account or + property. + + Valid values: predefinedRoles/read + predefinedRoles/collaborate predefinedRoles/edit + predefinedRoles/manage-users + + Excludes roles that are inherited from a higher-level + entity, group, or organization admin role. + + A UserLink that is updated to have an empty list of + direct_roles will be deleted. + """ + + name = proto.Field(proto.STRING, number=1) + + email_address = proto.Field(proto.STRING, number=2) + + direct_roles = proto.RepeatedField(proto.STRING, number=3) + + +class AuditUserLink(proto.Message): + r"""Read-only resource used to summarize a principal's effective + roles. + + Attributes: + name (str): + Example format: + properties/1234/userLinks/5678 + email_address (str): + Email address of the linked user + direct_roles (Sequence[str]): + Roles directly assigned to this user for this + entity. + Format: predefinedRoles/read + + Excludes roles that are inherited from an + account (if this is for a property), group, or + organization admin role. + effective_roles (Sequence[str]): + Union of all permissions a user has at this + account or property (includes direct + permissions, group-inherited permissions, etc.). + Format: predefinedRoles/read + """ + + name = proto.Field(proto.STRING, number=1) + + email_address = proto.Field(proto.STRING, number=2) + + direct_roles = proto.RepeatedField(proto.STRING, number=3) + + effective_roles = proto.RepeatedField(proto.STRING, number=4) + + +class EnhancedMeasurementSettings(proto.Message): + r"""Singleton resource under a WebDataStream, configuring + measurement of additional site interactions and content. + + Attributes: + name (str): + Output only. Resource name of this Data Stream. Format: + properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings + Example: + "properties/1000/webDataStreams/2000/enhancedMeasurementSettings". + stream_enabled (bool): + Indicates whether Enhanced Measurement + Settings will be used to automatically measure + interactions and content on this web stream. + Changing this value does not affect the settings + themselves, but determines whether they are + respected. + page_views_enabled (bool): + Output only. If enabled, capture a page view + event each time a page loads or the website + changes the browser history state. + scrolls_enabled (bool): + If enabled, capture scroll events each time a + visitor gets to the bottom of a page. + outbound_clicks_enabled (bool): + If enabled, capture an outbound click event + each time a visitor clicks a link that leads + them away from your domain. + site_search_enabled (bool): + If enabled, capture a view search results + event each time a visitor performs a search on + your site (based on a query parameter). + video_engagement_enabled (bool): + If enabled, capture video play, progress, and + complete events as visitors view embedded videos + on your site. + file_downloads_enabled (bool): + If enabled, capture a file download event + each time a link is clicked with a common + document, compressed file, application, video, + or audio extension. + page_loads_enabled (bool): + Output only. If enabled, capture a page view + event each time a page loads. + page_changes_enabled (bool): + If enabled, capture a page view event each + time the website changes the browser history + state. + search_query_parameter (str): + Required. URL query parameters to interpret + as site search parameters. Max length is 1024 + characters. Must not be empty. + uri_query_parameter (str): + Additional URL query parameters. + Max length is 1024 characters. + """ + + name = proto.Field(proto.STRING, number=1) + + stream_enabled = proto.Field(proto.BOOL, number=2) + + page_views_enabled = proto.Field(proto.BOOL, number=3) + + scrolls_enabled = proto.Field(proto.BOOL, number=4) + + outbound_clicks_enabled = proto.Field(proto.BOOL, number=5) + + site_search_enabled = proto.Field(proto.BOOL, number=7) + + video_engagement_enabled = proto.Field(proto.BOOL, number=9) + + file_downloads_enabled = proto.Field(proto.BOOL, number=10) + + page_loads_enabled = proto.Field(proto.BOOL, number=12) + + page_changes_enabled = proto.Field(proto.BOOL, number=13) + + search_query_parameter = proto.Field(proto.STRING, number=16) + + uri_query_parameter = proto.Field(proto.STRING, number=17) + + +class FirebaseLink(proto.Message): + r"""A link between an GA4 property and a Firebase project. + + Attributes: + name (str): + Output only. Example format: + properties/1234/firebaseLinks/5678 + project (str): + Immutable. Firebase project resource name. When creating a + FirebaseLink, you may provide this resource name using + either a project number or project ID. Once this resource + has been created, returned FirebaseLinks will always have a + project_name that contains a project number. + + Format: 'projects/{project number}' Example: 'projects/1234' + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this FirebaseLink was + originally created. + maximum_user_access (google.analytics.admin_v1alpha.types.MaximumUserAccess): + Maximum user access to the GA4 property + allowed to admins of the linked Firebase + project. + """ + + name = proto.Field(proto.STRING, number=1) + + project = proto.Field(proto.STRING, number=2) + + create_time = proto.Field(proto.MESSAGE, number=3, + message=timestamp.Timestamp, + ) + + maximum_user_access = proto.Field(proto.ENUM, number=4, + enum='MaximumUserAccess', + ) + + +class GlobalSiteTag(proto.Message): + r"""Read-only resource with the tag for sending data from a + website to a WebDataStream. + + Attributes: + name (str): + Output only. Resource name for this + GlobalSiteTag resource. Format: + properties/{propertyId}/globalSiteTag + snippet (str): + Immutable. JavaScript code snippet to be + pasted as the first item into the head tag of + every webpage to measure. + """ + + name = proto.Field(proto.STRING, number=1) + + snippet = proto.Field(proto.STRING, number=2) + + +class GoogleAdsLink(proto.Message): + r"""A link between an GA4 property and a Google Ads account. + + Attributes: + name (str): + Output only. Format: + properties/{propertyId}/googleAdsLinks/{googleAdsLinkId} + Note: googleAdsLinkId is not the Google Ads + customer ID. + customer_id (str): + Immutable. Google Ads customer ID. + can_manage_clients (bool): + Output only. If true, this link is for a + Google Ads manager account. + ads_personalization_enabled (google.protobuf.wrappers_pb2.BoolValue): + Enable personalized advertising features with + this integration. Automatically publish my + Google Analytics audience lists and Google + Analytics remarketing events/parameters to the + linked Google Ads account. If this field is not + set on create/update it will be defaulted to + true. + email_address (str): + Output only. Email address of the user that + created the link. An empty string will be + returned if the email address can't be + retrieved. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this link was + originally created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this link was last + updated. + """ + + name = proto.Field(proto.STRING, number=1) + + customer_id = proto.Field(proto.STRING, number=3) + + can_manage_clients = proto.Field(proto.BOOL, number=4) + + ads_personalization_enabled = proto.Field(proto.MESSAGE, number=5, + message=wrappers.BoolValue, + ) + + email_address = proto.Field(proto.STRING, number=6) + + create_time = proto.Field(proto.MESSAGE, number=7, + message=timestamp.Timestamp, + ) + + update_time = proto.Field(proto.MESSAGE, number=8, + message=timestamp.Timestamp, + ) + + +class DataSharingSettings(proto.Message): + r"""A resource message representing data sharing settings of a + Google Analytics account. + + Attributes: + name (str): + Output only. Resource name. + Format: accounts/{account}/dataSharingSettings + Example: "accounts/1000/dataSharingSettings". + sharing_with_google_support_enabled (bool): + Allows Google support to access the data in + order to help troubleshoot issues. + sharing_with_google_assigned_sales_enabled (bool): + Allows Google sales teams that are assigned + to the customer to access the data in order to + suggest configuration changes to improve + results. Sales team restrictions still apply + when enabled. + sharing_with_google_any_sales_enabled (bool): + Allows any of Google sales to access the data + in order to suggest configuration changes to + improve results. + sharing_with_google_products_enabled (bool): + Allows Google to use the data to improve + other Google products or services. + sharing_with_others_enabled (bool): + Allows Google to share the data anonymously + in aggregate form with others. + """ + + name = proto.Field(proto.STRING, number=1) + + sharing_with_google_support_enabled = proto.Field(proto.BOOL, number=2) + + sharing_with_google_assigned_sales_enabled = proto.Field(proto.BOOL, number=3) + + sharing_with_google_any_sales_enabled = proto.Field(proto.BOOL, number=4) + + sharing_with_google_products_enabled = proto.Field(proto.BOOL, number=5) + + sharing_with_others_enabled = proto.Field(proto.BOOL, number=6) + + +class AccountSummary(proto.Message): + r"""A virtual resource representing an overview of an account and + all its child GA4 properties. + + Attributes: + name (str): + Resource name for this account summary. Format: + accountSummaries/{account_id} Example: + "accountSummaries/1000". + account (str): + Resource name of account referred to by this account summary + Format: accounts/{account_id} Example: "accounts/1000". + display_name (str): + Display name for the account referred to in + this account summary. + property_summaries (Sequence[google.analytics.admin_v1alpha.types.PropertySummary]): + List of summaries for child accounts of this + account. + """ + + name = proto.Field(proto.STRING, number=1) + + account = proto.Field(proto.STRING, number=2) + + display_name = proto.Field(proto.STRING, number=3) + + property_summaries = proto.RepeatedField(proto.MESSAGE, number=4, + message='PropertySummary', + ) + + +class PropertySummary(proto.Message): + r"""A virtual resource representing metadata for an GA4 property. + + Attributes: + property (str): + Resource name of property referred to by this property + summary Format: properties/{property_id} Example: + "properties/1000". + display_name (str): + Display name for the property referred to in + this account summary. + """ + + property = proto.Field(proto.STRING, number=1) + + display_name = proto.Field(proto.STRING, number=2) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/mypy.ini b/owl-bot-staging/v1alpha/mypy.ini new file mode 100644 index 00000000..4505b485 --- /dev/null +++ b/owl-bot-staging/v1alpha/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1alpha/noxfile.py b/owl-bot-staging/v1alpha/noxfile.py new file mode 100644 index 00000000..372f13ba --- /dev/null +++ b/owl-bot-staging/v1alpha/noxfile.py @@ -0,0 +1,72 @@ +# -*- 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 shutil + +import nox # type: ignore + + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/analytics/admin_v1alpha/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py new file mode 100644 index 00000000..4aaee832 --- /dev/null +++ b/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py @@ -0,0 +1,226 @@ +#! /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 adminCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'audit_user_links': ('parent', 'page_size', 'page_token', ), + 'batch_create_user_links': ('parent', 'requests', 'notify_new_users', ), + 'batch_delete_user_links': ('parent', 'requests', ), + 'batch_get_user_links': ('parent', 'names', ), + 'batch_update_user_links': ('parent', 'requests', ), + 'create_android_app_data_stream': ('android_app_data_stream', 'parent', ), + 'create_firebase_link': ('parent', 'firebase_link', ), + 'create_google_ads_link': ('parent', 'google_ads_link', ), + 'create_ios_app_data_stream': ('ios_app_data_stream', 'parent', ), + 'create_property': ('property', ), + 'create_user_link': ('parent', 'user_link', 'notify_new_user', ), + 'create_web_data_stream': ('web_data_stream', 'parent', ), + 'delete_account': ('name', ), + 'delete_android_app_data_stream': ('name', ), + 'delete_firebase_link': ('name', ), + 'delete_google_ads_link': ('name', ), + 'delete_ios_app_data_stream': ('name', ), + 'delete_property': ('name', ), + 'delete_user_link': ('name', ), + 'delete_web_data_stream': ('name', ), + 'get_account': ('name', ), + 'get_android_app_data_stream': ('name', ), + 'get_data_sharing_settings': ('name', ), + 'get_enhanced_measurement_settings': ('name', ), + 'get_global_site_tag': ('name', ), + 'get_ios_app_data_stream': ('name', ), + 'get_property': ('name', ), + 'get_user_link': ('name', ), + 'get_web_data_stream': ('name', ), + 'list_accounts': ('page_size', 'page_token', 'show_deleted', ), + 'list_account_summaries': ('page_size', 'page_token', ), + 'list_android_app_data_streams': ('parent', 'page_size', 'page_token', ), + 'list_firebase_links': ('parent', 'page_size', 'page_token', ), + 'list_google_ads_links': ('parent', 'page_size', 'page_token', ), + 'list_ios_app_data_streams': ('parent', 'page_size', 'page_token', ), + 'list_properties': ('filter', 'page_size', 'page_token', 'show_deleted', ), + 'list_user_links': ('parent', 'page_size', 'page_token', ), + 'list_web_data_streams': ('parent', 'page_size', 'page_token', ), + 'provision_account_ticket': ('account', 'redirect_uri', ), + 'update_account': ('account', 'update_mask', ), + 'update_android_app_data_stream': ('android_app_data_stream', 'update_mask', ), + 'update_enhanced_measurement_settings': ('enhanced_measurement_settings', 'update_mask', ), + 'update_firebase_link': ('firebase_link', 'update_mask', ), + 'update_google_ads_link': ('update_mask', 'google_ads_link', ), + 'update_ios_app_data_stream': ('ios_app_data_stream', 'update_mask', ), + 'update_property': ('property', 'update_mask', ), + 'update_user_link': ('user_link', ), + 'update_web_data_stream': ('web_data_stream', 'update_mask', ), + + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), + cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=adminCallTransformer(), +): + """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 admin 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/v1alpha/setup.py b/owl-bot-staging/v1alpha/setup.py new file mode 100644 index 00000000..5882b1ac --- /dev/null +++ b/owl-bot-staging/v1alpha/setup.py @@ -0,0 +1,55 @@ +# -*- 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-analytics-admin', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.analytics'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.22.2, < 2.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__init__.py new file mode 100644 index 00000000..6a730153 --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__init__.py @@ -0,0 +1,17 @@ + +# -*- 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/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py b/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py new file mode 100644 index 00000000..511e3fb9 --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py @@ -0,0 +1,14201 @@ +# -*- 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 import auth +from google.analytics.admin_v1alpha.services.analytics_admin_service import AnalyticsAdminServiceAsyncClient +from google.analytics.admin_v1alpha.services.analytics_admin_service import AnalyticsAdminServiceClient +from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers +from google.analytics.admin_v1alpha.services.analytics_admin_service import transports +from google.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources +from google.api_core import client_options +from google.api_core import exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.auth import credentials +from google.auth.exceptions import MutualTLSChannelError +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import wrappers_pb2 as wrappers # type: ignore + + +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 AnalyticsAdminServiceClient._get_default_mtls_endpoint(None) is None + assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + AnalyticsAdminServiceClient, + AnalyticsAdminServiceAsyncClient, +]) +def test_analytics_admin_service_client_from_service_account_info(client_class): + creds = 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 == 'analyticsadmin.googleapis.com:443' + + +@pytest.mark.parametrize("client_class", [ + AnalyticsAdminServiceClient, + AnalyticsAdminServiceAsyncClient, +]) +def test_analytics_admin_service_client_from_service_account_file(client_class): + creds = 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 == 'analyticsadmin.googleapis.com:443' + + +def test_analytics_admin_service_client_get_transport_class(): + transport = AnalyticsAdminServiceClient.get_transport_class() + available_transports = [ + transports.AnalyticsAdminServiceGrpcTransport, + ] + assert transport in available_transports + + transport = AnalyticsAdminServiceClient.get_transport_class("grpc") + assert transport == transports.AnalyticsAdminServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc"), + (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(AnalyticsAdminServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AnalyticsAdminServiceClient)) +@mock.patch.object(AnalyticsAdminServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AnalyticsAdminServiceAsyncClient)) +def test_analytics_admin_service_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(AnalyticsAdminServiceClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=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(AnalyticsAdminServiceClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + + (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc", "true"), + (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc", "false"), + (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), + +]) +@mock.patch.object(AnalyticsAdminServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AnalyticsAdminServiceClient)) +@mock.patch.object(AnalyticsAdminServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AnalyticsAdminServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_analytics_admin_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc"), + (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_analytics_admin_service_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + options = client_options.ClientOptions( + scopes=["1", "2"], + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc"), + (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_analytics_admin_service_client_client_options_credentials_file(client_class, transport_class, transport_name): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_analytics_admin_service_client_client_options_from_dict(): + with mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = AnalyticsAdminServiceClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_get_account(transport: str = 'grpc', request_type=analytics_admin.GetAccountRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Account( + name='name_value', + + display_name='display_name_value', + + region_code='region_code_value', + + deleted=True, + + ) + + response = client.get_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetAccountRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.Account) + + assert response.name == 'name_value' + + assert response.display_name == 'display_name_value' + + assert response.region_code == 'region_code_value' + + assert response.deleted is True + + +def test_get_account_from_dict(): + test_get_account(request_type=dict) + + +def test_get_account_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_account), + '__call__') as call: + client.get_account() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetAccountRequest() + +@pytest.mark.asyncio +async def test_get_account_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetAccountRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account( + name='name_value', + display_name='display_name_value', + region_code='region_code_value', + deleted=True, + )) + + response = await client.get_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetAccountRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Account) + + assert response.name == 'name_value' + + assert response.display_name == 'display_name_value' + + assert response.region_code == 'region_code_value' + + assert response.deleted is True + + +@pytest.mark.asyncio +async def test_get_account_async_from_dict(): + await test_get_account_async(request_type=dict) + + +def test_get_account_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetAccountRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_account), + '__call__') as call: + call.return_value = resources.Account() + + client.get_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_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_account_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetAccountRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_account), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) + + await client.get_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_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_account_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Account() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_account( + 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_account_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_account( + analytics_admin.GetAccountRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_account_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Account() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_account( + 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_account_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_account( + analytics_admin.GetAccountRequest(), + name='name_value', + ) + + +def test_list_accounts(transport: str = 'grpc', request_type=analytics_admin.ListAccountsRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_accounts), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAccountsResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_accounts(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListAccountsRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListAccountsPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_accounts_from_dict(): + test_list_accounts(request_type=dict) + + +def test_list_accounts_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_accounts), + '__call__') as call: + client.list_accounts() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListAccountsRequest() + +@pytest.mark.asyncio +async def test_list_accounts_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListAccountsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_accounts), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAccountsResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_accounts(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListAccountsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAccountsAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_accounts_async_from_dict(): + await test_list_accounts_async(request_type=dict) + + +def test_list_accounts_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_accounts), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + resources.Account(), + ], + next_page_token='abc', + ), + analytics_admin.ListAccountsResponse( + accounts=[], + next_page_token='def', + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + ], + ), + RuntimeError, + ) + + metadata = () + pager = client.list_accounts(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.Account) + for i in results) + +def test_list_accounts_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_accounts), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + resources.Account(), + ], + next_page_token='abc', + ), + analytics_admin.ListAccountsResponse( + accounts=[], + next_page_token='def', + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + ], + ), + RuntimeError, + ) + pages = list(client.list_accounts(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_accounts_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_accounts), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + resources.Account(), + ], + next_page_token='abc', + ), + analytics_admin.ListAccountsResponse( + accounts=[], + next_page_token='def', + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_accounts(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.Account) + for i in responses) + +@pytest.mark.asyncio +async def test_list_accounts_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_accounts), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + resources.Account(), + ], + next_page_token='abc', + ), + analytics_admin.ListAccountsResponse( + accounts=[], + next_page_token='def', + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_accounts(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_account(transport: str = 'grpc', request_type=analytics_admin.DeleteAccountRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteAccountRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_account_from_dict(): + test_delete_account(request_type=dict) + + +def test_delete_account_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_account), + '__call__') as call: + client.delete_account() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteAccountRequest() + +@pytest.mark.asyncio +async def test_delete_account_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteAccountRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteAccountRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_account_async_from_dict(): + await test_delete_account_async(request_type=dict) + + +def test_delete_account_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteAccountRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_account), + '__call__') as call: + call.return_value = None + + client.delete_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_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_account_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteAccountRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_account), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_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_account_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_account( + 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_account_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_account( + analytics_admin.DeleteAccountRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_account_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_account( + 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_account_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_account( + analytics_admin.DeleteAccountRequest(), + name='name_value', + ) + + +def test_update_account(transport: str = 'grpc', request_type=analytics_admin.UpdateAccountRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Account( + name='name_value', + + display_name='display_name_value', + + region_code='region_code_value', + + deleted=True, + + ) + + response = client.update_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateAccountRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.Account) + + assert response.name == 'name_value' + + assert response.display_name == 'display_name_value' + + assert response.region_code == 'region_code_value' + + assert response.deleted is True + + +def test_update_account_from_dict(): + test_update_account(request_type=dict) + + +def test_update_account_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_account), + '__call__') as call: + client.update_account() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateAccountRequest() + +@pytest.mark.asyncio +async def test_update_account_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateAccountRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account( + name='name_value', + display_name='display_name_value', + region_code='region_code_value', + deleted=True, + )) + + response = await client.update_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateAccountRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Account) + + assert response.name == 'name_value' + + assert response.display_name == 'display_name_value' + + assert response.region_code == 'region_code_value' + + assert response.deleted is True + + +@pytest.mark.asyncio +async def test_update_account_async_from_dict(): + await test_update_account_async(request_type=dict) + + +def test_update_account_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateAccountRequest() + request.account.name = 'account.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_account), + '__call__') as call: + call.return_value = resources.Account() + + client.update_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'account.name=account.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_account_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateAccountRequest() + request.account.name = 'account.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_account), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) + + await client.update_account(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'account.name=account.name/value', + ) in kw['metadata'] + + +def test_update_account_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Account() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_account( + account=resources.Account(name='name_value'), + update_mask=field_mask.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].account == resources.Account(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +def test_update_account_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_account( + analytics_admin.UpdateAccountRequest(), + account=resources.Account(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_account_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_account), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Account() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_account( + account=resources.Account(name='name_value'), + update_mask=field_mask.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].account == resources.Account(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_account_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_account( + analytics_admin.UpdateAccountRequest(), + account=resources.Account(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +def test_provision_account_ticket(transport: str = 'grpc', request_type=analytics_admin.ProvisionAccountTicketRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_account_ticket), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ProvisionAccountTicketResponse( + account_ticket_id='account_ticket_id_value', + + ) + + response = client.provision_account_ticket(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ProvisionAccountTicketRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, analytics_admin.ProvisionAccountTicketResponse) + + assert response.account_ticket_id == 'account_ticket_id_value' + + +def test_provision_account_ticket_from_dict(): + test_provision_account_ticket(request_type=dict) + + +def test_provision_account_ticket_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_account_ticket), + '__call__') as call: + client.provision_account_ticket() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ProvisionAccountTicketRequest() + +@pytest.mark.asyncio +async def test_provision_account_ticket_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ProvisionAccountTicketRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_account_ticket), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ProvisionAccountTicketResponse( + account_ticket_id='account_ticket_id_value', + )) + + response = await client.provision_account_ticket(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ProvisionAccountTicketRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.ProvisionAccountTicketResponse) + + assert response.account_ticket_id == 'account_ticket_id_value' + + +@pytest.mark.asyncio +async def test_provision_account_ticket_async_from_dict(): + await test_provision_account_ticket_async(request_type=dict) + + +def test_list_account_summaries(transport: str = 'grpc', request_type=analytics_admin.ListAccountSummariesRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_account_summaries), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAccountSummariesResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_account_summaries(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListAccountSummariesRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListAccountSummariesPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_account_summaries_from_dict(): + test_list_account_summaries(request_type=dict) + + +def test_list_account_summaries_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_account_summaries), + '__call__') as call: + client.list_account_summaries() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListAccountSummariesRequest() + +@pytest.mark.asyncio +async def test_list_account_summaries_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListAccountSummariesRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_account_summaries), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAccountSummariesResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_account_summaries(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListAccountSummariesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAccountSummariesAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_account_summaries_async_from_dict(): + await test_list_account_summaries_async(request_type=dict) + + +def test_list_account_summaries_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_account_summaries), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token='abc', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], + next_page_token='def', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + RuntimeError, + ) + + metadata = () + pager = client.list_account_summaries(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.AccountSummary) + for i in results) + +def test_list_account_summaries_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_account_summaries), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token='abc', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], + next_page_token='def', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + RuntimeError, + ) + pages = list(client.list_account_summaries(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_account_summaries_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_account_summaries), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token='abc', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], + next_page_token='def', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_account_summaries(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.AccountSummary) + for i in responses) + +@pytest.mark.asyncio +async def test_list_account_summaries_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_account_summaries), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token='abc', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], + next_page_token='def', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_account_summaries(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_property(transport: str = 'grpc', request_type=analytics_admin.GetPropertyRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property( + name='name_value', + + parent='parent_value', + + display_name='display_name_value', + + industry_category=resources.IndustryCategory.AUTOMOTIVE, + + time_zone='time_zone_value', + + currency_code='currency_code_value', + + deleted=True, + + ) + + response = client.get_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetPropertyRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.Property) + + assert response.name == 'name_value' + + assert response.parent == 'parent_value' + + assert response.display_name == 'display_name_value' + + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + + assert response.time_zone == 'time_zone_value' + + assert response.currency_code == 'currency_code_value' + + assert response.deleted is True + + +def test_get_property_from_dict(): + test_get_property(request_type=dict) + + +def test_get_property_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_property), + '__call__') as call: + client.get_property() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetPropertyRequest() + +@pytest.mark.asyncio +async def test_get_property_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetPropertyRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property( + name='name_value', + parent='parent_value', + display_name='display_name_value', + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone='time_zone_value', + currency_code='currency_code_value', + deleted=True, + )) + + response = await client.get_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetPropertyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Property) + + assert response.name == 'name_value' + + assert response.parent == 'parent_value' + + assert response.display_name == 'display_name_value' + + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + + assert response.time_zone == 'time_zone_value' + + assert response.currency_code == 'currency_code_value' + + assert response.deleted is True + + +@pytest.mark.asyncio +async def test_get_property_async_from_dict(): + await test_get_property_async(request_type=dict) + + +def test_get_property_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetPropertyRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_property), + '__call__') as call: + call.return_value = resources.Property() + + client.get_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_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_property_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetPropertyRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_property), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) + + await client.get_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_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_property_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_property( + 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_property_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_property( + analytics_admin.GetPropertyRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_property_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_property( + 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_property_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_property( + analytics_admin.GetPropertyRequest(), + name='name_value', + ) + + +def test_list_properties(transport: str = 'grpc', request_type=analytics_admin.ListPropertiesRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_properties), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListPropertiesResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_properties(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListPropertiesRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListPropertiesPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_properties_from_dict(): + test_list_properties(request_type=dict) + + +def test_list_properties_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_properties), + '__call__') as call: + client.list_properties() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListPropertiesRequest() + +@pytest.mark.asyncio +async def test_list_properties_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListPropertiesRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_properties), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListPropertiesResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_properties(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListPropertiesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPropertiesAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_properties_async_from_dict(): + await test_list_properties_async(request_type=dict) + + +def test_list_properties_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_properties), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + resources.Property(), + ], + next_page_token='abc', + ), + analytics_admin.ListPropertiesResponse( + properties=[], + next_page_token='def', + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + ], + next_page_token='ghi', + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + ], + ), + RuntimeError, + ) + + metadata = () + pager = client.list_properties(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.Property) + for i in results) + +def test_list_properties_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_properties), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + resources.Property(), + ], + next_page_token='abc', + ), + analytics_admin.ListPropertiesResponse( + properties=[], + next_page_token='def', + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + ], + next_page_token='ghi', + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + ], + ), + RuntimeError, + ) + pages = list(client.list_properties(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_properties_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_properties), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + resources.Property(), + ], + next_page_token='abc', + ), + analytics_admin.ListPropertiesResponse( + properties=[], + next_page_token='def', + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + ], + next_page_token='ghi', + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_properties(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.Property) + for i in responses) + +@pytest.mark.asyncio +async def test_list_properties_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_properties), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + resources.Property(), + ], + next_page_token='abc', + ), + analytics_admin.ListPropertiesResponse( + properties=[], + next_page_token='def', + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + ], + next_page_token='ghi', + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_properties(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_property(transport: str = 'grpc', request_type=analytics_admin.CreatePropertyRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property( + name='name_value', + + parent='parent_value', + + display_name='display_name_value', + + industry_category=resources.IndustryCategory.AUTOMOTIVE, + + time_zone='time_zone_value', + + currency_code='currency_code_value', + + deleted=True, + + ) + + response = client.create_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreatePropertyRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.Property) + + assert response.name == 'name_value' + + assert response.parent == 'parent_value' + + assert response.display_name == 'display_name_value' + + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + + assert response.time_zone == 'time_zone_value' + + assert response.currency_code == 'currency_code_value' + + assert response.deleted is True + + +def test_create_property_from_dict(): + test_create_property(request_type=dict) + + +def test_create_property_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_property), + '__call__') as call: + client.create_property() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreatePropertyRequest() + +@pytest.mark.asyncio +async def test_create_property_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreatePropertyRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property( + name='name_value', + parent='parent_value', + display_name='display_name_value', + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone='time_zone_value', + currency_code='currency_code_value', + deleted=True, + )) + + response = await client.create_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreatePropertyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Property) + + assert response.name == 'name_value' + + assert response.parent == 'parent_value' + + assert response.display_name == 'display_name_value' + + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + + assert response.time_zone == 'time_zone_value' + + assert response.currency_code == 'currency_code_value' + + assert response.deleted is True + + +@pytest.mark.asyncio +async def test_create_property_async_from_dict(): + await test_create_property_async(request_type=dict) + + +def test_create_property_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_property( + property=resources.Property(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].property == resources.Property(name='name_value') + + +def test_create_property_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_property( + analytics_admin.CreatePropertyRequest(), + property=resources.Property(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_property_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_property( + property=resources.Property(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].property == resources.Property(name='name_value') + + +@pytest.mark.asyncio +async def test_create_property_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_property( + analytics_admin.CreatePropertyRequest(), + property=resources.Property(name='name_value'), + ) + + +def test_delete_property(transport: str = 'grpc', request_type=analytics_admin.DeletePropertyRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeletePropertyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_property_from_dict(): + test_delete_property(request_type=dict) + + +def test_delete_property_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_property), + '__call__') as call: + client.delete_property() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeletePropertyRequest() + +@pytest.mark.asyncio +async def test_delete_property_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeletePropertyRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeletePropertyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_property_async_from_dict(): + await test_delete_property_async(request_type=dict) + + +def test_delete_property_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeletePropertyRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_property), + '__call__') as call: + call.return_value = None + + client.delete_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_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_property_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeletePropertyRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_property), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_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_property_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_property( + 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_property_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_property( + analytics_admin.DeletePropertyRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_property_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_property( + 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_property_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_property( + analytics_admin.DeletePropertyRequest(), + name='name_value', + ) + + +def test_update_property(transport: str = 'grpc', request_type=analytics_admin.UpdatePropertyRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property( + name='name_value', + + parent='parent_value', + + display_name='display_name_value', + + industry_category=resources.IndustryCategory.AUTOMOTIVE, + + time_zone='time_zone_value', + + currency_code='currency_code_value', + + deleted=True, + + ) + + response = client.update_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdatePropertyRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.Property) + + assert response.name == 'name_value' + + assert response.parent == 'parent_value' + + assert response.display_name == 'display_name_value' + + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + + assert response.time_zone == 'time_zone_value' + + assert response.currency_code == 'currency_code_value' + + assert response.deleted is True + + +def test_update_property_from_dict(): + test_update_property(request_type=dict) + + +def test_update_property_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_property), + '__call__') as call: + client.update_property() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdatePropertyRequest() + +@pytest.mark.asyncio +async def test_update_property_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdatePropertyRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property( + name='name_value', + parent='parent_value', + display_name='display_name_value', + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone='time_zone_value', + currency_code='currency_code_value', + deleted=True, + )) + + response = await client.update_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdatePropertyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Property) + + assert response.name == 'name_value' + + assert response.parent == 'parent_value' + + assert response.display_name == 'display_name_value' + + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + + assert response.time_zone == 'time_zone_value' + + assert response.currency_code == 'currency_code_value' + + assert response.deleted is True + + +@pytest.mark.asyncio +async def test_update_property_async_from_dict(): + await test_update_property_async(request_type=dict) + + +def test_update_property_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdatePropertyRequest() + request.property.name = 'property.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_property), + '__call__') as call: + call.return_value = resources.Property() + + client.update_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'property.name=property.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_property_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdatePropertyRequest() + request.property.name = 'property.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_property), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) + + await client.update_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'property.name=property.name/value', + ) in kw['metadata'] + + +def test_update_property_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_property( + property=resources.Property(name='name_value'), + update_mask=field_mask.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].property == resources.Property(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +def test_update_property_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_property( + analytics_admin.UpdatePropertyRequest(), + property=resources.Property(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_property_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_property), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_property( + property=resources.Property(name='name_value'), + update_mask=field_mask.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].property == resources.Property(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_property_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_property( + analytics_admin.UpdatePropertyRequest(), + property=resources.Property(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +def test_get_user_link(transport: str = 'grpc', request_type=analytics_admin.GetUserLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink( + name='name_value', + + email_address='email_address_value', + + direct_roles=['direct_roles_value'], + + ) + + response = client.get_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetUserLinkRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.UserLink) + + assert response.name == 'name_value' + + assert response.email_address == 'email_address_value' + + assert response.direct_roles == ['direct_roles_value'] + + +def test_get_user_link_from_dict(): + test_get_user_link(request_type=dict) + + +def test_get_user_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_user_link), + '__call__') as call: + client.get_user_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetUserLinkRequest() + +@pytest.mark.asyncio +async def test_get_user_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetUserLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink( + name='name_value', + email_address='email_address_value', + direct_roles=['direct_roles_value'], + )) + + response = await client.get_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetUserLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.UserLink) + + assert response.name == 'name_value' + + assert response.email_address == 'email_address_value' + + assert response.direct_roles == ['direct_roles_value'] + + +@pytest.mark.asyncio +async def test_get_user_link_async_from_dict(): + await test_get_user_link_async(request_type=dict) + + +def test_get_user_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetUserLinkRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_user_link), + '__call__') as call: + call.return_value = resources.UserLink() + + client.get_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_user_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetUserLinkRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_user_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) + + await client.get_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_get_user_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_user_link( + 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_user_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_user_link( + analytics_admin.GetUserLinkRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_user_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_user_link( + 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_user_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_user_link( + analytics_admin.GetUserLinkRequest(), + name='name_value', + ) + + +def test_batch_get_user_links(transport: str = 'grpc', request_type=analytics_admin.BatchGetUserLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.BatchGetUserLinksResponse( + ) + + response = client.batch_get_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchGetUserLinksRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) + + +def test_batch_get_user_links_from_dict(): + test_batch_get_user_links(request_type=dict) + + +def test_batch_get_user_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_user_links), + '__call__') as call: + client.batch_get_user_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchGetUserLinksRequest() + +@pytest.mark.asyncio +async def test_batch_get_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.BatchGetUserLinksRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchGetUserLinksResponse( + )) + + response = await client.batch_get_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchGetUserLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) + + +@pytest.mark.asyncio +async def test_batch_get_user_links_async_from_dict(): + await test_batch_get_user_links_async(request_type=dict) + + +def test_batch_get_user_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.BatchGetUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_user_links), + '__call__') as call: + call.return_value = analytics_admin.BatchGetUserLinksResponse() + + client.batch_get_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_batch_get_user_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.BatchGetUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_user_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchGetUserLinksResponse()) + + await client.batch_get_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_list_user_links(transport: str = 'grpc', request_type=analytics_admin.ListUserLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListUserLinksResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListUserLinksRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListUserLinksPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_user_links_from_dict(): + test_list_user_links(request_type=dict) + + +def test_list_user_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__') as call: + client.list_user_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListUserLinksRequest() + +@pytest.mark.asyncio +async def test_list_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListUserLinksRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListUserLinksResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListUserLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListUserLinksAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_user_links_async_from_dict(): + await test_list_user_links_async(request_type=dict) + + +def test_list_user_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__') as call: + call.return_value = analytics_admin.ListUserLinksResponse() + + client.list_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_user_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListUserLinksResponse()) + + await client.list_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_list_user_links_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListUserLinksResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_user_links( + 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_user_links_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_user_links( + analytics_admin.ListUserLinksRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_user_links_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListUserLinksResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListUserLinksResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_user_links( + 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_user_links_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_user_links( + analytics_admin.ListUserLinksRequest(), + parent='parent_value', + ) + + +def test_list_user_links_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + resources.UserLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListUserLinksResponse( + user_links=[], + next_page_token='def', + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_user_links(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.UserLink) + for i in results) + +def test_list_user_links_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + resources.UserLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListUserLinksResponse( + user_links=[], + next_page_token='def', + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + ], + ), + RuntimeError, + ) + pages = list(client.list_user_links(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_user_links_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + resources.UserLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListUserLinksResponse( + user_links=[], + next_page_token='def', + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_user_links(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.UserLink) + for i in responses) + +@pytest.mark.asyncio +async def test_list_user_links_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_user_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + resources.UserLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListUserLinksResponse( + user_links=[], + next_page_token='def', + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_user_links(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_audit_user_links(transport: str = 'grpc', request_type=analytics_admin.AuditUserLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.AuditUserLinksResponse( + next_page_token='next_page_token_value', + + ) + + response = client.audit_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.AuditUserLinksRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.AuditUserLinksPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_audit_user_links_from_dict(): + test_audit_user_links(request_type=dict) + + +def test_audit_user_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__') as call: + client.audit_user_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.AuditUserLinksRequest() + +@pytest.mark.asyncio +async def test_audit_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.AuditUserLinksRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.AuditUserLinksResponse( + next_page_token='next_page_token_value', + )) + + response = await client.audit_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.AuditUserLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.AuditUserLinksAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_audit_user_links_async_from_dict(): + await test_audit_user_links_async(request_type=dict) + + +def test_audit_user_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.AuditUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__') as call: + call.return_value = analytics_admin.AuditUserLinksResponse() + + client.audit_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_audit_user_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.AuditUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.AuditUserLinksResponse()) + + await client.audit_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_audit_user_links_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + next_page_token='abc', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[], + next_page_token='def', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + ], + next_page_token='ghi', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.audit_user_links(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.AuditUserLink) + for i in results) + +def test_audit_user_links_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + next_page_token='abc', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[], + next_page_token='def', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + ], + next_page_token='ghi', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + ), + RuntimeError, + ) + pages = list(client.audit_user_links(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_audit_user_links_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + next_page_token='abc', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[], + next_page_token='def', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + ], + next_page_token='ghi', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + ), + RuntimeError, + ) + async_pager = await client.audit_user_links(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.AuditUserLink) + for i in responses) + +@pytest.mark.asyncio +async def test_audit_user_links_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.audit_user_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + next_page_token='abc', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[], + next_page_token='def', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + ], + next_page_token='ghi', + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.audit_user_links(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_create_user_link(transport: str = 'grpc', request_type=analytics_admin.CreateUserLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink( + name='name_value', + + email_address='email_address_value', + + direct_roles=['direct_roles_value'], + + ) + + response = client.create_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateUserLinkRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.UserLink) + + assert response.name == 'name_value' + + assert response.email_address == 'email_address_value' + + assert response.direct_roles == ['direct_roles_value'] + + +def test_create_user_link_from_dict(): + test_create_user_link(request_type=dict) + + +def test_create_user_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_user_link), + '__call__') as call: + client.create_user_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateUserLinkRequest() + +@pytest.mark.asyncio +async def test_create_user_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateUserLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink( + name='name_value', + email_address='email_address_value', + direct_roles=['direct_roles_value'], + )) + + response = await client.create_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateUserLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.UserLink) + + assert response.name == 'name_value' + + assert response.email_address == 'email_address_value' + + assert response.direct_roles == ['direct_roles_value'] + + +@pytest.mark.asyncio +async def test_create_user_link_async_from_dict(): + await test_create_user_link_async(request_type=dict) + + +def test_create_user_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateUserLinkRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_user_link), + '__call__') as call: + call.return_value = resources.UserLink() + + client.create_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_user_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateUserLinkRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_user_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) + + await client.create_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_create_user_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_user_link( + parent='parent_value', + user_link=resources.UserLink(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].parent == 'parent_value' + + assert args[0].user_link == resources.UserLink(name='name_value') + + +def test_create_user_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_user_link( + analytics_admin.CreateUserLinkRequest(), + parent='parent_value', + user_link=resources.UserLink(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_user_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_user_link( + parent='parent_value', + user_link=resources.UserLink(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].parent == 'parent_value' + + assert args[0].user_link == resources.UserLink(name='name_value') + + +@pytest.mark.asyncio +async def test_create_user_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_user_link( + analytics_admin.CreateUserLinkRequest(), + parent='parent_value', + user_link=resources.UserLink(name='name_value'), + ) + + +def test_batch_create_user_links(transport: str = 'grpc', request_type=analytics_admin.BatchCreateUserLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.BatchCreateUserLinksResponse( + ) + + response = client.batch_create_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchCreateUserLinksRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) + + +def test_batch_create_user_links_from_dict(): + test_batch_create_user_links(request_type=dict) + + +def test_batch_create_user_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_user_links), + '__call__') as call: + client.batch_create_user_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchCreateUserLinksRequest() + +@pytest.mark.asyncio +async def test_batch_create_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.BatchCreateUserLinksRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchCreateUserLinksResponse( + )) + + response = await client.batch_create_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchCreateUserLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) + + +@pytest.mark.asyncio +async def test_batch_create_user_links_async_from_dict(): + await test_batch_create_user_links_async(request_type=dict) + + +def test_batch_create_user_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.BatchCreateUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_user_links), + '__call__') as call: + call.return_value = analytics_admin.BatchCreateUserLinksResponse() + + client.batch_create_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_batch_create_user_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.BatchCreateUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_user_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchCreateUserLinksResponse()) + + await client.batch_create_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_update_user_link(transport: str = 'grpc', request_type=analytics_admin.UpdateUserLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink( + name='name_value', + + email_address='email_address_value', + + direct_roles=['direct_roles_value'], + + ) + + response = client.update_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateUserLinkRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.UserLink) + + assert response.name == 'name_value' + + assert response.email_address == 'email_address_value' + + assert response.direct_roles == ['direct_roles_value'] + + +def test_update_user_link_from_dict(): + test_update_user_link(request_type=dict) + + +def test_update_user_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_user_link), + '__call__') as call: + client.update_user_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateUserLinkRequest() + +@pytest.mark.asyncio +async def test_update_user_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateUserLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink( + name='name_value', + email_address='email_address_value', + direct_roles=['direct_roles_value'], + )) + + response = await client.update_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateUserLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.UserLink) + + assert response.name == 'name_value' + + assert response.email_address == 'email_address_value' + + assert response.direct_roles == ['direct_roles_value'] + + +@pytest.mark.asyncio +async def test_update_user_link_async_from_dict(): + await test_update_user_link_async(request_type=dict) + + +def test_update_user_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateUserLinkRequest() + request.user_link.name = 'user_link.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_user_link), + '__call__') as call: + call.return_value = resources.UserLink() + + client.update_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'user_link.name=user_link.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_user_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateUserLinkRequest() + request.user_link.name = 'user_link.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_user_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) + + await client.update_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'user_link.name=user_link.name/value', + ) in kw['metadata'] + + +def test_update_user_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_user_link( + user_link=resources.UserLink(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].user_link == resources.UserLink(name='name_value') + + +def test_update_user_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_user_link( + analytics_admin.UpdateUserLinkRequest(), + user_link=resources.UserLink(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_update_user_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.UserLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_user_link( + user_link=resources.UserLink(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].user_link == resources.UserLink(name='name_value') + + +@pytest.mark.asyncio +async def test_update_user_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_user_link( + analytics_admin.UpdateUserLinkRequest(), + user_link=resources.UserLink(name='name_value'), + ) + + +def test_batch_update_user_links(transport: str = 'grpc', request_type=analytics_admin.BatchUpdateUserLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.BatchUpdateUserLinksResponse( + ) + + response = client.batch_update_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) + + +def test_batch_update_user_links_from_dict(): + test_batch_update_user_links(request_type=dict) + + +def test_batch_update_user_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_user_links), + '__call__') as call: + client.batch_update_user_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() + +@pytest.mark.asyncio +async def test_batch_update_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.BatchUpdateUserLinksRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchUpdateUserLinksResponse( + )) + + response = await client.batch_update_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) + + +@pytest.mark.asyncio +async def test_batch_update_user_links_async_from_dict(): + await test_batch_update_user_links_async(request_type=dict) + + +def test_batch_update_user_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.BatchUpdateUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_user_links), + '__call__') as call: + call.return_value = analytics_admin.BatchUpdateUserLinksResponse() + + client.batch_update_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_batch_update_user_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.BatchUpdateUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_user_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchUpdateUserLinksResponse()) + + await client.batch_update_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_delete_user_link(transport: str = 'grpc', request_type=analytics_admin.DeleteUserLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteUserLinkRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_user_link_from_dict(): + test_delete_user_link(request_type=dict) + + +def test_delete_user_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_user_link), + '__call__') as call: + client.delete_user_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteUserLinkRequest() + +@pytest.mark.asyncio +async def test_delete_user_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteUserLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteUserLinkRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_user_link_async_from_dict(): + await test_delete_user_link_async(request_type=dict) + + +def test_delete_user_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteUserLinkRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_user_link), + '__call__') as call: + call.return_value = None + + client.delete_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_user_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteUserLinkRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_user_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_user_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_delete_user_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_user_link( + 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_user_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_user_link( + analytics_admin.DeleteUserLinkRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_user_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_user_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_user_link( + 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_user_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_user_link( + analytics_admin.DeleteUserLinkRequest(), + name='name_value', + ) + + +def test_batch_delete_user_links(transport: str = 'grpc', request_type=analytics_admin.BatchDeleteUserLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.batch_delete_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_batch_delete_user_links_from_dict(): + test_batch_delete_user_links(request_type=dict) + + +def test_batch_delete_user_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_user_links), + '__call__') as call: + client.batch_delete_user_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() + +@pytest.mark.asyncio +async def test_batch_delete_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.BatchDeleteUserLinksRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_user_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.batch_delete_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_batch_delete_user_links_async_from_dict(): + await test_batch_delete_user_links_async(request_type=dict) + + +def test_batch_delete_user_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.BatchDeleteUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_user_links), + '__call__') as call: + call.return_value = None + + client.batch_delete_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_batch_delete_user_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.BatchDeleteUserLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_user_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.batch_delete_user_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_get_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.GetWebDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream( + name='name_value', + + measurement_id='measurement_id_value', + + firebase_app_id='firebase_app_id_value', + + default_uri='default_uri_value', + + display_name='display_name_value', + + ) + + response = client.get_web_data_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] == analytics_admin.GetWebDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.WebDataStream) + + assert response.name == 'name_value' + + assert response.measurement_id == 'measurement_id_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.default_uri == 'default_uri_value' + + assert response.display_name == 'display_name_value' + + +def test_get_web_data_stream_from_dict(): + test_get_web_data_stream(request_type=dict) + + +def test_get_web_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_web_data_stream), + '__call__') as call: + client.get_web_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetWebDataStreamRequest() + +@pytest.mark.asyncio +async def test_get_web_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetWebDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream( + name='name_value', + measurement_id='measurement_id_value', + firebase_app_id='firebase_app_id_value', + default_uri='default_uri_value', + display_name='display_name_value', + )) + + response = await client.get_web_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetWebDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.WebDataStream) + + assert response.name == 'name_value' + + assert response.measurement_id == 'measurement_id_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.default_uri == 'default_uri_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_get_web_data_stream_async_from_dict(): + await test_get_web_data_stream_async(request_type=dict) + + +def test_get_web_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetWebDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_web_data_stream), + '__call__') as call: + call.return_value = resources.WebDataStream() + + client.get_web_data_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_web_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetWebDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_web_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) + + await client.get_web_data_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_web_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_web_data_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_web_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_web_data_stream( + analytics_admin.GetWebDataStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_web_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_web_data_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_web_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_web_data_stream( + analytics_admin.GetWebDataStreamRequest(), + name='name_value', + ) + + +def test_delete_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.DeleteWebDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_web_data_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] == analytics_admin.DeleteWebDataStreamRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_web_data_stream_from_dict(): + test_delete_web_data_stream(request_type=dict) + + +def test_delete_web_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_web_data_stream), + '__call__') as call: + client.delete_web_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteWebDataStreamRequest() + +@pytest.mark.asyncio +async def test_delete_web_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteWebDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_web_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteWebDataStreamRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_web_data_stream_async_from_dict(): + await test_delete_web_data_stream_async(request_type=dict) + + +def test_delete_web_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteWebDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_web_data_stream), + '__call__') as call: + call.return_value = None + + client.delete_web_data_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_web_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteWebDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_web_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_web_data_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_web_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_web_data_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_web_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_web_data_stream( + analytics_admin.DeleteWebDataStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_web_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_web_data_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_web_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_web_data_stream( + analytics_admin.DeleteWebDataStreamRequest(), + name='name_value', + ) + + +def test_update_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.UpdateWebDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream( + name='name_value', + + measurement_id='measurement_id_value', + + firebase_app_id='firebase_app_id_value', + + default_uri='default_uri_value', + + display_name='display_name_value', + + ) + + response = client.update_web_data_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] == analytics_admin.UpdateWebDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.WebDataStream) + + assert response.name == 'name_value' + + assert response.measurement_id == 'measurement_id_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.default_uri == 'default_uri_value' + + assert response.display_name == 'display_name_value' + + +def test_update_web_data_stream_from_dict(): + test_update_web_data_stream(request_type=dict) + + +def test_update_web_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_web_data_stream), + '__call__') as call: + client.update_web_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateWebDataStreamRequest() + +@pytest.mark.asyncio +async def test_update_web_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateWebDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream( + name='name_value', + measurement_id='measurement_id_value', + firebase_app_id='firebase_app_id_value', + default_uri='default_uri_value', + display_name='display_name_value', + )) + + response = await client.update_web_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateWebDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.WebDataStream) + + assert response.name == 'name_value' + + assert response.measurement_id == 'measurement_id_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.default_uri == 'default_uri_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_update_web_data_stream_async_from_dict(): + await test_update_web_data_stream_async(request_type=dict) + + +def test_update_web_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateWebDataStreamRequest() + request.web_data_stream.name = 'web_data_stream.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_web_data_stream), + '__call__') as call: + call.return_value = resources.WebDataStream() + + client.update_web_data_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', + 'web_data_stream.name=web_data_stream.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_web_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateWebDataStreamRequest() + request.web_data_stream.name = 'web_data_stream.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_web_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) + + await client.update_web_data_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', + 'web_data_stream.name=web_data_stream.name/value', + ) in kw['metadata'] + + +def test_update_web_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_web_data_stream( + web_data_stream=resources.WebDataStream(name='name_value'), + update_mask=field_mask.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].web_data_stream == resources.WebDataStream(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +def test_update_web_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_web_data_stream( + analytics_admin.UpdateWebDataStreamRequest(), + web_data_stream=resources.WebDataStream(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_web_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_web_data_stream( + web_data_stream=resources.WebDataStream(name='name_value'), + update_mask=field_mask.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].web_data_stream == resources.WebDataStream(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_web_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_web_data_stream( + analytics_admin.UpdateWebDataStreamRequest(), + web_data_stream=resources.WebDataStream(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +def test_create_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.CreateWebDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream( + name='name_value', + + measurement_id='measurement_id_value', + + firebase_app_id='firebase_app_id_value', + + default_uri='default_uri_value', + + display_name='display_name_value', + + ) + + response = client.create_web_data_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] == analytics_admin.CreateWebDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.WebDataStream) + + assert response.name == 'name_value' + + assert response.measurement_id == 'measurement_id_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.default_uri == 'default_uri_value' + + assert response.display_name == 'display_name_value' + + +def test_create_web_data_stream_from_dict(): + test_create_web_data_stream(request_type=dict) + + +def test_create_web_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_web_data_stream), + '__call__') as call: + client.create_web_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateWebDataStreamRequest() + +@pytest.mark.asyncio +async def test_create_web_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateWebDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream( + name='name_value', + measurement_id='measurement_id_value', + firebase_app_id='firebase_app_id_value', + default_uri='default_uri_value', + display_name='display_name_value', + )) + + response = await client.create_web_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateWebDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.WebDataStream) + + assert response.name == 'name_value' + + assert response.measurement_id == 'measurement_id_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.default_uri == 'default_uri_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_create_web_data_stream_async_from_dict(): + await test_create_web_data_stream_async(request_type=dict) + + +def test_create_web_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateWebDataStreamRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_web_data_stream), + '__call__') as call: + call.return_value = resources.WebDataStream() + + client.create_web_data_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_web_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateWebDataStreamRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_web_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) + + await client.create_web_data_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_web_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_web_data_stream( + parent='parent_value', + web_data_stream=resources.WebDataStream(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].parent == 'parent_value' + + assert args[0].web_data_stream == resources.WebDataStream(name='name_value') + + +def test_create_web_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_web_data_stream( + analytics_admin.CreateWebDataStreamRequest(), + parent='parent_value', + web_data_stream=resources.WebDataStream(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_web_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_web_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.WebDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_web_data_stream( + parent='parent_value', + web_data_stream=resources.WebDataStream(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].parent == 'parent_value' + + assert args[0].web_data_stream == resources.WebDataStream(name='name_value') + + +@pytest.mark.asyncio +async def test_create_web_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_web_data_stream( + analytics_admin.CreateWebDataStreamRequest(), + parent='parent_value', + web_data_stream=resources.WebDataStream(name='name_value'), + ) + + +def test_list_web_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListWebDataStreamsRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListWebDataStreamsResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_web_data_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] == analytics_admin.ListWebDataStreamsRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListWebDataStreamsPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_web_data_streams_from_dict(): + test_list_web_data_streams(request_type=dict) + + +def test_list_web_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__') as call: + client.list_web_data_streams() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListWebDataStreamsRequest() + +@pytest.mark.asyncio +async def test_list_web_data_streams_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListWebDataStreamsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_web_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListWebDataStreamsResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_web_data_streams(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListWebDataStreamsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListWebDataStreamsAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_web_data_streams_async_from_dict(): + await test_list_web_data_streams_async(request_type=dict) + + +def test_list_web_data_streams_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListWebDataStreamsRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__') as call: + call.return_value = analytics_admin.ListWebDataStreamsResponse() + + client.list_web_data_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_web_data_streams_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListWebDataStreamsRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListWebDataStreamsResponse()) + + await client.list_web_data_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_web_data_streams_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListWebDataStreamsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_web_data_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_web_data_streams_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_web_data_streams( + analytics_admin.ListWebDataStreamsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_web_data_streams_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListWebDataStreamsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListWebDataStreamsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_web_data_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_web_data_streams_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_web_data_streams( + analytics_admin.ListWebDataStreamsRequest(), + parent='parent_value', + ) + + +def test_list_web_data_streams_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + resources.WebDataStream(), + resources.WebDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + resources.WebDataStream(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_web_data_streams(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.WebDataStream) + for i in results) + +def test_list_web_data_streams_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + resources.WebDataStream(), + resources.WebDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + resources.WebDataStream(), + ], + ), + RuntimeError, + ) + pages = list(client.list_web_data_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_web_data_streams_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + resources.WebDataStream(), + resources.WebDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + resources.WebDataStream(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_web_data_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, resources.WebDataStream) + for i in responses) + +@pytest.mark.asyncio +async def test_list_web_data_streams_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_web_data_streams), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + resources.WebDataStream(), + resources.WebDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListWebDataStreamsResponse( + web_data_streams=[ + resources.WebDataStream(), + resources.WebDataStream(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_web_data_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_ios_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.GetIosAppDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream( + name='name_value', + + firebase_app_id='firebase_app_id_value', + + bundle_id='bundle_id_value', + + display_name='display_name_value', + + ) + + response = client.get_ios_app_data_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] == analytics_admin.GetIosAppDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.IosAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.bundle_id == 'bundle_id_value' + + assert response.display_name == 'display_name_value' + + +def test_get_ios_app_data_stream_from_dict(): + test_get_ios_app_data_stream(request_type=dict) + + +def test_get_ios_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ios_app_data_stream), + '__call__') as call: + client.get_ios_app_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetIosAppDataStreamRequest() + +@pytest.mark.asyncio +async def test_get_ios_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetIosAppDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream( + name='name_value', + firebase_app_id='firebase_app_id_value', + bundle_id='bundle_id_value', + display_name='display_name_value', + )) + + response = await client.get_ios_app_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetIosAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IosAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.bundle_id == 'bundle_id_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_get_ios_app_data_stream_async_from_dict(): + await test_get_ios_app_data_stream_async(request_type=dict) + + +def test_get_ios_app_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetIosAppDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ios_app_data_stream), + '__call__') as call: + call.return_value = resources.IosAppDataStream() + + client.get_ios_app_data_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_ios_app_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetIosAppDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ios_app_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) + + await client.get_ios_app_data_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_ios_app_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_ios_app_data_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_ios_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_ios_app_data_stream( + analytics_admin.GetIosAppDataStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_ios_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_ios_app_data_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_ios_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_ios_app_data_stream( + analytics_admin.GetIosAppDataStreamRequest(), + name='name_value', + ) + + +def test_delete_ios_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.DeleteIosAppDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_ios_app_data_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] == analytics_admin.DeleteIosAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_ios_app_data_stream_from_dict(): + test_delete_ios_app_data_stream(request_type=dict) + + +def test_delete_ios_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ios_app_data_stream), + '__call__') as call: + client.delete_ios_app_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteIosAppDataStreamRequest() + +@pytest.mark.asyncio +async def test_delete_ios_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteIosAppDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_ios_app_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteIosAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_ios_app_data_stream_async_from_dict(): + await test_delete_ios_app_data_stream_async(request_type=dict) + + +def test_delete_ios_app_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteIosAppDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ios_app_data_stream), + '__call__') as call: + call.return_value = None + + client.delete_ios_app_data_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_ios_app_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteIosAppDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ios_app_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_ios_app_data_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_ios_app_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_ios_app_data_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_ios_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_ios_app_data_stream( + analytics_admin.DeleteIosAppDataStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_ios_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_ios_app_data_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_ios_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_ios_app_data_stream( + analytics_admin.DeleteIosAppDataStreamRequest(), + name='name_value', + ) + + +def test_update_ios_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.UpdateIosAppDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream( + name='name_value', + + firebase_app_id='firebase_app_id_value', + + bundle_id='bundle_id_value', + + display_name='display_name_value', + + ) + + response = client.update_ios_app_data_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] == analytics_admin.UpdateIosAppDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.IosAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.bundle_id == 'bundle_id_value' + + assert response.display_name == 'display_name_value' + + +def test_update_ios_app_data_stream_from_dict(): + test_update_ios_app_data_stream(request_type=dict) + + +def test_update_ios_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ios_app_data_stream), + '__call__') as call: + client.update_ios_app_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateIosAppDataStreamRequest() + +@pytest.mark.asyncio +async def test_update_ios_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateIosAppDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream( + name='name_value', + firebase_app_id='firebase_app_id_value', + bundle_id='bundle_id_value', + display_name='display_name_value', + )) + + response = await client.update_ios_app_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateIosAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IosAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.bundle_id == 'bundle_id_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_update_ios_app_data_stream_async_from_dict(): + await test_update_ios_app_data_stream_async(request_type=dict) + + +def test_update_ios_app_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateIosAppDataStreamRequest() + request.ios_app_data_stream.name = 'ios_app_data_stream.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ios_app_data_stream), + '__call__') as call: + call.return_value = resources.IosAppDataStream() + + client.update_ios_app_data_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', + 'ios_app_data_stream.name=ios_app_data_stream.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_ios_app_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateIosAppDataStreamRequest() + request.ios_app_data_stream.name = 'ios_app_data_stream.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ios_app_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) + + await client.update_ios_app_data_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', + 'ios_app_data_stream.name=ios_app_data_stream.name/value', + ) in kw['metadata'] + + +def test_update_ios_app_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_ios_app_data_stream( + ios_app_data_stream=resources.IosAppDataStream(name='name_value'), + update_mask=field_mask.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].ios_app_data_stream == resources.IosAppDataStream(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +def test_update_ios_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_ios_app_data_stream( + analytics_admin.UpdateIosAppDataStreamRequest(), + ios_app_data_stream=resources.IosAppDataStream(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_ios_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_ios_app_data_stream( + ios_app_data_stream=resources.IosAppDataStream(name='name_value'), + update_mask=field_mask.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].ios_app_data_stream == resources.IosAppDataStream(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_ios_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_ios_app_data_stream( + analytics_admin.UpdateIosAppDataStreamRequest(), + ios_app_data_stream=resources.IosAppDataStream(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +def test_create_ios_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.CreateIosAppDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream( + name='name_value', + + firebase_app_id='firebase_app_id_value', + + bundle_id='bundle_id_value', + + display_name='display_name_value', + + ) + + response = client.create_ios_app_data_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] == analytics_admin.CreateIosAppDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.IosAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.bundle_id == 'bundle_id_value' + + assert response.display_name == 'display_name_value' + + +def test_create_ios_app_data_stream_from_dict(): + test_create_ios_app_data_stream(request_type=dict) + + +def test_create_ios_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ios_app_data_stream), + '__call__') as call: + client.create_ios_app_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() + +@pytest.mark.asyncio +async def test_create_ios_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateIosAppDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream( + name='name_value', + firebase_app_id='firebase_app_id_value', + bundle_id='bundle_id_value', + display_name='display_name_value', + )) + + response = await client.create_ios_app_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IosAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.bundle_id == 'bundle_id_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_create_ios_app_data_stream_async_from_dict(): + await test_create_ios_app_data_stream_async(request_type=dict) + + +def test_create_ios_app_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateIosAppDataStreamRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ios_app_data_stream), + '__call__') as call: + call.return_value = resources.IosAppDataStream() + + client.create_ios_app_data_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_ios_app_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateIosAppDataStreamRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ios_app_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) + + await client.create_ios_app_data_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_ios_app_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_ios_app_data_stream( + parent='parent_value', + ios_app_data_stream=resources.IosAppDataStream(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].parent == 'parent_value' + + assert args[0].ios_app_data_stream == resources.IosAppDataStream(name='name_value') + + +def test_create_ios_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_ios_app_data_stream( + analytics_admin.CreateIosAppDataStreamRequest(), + parent='parent_value', + ios_app_data_stream=resources.IosAppDataStream(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_ios_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ios_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IosAppDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_ios_app_data_stream( + parent='parent_value', + ios_app_data_stream=resources.IosAppDataStream(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].parent == 'parent_value' + + assert args[0].ios_app_data_stream == resources.IosAppDataStream(name='name_value') + + +@pytest.mark.asyncio +async def test_create_ios_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_ios_app_data_stream( + analytics_admin.CreateIosAppDataStreamRequest(), + parent='parent_value', + ios_app_data_stream=resources.IosAppDataStream(name='name_value'), + ) + + +def test_list_ios_app_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListIosAppDataStreamsRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListIosAppDataStreamsResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_ios_app_data_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] == analytics_admin.ListIosAppDataStreamsRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListIosAppDataStreamsPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_ios_app_data_streams_from_dict(): + test_list_ios_app_data_streams(request_type=dict) + + +def test_list_ios_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__') as call: + client.list_ios_app_data_streams() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() + +@pytest.mark.asyncio +async def test_list_ios_app_data_streams_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListIosAppDataStreamsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_ios_app_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListIosAppDataStreamsResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_ios_app_data_streams(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListIosAppDataStreamsAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_ios_app_data_streams_async_from_dict(): + await test_list_ios_app_data_streams_async(request_type=dict) + + +def test_list_ios_app_data_streams_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListIosAppDataStreamsRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__') as call: + call.return_value = analytics_admin.ListIosAppDataStreamsResponse() + + client.list_ios_app_data_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_ios_app_data_streams_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListIosAppDataStreamsRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListIosAppDataStreamsResponse()) + + await client.list_ios_app_data_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_ios_app_data_streams_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListIosAppDataStreamsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_ios_app_data_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_ios_app_data_streams_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_ios_app_data_streams( + analytics_admin.ListIosAppDataStreamsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_ios_app_data_streams_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListIosAppDataStreamsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListIosAppDataStreamsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_ios_app_data_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_ios_app_data_streams_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_ios_app_data_streams( + analytics_admin.ListIosAppDataStreamsRequest(), + parent='parent_value', + ) + + +def test_list_ios_app_data_streams_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_ios_app_data_streams(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.IosAppDataStream) + for i in results) + +def test_list_ios_app_data_streams_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + ), + RuntimeError, + ) + pages = list(client.list_ios_app_data_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_ios_app_data_streams_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_ios_app_data_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, resources.IosAppDataStream) + for i in responses) + +@pytest.mark.asyncio +async def test_list_ios_app_data_streams_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ios_app_data_streams), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_ios_app_data_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_android_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.GetAndroidAppDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream( + name='name_value', + + firebase_app_id='firebase_app_id_value', + + package_name='package_name_value', + + display_name='display_name_value', + + ) + + response = client.get_android_app_data_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] == analytics_admin.GetAndroidAppDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.AndroidAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.package_name == 'package_name_value' + + assert response.display_name == 'display_name_value' + + +def test_get_android_app_data_stream_from_dict(): + test_get_android_app_data_stream(request_type=dict) + + +def test_get_android_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_android_app_data_stream), + '__call__') as call: + client.get_android_app_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetAndroidAppDataStreamRequest() + +@pytest.mark.asyncio +async def test_get_android_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetAndroidAppDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream( + name='name_value', + firebase_app_id='firebase_app_id_value', + package_name='package_name_value', + display_name='display_name_value', + )) + + response = await client.get_android_app_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetAndroidAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.AndroidAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.package_name == 'package_name_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_get_android_app_data_stream_async_from_dict(): + await test_get_android_app_data_stream_async(request_type=dict) + + +def test_get_android_app_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetAndroidAppDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_android_app_data_stream), + '__call__') as call: + call.return_value = resources.AndroidAppDataStream() + + client.get_android_app_data_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_android_app_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetAndroidAppDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_android_app_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) + + await client.get_android_app_data_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_android_app_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_android_app_data_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_android_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_android_app_data_stream( + analytics_admin.GetAndroidAppDataStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_android_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_android_app_data_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_android_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_android_app_data_stream( + analytics_admin.GetAndroidAppDataStreamRequest(), + name='name_value', + ) + + +def test_delete_android_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.DeleteAndroidAppDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_android_app_data_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] == analytics_admin.DeleteAndroidAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_android_app_data_stream_from_dict(): + test_delete_android_app_data_stream(request_type=dict) + + +def test_delete_android_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_android_app_data_stream), + '__call__') as call: + client.delete_android_app_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteAndroidAppDataStreamRequest() + +@pytest.mark.asyncio +async def test_delete_android_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteAndroidAppDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_android_app_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteAndroidAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_android_app_data_stream_async_from_dict(): + await test_delete_android_app_data_stream_async(request_type=dict) + + +def test_delete_android_app_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteAndroidAppDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_android_app_data_stream), + '__call__') as call: + call.return_value = None + + client.delete_android_app_data_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_android_app_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteAndroidAppDataStreamRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_android_app_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_android_app_data_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_android_app_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_android_app_data_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_android_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_android_app_data_stream( + analytics_admin.DeleteAndroidAppDataStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_android_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_android_app_data_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_android_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_android_app_data_stream( + analytics_admin.DeleteAndroidAppDataStreamRequest(), + name='name_value', + ) + + +def test_update_android_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.UpdateAndroidAppDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream( + name='name_value', + + firebase_app_id='firebase_app_id_value', + + package_name='package_name_value', + + display_name='display_name_value', + + ) + + response = client.update_android_app_data_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] == analytics_admin.UpdateAndroidAppDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.AndroidAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.package_name == 'package_name_value' + + assert response.display_name == 'display_name_value' + + +def test_update_android_app_data_stream_from_dict(): + test_update_android_app_data_stream(request_type=dict) + + +def test_update_android_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_android_app_data_stream), + '__call__') as call: + client.update_android_app_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateAndroidAppDataStreamRequest() + +@pytest.mark.asyncio +async def test_update_android_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateAndroidAppDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream( + name='name_value', + firebase_app_id='firebase_app_id_value', + package_name='package_name_value', + display_name='display_name_value', + )) + + response = await client.update_android_app_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateAndroidAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.AndroidAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.package_name == 'package_name_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_update_android_app_data_stream_async_from_dict(): + await test_update_android_app_data_stream_async(request_type=dict) + + +def test_update_android_app_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateAndroidAppDataStreamRequest() + request.android_app_data_stream.name = 'android_app_data_stream.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_android_app_data_stream), + '__call__') as call: + call.return_value = resources.AndroidAppDataStream() + + client.update_android_app_data_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', + 'android_app_data_stream.name=android_app_data_stream.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_android_app_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateAndroidAppDataStreamRequest() + request.android_app_data_stream.name = 'android_app_data_stream.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_android_app_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) + + await client.update_android_app_data_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', + 'android_app_data_stream.name=android_app_data_stream.name/value', + ) in kw['metadata'] + + +def test_update_android_app_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_android_app_data_stream( + android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), + update_mask=field_mask.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].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +def test_update_android_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_android_app_data_stream( + analytics_admin.UpdateAndroidAppDataStreamRequest(), + android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_android_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_android_app_data_stream( + android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), + update_mask=field_mask.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].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_android_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_android_app_data_stream( + analytics_admin.UpdateAndroidAppDataStreamRequest(), + android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +def test_create_android_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.CreateAndroidAppDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream( + name='name_value', + + firebase_app_id='firebase_app_id_value', + + package_name='package_name_value', + + display_name='display_name_value', + + ) + + response = client.create_android_app_data_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] == analytics_admin.CreateAndroidAppDataStreamRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.AndroidAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.package_name == 'package_name_value' + + assert response.display_name == 'display_name_value' + + +def test_create_android_app_data_stream_from_dict(): + test_create_android_app_data_stream(request_type=dict) + + +def test_create_android_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_android_app_data_stream), + '__call__') as call: + client.create_android_app_data_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() + +@pytest.mark.asyncio +async def test_create_android_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateAndroidAppDataStreamRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream( + name='name_value', + firebase_app_id='firebase_app_id_value', + package_name='package_name_value', + display_name='display_name_value', + )) + + response = await client.create_android_app_data_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.AndroidAppDataStream) + + assert response.name == 'name_value' + + assert response.firebase_app_id == 'firebase_app_id_value' + + assert response.package_name == 'package_name_value' + + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_create_android_app_data_stream_async_from_dict(): + await test_create_android_app_data_stream_async(request_type=dict) + + +def test_create_android_app_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateAndroidAppDataStreamRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_android_app_data_stream), + '__call__') as call: + call.return_value = resources.AndroidAppDataStream() + + client.create_android_app_data_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_android_app_data_stream_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateAndroidAppDataStreamRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_android_app_data_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) + + await client.create_android_app_data_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_android_app_data_stream_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_android_app_data_stream( + parent='parent_value', + android_app_data_stream=resources.AndroidAppDataStream(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].parent == 'parent_value' + + assert args[0].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') + + +def test_create_android_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_android_app_data_stream( + analytics_admin.CreateAndroidAppDataStreamRequest(), + parent='parent_value', + android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_android_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_android_app_data_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AndroidAppDataStream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_android_app_data_stream( + parent='parent_value', + android_app_data_stream=resources.AndroidAppDataStream(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].parent == 'parent_value' + + assert args[0].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') + + +@pytest.mark.asyncio +async def test_create_android_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_android_app_data_stream( + analytics_admin.CreateAndroidAppDataStreamRequest(), + parent='parent_value', + android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), + ) + + +def test_list_android_app_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListAndroidAppDataStreamsRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_android_app_data_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] == analytics_admin.ListAndroidAppDataStreamsRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListAndroidAppDataStreamsPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_android_app_data_streams_from_dict(): + test_list_android_app_data_streams(request_type=dict) + + +def test_list_android_app_data_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 = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__') as call: + client.list_android_app_data_streams() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListAndroidAppDataStreamsRequest() + +@pytest.mark.asyncio +async def test_list_android_app_data_streams_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListAndroidAppDataStreamsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_android_app_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAndroidAppDataStreamsResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_android_app_data_streams(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListAndroidAppDataStreamsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAndroidAppDataStreamsAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_android_app_data_streams_async_from_dict(): + await test_list_android_app_data_streams_async(request_type=dict) + + +def test_list_android_app_data_streams_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListAndroidAppDataStreamsRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__') as call: + call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() + + client.list_android_app_data_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_android_app_data_streams_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListAndroidAppDataStreamsRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAndroidAppDataStreamsResponse()) + + await client.list_android_app_data_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_android_app_data_streams_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_android_app_data_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_android_app_data_streams_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_android_app_data_streams( + analytics_admin.ListAndroidAppDataStreamsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_android_app_data_streams_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAndroidAppDataStreamsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_android_app_data_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_android_app_data_streams_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_android_app_data_streams( + analytics_admin.ListAndroidAppDataStreamsRequest(), + parent='parent_value', + ) + + +def test_list_android_app_data_streams_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_android_app_data_streams(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.AndroidAppDataStream) + for i in results) + +def test_list_android_app_data_streams_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + ], + ), + RuntimeError, + ) + pages = list(client.list_android_app_data_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_android_app_data_streams_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_android_app_data_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, resources.AndroidAppDataStream) + for i in responses) + +@pytest.mark.asyncio +async def test_list_android_app_data_streams_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_android_app_data_streams), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + ], + next_page_token='abc', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[], + next_page_token='def', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + ], + next_page_token='ghi', + ), + analytics_admin.ListAndroidAppDataStreamsResponse( + android_app_data_streams=[ + resources.AndroidAppDataStream(), + resources.AndroidAppDataStream(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_android_app_data_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_enhanced_measurement_settings(transport: str = 'grpc', request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_enhanced_measurement_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.EnhancedMeasurementSettings( + name='name_value', + + stream_enabled=True, + + page_views_enabled=True, + + scrolls_enabled=True, + + outbound_clicks_enabled=True, + + site_search_enabled=True, + + video_engagement_enabled=True, + + file_downloads_enabled=True, + + page_loads_enabled=True, + + page_changes_enabled=True, + + search_query_parameter='search_query_parameter_value', + + uri_query_parameter='uri_query_parameter_value', + + ) + + response = client.get_enhanced_measurement_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.EnhancedMeasurementSettings) + + assert response.name == 'name_value' + + assert response.stream_enabled is True + + assert response.page_views_enabled is True + + assert response.scrolls_enabled is True + + assert response.outbound_clicks_enabled is True + + assert response.site_search_enabled is True + + assert response.video_engagement_enabled is True + + assert response.file_downloads_enabled is True + + assert response.page_loads_enabled is True + + assert response.page_changes_enabled is True + + assert response.search_query_parameter == 'search_query_parameter_value' + + assert response.uri_query_parameter == 'uri_query_parameter_value' + + +def test_get_enhanced_measurement_settings_from_dict(): + test_get_enhanced_measurement_settings(request_type=dict) + + +def test_get_enhanced_measurement_settings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_enhanced_measurement_settings), + '__call__') as call: + client.get_enhanced_measurement_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() + +@pytest.mark.asyncio +async def test_get_enhanced_measurement_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_enhanced_measurement_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings( + name='name_value', + stream_enabled=True, + page_views_enabled=True, + scrolls_enabled=True, + outbound_clicks_enabled=True, + site_search_enabled=True, + video_engagement_enabled=True, + file_downloads_enabled=True, + page_loads_enabled=True, + page_changes_enabled=True, + search_query_parameter='search_query_parameter_value', + uri_query_parameter='uri_query_parameter_value', + )) + + response = await client.get_enhanced_measurement_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.EnhancedMeasurementSettings) + + assert response.name == 'name_value' + + assert response.stream_enabled is True + + assert response.page_views_enabled is True + + assert response.scrolls_enabled is True + + assert response.outbound_clicks_enabled is True + + assert response.site_search_enabled is True + + assert response.video_engagement_enabled is True + + assert response.file_downloads_enabled is True + + assert response.page_loads_enabled is True + + assert response.page_changes_enabled is True + + assert response.search_query_parameter == 'search_query_parameter_value' + + assert response.uri_query_parameter == 'uri_query_parameter_value' + + +@pytest.mark.asyncio +async def test_get_enhanced_measurement_settings_async_from_dict(): + await test_get_enhanced_measurement_settings_async(request_type=dict) + + +def test_get_enhanced_measurement_settings_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetEnhancedMeasurementSettingsRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_enhanced_measurement_settings), + '__call__') as call: + call.return_value = resources.EnhancedMeasurementSettings() + + client.get_enhanced_measurement_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_enhanced_measurement_settings_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetEnhancedMeasurementSettingsRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_enhanced_measurement_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings()) + + await client.get_enhanced_measurement_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_get_enhanced_measurement_settings_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_enhanced_measurement_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.EnhancedMeasurementSettings() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_enhanced_measurement_settings( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == 'name_value' + + +def test_get_enhanced_measurement_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_enhanced_measurement_settings( + analytics_admin.GetEnhancedMeasurementSettingsRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_enhanced_measurement_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_enhanced_measurement_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.EnhancedMeasurementSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_enhanced_measurement_settings( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_enhanced_measurement_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_enhanced_measurement_settings( + analytics_admin.GetEnhancedMeasurementSettingsRequest(), + name='name_value', + ) + + +def test_update_enhanced_measurement_settings(transport: str = 'grpc', request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_enhanced_measurement_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.EnhancedMeasurementSettings( + name='name_value', + + stream_enabled=True, + + page_views_enabled=True, + + scrolls_enabled=True, + + outbound_clicks_enabled=True, + + site_search_enabled=True, + + video_engagement_enabled=True, + + file_downloads_enabled=True, + + page_loads_enabled=True, + + page_changes_enabled=True, + + search_query_parameter='search_query_parameter_value', + + uri_query_parameter='uri_query_parameter_value', + + ) + + response = client.update_enhanced_measurement_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.EnhancedMeasurementSettings) + + assert response.name == 'name_value' + + assert response.stream_enabled is True + + assert response.page_views_enabled is True + + assert response.scrolls_enabled is True + + assert response.outbound_clicks_enabled is True + + assert response.site_search_enabled is True + + assert response.video_engagement_enabled is True + + assert response.file_downloads_enabled is True + + assert response.page_loads_enabled is True + + assert response.page_changes_enabled is True + + assert response.search_query_parameter == 'search_query_parameter_value' + + assert response.uri_query_parameter == 'uri_query_parameter_value' + + +def test_update_enhanced_measurement_settings_from_dict(): + test_update_enhanced_measurement_settings(request_type=dict) + + +def test_update_enhanced_measurement_settings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_enhanced_measurement_settings), + '__call__') as call: + client.update_enhanced_measurement_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + +@pytest.mark.asyncio +async def test_update_enhanced_measurement_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_enhanced_measurement_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings( + name='name_value', + stream_enabled=True, + page_views_enabled=True, + scrolls_enabled=True, + outbound_clicks_enabled=True, + site_search_enabled=True, + video_engagement_enabled=True, + file_downloads_enabled=True, + page_loads_enabled=True, + page_changes_enabled=True, + search_query_parameter='search_query_parameter_value', + uri_query_parameter='uri_query_parameter_value', + )) + + response = await client.update_enhanced_measurement_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.EnhancedMeasurementSettings) + + assert response.name == 'name_value' + + assert response.stream_enabled is True + + assert response.page_views_enabled is True + + assert response.scrolls_enabled is True + + assert response.outbound_clicks_enabled is True + + assert response.site_search_enabled is True + + assert response.video_engagement_enabled is True + + assert response.file_downloads_enabled is True + + assert response.page_loads_enabled is True + + assert response.page_changes_enabled is True + + assert response.search_query_parameter == 'search_query_parameter_value' + + assert response.uri_query_parameter == 'uri_query_parameter_value' + + +@pytest.mark.asyncio +async def test_update_enhanced_measurement_settings_async_from_dict(): + await test_update_enhanced_measurement_settings_async(request_type=dict) + + +def test_update_enhanced_measurement_settings_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + request.enhanced_measurement_settings.name = 'enhanced_measurement_settings.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_enhanced_measurement_settings), + '__call__') as call: + call.return_value = resources.EnhancedMeasurementSettings() + + client.update_enhanced_measurement_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'enhanced_measurement_settings.name=enhanced_measurement_settings.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_enhanced_measurement_settings_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + request.enhanced_measurement_settings.name = 'enhanced_measurement_settings.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_enhanced_measurement_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings()) + + await client.update_enhanced_measurement_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'enhanced_measurement_settings.name=enhanced_measurement_settings.name/value', + ) in kw['metadata'] + + +def test_update_enhanced_measurement_settings_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_enhanced_measurement_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.EnhancedMeasurementSettings() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_enhanced_measurement_settings( + enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), + update_mask=field_mask.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].enhanced_measurement_settings == resources.EnhancedMeasurementSettings(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +def test_update_enhanced_measurement_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_enhanced_measurement_settings( + analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), + enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_enhanced_measurement_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_enhanced_measurement_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.EnhancedMeasurementSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_enhanced_measurement_settings( + enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), + update_mask=field_mask.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].enhanced_measurement_settings == resources.EnhancedMeasurementSettings(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_enhanced_measurement_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_enhanced_measurement_settings( + analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), + enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +def test_create_firebase_link(transport: str = 'grpc', request_type=analytics_admin.CreateFirebaseLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FirebaseLink( + name='name_value', + + project='project_value', + + maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, + + ) + + response = client.create_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateFirebaseLinkRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.FirebaseLink) + + assert response.name == 'name_value' + + assert response.project == 'project_value' + + assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS + + +def test_create_firebase_link_from_dict(): + test_create_firebase_link(request_type=dict) + + +def test_create_firebase_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firebase_link), + '__call__') as call: + client.create_firebase_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateFirebaseLinkRequest() + +@pytest.mark.asyncio +async def test_create_firebase_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateFirebaseLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink( + name='name_value', + project='project_value', + maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, + )) + + response = await client.create_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateFirebaseLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.FirebaseLink) + + assert response.name == 'name_value' + + assert response.project == 'project_value' + + assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS + + +@pytest.mark.asyncio +async def test_create_firebase_link_async_from_dict(): + await test_create_firebase_link_async(request_type=dict) + + +def test_create_firebase_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateFirebaseLinkRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firebase_link), + '__call__') as call: + call.return_value = resources.FirebaseLink() + + client.create_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_firebase_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateFirebaseLinkRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firebase_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink()) + + await client.create_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_create_firebase_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FirebaseLink() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_firebase_link( + parent='parent_value', + firebase_link=resources.FirebaseLink(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].parent == 'parent_value' + + assert args[0].firebase_link == resources.FirebaseLink(name='name_value') + + +def test_create_firebase_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_firebase_link( + analytics_admin.CreateFirebaseLinkRequest(), + parent='parent_value', + firebase_link=resources.FirebaseLink(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_firebase_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FirebaseLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_firebase_link( + parent='parent_value', + firebase_link=resources.FirebaseLink(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].parent == 'parent_value' + + assert args[0].firebase_link == resources.FirebaseLink(name='name_value') + + +@pytest.mark.asyncio +async def test_create_firebase_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_firebase_link( + analytics_admin.CreateFirebaseLinkRequest(), + parent='parent_value', + firebase_link=resources.FirebaseLink(name='name_value'), + ) + + +def test_update_firebase_link(transport: str = 'grpc', request_type=analytics_admin.UpdateFirebaseLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FirebaseLink( + name='name_value', + + project='project_value', + + maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, + + ) + + response = client.update_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.FirebaseLink) + + assert response.name == 'name_value' + + assert response.project == 'project_value' + + assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS + + +def test_update_firebase_link_from_dict(): + test_update_firebase_link(request_type=dict) + + +def test_update_firebase_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firebase_link), + '__call__') as call: + client.update_firebase_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() + +@pytest.mark.asyncio +async def test_update_firebase_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateFirebaseLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink( + name='name_value', + project='project_value', + maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, + )) + + response = await client.update_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.FirebaseLink) + + assert response.name == 'name_value' + + assert response.project == 'project_value' + + assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS + + +@pytest.mark.asyncio +async def test_update_firebase_link_async_from_dict(): + await test_update_firebase_link_async(request_type=dict) + + +def test_update_firebase_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateFirebaseLinkRequest() + request.firebase_link.name = 'firebase_link.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firebase_link), + '__call__') as call: + call.return_value = resources.FirebaseLink() + + client.update_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'firebase_link.name=firebase_link.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_firebase_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateFirebaseLinkRequest() + request.firebase_link.name = 'firebase_link.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firebase_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink()) + + await client.update_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'firebase_link.name=firebase_link.name/value', + ) in kw['metadata'] + + +def test_update_firebase_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FirebaseLink() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_firebase_link( + firebase_link=resources.FirebaseLink(name='name_value'), + update_mask=field_mask.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].firebase_link == resources.FirebaseLink(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +def test_update_firebase_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_firebase_link( + analytics_admin.UpdateFirebaseLinkRequest(), + firebase_link=resources.FirebaseLink(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_firebase_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.FirebaseLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_firebase_link( + firebase_link=resources.FirebaseLink(name='name_value'), + update_mask=field_mask.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].firebase_link == resources.FirebaseLink(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_firebase_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_firebase_link( + analytics_admin.UpdateFirebaseLinkRequest(), + firebase_link=resources.FirebaseLink(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +def test_delete_firebase_link(transport: str = 'grpc', request_type=analytics_admin.DeleteFirebaseLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_firebase_link_from_dict(): + test_delete_firebase_link(request_type=dict) + + +def test_delete_firebase_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firebase_link), + '__call__') as call: + client.delete_firebase_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() + +@pytest.mark.asyncio +async def test_delete_firebase_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteFirebaseLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_firebase_link_async_from_dict(): + await test_delete_firebase_link_async(request_type=dict) + + +def test_delete_firebase_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteFirebaseLinkRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firebase_link), + '__call__') as call: + call.return_value = None + + client.delete_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_firebase_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteFirebaseLinkRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firebase_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_firebase_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_delete_firebase_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_firebase_link( + 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_firebase_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_firebase_link( + analytics_admin.DeleteFirebaseLinkRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_firebase_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firebase_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_firebase_link( + 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_firebase_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_firebase_link( + analytics_admin.DeleteFirebaseLinkRequest(), + name='name_value', + ) + + +def test_list_firebase_links(transport: str = 'grpc', request_type=analytics_admin.ListFirebaseLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_firebase_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListFirebaseLinksResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_firebase_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListFirebaseLinksRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListFirebaseLinksPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_firebase_links_from_dict(): + test_list_firebase_links(request_type=dict) + + +def test_list_firebase_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__') as call: + client.list_firebase_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListFirebaseLinksRequest() + +@pytest.mark.asyncio +async def test_list_firebase_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListFirebaseLinksRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_firebase_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListFirebaseLinksResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_firebase_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListFirebaseLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFirebaseLinksAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_firebase_links_async_from_dict(): + await test_list_firebase_links_async(request_type=dict) + + +def test_list_firebase_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListFirebaseLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__') as call: + call.return_value = analytics_admin.ListFirebaseLinksResponse() + + client.list_firebase_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_firebase_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListFirebaseLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListFirebaseLinksResponse()) + + await client.list_firebase_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_list_firebase_links_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListFirebaseLinksResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_firebase_links( + 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_firebase_links_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_firebase_links( + analytics_admin.ListFirebaseLinksRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_firebase_links_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListFirebaseLinksResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListFirebaseLinksResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_firebase_links( + 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_firebase_links_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_firebase_links( + analytics_admin.ListFirebaseLinksRequest(), + parent='parent_value', + ) + + +def test_list_firebase_links_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], + next_page_token='def', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_firebase_links(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.FirebaseLink) + for i in results) + +def test_list_firebase_links_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], + next_page_token='def', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + ), + RuntimeError, + ) + pages = list(client.list_firebase_links(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_firebase_links_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], + next_page_token='def', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_firebase_links(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.FirebaseLink) + for i in responses) + +@pytest.mark.asyncio +async def test_list_firebase_links_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], + next_page_token='def', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_firebase_links(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_global_site_tag(transport: str = 'grpc', request_type=analytics_admin.GetGlobalSiteTagRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_global_site_tag), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GlobalSiteTag( + name='name_value', + + snippet='snippet_value', + + ) + + response = client.get_global_site_tag(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetGlobalSiteTagRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.GlobalSiteTag) + + assert response.name == 'name_value' + + assert response.snippet == 'snippet_value' + + +def test_get_global_site_tag_from_dict(): + test_get_global_site_tag(request_type=dict) + + +def test_get_global_site_tag_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_global_site_tag), + '__call__') as call: + client.get_global_site_tag() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetGlobalSiteTagRequest() + +@pytest.mark.asyncio +async def test_get_global_site_tag_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetGlobalSiteTagRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_global_site_tag), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GlobalSiteTag( + name='name_value', + snippet='snippet_value', + )) + + response = await client.get_global_site_tag(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetGlobalSiteTagRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GlobalSiteTag) + + assert response.name == 'name_value' + + assert response.snippet == 'snippet_value' + + +@pytest.mark.asyncio +async def test_get_global_site_tag_async_from_dict(): + await test_get_global_site_tag_async(request_type=dict) + + +def test_get_global_site_tag_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetGlobalSiteTagRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_global_site_tag), + '__call__') as call: + call.return_value = resources.GlobalSiteTag() + + client.get_global_site_tag(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_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_global_site_tag_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetGlobalSiteTagRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_global_site_tag), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GlobalSiteTag()) + + await client.get_global_site_tag(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_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_global_site_tag_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_global_site_tag), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GlobalSiteTag() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_global_site_tag( + 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_global_site_tag_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_global_site_tag( + analytics_admin.GetGlobalSiteTagRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_global_site_tag_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_global_site_tag), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GlobalSiteTag() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GlobalSiteTag()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_global_site_tag( + 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_global_site_tag_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_global_site_tag( + analytics_admin.GetGlobalSiteTagRequest(), + name='name_value', + ) + + +def test_create_google_ads_link(transport: str = 'grpc', request_type=analytics_admin.CreateGoogleAdsLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleAdsLink( + name='name_value', + + customer_id='customer_id_value', + + can_manage_clients=True, + + email_address='email_address_value', + + ) + + response = client.create_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.GoogleAdsLink) + + assert response.name == 'name_value' + + assert response.customer_id == 'customer_id_value' + + assert response.can_manage_clients is True + + assert response.email_address == 'email_address_value' + + +def test_create_google_ads_link_from_dict(): + test_create_google_ads_link(request_type=dict) + + +def test_create_google_ads_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_google_ads_link), + '__call__') as call: + client.create_google_ads_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() + +@pytest.mark.asyncio +async def test_create_google_ads_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateGoogleAdsLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink( + name='name_value', + customer_id='customer_id_value', + can_manage_clients=True, + email_address='email_address_value', + )) + + response = await client.create_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleAdsLink) + + assert response.name == 'name_value' + + assert response.customer_id == 'customer_id_value' + + assert response.can_manage_clients is True + + assert response.email_address == 'email_address_value' + + +@pytest.mark.asyncio +async def test_create_google_ads_link_async_from_dict(): + await test_create_google_ads_link_async(request_type=dict) + + +def test_create_google_ads_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateGoogleAdsLinkRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_google_ads_link), + '__call__') as call: + call.return_value = resources.GoogleAdsLink() + + client.create_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_google_ads_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateGoogleAdsLinkRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_google_ads_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink()) + + await client.create_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_create_google_ads_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleAdsLink() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_google_ads_link( + parent='parent_value', + google_ads_link=resources.GoogleAdsLink(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].parent == 'parent_value' + + assert args[0].google_ads_link == resources.GoogleAdsLink(name='name_value') + + +def test_create_google_ads_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_google_ads_link( + analytics_admin.CreateGoogleAdsLinkRequest(), + parent='parent_value', + google_ads_link=resources.GoogleAdsLink(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_google_ads_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleAdsLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_google_ads_link( + parent='parent_value', + google_ads_link=resources.GoogleAdsLink(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].parent == 'parent_value' + + assert args[0].google_ads_link == resources.GoogleAdsLink(name='name_value') + + +@pytest.mark.asyncio +async def test_create_google_ads_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_google_ads_link( + analytics_admin.CreateGoogleAdsLinkRequest(), + parent='parent_value', + google_ads_link=resources.GoogleAdsLink(name='name_value'), + ) + + +def test_update_google_ads_link(transport: str = 'grpc', request_type=analytics_admin.UpdateGoogleAdsLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleAdsLink( + name='name_value', + + customer_id='customer_id_value', + + can_manage_clients=True, + + email_address='email_address_value', + + ) + + response = client.update_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.GoogleAdsLink) + + assert response.name == 'name_value' + + assert response.customer_id == 'customer_id_value' + + assert response.can_manage_clients is True + + assert response.email_address == 'email_address_value' + + +def test_update_google_ads_link_from_dict(): + test_update_google_ads_link(request_type=dict) + + +def test_update_google_ads_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_ads_link), + '__call__') as call: + client.update_google_ads_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() + +@pytest.mark.asyncio +async def test_update_google_ads_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateGoogleAdsLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink( + name='name_value', + customer_id='customer_id_value', + can_manage_clients=True, + email_address='email_address_value', + )) + + response = await client.update_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleAdsLink) + + assert response.name == 'name_value' + + assert response.customer_id == 'customer_id_value' + + assert response.can_manage_clients is True + + assert response.email_address == 'email_address_value' + + +@pytest.mark.asyncio +async def test_update_google_ads_link_async_from_dict(): + await test_update_google_ads_link_async(request_type=dict) + + +def test_update_google_ads_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateGoogleAdsLinkRequest() + request.google_ads_link.name = 'google_ads_link.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_ads_link), + '__call__') as call: + call.return_value = resources.GoogleAdsLink() + + client.update_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'google_ads_link.name=google_ads_link.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_google_ads_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateGoogleAdsLinkRequest() + request.google_ads_link.name = 'google_ads_link.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_ads_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink()) + + await client.update_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'google_ads_link.name=google_ads_link.name/value', + ) in kw['metadata'] + + +def test_update_google_ads_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleAdsLink() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_google_ads_link( + google_ads_link=resources.GoogleAdsLink(name='name_value'), + update_mask=field_mask.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].google_ads_link == resources.GoogleAdsLink(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +def test_update_google_ads_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_google_ads_link( + analytics_admin.UpdateGoogleAdsLinkRequest(), + google_ads_link=resources.GoogleAdsLink(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_google_ads_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleAdsLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_google_ads_link( + google_ads_link=resources.GoogleAdsLink(name='name_value'), + update_mask=field_mask.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].google_ads_link == resources.GoogleAdsLink(name='name_value') + + assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_google_ads_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_google_ads_link( + analytics_admin.UpdateGoogleAdsLinkRequest(), + google_ads_link=resources.GoogleAdsLink(name='name_value'), + update_mask=field_mask.FieldMask(paths=['paths_value']), + ) + + +def test_delete_google_ads_link(transport: str = 'grpc', request_type=analytics_admin.DeleteGoogleAdsLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_google_ads_link_from_dict(): + test_delete_google_ads_link(request_type=dict) + + +def test_delete_google_ads_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_google_ads_link), + '__call__') as call: + client.delete_google_ads_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() + +@pytest.mark.asyncio +async def test_delete_google_ads_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteGoogleAdsLinkRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + response = await client.delete_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_google_ads_link_async_from_dict(): + await test_delete_google_ads_link_async(request_type=dict) + + +def test_delete_google_ads_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteGoogleAdsLinkRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_google_ads_link), + '__call__') as call: + call.return_value = None + + client.delete_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_google_ads_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteGoogleAdsLinkRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_google_ads_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + + await client.delete_google_ads_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_delete_google_ads_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_google_ads_link( + 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_google_ads_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_google_ads_link( + analytics_admin.DeleteGoogleAdsLinkRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_google_ads_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_google_ads_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_google_ads_link( + 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_google_ads_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_google_ads_link( + analytics_admin.DeleteGoogleAdsLinkRequest(), + name='name_value', + ) + + +def test_list_google_ads_links(transport: str = 'grpc', request_type=analytics_admin.ListGoogleAdsLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_ads_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListGoogleAdsLinksResponse( + next_page_token='next_page_token_value', + + ) + + response = client.list_google_ads_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, pagers.ListGoogleAdsLinksPager) + + assert response.next_page_token == 'next_page_token_value' + + +def test_list_google_ads_links_from_dict(): + test_list_google_ads_links(request_type=dict) + + +def test_list_google_ads_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__') as call: + client.list_google_ads_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() + +@pytest.mark.asyncio +async def test_list_google_ads_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListGoogleAdsLinksRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_ads_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListGoogleAdsLinksResponse( + next_page_token='next_page_token_value', + )) + + response = await client.list_google_ads_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListGoogleAdsLinksAsyncPager) + + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_google_ads_links_async_from_dict(): + await test_list_google_ads_links_async(request_type=dict) + + +def test_list_google_ads_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListGoogleAdsLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__') as call: + call.return_value = analytics_admin.ListGoogleAdsLinksResponse() + + client.list_google_ads_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_google_ads_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListGoogleAdsLinksRequest() + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListGoogleAdsLinksResponse()) + + await client.list_google_ads_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent/value', + ) in kw['metadata'] + + +def test_list_google_ads_links_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListGoogleAdsLinksResponse() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_google_ads_links( + 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_google_ads_links_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_google_ads_links( + analytics_admin.ListGoogleAdsLinksRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_google_ads_links_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListGoogleAdsLinksResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListGoogleAdsLinksResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_google_ads_links( + 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_google_ads_links_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_google_ads_links( + analytics_admin.ListGoogleAdsLinksRequest(), + parent='parent_value', + ) + + +def test_list_google_ads_links_pager(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[], + next_page_token='def', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_google_ads_links(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.GoogleAdsLink) + for i in results) + +def test_list_google_ads_links_pages(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[], + next_page_token='def', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + ), + RuntimeError, + ) + pages = list(client.list_google_ads_links(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_google_ads_links_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[], + next_page_token='def', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_google_ads_links(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.GoogleAdsLink) + for i in responses) + +@pytest.mark.asyncio +async def test_list_google_ads_links_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_google_ads_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + next_page_token='abc', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[], + next_page_token='def', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + ], + next_page_token='ghi', + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_google_ads_links(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_data_sharing_settings(transport: str = 'grpc', request_type=analytics_admin.GetDataSharingSettingsRequest): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_data_sharing_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.DataSharingSettings( + name='name_value', + + sharing_with_google_support_enabled=True, + + sharing_with_google_assigned_sales_enabled=True, + + sharing_with_google_any_sales_enabled=True, + + sharing_with_google_products_enabled=True, + + sharing_with_others_enabled=True, + + ) + + response = client.get_data_sharing_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetDataSharingSettingsRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.DataSharingSettings) + + assert response.name == 'name_value' + + assert response.sharing_with_google_support_enabled is True + + assert response.sharing_with_google_assigned_sales_enabled is True + + assert response.sharing_with_google_any_sales_enabled is True + + assert response.sharing_with_google_products_enabled is True + + assert response.sharing_with_others_enabled is True + + +def test_get_data_sharing_settings_from_dict(): + test_get_data_sharing_settings(request_type=dict) + + +def test_get_data_sharing_settings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), + '__call__') as call: + client.get_data_sharing_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetDataSharingSettingsRequest() + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetDataSharingSettingsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_data_sharing_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.DataSharingSettings( + name='name_value', + sharing_with_google_support_enabled=True, + sharing_with_google_assigned_sales_enabled=True, + sharing_with_google_any_sales_enabled=True, + sharing_with_google_products_enabled=True, + sharing_with_others_enabled=True, + )) + + response = await client.get_data_sharing_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetDataSharingSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.DataSharingSettings) + + assert response.name == 'name_value' + + assert response.sharing_with_google_support_enabled is True + + assert response.sharing_with_google_assigned_sales_enabled is True + + assert response.sharing_with_google_any_sales_enabled is True + + assert response.sharing_with_google_products_enabled is True + + assert response.sharing_with_others_enabled is True + + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_async_from_dict(): + await test_get_data_sharing_settings_async(request_type=dict) + + +def test_get_data_sharing_settings_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetDataSharingSettingsRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), + '__call__') as call: + call.return_value = resources.DataSharingSettings() + + client.get_data_sharing_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetDataSharingSettingsRequest() + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.DataSharingSettings()) + + await client.get_data_sharing_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_get_data_sharing_settings_flattened(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.DataSharingSettings() + + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_data_sharing_settings( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0].name == 'name_value' + + +def test_get_data_sharing_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_data_sharing_settings( + analytics_admin.GetDataSharingSettingsRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.DataSharingSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.DataSharingSettings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_data_sharing_settings( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=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_data_sharing_settings( + analytics_admin.GetDataSharingSettingsRequest(), + name='name_value', + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.AnalyticsAdminServiceGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.AnalyticsAdminServiceGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = AnalyticsAdminServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.AnalyticsAdminServiceGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = AnalyticsAdminServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.AnalyticsAdminServiceGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.AnalyticsAdminServiceGrpcTransport( + credentials=credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( + credentials=credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize("transport_class", [ + transports.AnalyticsAdminServiceGrpcTransport, + transports.AnalyticsAdminServiceGrpcAsyncIOTransport, +]) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(auth, 'default') as adc: + adc.return_value = (credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.AnalyticsAdminServiceGrpcTransport, + ) + + +def test_analytics_admin_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(exceptions.DuplicateCredentialArgs): + transport = transports.AnalyticsAdminServiceTransport( + credentials=credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_analytics_admin_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.AnalyticsAdminServiceTransport( + credentials=credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'get_account', + 'list_accounts', + 'delete_account', + 'update_account', + 'provision_account_ticket', + 'list_account_summaries', + 'get_property', + 'list_properties', + 'create_property', + 'delete_property', + 'update_property', + 'get_user_link', + 'batch_get_user_links', + 'list_user_links', + 'audit_user_links', + 'create_user_link', + 'batch_create_user_links', + 'update_user_link', + 'batch_update_user_links', + 'delete_user_link', + 'batch_delete_user_links', + 'get_web_data_stream', + 'delete_web_data_stream', + 'update_web_data_stream', + 'create_web_data_stream', + 'list_web_data_streams', + 'get_ios_app_data_stream', + 'delete_ios_app_data_stream', + 'update_ios_app_data_stream', + 'create_ios_app_data_stream', + 'list_ios_app_data_streams', + 'get_android_app_data_stream', + 'delete_android_app_data_stream', + 'update_android_app_data_stream', + 'create_android_app_data_stream', + 'list_android_app_data_streams', + 'get_enhanced_measurement_settings', + 'update_enhanced_measurement_settings', + 'create_firebase_link', + 'update_firebase_link', + 'delete_firebase_link', + 'list_firebase_links', + 'get_global_site_tag', + 'create_google_ads_link', + 'update_google_ads_link', + 'delete_google_ads_link', + 'list_google_ads_links', + 'get_data_sharing_settings', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + +def test_analytics_admin_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(auth, 'load_credentials_from_file') as load_creds, mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (credentials.AnonymousCredentials(), None) + transport = transports.AnalyticsAdminServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/analytics.edit', + 'https://www.googleapis.com/auth/analytics.manage.users', + 'https://www.googleapis.com/auth/analytics.manage.users.readonly', + 'https://www.googleapis.com/auth/analytics.readonly', + ), + quota_project_id="octopus", + ) + + +def test_analytics_admin_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(auth, 'default') as adc, mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (credentials.AnonymousCredentials(), None) + transport = transports.AnalyticsAdminServiceTransport() + adc.assert_called_once() + + +def test_analytics_admin_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(auth, 'default') as adc: + adc.return_value = (credentials.AnonymousCredentials(), None) + AnalyticsAdminServiceClient() + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/analytics.edit', + 'https://www.googleapis.com/auth/analytics.manage.users', + 'https://www.googleapis.com/auth/analytics.manage.users.readonly', + 'https://www.googleapis.com/auth/analytics.readonly',), + quota_project_id=None, + ) + + +def test_analytics_admin_service_transport_auth_adc(): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(auth, 'default') as adc: + adc.return_value = (credentials.AnonymousCredentials(), None) + transports.AnalyticsAdminServiceGrpcTransport(host="squid.clam.whelk", quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/analytics.edit', + 'https://www.googleapis.com/auth/analytics.manage.users', + 'https://www.googleapis.com/auth/analytics.manage.users.readonly', + 'https://www.googleapis.com/auth/analytics.readonly',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize("transport_class", [transports.AnalyticsAdminServiceGrpcTransport, transports.AnalyticsAdminServiceGrpcAsyncIOTransport]) +def test_analytics_admin_service_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/analytics.edit', + 'https://www.googleapis.com/auth/analytics.manage.users', + 'https://www.googleapis.com/auth/analytics.manage.users.readonly', + 'https://www.googleapis.com/auth/analytics.readonly', + ), + 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_analytics_admin_service_host_no_port(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='analyticsadmin.googleapis.com'), + ) + assert client.transport._host == 'analyticsadmin.googleapis.com:443' + + +def test_analytics_admin_service_host_with_port(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='analyticsadmin.googleapis.com:8000'), + ) + assert client.transport._host == 'analyticsadmin.googleapis.com:8000' + + +def test_analytics_admin_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.AnalyticsAdminServiceGrpcTransport( + 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_analytics_admin_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( + 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.AnalyticsAdminServiceGrpcTransport, transports.AnalyticsAdminServiceGrpcAsyncIOTransport]) +def test_analytics_admin_service_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/analytics.edit', + 'https://www.googleapis.com/auth/analytics.manage.users', + 'https://www.googleapis.com/auth/analytics.manage.users.readonly', + 'https://www.googleapis.com/auth/analytics.readonly', + ), + 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.AnalyticsAdminServiceGrpcTransport, transports.AnalyticsAdminServiceGrpcAsyncIOTransport]) +def test_analytics_admin_service_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/analytics.edit', + 'https://www.googleapis.com/auth/analytics.manage.users', + 'https://www.googleapis.com/auth/analytics.manage.users.readonly', + 'https://www.googleapis.com/auth/analytics.readonly', + ), + 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_account_path(): + account = "squid" + + expected = "accounts/{account}".format(account=account, ) + actual = AnalyticsAdminServiceClient.account_path(account) + assert expected == actual + + +def test_parse_account_path(): + expected = { + "account": "clam", + + } + path = AnalyticsAdminServiceClient.account_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_account_path(path) + assert expected == actual + +def test_account_summary_path(): + account_summary = "whelk" + + expected = "accountSummaries/{account_summary}".format(account_summary=account_summary, ) + actual = AnalyticsAdminServiceClient.account_summary_path(account_summary) + assert expected == actual + + +def test_parse_account_summary_path(): + expected = { + "account_summary": "octopus", + + } + path = AnalyticsAdminServiceClient.account_summary_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_account_summary_path(path) + assert expected == actual + +def test_android_app_data_stream_path(): + property = "oyster" + android_app_data_stream = "nudibranch" + + expected = "properties/{property}/androidAppDataStreams/{android_app_data_stream}".format(property=property, android_app_data_stream=android_app_data_stream, ) + actual = AnalyticsAdminServiceClient.android_app_data_stream_path(property, android_app_data_stream) + assert expected == actual + + +def test_parse_android_app_data_stream_path(): + expected = { + "property": "cuttlefish", + "android_app_data_stream": "mussel", + + } + path = AnalyticsAdminServiceClient.android_app_data_stream_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_android_app_data_stream_path(path) + assert expected == actual + +def test_data_sharing_settings_path(): + account = "winkle" + + expected = "accounts/{account}/dataSharingSettings".format(account=account, ) + actual = AnalyticsAdminServiceClient.data_sharing_settings_path(account) + assert expected == actual + + +def test_parse_data_sharing_settings_path(): + expected = { + "account": "nautilus", + + } + path = AnalyticsAdminServiceClient.data_sharing_settings_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_data_sharing_settings_path(path) + assert expected == actual + +def test_enhanced_measurement_settings_path(): + property = "scallop" + web_data_stream = "abalone" + + expected = "properties/{property}/webDataStreams/{web_data_stream}/enhancedMeasurementSettings".format(property=property, web_data_stream=web_data_stream, ) + actual = AnalyticsAdminServiceClient.enhanced_measurement_settings_path(property, web_data_stream) + assert expected == actual + + +def test_parse_enhanced_measurement_settings_path(): + expected = { + "property": "squid", + "web_data_stream": "clam", + + } + path = AnalyticsAdminServiceClient.enhanced_measurement_settings_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_enhanced_measurement_settings_path(path) + assert expected == actual + +def test_firebase_link_path(): + property = "whelk" + firebase_link = "octopus" + + expected = "properties/{property}/firebaseLinks/{firebase_link}".format(property=property, firebase_link=firebase_link, ) + actual = AnalyticsAdminServiceClient.firebase_link_path(property, firebase_link) + assert expected == actual + + +def test_parse_firebase_link_path(): + expected = { + "property": "oyster", + "firebase_link": "nudibranch", + + } + path = AnalyticsAdminServiceClient.firebase_link_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_firebase_link_path(path) + assert expected == actual + +def test_global_site_tag_path(): + property = "cuttlefish" + + expected = "properties/{property}/globalSiteTag".format(property=property, ) + actual = AnalyticsAdminServiceClient.global_site_tag_path(property) + assert expected == actual + + +def test_parse_global_site_tag_path(): + expected = { + "property": "mussel", + + } + path = AnalyticsAdminServiceClient.global_site_tag_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_global_site_tag_path(path) + assert expected == actual + +def test_google_ads_link_path(): + property = "winkle" + google_ads_link = "nautilus" + + expected = "properties/{property}/googleAdsLinks/{google_ads_link}".format(property=property, google_ads_link=google_ads_link, ) + actual = AnalyticsAdminServiceClient.google_ads_link_path(property, google_ads_link) + assert expected == actual + + +def test_parse_google_ads_link_path(): + expected = { + "property": "scallop", + "google_ads_link": "abalone", + + } + path = AnalyticsAdminServiceClient.google_ads_link_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_google_ads_link_path(path) + assert expected == actual + +def test_ios_app_data_stream_path(): + property = "squid" + ios_app_data_stream = "clam" + + expected = "properties/{property}/iosAppDataStreams/{ios_app_data_stream}".format(property=property, ios_app_data_stream=ios_app_data_stream, ) + actual = AnalyticsAdminServiceClient.ios_app_data_stream_path(property, ios_app_data_stream) + assert expected == actual + + +def test_parse_ios_app_data_stream_path(): + expected = { + "property": "whelk", + "ios_app_data_stream": "octopus", + + } + path = AnalyticsAdminServiceClient.ios_app_data_stream_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_ios_app_data_stream_path(path) + assert expected == actual + +def test_property_path(): + property = "oyster" + + expected = "properties/{property}".format(property=property, ) + actual = AnalyticsAdminServiceClient.property_path(property) + assert expected == actual + + +def test_parse_property_path(): + expected = { + "property": "nudibranch", + + } + path = AnalyticsAdminServiceClient.property_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_property_path(path) + assert expected == actual + +def test_user_link_path(): + account = "cuttlefish" + user_link = "mussel" + + expected = "accounts/{account}/userLinks/{user_link}".format(account=account, user_link=user_link, ) + actual = AnalyticsAdminServiceClient.user_link_path(account, user_link) + assert expected == actual + + +def test_parse_user_link_path(): + expected = { + "account": "winkle", + "user_link": "nautilus", + + } + path = AnalyticsAdminServiceClient.user_link_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_user_link_path(path) + assert expected == actual + +def test_web_data_stream_path(): + property = "scallop" + web_data_stream = "abalone" + + expected = "properties/{property}/webDataStreams/{web_data_stream}".format(property=property, web_data_stream=web_data_stream, ) + actual = AnalyticsAdminServiceClient.web_data_stream_path(property, web_data_stream) + assert expected == actual + + +def test_parse_web_data_stream_path(): + expected = { + "property": "squid", + "web_data_stream": "clam", + + } + path = AnalyticsAdminServiceClient.web_data_stream_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_web_data_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 = AnalyticsAdminServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "octopus", + + } + path = AnalyticsAdminServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "oyster" + + expected = "folders/{folder}".format(folder=folder, ) + actual = AnalyticsAdminServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nudibranch", + + } + path = AnalyticsAdminServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "cuttlefish" + + expected = "organizations/{organization}".format(organization=organization, ) + actual = AnalyticsAdminServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "mussel", + + } + path = AnalyticsAdminServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "winkle" + + expected = "projects/{project}".format(project=project, ) + actual = AnalyticsAdminServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nautilus", + + } + path = AnalyticsAdminServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.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 = AnalyticsAdminServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "squid", + "location": "clam", + + } + path = AnalyticsAdminServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.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.AnalyticsAdminServiceTransport, '_prep_wrapped_messages') as prep: + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.AnalyticsAdminServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = AnalyticsAdminServiceClient.get_transport_class() + transport = transport_class( + credentials=credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) From f40773d14a915b7a9abe9756371da6cc1e0d9eed Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 15 May 2021 09:37:43 -0400 Subject: [PATCH 3/3] chore: run the post processor --- .pre-commit-config.yaml | 2 +- CONTRIBUTING.rst | 16 +- noxfile.py | 14 +- owl-bot-staging/v1alpha/MANIFEST.in | 2 - owl-bot-staging/v1alpha/README.rst | 49 - .../admin_v1alpha/analytics_admin_service.rst | 11 - .../v1alpha/docs/admin_v1alpha/services.rst | 6 - .../v1alpha/docs/admin_v1alpha/types.rst | 7 - owl-bot-staging/v1alpha/docs/conf.py | 378 - owl-bot-staging/v1alpha/docs/index.rst | 7 - .../google/analytics/admin/__init__.py | 180 - .../v1alpha/google/analytics/admin/py.typed | 2 - .../analytics/admin_v1alpha/__init__.py | 179 - .../google/analytics/admin_v1alpha/py.typed | 2 - .../admin_v1alpha/services/__init__.py | 16 - .../analytics_admin_service/__init__.py | 24 - .../analytics_admin_service/async_client.py | 4014 ----- .../analytics_admin_service/client.py | 4333 ----- .../analytics_admin_service/pagers.py | 1241 -- .../transports/__init__.py | 35 - .../transports/base.py | 790 - .../transports/grpc.py | 1567 -- .../transports/grpc_asyncio.py | 1572 -- .../analytics/admin_v1alpha/types/__init__.py | 180 - .../admin_v1alpha/types/analytics_admin.py | 1354 -- .../admin_v1alpha/types/resources.py | 712 - owl-bot-staging/v1alpha/mypy.ini | 3 - owl-bot-staging/v1alpha/noxfile.py | 72 - .../scripts/fixup_admin_v1alpha_keywords.py | 226 - owl-bot-staging/v1alpha/setup.py | 55 - .../unit/gapic/admin_v1alpha/__init__.py | 17 - .../test_analytics_admin_service.py | 14201 ---------------- 32 files changed, 4 insertions(+), 31263 deletions(-) delete mode 100644 owl-bot-staging/v1alpha/MANIFEST.in delete mode 100644 owl-bot-staging/v1alpha/README.rst delete mode 100644 owl-bot-staging/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst delete mode 100644 owl-bot-staging/v1alpha/docs/admin_v1alpha/services.rst delete mode 100644 owl-bot-staging/v1alpha/docs/admin_v1alpha/types.rst delete mode 100644 owl-bot-staging/v1alpha/docs/conf.py delete mode 100644 owl-bot-staging/v1alpha/docs/index.rst delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin/py.typed delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/py.typed delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py delete mode 100644 owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py delete mode 100644 owl-bot-staging/v1alpha/mypy.ini delete mode 100644 owl-bot-staging/v1alpha/noxfile.py delete mode 100644 owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py delete mode 100644 owl-bot-staging/v1alpha/setup.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8912e9b5..1bbd7878 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,6 @@ repos: hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.0 + rev: 3.9.1 hooks: - id: flake8 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 31424162..2cd4fe5f 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -160,21 +160,7 @@ Running System Tests auth settings and change some configuration in your project to run all the tests. -- System tests will be run against an actual project and - so you'll need to provide some environment variables to facilitate - authentication to your project: - - - ``GOOGLE_APPLICATION_CREDENTIALS``: The path to a JSON key file; - Such a file can be downloaded directly from the developer's console by clicking - "Generate new JSON key". See private key - `docs `__ - for more details. - -- Once you have downloaded your json keys, set the environment variable - ``GOOGLE_APPLICATION_CREDENTIALS`` to the absolute path of the json file:: - - $ export GOOGLE_APPLICATION_CREDENTIALS="/Users//path/to/app_credentials.json" - +- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication `__. Some tests require a service account. For those tests see `Authenticating as a service account `__. ************* Test Coverage diff --git a/noxfile.py b/noxfile.py index 9def65d8..f4cbe268 100644 --- a/noxfile.py +++ b/noxfile.py @@ -62,16 +62,9 @@ def lint(session): session.run("flake8", "google", "tests") -@nox.session(python="3.6") +@nox.session(python=DEFAULT_PYTHON_VERSION) def blacken(session): - """Run black. - - Format code to uniform standard. - - This currently uses Python 3.6 due to the automated Kokoro run of synthtool. - That run uses an image that doesn't have 3.6 installed. Before updating this - check the state of the `gcp_ubuntu_config` we use for that Kokoro run. - """ + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( "black", *BLACK_PATHS, @@ -131,9 +124,6 @@ def system(session): # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": session.skip("RUN_SYSTEM_TESTS is set to false, skipping") - # Sanity check: Only run tests if the environment variable is set. - if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): - session.skip("Credentials must be set via environment variable") # Install pyopenssl for mTLS testing. if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": session.install("pyopenssl") diff --git a/owl-bot-staging/v1alpha/MANIFEST.in b/owl-bot-staging/v1alpha/MANIFEST.in deleted file mode 100644 index 0377d1d1..00000000 --- a/owl-bot-staging/v1alpha/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/analytics/admin *.py -recursive-include google/analytics/admin_v1alpha *.py diff --git a/owl-bot-staging/v1alpha/README.rst b/owl-bot-staging/v1alpha/README.rst deleted file mode 100644 index 890880fa..00000000 --- a/owl-bot-staging/v1alpha/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Analytics Admin 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 Analytics Admin 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/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst b/owl-bot-staging/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst deleted file mode 100644 index 25d3cf20..00000000 --- a/owl-bot-staging/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst +++ /dev/null @@ -1,11 +0,0 @@ -AnalyticsAdminService ---------------------------------------- - -.. automodule:: google.analytics.admin_v1alpha.services.analytics_admin_service - :members: - :inherited-members: - - -.. automodule:: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v1alpha/docs/admin_v1alpha/services.rst b/owl-bot-staging/v1alpha/docs/admin_v1alpha/services.rst deleted file mode 100644 index 8d20fd9c..00000000 --- a/owl-bot-staging/v1alpha/docs/admin_v1alpha/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Analytics Admin v1alpha API -=============================================== -.. toctree:: - :maxdepth: 2 - - analytics_admin_service diff --git a/owl-bot-staging/v1alpha/docs/admin_v1alpha/types.rst b/owl-bot-staging/v1alpha/docs/admin_v1alpha/types.rst deleted file mode 100644 index 30d49a78..00000000 --- a/owl-bot-staging/v1alpha/docs/admin_v1alpha/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Analytics Admin v1alpha API -============================================ - -.. automodule:: google.analytics.admin_v1alpha.types - :members: - :undoc-members: - :show-inheritance: diff --git a/owl-bot-staging/v1alpha/docs/conf.py b/owl-bot-staging/v1alpha/docs/conf.py deleted file mode 100644 index 01d2cf47..00000000 --- a/owl-bot-staging/v1alpha/docs/conf.py +++ /dev/null @@ -1,378 +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-analytics-admin 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-analytics-admin" -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 Analytics 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-analytics-admin-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-analytics-admin.tex", - u"google-analytics-admin 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-analytics-admin", - u"Google Analytics Admin 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-analytics-admin", - u"google-analytics-admin Documentation", - author, - "google-analytics-admin", - "GAPIC library for Google Analytics Admin 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/v1alpha/docs/index.rst b/owl-bot-staging/v1alpha/docs/index.rst deleted file mode 100644 index f2ac5cfe..00000000 --- a/owl-bot-staging/v1alpha/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - admin_v1alpha/services - admin_v1alpha/types diff --git a/owl-bot-staging/v1alpha/google/analytics/admin/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin/__init__.py deleted file mode 100644 index 323582ba..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin/__init__.py +++ /dev/null @@ -1,180 +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.analytics.admin_v1alpha.services.analytics_admin_service.async_client import AnalyticsAdminServiceAsyncClient -from google.analytics.admin_v1alpha.services.analytics_admin_service.client import AnalyticsAdminServiceClient -from google.analytics.admin_v1alpha.types.analytics_admin import AuditUserLinksRequest -from google.analytics.admin_v1alpha.types.analytics_admin import AuditUserLinksResponse -from google.analytics.admin_v1alpha.types.analytics_admin import BatchCreateUserLinksRequest -from google.analytics.admin_v1alpha.types.analytics_admin import BatchCreateUserLinksResponse -from google.analytics.admin_v1alpha.types.analytics_admin import BatchDeleteUserLinksRequest -from google.analytics.admin_v1alpha.types.analytics_admin import BatchGetUserLinksRequest -from google.analytics.admin_v1alpha.types.analytics_admin import BatchGetUserLinksResponse -from google.analytics.admin_v1alpha.types.analytics_admin import BatchUpdateUserLinksRequest -from google.analytics.admin_v1alpha.types.analytics_admin import BatchUpdateUserLinksResponse -from google.analytics.admin_v1alpha.types.analytics_admin import CreateAndroidAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import CreateFirebaseLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import CreateGoogleAdsLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import CreateIosAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import CreatePropertyRequest -from google.analytics.admin_v1alpha.types.analytics_admin import CreateUserLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import CreateWebDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import DeleteAccountRequest -from google.analytics.admin_v1alpha.types.analytics_admin import DeleteAndroidAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import DeleteFirebaseLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import DeleteGoogleAdsLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import DeleteIosAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import DeletePropertyRequest -from google.analytics.admin_v1alpha.types.analytics_admin import DeleteUserLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import DeleteWebDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetAccountRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetAndroidAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetDataSharingSettingsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetEnhancedMeasurementSettingsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetGlobalSiteTagRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetIosAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetPropertyRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetUserLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetWebDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountSummariesRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountSummariesResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListAndroidAppDataStreamsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListAndroidAppDataStreamsResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListFirebaseLinksRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListFirebaseLinksResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListGoogleAdsLinksRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListGoogleAdsLinksResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListIosAppDataStreamsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListIosAppDataStreamsResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListPropertiesRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListPropertiesResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListUserLinksRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListUserLinksResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListWebDataStreamsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListWebDataStreamsResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ProvisionAccountTicketRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ProvisionAccountTicketResponse -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateAccountRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateAndroidAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateEnhancedMeasurementSettingsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateFirebaseLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateGoogleAdsLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateIosAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdatePropertyRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateUserLinkRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateWebDataStreamRequest -from google.analytics.admin_v1alpha.types.resources import Account -from google.analytics.admin_v1alpha.types.resources import AccountSummary -from google.analytics.admin_v1alpha.types.resources import AndroidAppDataStream -from google.analytics.admin_v1alpha.types.resources import AuditUserLink -from google.analytics.admin_v1alpha.types.resources import DataSharingSettings -from google.analytics.admin_v1alpha.types.resources import EnhancedMeasurementSettings -from google.analytics.admin_v1alpha.types.resources import FirebaseLink -from google.analytics.admin_v1alpha.types.resources import GlobalSiteTag -from google.analytics.admin_v1alpha.types.resources import GoogleAdsLink -from google.analytics.admin_v1alpha.types.resources import IndustryCategory -from google.analytics.admin_v1alpha.types.resources import IosAppDataStream -from google.analytics.admin_v1alpha.types.resources import MaximumUserAccess -from google.analytics.admin_v1alpha.types.resources import Property -from google.analytics.admin_v1alpha.types.resources import PropertySummary -from google.analytics.admin_v1alpha.types.resources import UserLink -from google.analytics.admin_v1alpha.types.resources import WebDataStream - -__all__ = ( - 'Account', - 'AccountSummary', - 'AnalyticsAdminServiceAsyncClient', - 'AnalyticsAdminServiceClient', - 'AndroidAppDataStream', - 'AuditUserLink', - 'AuditUserLinksRequest', - 'AuditUserLinksResponse', - 'BatchCreateUserLinksRequest', - 'BatchCreateUserLinksResponse', - 'BatchDeleteUserLinksRequest', - 'BatchGetUserLinksRequest', - 'BatchGetUserLinksResponse', - 'BatchUpdateUserLinksRequest', - 'BatchUpdateUserLinksResponse', - 'CreateAndroidAppDataStreamRequest', - 'CreateFirebaseLinkRequest', - 'CreateGoogleAdsLinkRequest', - 'CreateIosAppDataStreamRequest', - 'CreatePropertyRequest', - 'CreateUserLinkRequest', - 'CreateWebDataStreamRequest', - 'DataSharingSettings', - 'DeleteAccountRequest', - 'DeleteAndroidAppDataStreamRequest', - 'DeleteFirebaseLinkRequest', - 'DeleteGoogleAdsLinkRequest', - 'DeleteIosAppDataStreamRequest', - 'DeletePropertyRequest', - 'DeleteUserLinkRequest', - 'DeleteWebDataStreamRequest', - 'EnhancedMeasurementSettings', - 'FirebaseLink', - 'GetAccountRequest', - 'GetAndroidAppDataStreamRequest', - 'GetDataSharingSettingsRequest', - 'GetEnhancedMeasurementSettingsRequest', - 'GetGlobalSiteTagRequest', - 'GetIosAppDataStreamRequest', - 'GetPropertyRequest', - 'GetUserLinkRequest', - 'GetWebDataStreamRequest', - 'GlobalSiteTag', - 'GoogleAdsLink', - 'IndustryCategory', - 'IosAppDataStream', - 'ListAccountSummariesRequest', - 'ListAccountSummariesResponse', - 'ListAccountsRequest', - 'ListAccountsResponse', - 'ListAndroidAppDataStreamsRequest', - 'ListAndroidAppDataStreamsResponse', - 'ListFirebaseLinksRequest', - 'ListFirebaseLinksResponse', - 'ListGoogleAdsLinksRequest', - 'ListGoogleAdsLinksResponse', - 'ListIosAppDataStreamsRequest', - 'ListIosAppDataStreamsResponse', - 'ListPropertiesRequest', - 'ListPropertiesResponse', - 'ListUserLinksRequest', - 'ListUserLinksResponse', - 'ListWebDataStreamsRequest', - 'ListWebDataStreamsResponse', - 'MaximumUserAccess', - 'Property', - 'PropertySummary', - 'ProvisionAccountTicketRequest', - 'ProvisionAccountTicketResponse', - 'UpdateAccountRequest', - 'UpdateAndroidAppDataStreamRequest', - 'UpdateEnhancedMeasurementSettingsRequest', - 'UpdateFirebaseLinkRequest', - 'UpdateGoogleAdsLinkRequest', - 'UpdateIosAppDataStreamRequest', - 'UpdatePropertyRequest', - 'UpdateUserLinkRequest', - 'UpdateWebDataStreamRequest', - 'UserLink', - 'WebDataStream', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin/py.typed b/owl-bot-staging/v1alpha/google/analytics/admin/py.typed deleted file mode 100644 index 3b7eb147..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-analytics-admin package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py deleted file mode 100644 index 38cfae6f..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py +++ /dev/null @@ -1,179 +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.analytics_admin_service import AnalyticsAdminServiceClient -from .types.analytics_admin import AuditUserLinksRequest -from .types.analytics_admin import AuditUserLinksResponse -from .types.analytics_admin import BatchCreateUserLinksRequest -from .types.analytics_admin import BatchCreateUserLinksResponse -from .types.analytics_admin import BatchDeleteUserLinksRequest -from .types.analytics_admin import BatchGetUserLinksRequest -from .types.analytics_admin import BatchGetUserLinksResponse -from .types.analytics_admin import BatchUpdateUserLinksRequest -from .types.analytics_admin import BatchUpdateUserLinksResponse -from .types.analytics_admin import CreateAndroidAppDataStreamRequest -from .types.analytics_admin import CreateFirebaseLinkRequest -from .types.analytics_admin import CreateGoogleAdsLinkRequest -from .types.analytics_admin import CreateIosAppDataStreamRequest -from .types.analytics_admin import CreatePropertyRequest -from .types.analytics_admin import CreateUserLinkRequest -from .types.analytics_admin import CreateWebDataStreamRequest -from .types.analytics_admin import DeleteAccountRequest -from .types.analytics_admin import DeleteAndroidAppDataStreamRequest -from .types.analytics_admin import DeleteFirebaseLinkRequest -from .types.analytics_admin import DeleteGoogleAdsLinkRequest -from .types.analytics_admin import DeleteIosAppDataStreamRequest -from .types.analytics_admin import DeletePropertyRequest -from .types.analytics_admin import DeleteUserLinkRequest -from .types.analytics_admin import DeleteWebDataStreamRequest -from .types.analytics_admin import GetAccountRequest -from .types.analytics_admin import GetAndroidAppDataStreamRequest -from .types.analytics_admin import GetDataSharingSettingsRequest -from .types.analytics_admin import GetEnhancedMeasurementSettingsRequest -from .types.analytics_admin import GetGlobalSiteTagRequest -from .types.analytics_admin import GetIosAppDataStreamRequest -from .types.analytics_admin import GetPropertyRequest -from .types.analytics_admin import GetUserLinkRequest -from .types.analytics_admin import GetWebDataStreamRequest -from .types.analytics_admin import ListAccountSummariesRequest -from .types.analytics_admin import ListAccountSummariesResponse -from .types.analytics_admin import ListAccountsRequest -from .types.analytics_admin import ListAccountsResponse -from .types.analytics_admin import ListAndroidAppDataStreamsRequest -from .types.analytics_admin import ListAndroidAppDataStreamsResponse -from .types.analytics_admin import ListFirebaseLinksRequest -from .types.analytics_admin import ListFirebaseLinksResponse -from .types.analytics_admin import ListGoogleAdsLinksRequest -from .types.analytics_admin import ListGoogleAdsLinksResponse -from .types.analytics_admin import ListIosAppDataStreamsRequest -from .types.analytics_admin import ListIosAppDataStreamsResponse -from .types.analytics_admin import ListPropertiesRequest -from .types.analytics_admin import ListPropertiesResponse -from .types.analytics_admin import ListUserLinksRequest -from .types.analytics_admin import ListUserLinksResponse -from .types.analytics_admin import ListWebDataStreamsRequest -from .types.analytics_admin import ListWebDataStreamsResponse -from .types.analytics_admin import ProvisionAccountTicketRequest -from .types.analytics_admin import ProvisionAccountTicketResponse -from .types.analytics_admin import UpdateAccountRequest -from .types.analytics_admin import UpdateAndroidAppDataStreamRequest -from .types.analytics_admin import UpdateEnhancedMeasurementSettingsRequest -from .types.analytics_admin import UpdateFirebaseLinkRequest -from .types.analytics_admin import UpdateGoogleAdsLinkRequest -from .types.analytics_admin import UpdateIosAppDataStreamRequest -from .types.analytics_admin import UpdatePropertyRequest -from .types.analytics_admin import UpdateUserLinkRequest -from .types.analytics_admin import UpdateWebDataStreamRequest -from .types.resources import Account -from .types.resources import AccountSummary -from .types.resources import AndroidAppDataStream -from .types.resources import AuditUserLink -from .types.resources import DataSharingSettings -from .types.resources import EnhancedMeasurementSettings -from .types.resources import FirebaseLink -from .types.resources import GlobalSiteTag -from .types.resources import GoogleAdsLink -from .types.resources import IndustryCategory -from .types.resources import IosAppDataStream -from .types.resources import MaximumUserAccess -from .types.resources import Property -from .types.resources import PropertySummary -from .types.resources import UserLink -from .types.resources import WebDataStream - - -__all__ = ( - 'Account', - 'AccountSummary', - 'AndroidAppDataStream', - 'AuditUserLink', - 'AuditUserLinksRequest', - 'AuditUserLinksResponse', - 'BatchCreateUserLinksRequest', - 'BatchCreateUserLinksResponse', - 'BatchDeleteUserLinksRequest', - 'BatchGetUserLinksRequest', - 'BatchGetUserLinksResponse', - 'BatchUpdateUserLinksRequest', - 'BatchUpdateUserLinksResponse', - 'CreateAndroidAppDataStreamRequest', - 'CreateFirebaseLinkRequest', - 'CreateGoogleAdsLinkRequest', - 'CreateIosAppDataStreamRequest', - 'CreatePropertyRequest', - 'CreateUserLinkRequest', - 'CreateWebDataStreamRequest', - 'DataSharingSettings', - 'DeleteAccountRequest', - 'DeleteAndroidAppDataStreamRequest', - 'DeleteFirebaseLinkRequest', - 'DeleteGoogleAdsLinkRequest', - 'DeleteIosAppDataStreamRequest', - 'DeletePropertyRequest', - 'DeleteUserLinkRequest', - 'DeleteWebDataStreamRequest', - 'EnhancedMeasurementSettings', - 'FirebaseLink', - 'GetAccountRequest', - 'GetAndroidAppDataStreamRequest', - 'GetDataSharingSettingsRequest', - 'GetEnhancedMeasurementSettingsRequest', - 'GetGlobalSiteTagRequest', - 'GetIosAppDataStreamRequest', - 'GetPropertyRequest', - 'GetUserLinkRequest', - 'GetWebDataStreamRequest', - 'GlobalSiteTag', - 'GoogleAdsLink', - 'IndustryCategory', - 'IosAppDataStream', - 'ListAccountSummariesRequest', - 'ListAccountSummariesResponse', - 'ListAccountsRequest', - 'ListAccountsResponse', - 'ListAndroidAppDataStreamsRequest', - 'ListAndroidAppDataStreamsResponse', - 'ListFirebaseLinksRequest', - 'ListFirebaseLinksResponse', - 'ListGoogleAdsLinksRequest', - 'ListGoogleAdsLinksResponse', - 'ListIosAppDataStreamsRequest', - 'ListIosAppDataStreamsResponse', - 'ListPropertiesRequest', - 'ListPropertiesResponse', - 'ListUserLinksRequest', - 'ListUserLinksResponse', - 'ListWebDataStreamsRequest', - 'ListWebDataStreamsResponse', - 'MaximumUserAccess', - 'Property', - 'PropertySummary', - 'ProvisionAccountTicketRequest', - 'ProvisionAccountTicketResponse', - 'UpdateAccountRequest', - 'UpdateAndroidAppDataStreamRequest', - 'UpdateEnhancedMeasurementSettingsRequest', - 'UpdateFirebaseLinkRequest', - 'UpdateGoogleAdsLinkRequest', - 'UpdateIosAppDataStreamRequest', - 'UpdatePropertyRequest', - 'UpdateUserLinkRequest', - 'UpdateWebDataStreamRequest', - 'UserLink', - 'WebDataStream', -'AnalyticsAdminServiceClient', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/py.typed b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/py.typed deleted file mode 100644 index 3b7eb147..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-analytics-admin package uses inline types. diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__init__.py deleted file mode 100644 index 42ffdf2b..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__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/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py deleted file mode 100644 index f5002cbc..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py +++ /dev/null @@ -1,24 +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 AnalyticsAdminServiceClient -from .async_client import AnalyticsAdminServiceAsyncClient - -__all__ = ( - 'AnalyticsAdminServiceClient', - 'AnalyticsAdminServiceAsyncClient', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py deleted file mode 100644 index 0d1d0050..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py +++ /dev/null @@ -1,4014 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers -from google.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore - -from .transports.base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport -from .client import AnalyticsAdminServiceClient - - -class AnalyticsAdminServiceAsyncClient: - """Service Interface for the Analytics Admin API (GA4).""" - - _client: AnalyticsAdminServiceClient - - DEFAULT_ENDPOINT = AnalyticsAdminServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = AnalyticsAdminServiceClient.DEFAULT_MTLS_ENDPOINT - - account_path = staticmethod(AnalyticsAdminServiceClient.account_path) - parse_account_path = staticmethod(AnalyticsAdminServiceClient.parse_account_path) - account_summary_path = staticmethod(AnalyticsAdminServiceClient.account_summary_path) - parse_account_summary_path = staticmethod(AnalyticsAdminServiceClient.parse_account_summary_path) - android_app_data_stream_path = staticmethod(AnalyticsAdminServiceClient.android_app_data_stream_path) - parse_android_app_data_stream_path = staticmethod(AnalyticsAdminServiceClient.parse_android_app_data_stream_path) - data_sharing_settings_path = staticmethod(AnalyticsAdminServiceClient.data_sharing_settings_path) - parse_data_sharing_settings_path = staticmethod(AnalyticsAdminServiceClient.parse_data_sharing_settings_path) - enhanced_measurement_settings_path = staticmethod(AnalyticsAdminServiceClient.enhanced_measurement_settings_path) - parse_enhanced_measurement_settings_path = staticmethod(AnalyticsAdminServiceClient.parse_enhanced_measurement_settings_path) - firebase_link_path = staticmethod(AnalyticsAdminServiceClient.firebase_link_path) - parse_firebase_link_path = staticmethod(AnalyticsAdminServiceClient.parse_firebase_link_path) - global_site_tag_path = staticmethod(AnalyticsAdminServiceClient.global_site_tag_path) - parse_global_site_tag_path = staticmethod(AnalyticsAdminServiceClient.parse_global_site_tag_path) - google_ads_link_path = staticmethod(AnalyticsAdminServiceClient.google_ads_link_path) - parse_google_ads_link_path = staticmethod(AnalyticsAdminServiceClient.parse_google_ads_link_path) - ios_app_data_stream_path = staticmethod(AnalyticsAdminServiceClient.ios_app_data_stream_path) - parse_ios_app_data_stream_path = staticmethod(AnalyticsAdminServiceClient.parse_ios_app_data_stream_path) - property_path = staticmethod(AnalyticsAdminServiceClient.property_path) - parse_property_path = staticmethod(AnalyticsAdminServiceClient.parse_property_path) - user_link_path = staticmethod(AnalyticsAdminServiceClient.user_link_path) - parse_user_link_path = staticmethod(AnalyticsAdminServiceClient.parse_user_link_path) - web_data_stream_path = staticmethod(AnalyticsAdminServiceClient.web_data_stream_path) - parse_web_data_stream_path = staticmethod(AnalyticsAdminServiceClient.parse_web_data_stream_path) - - common_billing_account_path = staticmethod(AnalyticsAdminServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(AnalyticsAdminServiceClient.parse_common_billing_account_path) - - common_folder_path = staticmethod(AnalyticsAdminServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(AnalyticsAdminServiceClient.parse_common_folder_path) - - common_organization_path = staticmethod(AnalyticsAdminServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(AnalyticsAdminServiceClient.parse_common_organization_path) - - common_project_path = staticmethod(AnalyticsAdminServiceClient.common_project_path) - parse_common_project_path = staticmethod(AnalyticsAdminServiceClient.parse_common_project_path) - - common_location_path = staticmethod(AnalyticsAdminServiceClient.common_location_path) - parse_common_location_path = staticmethod(AnalyticsAdminServiceClient.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: - AnalyticsAdminServiceAsyncClient: The constructed client. - """ - return AnalyticsAdminServiceClient.from_service_account_info.__func__(AnalyticsAdminServiceAsyncClient, 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: - AnalyticsAdminServiceAsyncClient: The constructed client. - """ - return AnalyticsAdminServiceClient.from_service_account_file.__func__(AnalyticsAdminServiceAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> AnalyticsAdminServiceTransport: - """Return the transport used by the client instance. - - Returns: - AnalyticsAdminServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(AnalyticsAdminServiceClient).get_transport_class, type(AnalyticsAdminServiceClient)) - - def __init__(self, *, - credentials: credentials.Credentials = None, - transport: Union[str, AnalyticsAdminServiceTransport] = 'grpc_asyncio', - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the analytics admin service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.AnalyticsAdminServiceTransport]): 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 = AnalyticsAdminServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def get_account(self, - request: analytics_admin.GetAccountRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Account: - r"""Lookup for a single Account. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetAccountRequest`): - The request object. Request message for GetAccount RPC. - name (:class:`str`): - Required. The name of the account to - lookup. Format: accounts/{account} - Example: "accounts/100" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.Account: - A resource message representing a - Google Analytics account. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = analytics_admin.GetAccountRequest(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_account, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_accounts(self, - request: analytics_admin.ListAccountsRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAccountsAsyncPager: - r"""Returns all accounts accessible by the caller. - Note that these accounts might not currently have GA4 - properties. Soft-deleted (ie: "trashed") accounts are - excluded by default. Returns an empty list if no - relevant accounts are found. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListAccountsRequest`): - The request object. Request message for ListAccounts - RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsAsyncPager: - Request message for ListAccounts RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.ListAccountsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_accounts, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListAccountsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_account(self, - request: analytics_admin.DeleteAccountRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Marks target Account as soft-deleted (ie: "trashed") - and returns it. - This API does not have a method to restore soft-deleted - accounts. However, they can be restored using the Trash - Can UI. - If the accounts are not restored before the expiration - time, the account and all child resources (eg: - Properties, GoogleAdsLinks, Streams, UserLinks) will be - permanently purged. - https://support.google.com/analytics/answer/6154772 - Returns an error if the target is not found. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteAccountRequest`): - The request object. Request message for DeleteAccount - RPC. - name (:class:`str`): - Required. The name of the Account to - soft-delete. Format: accounts/{account} - Example: "accounts/100" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.DeleteAccountRequest(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_account, - 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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def update_account(self, - request: analytics_admin.UpdateAccountRequest = None, - *, - account: resources.Account = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Account: - r"""Updates an account. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateAccountRequest`): - The request object. Request message for UpdateAccount - RPC. - account (:class:`google.analytics.admin_v1alpha.types.Account`): - Required. The account to update. The account's ``name`` - field is used to identify the account. - - This corresponds to the ``account`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.Account: - A resource message representing a - Google Analytics account. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([account, 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 = analytics_admin.UpdateAccountRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if account is not None: - request.account = account - 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_account, - 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(( - ('account.name', request.account.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def provision_account_ticket(self, - request: analytics_admin.ProvisionAccountTicketRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.ProvisionAccountTicketResponse: - r"""Requests a ticket for creating an account. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ProvisionAccountTicketRequest`): - The request object. Request message for - ProvisionAccountTicket RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.ProvisionAccountTicketResponse: - Response message for - ProvisionAccountTicket RPC. - - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.ProvisionAccountTicketRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.provision_account_ticket, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_account_summaries(self, - request: analytics_admin.ListAccountSummariesRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAccountSummariesAsyncPager: - r"""Returns summaries of all accounts accessible by the - caller. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListAccountSummariesRequest`): - The request object. Request message for - ListAccountSummaries RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountSummariesAsyncPager: - Response message for - ListAccountSummaries RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.ListAccountSummariesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_account_summaries, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListAccountSummariesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_property(self, - request: analytics_admin.GetPropertyRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Property: - r"""Lookup for a single "GA4" Property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetPropertyRequest`): - The request object. Request message for GetProperty RPC. - name (:class:`str`): - Required. The name of the property to lookup. Format: - properties/{property_id} Example: "properties/1000" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.Property: - A resource message representing a - Google Analytics GA4 property. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = analytics_admin.GetPropertyRequest(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_property, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_properties(self, - request: analytics_admin.ListPropertiesRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPropertiesAsyncPager: - r"""Returns child Properties under the specified parent - Account. - Only "GA4" properties will be returned. - Properties will be excluded if the caller does not have - access. Soft-deleted (ie: "trashed") properties are - excluded by default. Returns an empty list if no - relevant properties are found. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListPropertiesRequest`): - The request object. Request message for ListProperties - RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListPropertiesAsyncPager: - Response message for ListProperties - RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.ListPropertiesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_properties, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListPropertiesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_property(self, - request: analytics_admin.CreatePropertyRequest = None, - *, - property: resources.Property = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Property: - r"""Creates an "GA4" property with the specified location - and attributes. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreatePropertyRequest`): - The request object. Request message for CreateProperty - RPC. - property (:class:`google.analytics.admin_v1alpha.types.Property`): - Required. The property to create. - Note: the supplied property must specify - its parent. - - This corresponds to the ``property`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.Property: - A resource message representing a - Google Analytics GA4 property. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([property]) - if request is 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 = analytics_admin.CreatePropertyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if property is not None: - request.property = property - - # 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_property, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_property(self, - request: analytics_admin.DeletePropertyRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Marks target Property as soft-deleted (ie: "trashed") - and returns it. - This API does not have a method to restore soft-deleted - properties. However, they can be restored using the - Trash Can UI. - If the properties are not restored before the expiration - time, the Property and all child resources (eg: - GoogleAdsLinks, Streams, UserLinks) will be permanently - purged. - https://support.google.com/analytics/answer/6154772 - Returns an error if the target is not found, or is not - an GA4 Property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeletePropertyRequest`): - The request object. Request message for DeleteProperty - RPC. - name (:class:`str`): - Required. The name of the Property to soft-delete. - Format: properties/{property_id} Example: - "properties/1000" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.DeletePropertyRequest(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_property, - 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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def update_property(self, - request: analytics_admin.UpdatePropertyRequest = None, - *, - property: resources.Property = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Property: - r"""Updates a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdatePropertyRequest`): - The request object. Request message for UpdateProperty - RPC. - property (:class:`google.analytics.admin_v1alpha.types.Property`): - Required. The property to update. The property's - ``name`` field is used to identify the property to be - updated. - - This corresponds to the ``property`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.Property: - A resource message representing a - Google Analytics GA4 property. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([property, 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 = analytics_admin.UpdatePropertyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if property is not None: - request.property = property - 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_property, - 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(( - ('property.name', request.property.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_user_link(self, - request: analytics_admin.GetUserLinkRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.UserLink: - r"""Gets information about a user's link to an account or - property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetUserLinkRequest`): - The request object. Request message for GetUserLink RPC. - name (:class:`str`): - Required. Example format: - accounts/1234/userLinks/5678 - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.UserLink: - A resource message representing a - user's permissions on an Account or - Property resource. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.GetUserLinkRequest(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_user_link, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def batch_get_user_links(self, - request: analytics_admin.BatchGetUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.BatchGetUserLinksResponse: - r"""Gets information about multiple users' links to an - account or property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest`): - The request object. Request message for - BatchGetUserLinks RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse: - Response message for - BatchGetUserLinks RPC. - - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.BatchGetUserLinksRequest(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.batch_get_user_links, - 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, - ) - - # Done; return the response. - return response - - async def list_user_links(self, - request: analytics_admin.ListUserLinksRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListUserLinksAsyncPager: - r"""Lists all user links on an account or property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListUserLinksRequest`): - The request object. Request message for ListUserLinks - RPC. - parent (:class:`str`): - Required. Example format: - accounts/1234 - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListUserLinksAsyncPager: - Response message for ListUserLinks - RPC. - 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 = analytics_admin.ListUserLinksRequest(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_user_links, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListUserLinksAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def audit_user_links(self, - request: analytics_admin.AuditUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.AuditUserLinksAsyncPager: - r"""Lists all user links on an account or property, - including implicit ones that come from effective - permissions granted by groups or organization admin - roles. - - If a returned user link does not have direct - permissions, they cannot be removed from the account or - property directly with the DeleteUserLink command. They - have to be removed from the group/etc that gives them - permissions, which is currently only usable/discoverable - in the GA or GMP UIs. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.AuditUserLinksRequest`): - The request object. Request message for AuditUserLinks - RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.AuditUserLinksAsyncPager: - Response message for AuditUserLinks - RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.AuditUserLinksRequest(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.audit_user_links, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.AuditUserLinksAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_user_link(self, - request: analytics_admin.CreateUserLinkRequest = None, - *, - parent: str = None, - user_link: resources.UserLink = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.UserLink: - r"""Creates a user link on an account or property. - If the user with the specified email already has - permissions on the account or property, then the user's - existing permissions will be unioned with the - permissions specified in the new UserLink. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateUserLinkRequest`): - The request object. Request message for CreateUserLink - RPC. - Users can have multiple email addresses associated with - their Google account, and one of these email addresses - is the "primary" email address. Any of the email - addresses associated with a Google account may be used - for a new UserLink, but the returned UserLink will - always contain the "primary" email address. As a result, - the input and output email address for this request may - differ. - parent (:class:`str`): - Required. Example format: - accounts/1234 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - user_link (:class:`google.analytics.admin_v1alpha.types.UserLink`): - Required. The user link to create. - This corresponds to the ``user_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.UserLink: - A resource message representing a - user's permissions on an Account or - Property resource. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, user_link]) - if request is 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 = analytics_admin.CreateUserLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if user_link is not None: - request.user_link = user_link - - # 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_user_link, - 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, - ) - - # Done; return the response. - return response - - async def batch_create_user_links(self, - request: analytics_admin.BatchCreateUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.BatchCreateUserLinksResponse: - r"""Creates information about multiple users' links to an - account or property. - This method is transactional. If any UserLink cannot be - created, none of the UserLinks will be created. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest`): - The request object. Request message for - BatchCreateUserLinks RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse: - Response message for - BatchCreateUserLinks RPC. - - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.BatchCreateUserLinksRequest(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.batch_create_user_links, - 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, - ) - - # Done; return the response. - return response - - async def update_user_link(self, - request: analytics_admin.UpdateUserLinkRequest = None, - *, - user_link: resources.UserLink = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.UserLink: - r"""Updates a user link on an account or property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateUserLinkRequest`): - The request object. Request message for UpdateUserLink - RPC. - user_link (:class:`google.analytics.admin_v1alpha.types.UserLink`): - Required. The user link to update. - This corresponds to the ``user_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.UserLink: - A resource message representing a - user's permissions on an Account or - Property resource. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([user_link]) - if request is 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 = analytics_admin.UpdateUserLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if user_link is not None: - request.user_link = user_link - - # 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_user_link, - 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(( - ('user_link.name', request.user_link.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def batch_update_user_links(self, - request: analytics_admin.BatchUpdateUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.BatchUpdateUserLinksResponse: - r"""Updates information about multiple users' links to an - account or property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest`): - The request object. Request message for - BatchUpdateUserLinks RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse: - Response message for - BatchUpdateUserLinks RPC. - - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.BatchUpdateUserLinksRequest(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.batch_update_user_links, - 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, - ) - - # Done; return the response. - return response - - async def delete_user_link(self, - request: analytics_admin.DeleteUserLinkRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a user link on an account or property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteUserLinkRequest`): - The request object. Request message for DeleteUserLink - RPC. - name (:class:`str`): - Required. Example format: - accounts/1234/userLinks/5678 - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.DeleteUserLinkRequest(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_user_link, - 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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def batch_delete_user_links(self, - request: analytics_admin.BatchDeleteUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes information about multiple users' links to an - account or property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest`): - The request object. Request message for - BatchDeleteUserLinks RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - - request = analytics_admin.BatchDeleteUserLinksRequest(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.batch_delete_user_links, - 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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def get_web_data_stream(self, - request: analytics_admin.GetWebDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.WebDataStream: - r"""Lookup for a single WebDataStream - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetWebDataStreamRequest`): - The request object. Request message for GetWebDataStream - RPC. - name (:class:`str`): - Required. The name of the web data stream to lookup. - Format: - properties/{property_id}/webDataStreams/{stream_id} - Example: "properties/123/webDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.WebDataStream: - A resource message representing a - Google Analytics web 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 = analytics_admin.GetWebDataStreamRequest(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_web_data_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, - ) - - # Done; return the response. - return response - - async def delete_web_data_stream(self, - request: analytics_admin.DeleteWebDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a web stream on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteWebDataStreamRequest`): - The request object. Request message for - DeleteWebDataStream RPC. - name (:class:`str`): - Required. The name of the web data stream to delete. - Format: - properties/{property_id}/webDataStreams/{stream_id} - Example: "properties/123/webDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.DeleteWebDataStreamRequest(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_web_data_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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def update_web_data_stream(self, - request: analytics_admin.UpdateWebDataStreamRequest = None, - *, - web_data_stream: resources.WebDataStream = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.WebDataStream: - r"""Updates a web stream on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateWebDataStreamRequest`): - The request object. Request message for - UpdateWebDataStream RPC. - web_data_stream (:class:`google.analytics.admin_v1alpha.types.WebDataStream`): - Required. The web stream to update. The ``name`` field - is used to identify the web stream to be updated. - - This corresponds to the ``web_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.WebDataStream: - A resource message representing a - Google Analytics web 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([web_data_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 = analytics_admin.UpdateWebDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if web_data_stream is not None: - request.web_data_stream = web_data_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_web_data_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(( - ('web_data_stream.name', request.web_data_stream.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_web_data_stream(self, - request: analytics_admin.CreateWebDataStreamRequest = None, - *, - parent: str = None, - web_data_stream: resources.WebDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.WebDataStream: - r"""Creates a web stream with the specified location and - attributes. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateWebDataStreamRequest`): - The request object. Request message for - CreateWebDataStream RPC. - parent (:class:`str`): - Required. The parent resource where - this web data stream will be created. - Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - web_data_stream (:class:`google.analytics.admin_v1alpha.types.WebDataStream`): - Required. The web stream to create. - This corresponds to the ``web_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.WebDataStream: - A resource message representing a - Google Analytics web 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, web_data_stream]) - if request is 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 = analytics_admin.CreateWebDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if web_data_stream is not None: - request.web_data_stream = web_data_stream - - # 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_web_data_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, - ) - - # Done; return the response. - return response - - async def list_web_data_streams(self, - request: analytics_admin.ListWebDataStreamsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListWebDataStreamsAsyncPager: - r"""Returns child web data streams under the specified - parent property. - Web data streams will be excluded if the caller does not - have access. Returns an empty list if no relevant web - data streams are found. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest`): - The request object. Request message for - ListWebDataStreams RPC. - parent (:class:`str`): - Required. The name of the parent - property. For example, to list results - of web streams under the property with - Id 123: "properties/123" - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListWebDataStreamsAsyncPager: - Request message for - ListWebDataStreams RPC. - 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 = analytics_admin.ListWebDataStreamsRequest(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_web_data_streams, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListWebDataStreamsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_ios_app_data_stream(self, - request: analytics_admin.GetIosAppDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IosAppDataStream: - r"""Lookup for a single IosAppDataStream - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetIosAppDataStreamRequest`): - The request object. Request message for - GetIosAppDataStream RPC. - name (:class:`str`): - Required. The name of the iOS app data stream to lookup. - Format: - properties/{property_id}/iosAppDataStreams/{stream_id} - Example: "properties/123/iosAppDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.IosAppDataStream: - A resource message representing a - Google Analytics IOS app 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 = analytics_admin.GetIosAppDataStreamRequest(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_ios_app_data_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, - ) - - # Done; return the response. - return response - - async def delete_ios_app_data_stream(self, - request: analytics_admin.DeleteIosAppDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes an iOS app stream on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteIosAppDataStreamRequest`): - The request object. Request message for - DeleteIosAppDataStream RPC. - name (:class:`str`): - Required. The name of the iOS app data stream to delete. - Format: - properties/{property_id}/iosAppDataStreams/{stream_id} - Example: "properties/123/iosAppDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.DeleteIosAppDataStreamRequest(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_ios_app_data_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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def update_ios_app_data_stream(self, - request: analytics_admin.UpdateIosAppDataStreamRequest = None, - *, - ios_app_data_stream: resources.IosAppDataStream = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IosAppDataStream: - r"""Updates an iOS app stream on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateIosAppDataStreamRequest`): - The request object. Request message for - UpdateIosAppDataStream RPC. - ios_app_data_stream (:class:`google.analytics.admin_v1alpha.types.IosAppDataStream`): - Required. The iOS app stream to update. The ``name`` - field is used to identify the iOS app stream to be - updated. - - This corresponds to the ``ios_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.IosAppDataStream: - A resource message representing a - Google Analytics IOS app 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([ios_app_data_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 = analytics_admin.UpdateIosAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if ios_app_data_stream is not None: - request.ios_app_data_stream = ios_app_data_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_ios_app_data_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(( - ('ios_app_data_stream.name', request.ios_app_data_stream.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_ios_app_data_stream(self, - request: analytics_admin.CreateIosAppDataStreamRequest = None, - *, - parent: str = None, - ios_app_data_stream: resources.IosAppDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IosAppDataStream: - r"""Creates an iOS app stream with the specified location - and attributes. - Note that an iOS app stream must be linked to a Firebase - app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateIosAppDataStreamRequest`): - The request object. Request message for - CreateIosAppDataStream RPC. - parent (:class:`str`): - Required. The parent resource where - this ios app data stream will be - created. Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - ios_app_data_stream (:class:`google.analytics.admin_v1alpha.types.IosAppDataStream`): - Required. The iOS app data stream to - create. - - This corresponds to the ``ios_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.IosAppDataStream: - A resource message representing a - Google Analytics IOS app 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, ios_app_data_stream]) - if request is 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 = analytics_admin.CreateIosAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if ios_app_data_stream is not None: - request.ios_app_data_stream = ios_app_data_stream - - # 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_ios_app_data_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, - ) - - # Done; return the response. - return response - - async def list_ios_app_data_streams(self, - request: analytics_admin.ListIosAppDataStreamsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListIosAppDataStreamsAsyncPager: - r"""Returns child iOS app data streams under the - specified parent property. - iOS app data streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - iOS app data streams are found. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest`): - The request object. Request message for - ListIosAppDataStreams RPC. - parent (:class:`str`): - Required. The name of the parent - property. For example, to list results - of app streams under the property with - Id 123: "properties/123" - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListIosAppDataStreamsAsyncPager: - Request message for - ListIosAppDataStreams RPC. - 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 = analytics_admin.ListIosAppDataStreamsRequest(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_ios_app_data_streams, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListIosAppDataStreamsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_android_app_data_stream(self, - request: analytics_admin.GetAndroidAppDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.AndroidAppDataStream: - r"""Lookup for a single AndroidAppDataStream - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetAndroidAppDataStreamRequest`): - The request object. Request message for - GetAndroidAppDataStream RPC. - name (:class:`str`): - Required. The name of the android app data stream to - lookup. Format: - properties/{property_id}/androidAppDataStreams/{stream_id} - Example: "properties/123/androidAppDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.AndroidAppDataStream: - A resource message representing a - Google Analytics Android app 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 = analytics_admin.GetAndroidAppDataStreamRequest(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_android_app_data_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, - ) - - # Done; return the response. - return response - - async def delete_android_app_data_stream(self, - request: analytics_admin.DeleteAndroidAppDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes an android app stream on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteAndroidAppDataStreamRequest`): - The request object. Request message for - DeleteAndroidAppDataStream RPC. - name (:class:`str`): - Required. The name of the android app data stream to - delete. Format: - properties/{property_id}/androidAppDataStreams/{stream_id} - Example: "properties/123/androidAppDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.DeleteAndroidAppDataStreamRequest(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_android_app_data_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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def update_android_app_data_stream(self, - request: analytics_admin.UpdateAndroidAppDataStreamRequest = None, - *, - android_app_data_stream: resources.AndroidAppDataStream = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.AndroidAppDataStream: - r"""Updates an android app stream on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateAndroidAppDataStreamRequest`): - The request object. Request message for - UpdateAndroidAppDataStream RPC. - android_app_data_stream (:class:`google.analytics.admin_v1alpha.types.AndroidAppDataStream`): - Required. The android app stream to update. The ``name`` - field is used to identify the android app stream to be - updated. - - This corresponds to the ``android_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.AndroidAppDataStream: - A resource message representing a - Google Analytics Android app 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([android_app_data_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 = analytics_admin.UpdateAndroidAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if android_app_data_stream is not None: - request.android_app_data_stream = android_app_data_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_android_app_data_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(( - ('android_app_data_stream.name', request.android_app_data_stream.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_android_app_data_stream(self, - request: analytics_admin.CreateAndroidAppDataStreamRequest = None, - *, - parent: str = None, - android_app_data_stream: resources.AndroidAppDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.AndroidAppDataStream: - r"""Creates an Android app stream with the specified - location and attributes. - Note that an Android app stream must be linked to a - Firebase app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateAndroidAppDataStreamRequest`): - The request object. Request message for - CreateAndroidAppDataStream RPC. - parent (:class:`str`): - Required. The parent resource where - this android app data stream will be - created. Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - android_app_data_stream (:class:`google.analytics.admin_v1alpha.types.AndroidAppDataStream`): - Required. The android app stream to - create. - - This corresponds to the ``android_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.AndroidAppDataStream: - A resource message representing a - Google Analytics Android app 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, android_app_data_stream]) - if request is 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 = analytics_admin.CreateAndroidAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if android_app_data_stream is not None: - request.android_app_data_stream = android_app_data_stream - - # 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_android_app_data_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, - ) - - # Done; return the response. - return response - - async def list_android_app_data_streams(self, - request: analytics_admin.ListAndroidAppDataStreamsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAndroidAppDataStreamsAsyncPager: - r"""Returns child android app streams under the specified - parent property. - Android app streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - android app streams are found. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest`): - The request object. Request message for - ListAndroidAppDataStreams RPC. - parent (:class:`str`): - Required. The name of the parent - property. For example, to limit results - to app streams under the property with - Id 123: "properties/123" - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAndroidAppDataStreamsAsyncPager: - Request message for - ListAndroidDataStreams RPC. - 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 = analytics_admin.ListAndroidAppDataStreamsRequest(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_android_app_data_streams, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListAndroidAppDataStreamsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_enhanced_measurement_settings(self, - request: analytics_admin.GetEnhancedMeasurementSettingsRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.EnhancedMeasurementSettings: - r"""Returns the singleton enhanced measurement settings - for this web stream. Note that the stream must enable - enhanced measurement for these settings to take effect. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest`): - The request object. Request message for - GetEnhancedMeasurementSettings RPC. - name (:class:`str`): - Required. The name of the settings to lookup. Format: - properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings - Example: - "properties/1000/webDataStreams/2000/enhancedMeasurementSettings" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: - Singleton resource under a - WebDataStream, configuring measurement - of additional site interactions and - content. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = analytics_admin.GetEnhancedMeasurementSettingsRequest(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_enhanced_measurement_settings, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_enhanced_measurement_settings(self, - request: analytics_admin.UpdateEnhancedMeasurementSettingsRequest = None, - *, - enhanced_measurement_settings: resources.EnhancedMeasurementSettings = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.EnhancedMeasurementSettings: - r"""Updates the singleton enhanced measurement settings - for this web stream. Note that the stream must enable - enhanced measurement for these settings to take effect. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateEnhancedMeasurementSettingsRequest`): - The request object. Request message for - UpdateEnhancedMeasurementSettings RPC. - enhanced_measurement_settings (:class:`google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings`): - Required. The settings to update. The ``name`` field is - used to identify the settings to be updated. - - This corresponds to the ``enhanced_measurement_settings`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: - Singleton resource under a - WebDataStream, configuring measurement - of additional site interactions and - content. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([enhanced_measurement_settings, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if enhanced_measurement_settings is not None: - request.enhanced_measurement_settings = enhanced_measurement_settings - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_enhanced_measurement_settings, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('enhanced_measurement_settings.name', request.enhanced_measurement_settings.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_firebase_link(self, - request: analytics_admin.CreateFirebaseLinkRequest = None, - *, - parent: str = None, - firebase_link: resources.FirebaseLink = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.FirebaseLink: - r"""Creates a FirebaseLink. - Properties can have at most one FirebaseLink. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest`): - The request object. Request message for - CreateFirebaseLink RPC - parent (:class:`str`): - Required. Format: properties/{property_id} Example: - properties/1234 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - firebase_link (:class:`google.analytics.admin_v1alpha.types.FirebaseLink`): - Required. The Firebase link to - create. - - This corresponds to the ``firebase_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.FirebaseLink: - A link between an GA4 property and a - Firebase project. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, firebase_link]) - if request is 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 = analytics_admin.CreateFirebaseLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if firebase_link is not None: - request.firebase_link = firebase_link - - # 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_firebase_link, - 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, - ) - - # Done; return the response. - return response - - async def update_firebase_link(self, - request: analytics_admin.UpdateFirebaseLinkRequest = None, - *, - firebase_link: resources.FirebaseLink = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.FirebaseLink: - r"""Updates a FirebaseLink on a property - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateFirebaseLinkRequest`): - The request object. Request message for - UpdateFirebaseLink RPC - firebase_link (:class:`google.analytics.admin_v1alpha.types.FirebaseLink`): - Required. The Firebase link to - update. - - This corresponds to the ``firebase_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.FirebaseLink: - A link between an GA4 property and a - Firebase project. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([firebase_link, 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 = analytics_admin.UpdateFirebaseLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if firebase_link is not None: - request.firebase_link = firebase_link - 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_firebase_link, - 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(( - ('firebase_link.name', request.firebase_link.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_firebase_link(self, - request: analytics_admin.DeleteFirebaseLinkRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a FirebaseLink on a property - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteFirebaseLinkRequest`): - The request object. Request message for - DeleteFirebaseLink RPC - name (:class:`str`): - Required. Format: - properties/{property_id}/firebaseLinks/{firebase_link_id} - Example: properties/1234/firebaseLinks/5678 - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.DeleteFirebaseLinkRequest(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_firebase_link, - 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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def list_firebase_links(self, - request: analytics_admin.ListFirebaseLinksRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFirebaseLinksAsyncPager: - r"""Lists FirebaseLinks on a property. - Properties can have at most one FirebaseLink. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest`): - The request object. Request message for - ListFirebaseLinks RPC - parent (:class:`str`): - Required. Format: properties/{property_id} Example: - properties/1234 - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListFirebaseLinksAsyncPager: - Response message for - ListFirebaseLinks RPC - 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 = analytics_admin.ListFirebaseLinksRequest(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_firebase_links, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListFirebaseLinksAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_global_site_tag(self, - request: analytics_admin.GetGlobalSiteTagRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GlobalSiteTag: - r"""Returns the Site Tag for the specified web stream. - Site Tags are immutable singletons. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetGlobalSiteTagRequest`): - The request object. Request message for GetGlobalSiteTag - RPC. - name (:class:`str`): - Required. The name of the site tag to lookup. Note that - site tags are singletons and do not have unique IDs. - Format: - properties/{property_id}/webDataStreams/{stream_id}/globalSiteTag - Example: - "properties/123/webDataStreams/456/globalSiteTag" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.GlobalSiteTag: - Read-only resource with the tag for - sending data from a website to a - WebDataStream. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = analytics_admin.GetGlobalSiteTagRequest(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_global_site_tag, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_google_ads_link(self, - request: analytics_admin.CreateGoogleAdsLinkRequest = None, - *, - parent: str = None, - google_ads_link: resources.GoogleAdsLink = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GoogleAdsLink: - r"""Creates a GoogleAdsLink. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest`): - The request object. Request message for - CreateGoogleAdsLink RPC - parent (:class:`str`): - Required. Example format: - properties/1234 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - google_ads_link (:class:`google.analytics.admin_v1alpha.types.GoogleAdsLink`): - Required. The GoogleAdsLink to - create. - - This corresponds to the ``google_ads_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.GoogleAdsLink: - A link between an GA4 property and a - Google Ads account. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, google_ads_link]) - if request is 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 = analytics_admin.CreateGoogleAdsLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if google_ads_link is not None: - request.google_ads_link = google_ads_link - - # 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_google_ads_link, - 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, - ) - - # Done; return the response. - return response - - async def update_google_ads_link(self, - request: analytics_admin.UpdateGoogleAdsLinkRequest = None, - *, - google_ads_link: resources.GoogleAdsLink = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GoogleAdsLink: - r"""Updates a GoogleAdsLink on a property - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateGoogleAdsLinkRequest`): - The request object. Request message for - UpdateGoogleAdsLink RPC - google_ads_link (:class:`google.analytics.admin_v1alpha.types.GoogleAdsLink`): - The GoogleAdsLink to update - This corresponds to the ``google_ads_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.GoogleAdsLink: - A link between an GA4 property and a - Google Ads account. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([google_ads_link, 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 = analytics_admin.UpdateGoogleAdsLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if google_ads_link is not None: - request.google_ads_link = google_ads_link - 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_google_ads_link, - 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(( - ('google_ads_link.name', request.google_ads_link.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_google_ads_link(self, - request: analytics_admin.DeleteGoogleAdsLinkRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a GoogleAdsLink on a property - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteGoogleAdsLinkRequest`): - The request object. Request message for - DeleteGoogleAdsLink RPC. - name (:class:`str`): - Required. Example format: - properties/1234/googleAdsLinks/5678 - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - request = analytics_admin.DeleteGoogleAdsLinkRequest(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_google_ads_link, - 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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def list_google_ads_links(self, - request: analytics_admin.ListGoogleAdsLinksRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListGoogleAdsLinksAsyncPager: - r"""Lists GoogleAdsLinks on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest`): - The request object. Request message for - ListGoogleAdsLinks RPC. - parent (:class:`str`): - Required. Example format: - properties/1234 - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListGoogleAdsLinksAsyncPager: - Response message for - ListGoogleAdsLinks RPC. - 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 = analytics_admin.ListGoogleAdsLinksRequest(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_google_ads_links, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListGoogleAdsLinksAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_data_sharing_settings(self, - request: analytics_admin.GetDataSharingSettingsRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.DataSharingSettings: - r"""Get data sharing settings on an account. - Data sharing settings are singletons. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetDataSharingSettingsRequest`): - The request object. Request message for - GetDataSharingSettings RPC. - name (:class:`str`): - Required. The name of the settings to - lookup. Format: - accounts/{account}/dataSharingSettings - Example: - "accounts/1000/dataSharingSettings" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.DataSharingSettings: - A resource message representing data - sharing settings of a Google Analytics - account. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = analytics_admin.GetDataSharingSettingsRequest(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_data_sharing_settings, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - - - - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-analytics-admin', - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - 'AnalyticsAdminServiceAsyncClient', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py deleted file mode 100644 index 3fac7ffd..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +++ /dev/null @@ -1,4333 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from collections import OrderedDict -from distutils import util -import os -import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers -from google.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore - -from .transports.base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import AnalyticsAdminServiceGrpcTransport -from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport - - -class AnalyticsAdminServiceClientMeta(type): - """Metaclass for the AnalyticsAdminService 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[AnalyticsAdminServiceTransport]] - _transport_registry['grpc'] = AnalyticsAdminServiceGrpcTransport - _transport_registry['grpc_asyncio'] = AnalyticsAdminServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[AnalyticsAdminServiceTransport]: - """Return 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 AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta): - """Service Interface for the Analytics Admin API (GA4).""" - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Convert 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 = 'analyticsadmin.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: - AnalyticsAdminServiceClient: 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: - AnalyticsAdminServiceClient: 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) -> AnalyticsAdminServiceTransport: - """Return the transport used by the client instance. - - Returns: - AnalyticsAdminServiceTransport: The transport used by the client instance. - """ - return self._transport - - @staticmethod - def account_path(account: str,) -> str: - """Return a fully-qualified account string.""" - return "accounts/{account}".format(account=account, ) - - @staticmethod - def parse_account_path(path: str) -> Dict[str,str]: - """Parse a account path into its component segments.""" - m = re.match(r"^accounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def account_summary_path(account_summary: str,) -> str: - """Return a fully-qualified account_summary string.""" - return "accountSummaries/{account_summary}".format(account_summary=account_summary, ) - - @staticmethod - def parse_account_summary_path(path: str) -> Dict[str,str]: - """Parse a account_summary path into its component segments.""" - m = re.match(r"^accountSummaries/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def android_app_data_stream_path(property: str,android_app_data_stream: str,) -> str: - """Return a fully-qualified android_app_data_stream string.""" - return "properties/{property}/androidAppDataStreams/{android_app_data_stream}".format(property=property, android_app_data_stream=android_app_data_stream, ) - - @staticmethod - def parse_android_app_data_stream_path(path: str) -> Dict[str,str]: - """Parse a android_app_data_stream path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/androidAppDataStreams/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def data_sharing_settings_path(account: str,) -> str: - """Return a fully-qualified data_sharing_settings string.""" - return "accounts/{account}/dataSharingSettings".format(account=account, ) - - @staticmethod - def parse_data_sharing_settings_path(path: str) -> Dict[str,str]: - """Parse a data_sharing_settings path into its component segments.""" - m = re.match(r"^accounts/(?P.+?)/dataSharingSettings$", path) - return m.groupdict() if m else {} - - @staticmethod - def enhanced_measurement_settings_path(property: str,web_data_stream: str,) -> str: - """Return a fully-qualified enhanced_measurement_settings string.""" - return "properties/{property}/webDataStreams/{web_data_stream}/enhancedMeasurementSettings".format(property=property, web_data_stream=web_data_stream, ) - - @staticmethod - def parse_enhanced_measurement_settings_path(path: str) -> Dict[str,str]: - """Parse a enhanced_measurement_settings path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/webDataStreams/(?P.+?)/enhancedMeasurementSettings$", path) - return m.groupdict() if m else {} - - @staticmethod - def firebase_link_path(property: str,firebase_link: str,) -> str: - """Return a fully-qualified firebase_link string.""" - return "properties/{property}/firebaseLinks/{firebase_link}".format(property=property, firebase_link=firebase_link, ) - - @staticmethod - def parse_firebase_link_path(path: str) -> Dict[str,str]: - """Parse a firebase_link path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/firebaseLinks/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def global_site_tag_path(property: str,) -> str: - """Return a fully-qualified global_site_tag string.""" - return "properties/{property}/globalSiteTag".format(property=property, ) - - @staticmethod - def parse_global_site_tag_path(path: str) -> Dict[str,str]: - """Parse a global_site_tag path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/globalSiteTag$", path) - return m.groupdict() if m else {} - - @staticmethod - def google_ads_link_path(property: str,google_ads_link: str,) -> str: - """Return a fully-qualified google_ads_link string.""" - return "properties/{property}/googleAdsLinks/{google_ads_link}".format(property=property, google_ads_link=google_ads_link, ) - - @staticmethod - def parse_google_ads_link_path(path: str) -> Dict[str,str]: - """Parse a google_ads_link path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/googleAdsLinks/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def ios_app_data_stream_path(property: str,ios_app_data_stream: str,) -> str: - """Return a fully-qualified ios_app_data_stream string.""" - return "properties/{property}/iosAppDataStreams/{ios_app_data_stream}".format(property=property, ios_app_data_stream=ios_app_data_stream, ) - - @staticmethod - def parse_ios_app_data_stream_path(path: str) -> Dict[str,str]: - """Parse a ios_app_data_stream path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/iosAppDataStreams/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def property_path(property: str,) -> str: - """Return a fully-qualified property string.""" - return "properties/{property}".format(property=property, ) - - @staticmethod - def parse_property_path(path: str) -> Dict[str,str]: - """Parse a property path into its component segments.""" - m = re.match(r"^properties/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def user_link_path(account: str,user_link: str,) -> str: - """Return a fully-qualified user_link string.""" - return "accounts/{account}/userLinks/{user_link}".format(account=account, user_link=user_link, ) - - @staticmethod - def parse_user_link_path(path: str) -> Dict[str,str]: - """Parse a user_link path into its component segments.""" - m = re.match(r"^accounts/(?P.+?)/userLinks/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def web_data_stream_path(property: str,web_data_stream: str,) -> str: - """Return a fully-qualified web_data_stream string.""" - return "properties/{property}/webDataStreams/{web_data_stream}".format(property=property, web_data_stream=web_data_stream, ) - - @staticmethod - def parse_web_data_stream_path(path: str) -> Dict[str,str]: - """Parse a web_data_stream path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/webDataStreams/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: - """Return 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: - """Return 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: - """Return 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: - """Return 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: - """Return 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[credentials.Credentials] = None, - transport: Union[str, AnalyticsAdminServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the analytics admin service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, AnalyticsAdminServiceTransport]): 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() - client_cert_source_func = mtls.default_client_cert_source() if is_mtls else 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": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT if is_mtls else 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, AnalyticsAdminServiceTransport): - # transport is a AnalyticsAdminServiceTransport instance. - if credentials or client_options.credentials_file: - raise ValueError('When providing a transport instance, ' - 'provide its credentials directly.') - if client_options.scopes: - raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." - ) - self._transport = transport - else: - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - ) - - def get_account(self, - request: analytics_admin.GetAccountRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Account: - r"""Lookup for a single Account. - - Args: - request (google.analytics.admin_v1alpha.types.GetAccountRequest): - The request object. Request message for GetAccount RPC. - name (str): - Required. The name of the account to - lookup. Format: accounts/{account} - Example: "accounts/100" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.Account: - A resource message representing a - Google Analytics account. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 analytics_admin.GetAccountRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetAccountRequest): - request = analytics_admin.GetAccountRequest(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_account] - - # Certain fields should be 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_accounts(self, - request: analytics_admin.ListAccountsRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAccountsPager: - r"""Returns all accounts accessible by the caller. - Note that these accounts might not currently have GA4 - properties. Soft-deleted (ie: "trashed") accounts are - excluded by default. Returns an empty list if no - relevant accounts are found. - - Args: - request (google.analytics.admin_v1alpha.types.ListAccountsRequest): - The request object. Request message for ListAccounts - RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsPager: - Request message for ListAccounts RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.ListAccountsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListAccountsRequest): - request = analytics_admin.ListAccountsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_accounts] - - # 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.ListAccountsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_account(self, - request: analytics_admin.DeleteAccountRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Marks target Account as soft-deleted (ie: "trashed") - and returns it. - This API does not have a method to restore soft-deleted - accounts. However, they can be restored using the Trash - Can UI. - If the accounts are not restored before the expiration - time, the account and all child resources (eg: - Properties, GoogleAdsLinks, Streams, UserLinks) will be - permanently purged. - https://support.google.com/analytics/answer/6154772 - Returns an error if the target is not found. - - Args: - request (google.analytics.admin_v1alpha.types.DeleteAccountRequest): - The request object. Request message for DeleteAccount - RPC. - name (str): - Required. The name of the Account to - soft-delete. Format: accounts/{account} - Example: "accounts/100" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.DeleteAccountRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteAccountRequest): - request = analytics_admin.DeleteAccountRequest(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_account] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def update_account(self, - request: analytics_admin.UpdateAccountRequest = None, - *, - account: resources.Account = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Account: - r"""Updates an account. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateAccountRequest): - The request object. Request message for UpdateAccount - RPC. - account (google.analytics.admin_v1alpha.types.Account): - Required. The account to update. The account's ``name`` - field is used to identify the account. - - This corresponds to the ``account`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.Account: - A resource message representing a - Google Analytics account. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([account, 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 analytics_admin.UpdateAccountRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateAccountRequest): - request = analytics_admin.UpdateAccountRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if account is not None: - request.account = account - 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_account] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('account.name', request.account.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def provision_account_ticket(self, - request: analytics_admin.ProvisionAccountTicketRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.ProvisionAccountTicketResponse: - r"""Requests a ticket for creating an account. - - Args: - request (google.analytics.admin_v1alpha.types.ProvisionAccountTicketRequest): - The request object. Request message for - ProvisionAccountTicket RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.ProvisionAccountTicketResponse: - Response message for - ProvisionAccountTicket RPC. - - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.ProvisionAccountTicketRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ProvisionAccountTicketRequest): - request = analytics_admin.ProvisionAccountTicketRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.provision_account_ticket] - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_account_summaries(self, - request: analytics_admin.ListAccountSummariesRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAccountSummariesPager: - r"""Returns summaries of all accounts accessible by the - caller. - - Args: - request (google.analytics.admin_v1alpha.types.ListAccountSummariesRequest): - The request object. Request message for - ListAccountSummaries RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountSummariesPager: - Response message for - ListAccountSummaries RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.ListAccountSummariesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListAccountSummariesRequest): - request = analytics_admin.ListAccountSummariesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_account_summaries] - - # 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.ListAccountSummariesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_property(self, - request: analytics_admin.GetPropertyRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Property: - r"""Lookup for a single "GA4" Property. - - Args: - request (google.analytics.admin_v1alpha.types.GetPropertyRequest): - The request object. Request message for GetProperty RPC. - name (str): - Required. The name of the property to lookup. Format: - properties/{property_id} Example: "properties/1000" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.Property: - A resource message representing a - Google Analytics GA4 property. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 analytics_admin.GetPropertyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetPropertyRequest): - request = analytics_admin.GetPropertyRequest(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_property] - - # Certain fields should be 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_properties(self, - request: analytics_admin.ListPropertiesRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPropertiesPager: - r"""Returns child Properties under the specified parent - Account. - Only "GA4" properties will be returned. - Properties will be excluded if the caller does not have - access. Soft-deleted (ie: "trashed") properties are - excluded by default. Returns an empty list if no - relevant properties are found. - - Args: - request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): - The request object. Request message for ListProperties - RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListPropertiesPager: - Response message for ListProperties - RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.ListPropertiesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListPropertiesRequest): - request = analytics_admin.ListPropertiesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_properties] - - # 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.ListPropertiesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_property(self, - request: analytics_admin.CreatePropertyRequest = None, - *, - property: resources.Property = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Property: - r"""Creates an "GA4" property with the specified location - and attributes. - - Args: - request (google.analytics.admin_v1alpha.types.CreatePropertyRequest): - The request object. Request message for CreateProperty - RPC. - property (google.analytics.admin_v1alpha.types.Property): - Required. The property to create. - Note: the supplied property must specify - its parent. - - This corresponds to the ``property`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.Property: - A resource message representing a - Google Analytics GA4 property. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([property]) - if request is 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 analytics_admin.CreatePropertyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreatePropertyRequest): - request = analytics_admin.CreatePropertyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if property is not None: - request.property = property - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_property] - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_property(self, - request: analytics_admin.DeletePropertyRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Marks target Property as soft-deleted (ie: "trashed") - and returns it. - This API does not have a method to restore soft-deleted - properties. However, they can be restored using the - Trash Can UI. - If the properties are not restored before the expiration - time, the Property and all child resources (eg: - GoogleAdsLinks, Streams, UserLinks) will be permanently - purged. - https://support.google.com/analytics/answer/6154772 - Returns an error if the target is not found, or is not - an GA4 Property. - - Args: - request (google.analytics.admin_v1alpha.types.DeletePropertyRequest): - The request object. Request message for DeleteProperty - RPC. - name (str): - Required. The name of the Property to soft-delete. - Format: properties/{property_id} Example: - "properties/1000" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.DeletePropertyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeletePropertyRequest): - request = analytics_admin.DeletePropertyRequest(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_property] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def update_property(self, - request: analytics_admin.UpdatePropertyRequest = None, - *, - property: resources.Property = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Property: - r"""Updates a property. - - Args: - request (google.analytics.admin_v1alpha.types.UpdatePropertyRequest): - The request object. Request message for UpdateProperty - RPC. - property (google.analytics.admin_v1alpha.types.Property): - Required. The property to update. The property's - ``name`` field is used to identify the property to be - updated. - - This corresponds to the ``property`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.Property: - A resource message representing a - Google Analytics GA4 property. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([property, 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 analytics_admin.UpdatePropertyRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdatePropertyRequest): - request = analytics_admin.UpdatePropertyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if property is not None: - request.property = property - 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_property] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('property.name', request.property.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_user_link(self, - request: analytics_admin.GetUserLinkRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.UserLink: - r"""Gets information about a user's link to an account or - property. - - Args: - request (google.analytics.admin_v1alpha.types.GetUserLinkRequest): - The request object. Request message for GetUserLink RPC. - name (str): - Required. Example format: - accounts/1234/userLinks/5678 - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.UserLink: - A resource message representing a - user's permissions on an Account or - Property resource. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.GetUserLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetUserLinkRequest): - request = analytics_admin.GetUserLinkRequest(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_user_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def batch_get_user_links(self, - request: analytics_admin.BatchGetUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.BatchGetUserLinksResponse: - r"""Gets information about multiple users' links to an - account or property. - - Args: - request (google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest): - The request object. Request message for - BatchGetUserLinks RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse: - Response message for - BatchGetUserLinks RPC. - - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.BatchGetUserLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.BatchGetUserLinksRequest): - request = analytics_admin.BatchGetUserLinksRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_get_user_links] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_user_links(self, - request: analytics_admin.ListUserLinksRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListUserLinksPager: - r"""Lists all user links on an account or property. - - Args: - request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): - The request object. Request message for ListUserLinks - RPC. - parent (str): - Required. Example format: - accounts/1234 - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListUserLinksPager: - Response message for ListUserLinks - RPC. - 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 analytics_admin.ListUserLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListUserLinksRequest): - request = analytics_admin.ListUserLinksRequest(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_user_links] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListUserLinksPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def audit_user_links(self, - request: analytics_admin.AuditUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.AuditUserLinksPager: - r"""Lists all user links on an account or property, - including implicit ones that come from effective - permissions granted by groups or organization admin - roles. - - If a returned user link does not have direct - permissions, they cannot be removed from the account or - property directly with the DeleteUserLink command. They - have to be removed from the group/etc that gives them - permissions, which is currently only usable/discoverable - in the GA or GMP UIs. - - Args: - request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): - The request object. Request message for AuditUserLinks - RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.AuditUserLinksPager: - Response message for AuditUserLinks - RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.AuditUserLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.AuditUserLinksRequest): - request = analytics_admin.AuditUserLinksRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.audit_user_links] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.AuditUserLinksPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_user_link(self, - request: analytics_admin.CreateUserLinkRequest = None, - *, - parent: str = None, - user_link: resources.UserLink = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.UserLink: - r"""Creates a user link on an account or property. - If the user with the specified email already has - permissions on the account or property, then the user's - existing permissions will be unioned with the - permissions specified in the new UserLink. - - Args: - request (google.analytics.admin_v1alpha.types.CreateUserLinkRequest): - The request object. Request message for CreateUserLink - RPC. - Users can have multiple email addresses associated with - their Google account, and one of these email addresses - is the "primary" email address. Any of the email - addresses associated with a Google account may be used - for a new UserLink, but the returned UserLink will - always contain the "primary" email address. As a result, - the input and output email address for this request may - differ. - parent (str): - Required. Example format: - accounts/1234 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - user_link (google.analytics.admin_v1alpha.types.UserLink): - Required. The user link to create. - This corresponds to the ``user_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.UserLink: - A resource message representing a - user's permissions on an Account or - Property resource. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, user_link]) - if request is 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 analytics_admin.CreateUserLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateUserLinkRequest): - request = analytics_admin.CreateUserLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if user_link is not None: - request.user_link = user_link - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_user_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def batch_create_user_links(self, - request: analytics_admin.BatchCreateUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.BatchCreateUserLinksResponse: - r"""Creates information about multiple users' links to an - account or property. - This method is transactional. If any UserLink cannot be - created, none of the UserLinks will be created. - - Args: - request (google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest): - The request object. Request message for - BatchCreateUserLinks RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse: - Response message for - BatchCreateUserLinks RPC. - - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.BatchCreateUserLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.BatchCreateUserLinksRequest): - request = analytics_admin.BatchCreateUserLinksRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_create_user_links] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_user_link(self, - request: analytics_admin.UpdateUserLinkRequest = None, - *, - user_link: resources.UserLink = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.UserLink: - r"""Updates a user link on an account or property. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateUserLinkRequest): - The request object. Request message for UpdateUserLink - RPC. - user_link (google.analytics.admin_v1alpha.types.UserLink): - Required. The user link to update. - This corresponds to the ``user_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.UserLink: - A resource message representing a - user's permissions on an Account or - Property resource. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([user_link]) - if request is 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 analytics_admin.UpdateUserLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateUserLinkRequest): - request = analytics_admin.UpdateUserLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if user_link is not None: - request.user_link = user_link - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_user_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('user_link.name', request.user_link.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def batch_update_user_links(self, - request: analytics_admin.BatchUpdateUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.BatchUpdateUserLinksResponse: - r"""Updates information about multiple users' links to an - account or property. - - Args: - request (google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest): - The request object. Request message for - BatchUpdateUserLinks RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse: - Response message for - BatchUpdateUserLinks RPC. - - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.BatchUpdateUserLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.BatchUpdateUserLinksRequest): - request = analytics_admin.BatchUpdateUserLinksRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_update_user_links] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_user_link(self, - request: analytics_admin.DeleteUserLinkRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a user link on an account or property. - - Args: - request (google.analytics.admin_v1alpha.types.DeleteUserLinkRequest): - The request object. Request message for DeleteUserLink - RPC. - name (str): - Required. Example format: - accounts/1234/userLinks/5678 - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.DeleteUserLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteUserLinkRequest): - request = analytics_admin.DeleteUserLinkRequest(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_user_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def batch_delete_user_links(self, - request: analytics_admin.BatchDeleteUserLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes information about multiple users' links to an - account or property. - - Args: - request (google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest): - The request object. Request message for - BatchDeleteUserLinks RPC. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.BatchDeleteUserLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.BatchDeleteUserLinksRequest): - request = analytics_admin.BatchDeleteUserLinksRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_delete_user_links] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def get_web_data_stream(self, - request: analytics_admin.GetWebDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.WebDataStream: - r"""Lookup for a single WebDataStream - - Args: - request (google.analytics.admin_v1alpha.types.GetWebDataStreamRequest): - The request object. Request message for GetWebDataStream - RPC. - name (str): - Required. The name of the web data stream to lookup. - Format: - properties/{property_id}/webDataStreams/{stream_id} - Example: "properties/123/webDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.WebDataStream: - A resource message representing a - Google Analytics web 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 analytics_admin.GetWebDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetWebDataStreamRequest): - request = analytics_admin.GetWebDataStreamRequest(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_web_data_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 delete_web_data_stream(self, - request: analytics_admin.DeleteWebDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a web stream on a property. - - Args: - request (google.analytics.admin_v1alpha.types.DeleteWebDataStreamRequest): - The request object. Request message for - DeleteWebDataStream RPC. - name (str): - Required. The name of the web data stream to delete. - Format: - properties/{property_id}/webDataStreams/{stream_id} - Example: "properties/123/webDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.DeleteWebDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteWebDataStreamRequest): - request = analytics_admin.DeleteWebDataStreamRequest(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_web_data_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. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def update_web_data_stream(self, - request: analytics_admin.UpdateWebDataStreamRequest = None, - *, - web_data_stream: resources.WebDataStream = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.WebDataStream: - r"""Updates a web stream on a property. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateWebDataStreamRequest): - The request object. Request message for - UpdateWebDataStream RPC. - web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): - Required. The web stream to update. The ``name`` field - is used to identify the web stream to be updated. - - This corresponds to the ``web_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.WebDataStream: - A resource message representing a - Google Analytics web 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([web_data_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 analytics_admin.UpdateWebDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateWebDataStreamRequest): - request = analytics_admin.UpdateWebDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if web_data_stream is not None: - request.web_data_stream = web_data_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_web_data_stream] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('web_data_stream.name', request.web_data_stream.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_web_data_stream(self, - request: analytics_admin.CreateWebDataStreamRequest = None, - *, - parent: str = None, - web_data_stream: resources.WebDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.WebDataStream: - r"""Creates a web stream with the specified location and - attributes. - - Args: - request (google.analytics.admin_v1alpha.types.CreateWebDataStreamRequest): - The request object. Request message for - CreateWebDataStream RPC. - parent (str): - Required. The parent resource where - this web data stream will be created. - Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): - Required. The web stream to create. - This corresponds to the ``web_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.WebDataStream: - A resource message representing a - Google Analytics web 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, web_data_stream]) - if request is 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 analytics_admin.CreateWebDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateWebDataStreamRequest): - request = analytics_admin.CreateWebDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if web_data_stream is not None: - request.web_data_stream = web_data_stream - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_web_data_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, - ) - - # Done; return the response. - return response - - def list_web_data_streams(self, - request: analytics_admin.ListWebDataStreamsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListWebDataStreamsPager: - r"""Returns child web data streams under the specified - parent property. - Web data streams will be excluded if the caller does not - have access. Returns an empty list if no relevant web - data streams are found. - - Args: - request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): - The request object. Request message for - ListWebDataStreams RPC. - parent (str): - Required. The name of the parent - property. For example, to list results - of web streams under the property with - Id 123: "properties/123" - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListWebDataStreamsPager: - Request message for - ListWebDataStreams RPC. - 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 analytics_admin.ListWebDataStreamsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListWebDataStreamsRequest): - request = analytics_admin.ListWebDataStreamsRequest(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_web_data_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.ListWebDataStreamsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_ios_app_data_stream(self, - request: analytics_admin.GetIosAppDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IosAppDataStream: - r"""Lookup for a single IosAppDataStream - - Args: - request (google.analytics.admin_v1alpha.types.GetIosAppDataStreamRequest): - The request object. Request message for - GetIosAppDataStream RPC. - name (str): - Required. The name of the iOS app data stream to lookup. - Format: - properties/{property_id}/iosAppDataStreams/{stream_id} - Example: "properties/123/iosAppDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.IosAppDataStream: - A resource message representing a - Google Analytics IOS app 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 analytics_admin.GetIosAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetIosAppDataStreamRequest): - request = analytics_admin.GetIosAppDataStreamRequest(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_ios_app_data_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 delete_ios_app_data_stream(self, - request: analytics_admin.DeleteIosAppDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes an iOS app stream on a property. - - Args: - request (google.analytics.admin_v1alpha.types.DeleteIosAppDataStreamRequest): - The request object. Request message for - DeleteIosAppDataStream RPC. - name (str): - Required. The name of the iOS app data stream to delete. - Format: - properties/{property_id}/iosAppDataStreams/{stream_id} - Example: "properties/123/iosAppDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.DeleteIosAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteIosAppDataStreamRequest): - request = analytics_admin.DeleteIosAppDataStreamRequest(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_ios_app_data_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. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def update_ios_app_data_stream(self, - request: analytics_admin.UpdateIosAppDataStreamRequest = None, - *, - ios_app_data_stream: resources.IosAppDataStream = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IosAppDataStream: - r"""Updates an iOS app stream on a property. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateIosAppDataStreamRequest): - The request object. Request message for - UpdateIosAppDataStream RPC. - ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): - Required. The iOS app stream to update. The ``name`` - field is used to identify the iOS app stream to be - updated. - - This corresponds to the ``ios_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.IosAppDataStream: - A resource message representing a - Google Analytics IOS app 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([ios_app_data_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 analytics_admin.UpdateIosAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateIosAppDataStreamRequest): - request = analytics_admin.UpdateIosAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if ios_app_data_stream is not None: - request.ios_app_data_stream = ios_app_data_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_ios_app_data_stream] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('ios_app_data_stream.name', request.ios_app_data_stream.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_ios_app_data_stream(self, - request: analytics_admin.CreateIosAppDataStreamRequest = None, - *, - parent: str = None, - ios_app_data_stream: resources.IosAppDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IosAppDataStream: - r"""Creates an iOS app stream with the specified location - and attributes. - Note that an iOS app stream must be linked to a Firebase - app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Args: - request (google.analytics.admin_v1alpha.types.CreateIosAppDataStreamRequest): - The request object. Request message for - CreateIosAppDataStream RPC. - parent (str): - Required. The parent resource where - this ios app data stream will be - created. Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): - Required. The iOS app data stream to - create. - - This corresponds to the ``ios_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.IosAppDataStream: - A resource message representing a - Google Analytics IOS app 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, ios_app_data_stream]) - if request is 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 analytics_admin.CreateIosAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateIosAppDataStreamRequest): - request = analytics_admin.CreateIosAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if ios_app_data_stream is not None: - request.ios_app_data_stream = ios_app_data_stream - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_ios_app_data_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, - ) - - # Done; return the response. - return response - - def list_ios_app_data_streams(self, - request: analytics_admin.ListIosAppDataStreamsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListIosAppDataStreamsPager: - r"""Returns child iOS app data streams under the - specified parent property. - iOS app data streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - iOS app data streams are found. - - Args: - request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): - The request object. Request message for - ListIosAppDataStreams RPC. - parent (str): - Required. The name of the parent - property. For example, to list results - of app streams under the property with - Id 123: "properties/123" - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListIosAppDataStreamsPager: - Request message for - ListIosAppDataStreams RPC. - 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 analytics_admin.ListIosAppDataStreamsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListIosAppDataStreamsRequest): - request = analytics_admin.ListIosAppDataStreamsRequest(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_ios_app_data_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.ListIosAppDataStreamsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_android_app_data_stream(self, - request: analytics_admin.GetAndroidAppDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.AndroidAppDataStream: - r"""Lookup for a single AndroidAppDataStream - - Args: - request (google.analytics.admin_v1alpha.types.GetAndroidAppDataStreamRequest): - The request object. Request message for - GetAndroidAppDataStream RPC. - name (str): - Required. The name of the android app data stream to - lookup. Format: - properties/{property_id}/androidAppDataStreams/{stream_id} - Example: "properties/123/androidAppDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.AndroidAppDataStream: - A resource message representing a - Google Analytics Android app 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 analytics_admin.GetAndroidAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetAndroidAppDataStreamRequest): - request = analytics_admin.GetAndroidAppDataStreamRequest(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_android_app_data_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 delete_android_app_data_stream(self, - request: analytics_admin.DeleteAndroidAppDataStreamRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes an android app stream on a property. - - Args: - request (google.analytics.admin_v1alpha.types.DeleteAndroidAppDataStreamRequest): - The request object. Request message for - DeleteAndroidAppDataStream RPC. - name (str): - Required. The name of the android app data stream to - delete. Format: - properties/{property_id}/androidAppDataStreams/{stream_id} - Example: "properties/123/androidAppDataStreams/456" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.DeleteAndroidAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteAndroidAppDataStreamRequest): - request = analytics_admin.DeleteAndroidAppDataStreamRequest(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_android_app_data_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. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def update_android_app_data_stream(self, - request: analytics_admin.UpdateAndroidAppDataStreamRequest = None, - *, - android_app_data_stream: resources.AndroidAppDataStream = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.AndroidAppDataStream: - r"""Updates an android app stream on a property. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateAndroidAppDataStreamRequest): - The request object. Request message for - UpdateAndroidAppDataStream RPC. - android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): - Required. The android app stream to update. The ``name`` - field is used to identify the android app stream to be - updated. - - This corresponds to the ``android_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.AndroidAppDataStream: - A resource message representing a - Google Analytics Android app 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([android_app_data_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 analytics_admin.UpdateAndroidAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateAndroidAppDataStreamRequest): - request = analytics_admin.UpdateAndroidAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if android_app_data_stream is not None: - request.android_app_data_stream = android_app_data_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_android_app_data_stream] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('android_app_data_stream.name', request.android_app_data_stream.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_android_app_data_stream(self, - request: analytics_admin.CreateAndroidAppDataStreamRequest = None, - *, - parent: str = None, - android_app_data_stream: resources.AndroidAppDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.AndroidAppDataStream: - r"""Creates an Android app stream with the specified - location and attributes. - Note that an Android app stream must be linked to a - Firebase app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Args: - request (google.analytics.admin_v1alpha.types.CreateAndroidAppDataStreamRequest): - The request object. Request message for - CreateAndroidAppDataStream RPC. - parent (str): - Required. The parent resource where - this android app data stream will be - created. Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): - Required. The android app stream to - create. - - This corresponds to the ``android_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.AndroidAppDataStream: - A resource message representing a - Google Analytics Android app 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, android_app_data_stream]) - if request is 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 analytics_admin.CreateAndroidAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateAndroidAppDataStreamRequest): - request = analytics_admin.CreateAndroidAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if android_app_data_stream is not None: - request.android_app_data_stream = android_app_data_stream - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_android_app_data_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, - ) - - # Done; return the response. - return response - - def list_android_app_data_streams(self, - request: analytics_admin.ListAndroidAppDataStreamsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAndroidAppDataStreamsPager: - r"""Returns child android app streams under the specified - parent property. - Android app streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - android app streams are found. - - Args: - request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): - The request object. Request message for - ListAndroidAppDataStreams RPC. - parent (str): - Required. The name of the parent - property. For example, to limit results - to app streams under the property with - Id 123: "properties/123" - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAndroidAppDataStreamsPager: - Request message for - ListAndroidDataStreams RPC. - 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 analytics_admin.ListAndroidAppDataStreamsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListAndroidAppDataStreamsRequest): - request = analytics_admin.ListAndroidAppDataStreamsRequest(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_android_app_data_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.ListAndroidAppDataStreamsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_enhanced_measurement_settings(self, - request: analytics_admin.GetEnhancedMeasurementSettingsRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.EnhancedMeasurementSettings: - r"""Returns the singleton enhanced measurement settings - for this web stream. Note that the stream must enable - enhanced measurement for these settings to take effect. - - Args: - request (google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest): - The request object. Request message for - GetEnhancedMeasurementSettings RPC. - name (str): - Required. The name of the settings to lookup. Format: - properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings - Example: - "properties/1000/webDataStreams/2000/enhancedMeasurementSettings" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: - Singleton resource under a - WebDataStream, configuring measurement - of additional site interactions and - content. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 analytics_admin.GetEnhancedMeasurementSettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetEnhancedMeasurementSettingsRequest): - request = analytics_admin.GetEnhancedMeasurementSettingsRequest(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_enhanced_measurement_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_enhanced_measurement_settings(self, - request: analytics_admin.UpdateEnhancedMeasurementSettingsRequest = None, - *, - enhanced_measurement_settings: resources.EnhancedMeasurementSettings = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.EnhancedMeasurementSettings: - r"""Updates the singleton enhanced measurement settings - for this web stream. Note that the stream must enable - enhanced measurement for these settings to take effect. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateEnhancedMeasurementSettingsRequest): - The request object. Request message for - UpdateEnhancedMeasurementSettings RPC. - enhanced_measurement_settings (google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings): - Required. The settings to update. The ``name`` field is - used to identify the settings to be updated. - - This corresponds to the ``enhanced_measurement_settings`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: - Singleton resource under a - WebDataStream, configuring measurement - of additional site interactions and - content. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([enhanced_measurement_settings, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.UpdateEnhancedMeasurementSettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateEnhancedMeasurementSettingsRequest): - request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if enhanced_measurement_settings is not None: - request.enhanced_measurement_settings = enhanced_measurement_settings - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_enhanced_measurement_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('enhanced_measurement_settings.name', request.enhanced_measurement_settings.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_firebase_link(self, - request: analytics_admin.CreateFirebaseLinkRequest = None, - *, - parent: str = None, - firebase_link: resources.FirebaseLink = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.FirebaseLink: - r"""Creates a FirebaseLink. - Properties can have at most one FirebaseLink. - - Args: - request (google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest): - The request object. Request message for - CreateFirebaseLink RPC - parent (str): - Required. Format: properties/{property_id} Example: - properties/1234 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): - Required. The Firebase link to - create. - - This corresponds to the ``firebase_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.FirebaseLink: - A link between an GA4 property and a - Firebase project. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, firebase_link]) - if request is 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 analytics_admin.CreateFirebaseLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateFirebaseLinkRequest): - request = analytics_admin.CreateFirebaseLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if firebase_link is not None: - request.firebase_link = firebase_link - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_firebase_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_firebase_link(self, - request: analytics_admin.UpdateFirebaseLinkRequest = None, - *, - firebase_link: resources.FirebaseLink = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.FirebaseLink: - r"""Updates a FirebaseLink on a property - - Args: - request (google.analytics.admin_v1alpha.types.UpdateFirebaseLinkRequest): - The request object. Request message for - UpdateFirebaseLink RPC - firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): - Required. The Firebase link to - update. - - This corresponds to the ``firebase_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.FirebaseLink: - A link between an GA4 property and a - Firebase project. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([firebase_link, 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 analytics_admin.UpdateFirebaseLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateFirebaseLinkRequest): - request = analytics_admin.UpdateFirebaseLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if firebase_link is not None: - request.firebase_link = firebase_link - 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_firebase_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('firebase_link.name', request.firebase_link.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_firebase_link(self, - request: analytics_admin.DeleteFirebaseLinkRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a FirebaseLink on a property - - Args: - request (google.analytics.admin_v1alpha.types.DeleteFirebaseLinkRequest): - The request object. Request message for - DeleteFirebaseLink RPC - name (str): - Required. Format: - properties/{property_id}/firebaseLinks/{firebase_link_id} - Example: properties/1234/firebaseLinks/5678 - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.DeleteFirebaseLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteFirebaseLinkRequest): - request = analytics_admin.DeleteFirebaseLinkRequest(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_firebase_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def list_firebase_links(self, - request: analytics_admin.ListFirebaseLinksRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListFirebaseLinksPager: - r"""Lists FirebaseLinks on a property. - Properties can have at most one FirebaseLink. - - Args: - request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): - The request object. Request message for - ListFirebaseLinks RPC - parent (str): - Required. Format: properties/{property_id} Example: - properties/1234 - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListFirebaseLinksPager: - Response message for - ListFirebaseLinks RPC - 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 analytics_admin.ListFirebaseLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListFirebaseLinksRequest): - request = analytics_admin.ListFirebaseLinksRequest(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_firebase_links] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListFirebaseLinksPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_global_site_tag(self, - request: analytics_admin.GetGlobalSiteTagRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GlobalSiteTag: - r"""Returns the Site Tag for the specified web stream. - Site Tags are immutable singletons. - - Args: - request (google.analytics.admin_v1alpha.types.GetGlobalSiteTagRequest): - The request object. Request message for GetGlobalSiteTag - RPC. - name (str): - Required. The name of the site tag to lookup. Note that - site tags are singletons and do not have unique IDs. - Format: - properties/{property_id}/webDataStreams/{stream_id}/globalSiteTag - Example: - "properties/123/webDataStreams/456/globalSiteTag" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.GlobalSiteTag: - Read-only resource with the tag for - sending data from a website to a - WebDataStream. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 analytics_admin.GetGlobalSiteTagRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetGlobalSiteTagRequest): - request = analytics_admin.GetGlobalSiteTagRequest(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_global_site_tag] - - # Certain fields should be 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_google_ads_link(self, - request: analytics_admin.CreateGoogleAdsLinkRequest = None, - *, - parent: str = None, - google_ads_link: resources.GoogleAdsLink = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GoogleAdsLink: - r"""Creates a GoogleAdsLink. - - Args: - request (google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest): - The request object. Request message for - CreateGoogleAdsLink RPC - parent (str): - Required. Example format: - properties/1234 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): - Required. The GoogleAdsLink to - create. - - This corresponds to the ``google_ads_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.GoogleAdsLink: - A link between an GA4 property and a - Google Ads account. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, google_ads_link]) - if request is 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 analytics_admin.CreateGoogleAdsLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateGoogleAdsLinkRequest): - request = analytics_admin.CreateGoogleAdsLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if google_ads_link is not None: - request.google_ads_link = google_ads_link - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_google_ads_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_google_ads_link(self, - request: analytics_admin.UpdateGoogleAdsLinkRequest = None, - *, - google_ads_link: resources.GoogleAdsLink = None, - update_mask: field_mask.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GoogleAdsLink: - r"""Updates a GoogleAdsLink on a property - - Args: - request (google.analytics.admin_v1alpha.types.UpdateGoogleAdsLinkRequest): - The request object. Request message for - UpdateGoogleAdsLink RPC - google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): - The GoogleAdsLink to update - This corresponds to the ``google_ads_link`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names - must be in snake case (e.g., "field_to_update"). Omitted - fields will not be updated. To replace the entire - entity, use one path with the string "*" to match all - fields. - - 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.analytics.admin_v1alpha.types.GoogleAdsLink: - A link between an GA4 property and a - Google Ads account. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([google_ads_link, 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 analytics_admin.UpdateGoogleAdsLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateGoogleAdsLinkRequest): - request = analytics_admin.UpdateGoogleAdsLinkRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if google_ads_link is not None: - request.google_ads_link = google_ads_link - 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_google_ads_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('google_ads_link.name', request.google_ads_link.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_google_ads_link(self, - request: analytics_admin.DeleteGoogleAdsLinkRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a GoogleAdsLink on a property - - Args: - request (google.analytics.admin_v1alpha.types.DeleteGoogleAdsLinkRequest): - The request object. Request message for - DeleteGoogleAdsLink RPC. - name (str): - Required. Example format: - properties/1234/googleAdsLinks/5678 - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.DeleteGoogleAdsLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteGoogleAdsLinkRequest): - request = analytics_admin.DeleteGoogleAdsLinkRequest(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_google_ads_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def list_google_ads_links(self, - request: analytics_admin.ListGoogleAdsLinksRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListGoogleAdsLinksPager: - r"""Lists GoogleAdsLinks on a property. - - Args: - request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): - The request object. Request message for - ListGoogleAdsLinks RPC. - parent (str): - Required. Example format: - properties/1234 - - 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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListGoogleAdsLinksPager: - Response message for - ListGoogleAdsLinks RPC. - 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 analytics_admin.ListGoogleAdsLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListGoogleAdsLinksRequest): - request = analytics_admin.ListGoogleAdsLinksRequest(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_google_ads_links] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListGoogleAdsLinksPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_data_sharing_settings(self, - request: analytics_admin.GetDataSharingSettingsRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.DataSharingSettings: - r"""Get data sharing settings on an account. - Data sharing settings are singletons. - - Args: - request (google.analytics.admin_v1alpha.types.GetDataSharingSettingsRequest): - The request object. Request message for - GetDataSharingSettings RPC. - name (str): - Required. The name of the settings to - lookup. Format: - accounts/{account}/dataSharingSettings - Example: - "accounts/1000/dataSharingSettings" - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.DataSharingSettings: - A resource message representing data - sharing settings of a Google Analytics - account. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 analytics_admin.GetDataSharingSettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetDataSharingSettingsRequest): - request = analytics_admin.GetDataSharingSettingsRequest(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_data_sharing_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - - - - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-analytics-admin', - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - 'AnalyticsAdminServiceClient', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py deleted file mode 100644 index 6f76b747..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py +++ /dev/null @@ -1,1241 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional - -from google.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources - - -class ListAccountsPager: - """A pager for iterating through ``list_accounts`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``accounts`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListAccounts`` requests and continue to iterate - through the ``accounts`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` - 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[..., analytics_admin.ListAccountsResponse], - request: analytics_admin.ListAccountsRequest, - response: analytics_admin.ListAccountsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListAccountsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListAccountsResponse): - 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 = analytics_admin.ListAccountsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListAccountsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.Account]: - for page in self.pages: - yield from page.accounts - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAccountsAsyncPager: - """A pager for iterating through ``list_accounts`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``accounts`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListAccounts`` requests and continue to iterate - through the ``accounts`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` - 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[analytics_admin.ListAccountsResponse]], - request: analytics_admin.ListAccountsRequest, - response: analytics_admin.ListAccountsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListAccountsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListAccountsResponse): - 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 = analytics_admin.ListAccountsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListAccountsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.Account]: - async def async_generator(): - async for page in self.pages: - for response in page.accounts: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAccountSummariesPager: - """A pager for iterating through ``list_account_summaries`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``account_summaries`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListAccountSummaries`` requests and continue to iterate - through the ``account_summaries`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` - 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[..., analytics_admin.ListAccountSummariesResponse], - request: analytics_admin.ListAccountSummariesRequest, - response: analytics_admin.ListAccountSummariesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListAccountSummariesRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListAccountSummariesResponse): - 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 = analytics_admin.ListAccountSummariesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListAccountSummariesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.AccountSummary]: - for page in self.pages: - yield from page.account_summaries - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAccountSummariesAsyncPager: - """A pager for iterating through ``list_account_summaries`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``account_summaries`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListAccountSummaries`` requests and continue to iterate - through the ``account_summaries`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` - 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[analytics_admin.ListAccountSummariesResponse]], - request: analytics_admin.ListAccountSummariesRequest, - response: analytics_admin.ListAccountSummariesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListAccountSummariesRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListAccountSummariesResponse): - 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 = analytics_admin.ListAccountSummariesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListAccountSummariesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.AccountSummary]: - async def async_generator(): - async for page in self.pages: - for response in page.account_summaries: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPropertiesPager: - """A pager for iterating through ``list_properties`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``properties`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListProperties`` requests and continue to iterate - through the ``properties`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` - 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[..., analytics_admin.ListPropertiesResponse], - request: analytics_admin.ListPropertiesRequest, - response: analytics_admin.ListPropertiesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListPropertiesResponse): - 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 = analytics_admin.ListPropertiesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListPropertiesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.Property]: - for page in self.pages: - yield from page.properties - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPropertiesAsyncPager: - """A pager for iterating through ``list_properties`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``properties`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListProperties`` requests and continue to iterate - through the ``properties`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` - 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[analytics_admin.ListPropertiesResponse]], - request: analytics_admin.ListPropertiesRequest, - response: analytics_admin.ListPropertiesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListPropertiesResponse): - 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 = analytics_admin.ListPropertiesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListPropertiesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.Property]: - async def async_generator(): - async for page in self.pages: - for response in page.properties: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListUserLinksPager: - """A pager for iterating through ``list_user_links`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` object, and - provides an ``__iter__`` method to iterate through its - ``user_links`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListUserLinks`` requests and continue to iterate - through the ``user_links`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` - 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[..., analytics_admin.ListUserLinksResponse], - request: analytics_admin.ListUserLinksRequest, - response: analytics_admin.ListUserLinksResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListUserLinksResponse): - 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 = analytics_admin.ListUserLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListUserLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.UserLink]: - for page in self.pages: - yield from page.user_links - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListUserLinksAsyncPager: - """A pager for iterating through ``list_user_links`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``user_links`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListUserLinks`` requests and continue to iterate - through the ``user_links`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` - 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[analytics_admin.ListUserLinksResponse]], - request: analytics_admin.ListUserLinksRequest, - response: analytics_admin.ListUserLinksResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListUserLinksResponse): - 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 = analytics_admin.ListUserLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListUserLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.UserLink]: - async def async_generator(): - async for page in self.pages: - for response in page.user_links: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class AuditUserLinksPager: - """A pager for iterating through ``audit_user_links`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` object, and - provides an ``__iter__`` method to iterate through its - ``user_links`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``AuditUserLinks`` requests and continue to iterate - through the ``user_links`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` - 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[..., analytics_admin.AuditUserLinksResponse], - request: analytics_admin.AuditUserLinksRequest, - response: analytics_admin.AuditUserLinksResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.AuditUserLinksResponse): - 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 = analytics_admin.AuditUserLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.AuditUserLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.AuditUserLink]: - for page in self.pages: - yield from page.user_links - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class AuditUserLinksAsyncPager: - """A pager for iterating through ``audit_user_links`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``user_links`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``AuditUserLinks`` requests and continue to iterate - through the ``user_links`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` - 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[analytics_admin.AuditUserLinksResponse]], - request: analytics_admin.AuditUserLinksRequest, - response: analytics_admin.AuditUserLinksResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.AuditUserLinksResponse): - 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 = analytics_admin.AuditUserLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.AuditUserLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.AuditUserLink]: - async def async_generator(): - async for page in self.pages: - for response in page.user_links: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListWebDataStreamsPager: - """A pager for iterating through ``list_web_data_streams`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``web_data_streams`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListWebDataStreams`` requests and continue to iterate - through the ``web_data_streams`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` - 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[..., analytics_admin.ListWebDataStreamsResponse], - request: analytics_admin.ListWebDataStreamsRequest, - response: analytics_admin.ListWebDataStreamsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse): - 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 = analytics_admin.ListWebDataStreamsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListWebDataStreamsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.WebDataStream]: - for page in self.pages: - yield from page.web_data_streams - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListWebDataStreamsAsyncPager: - """A pager for iterating through ``list_web_data_streams`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``web_data_streams`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListWebDataStreams`` requests and continue to iterate - through the ``web_data_streams`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` - 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[analytics_admin.ListWebDataStreamsResponse]], - request: analytics_admin.ListWebDataStreamsRequest, - response: analytics_admin.ListWebDataStreamsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse): - 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 = analytics_admin.ListWebDataStreamsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListWebDataStreamsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.WebDataStream]: - async def async_generator(): - async for page in self.pages: - for response in page.web_data_streams: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListIosAppDataStreamsPager: - """A pager for iterating through ``list_ios_app_data_streams`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``ios_app_data_streams`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListIosAppDataStreams`` requests and continue to iterate - through the ``ios_app_data_streams`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` - 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[..., analytics_admin.ListIosAppDataStreamsResponse], - request: analytics_admin.ListIosAppDataStreamsRequest, - response: analytics_admin.ListIosAppDataStreamsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse): - 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 = analytics_admin.ListIosAppDataStreamsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListIosAppDataStreamsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.IosAppDataStream]: - for page in self.pages: - yield from page.ios_app_data_streams - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListIosAppDataStreamsAsyncPager: - """A pager for iterating through ``list_ios_app_data_streams`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``ios_app_data_streams`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListIosAppDataStreams`` requests and continue to iterate - through the ``ios_app_data_streams`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` - 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[analytics_admin.ListIosAppDataStreamsResponse]], - request: analytics_admin.ListIosAppDataStreamsRequest, - response: analytics_admin.ListIosAppDataStreamsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse): - 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 = analytics_admin.ListIosAppDataStreamsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListIosAppDataStreamsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.IosAppDataStream]: - async def async_generator(): - async for page in self.pages: - for response in page.ios_app_data_streams: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAndroidAppDataStreamsPager: - """A pager for iterating through ``list_android_app_data_streams`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``android_app_data_streams`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListAndroidAppDataStreams`` requests and continue to iterate - through the ``android_app_data_streams`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` - 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[..., analytics_admin.ListAndroidAppDataStreamsResponse], - request: analytics_admin.ListAndroidAppDataStreamsRequest, - response: analytics_admin.ListAndroidAppDataStreamsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse): - 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 = analytics_admin.ListAndroidAppDataStreamsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListAndroidAppDataStreamsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.AndroidAppDataStream]: - for page in self.pages: - yield from page.android_app_data_streams - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAndroidAppDataStreamsAsyncPager: - """A pager for iterating through ``list_android_app_data_streams`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``android_app_data_streams`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListAndroidAppDataStreams`` requests and continue to iterate - through the ``android_app_data_streams`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` - 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[analytics_admin.ListAndroidAppDataStreamsResponse]], - request: analytics_admin.ListAndroidAppDataStreamsRequest, - response: analytics_admin.ListAndroidAppDataStreamsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse): - 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 = analytics_admin.ListAndroidAppDataStreamsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListAndroidAppDataStreamsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.AndroidAppDataStream]: - async def async_generator(): - async for page in self.pages: - for response in page.android_app_data_streams: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListFirebaseLinksPager: - """A pager for iterating through ``list_firebase_links`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` object, and - provides an ``__iter__`` method to iterate through its - ``firebase_links`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListFirebaseLinks`` requests and continue to iterate - through the ``firebase_links`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` - 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[..., analytics_admin.ListFirebaseLinksResponse], - request: analytics_admin.ListFirebaseLinksRequest, - response: analytics_admin.ListFirebaseLinksResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse): - 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 = analytics_admin.ListFirebaseLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListFirebaseLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.FirebaseLink]: - for page in self.pages: - yield from page.firebase_links - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListFirebaseLinksAsyncPager: - """A pager for iterating through ``list_firebase_links`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``firebase_links`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListFirebaseLinks`` requests and continue to iterate - through the ``firebase_links`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` - 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[analytics_admin.ListFirebaseLinksResponse]], - request: analytics_admin.ListFirebaseLinksRequest, - response: analytics_admin.ListFirebaseLinksResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse): - 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 = analytics_admin.ListFirebaseLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListFirebaseLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.FirebaseLink]: - async def async_generator(): - async for page in self.pages: - for response in page.firebase_links: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListGoogleAdsLinksPager: - """A pager for iterating through ``list_google_ads_links`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` object, and - provides an ``__iter__`` method to iterate through its - ``google_ads_links`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListGoogleAdsLinks`` requests and continue to iterate - through the ``google_ads_links`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` - 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[..., analytics_admin.ListGoogleAdsLinksResponse], - request: analytics_admin.ListGoogleAdsLinksRequest, - response: analytics_admin.ListGoogleAdsLinksResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse): - 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 = analytics_admin.ListGoogleAdsLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_admin.ListGoogleAdsLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.GoogleAdsLink]: - for page in self.pages: - yield from page.google_ads_links - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListGoogleAdsLinksAsyncPager: - """A pager for iterating through ``list_google_ads_links`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``google_ads_links`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListGoogleAdsLinks`` requests and continue to iterate - through the ``google_ads_links`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` - 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[analytics_admin.ListGoogleAdsLinksResponse]], - request: analytics_admin.ListGoogleAdsLinksRequest, - response: analytics_admin.ListGoogleAdsLinksResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse): - 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 = analytics_admin.ListGoogleAdsLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_admin.ListGoogleAdsLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.GoogleAdsLink]: - async def async_generator(): - async for page in self.pages: - for response in page.google_ads_links: - 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/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py deleted file mode 100644 index c11f91bc..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py +++ /dev/null @@ -1,35 +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 AnalyticsAdminServiceTransport -from .grpc import AnalyticsAdminServiceGrpcTransport -from .grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[AnalyticsAdminServiceTransport]] -_transport_registry['grpc'] = AnalyticsAdminServiceGrpcTransport -_transport_registry['grpc_asyncio'] = AnalyticsAdminServiceGrpcAsyncIOTransport - -__all__ = ( - 'AnalyticsAdminServiceTransport', - 'AnalyticsAdminServiceGrpcTransport', - 'AnalyticsAdminServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py deleted file mode 100644 index 9570d80c..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py +++ /dev/null @@ -1,790 +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 -import typing -import pkg_resources - -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore - -from google.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources -from google.protobuf import empty_pb2 as empty # type: ignore - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-analytics-admin', - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - -class AnalyticsAdminServiceTransport(abc.ABC): - """Abstract transport class for AnalyticsAdminService.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/analytics.edit', - 'https://www.googleapis.com/auth/analytics.manage.users', - 'https://www.googleapis.com/auth/analytics.manage.users.readonly', - 'https://www.googleapis.com/auth/analytics.readonly', - ) - - def __init__( - self, *, - host: str = 'analyticsadmin.googleapis.com', - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - # Save the scopes. - self._scopes = scopes or self.AUTH_SCOPES - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") - - if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, - scopes=self._scopes, - quota_project_id=quota_project_id - ) - - elif credentials is None: - credentials, _ = auth.default(scopes=self._scopes, quota_project_id=quota_project_id) - - # Save the credentials. - self._credentials = credentials - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.get_account: gapic_v1.method.wrap_method( - self.get_account, - default_timeout=60.0, - client_info=client_info, - ), - self.list_accounts: gapic_v1.method.wrap_method( - self.list_accounts, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_account: gapic_v1.method.wrap_method( - self.delete_account, - default_timeout=60.0, - client_info=client_info, - ), - self.update_account: gapic_v1.method.wrap_method( - self.update_account, - default_timeout=60.0, - client_info=client_info, - ), - self.provision_account_ticket: gapic_v1.method.wrap_method( - self.provision_account_ticket, - default_timeout=60.0, - client_info=client_info, - ), - self.list_account_summaries: gapic_v1.method.wrap_method( - self.list_account_summaries, - default_timeout=None, - client_info=client_info, - ), - self.get_property: gapic_v1.method.wrap_method( - self.get_property, - default_timeout=60.0, - client_info=client_info, - ), - self.list_properties: gapic_v1.method.wrap_method( - self.list_properties, - default_timeout=60.0, - client_info=client_info, - ), - self.create_property: gapic_v1.method.wrap_method( - self.create_property, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_property: gapic_v1.method.wrap_method( - self.delete_property, - default_timeout=60.0, - client_info=client_info, - ), - self.update_property: gapic_v1.method.wrap_method( - self.update_property, - default_timeout=60.0, - client_info=client_info, - ), - self.get_user_link: gapic_v1.method.wrap_method( - self.get_user_link, - default_timeout=60.0, - client_info=client_info, - ), - self.batch_get_user_links: gapic_v1.method.wrap_method( - self.batch_get_user_links, - default_timeout=60.0, - client_info=client_info, - ), - self.list_user_links: gapic_v1.method.wrap_method( - self.list_user_links, - default_timeout=60.0, - client_info=client_info, - ), - self.audit_user_links: gapic_v1.method.wrap_method( - self.audit_user_links, - default_timeout=60.0, - client_info=client_info, - ), - self.create_user_link: gapic_v1.method.wrap_method( - self.create_user_link, - default_timeout=60.0, - client_info=client_info, - ), - self.batch_create_user_links: gapic_v1.method.wrap_method( - self.batch_create_user_links, - default_timeout=60.0, - client_info=client_info, - ), - self.update_user_link: gapic_v1.method.wrap_method( - self.update_user_link, - default_timeout=60.0, - client_info=client_info, - ), - self.batch_update_user_links: gapic_v1.method.wrap_method( - self.batch_update_user_links, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_user_link: gapic_v1.method.wrap_method( - self.delete_user_link, - default_timeout=60.0, - client_info=client_info, - ), - self.batch_delete_user_links: gapic_v1.method.wrap_method( - self.batch_delete_user_links, - default_timeout=60.0, - client_info=client_info, - ), - self.get_web_data_stream: gapic_v1.method.wrap_method( - self.get_web_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_web_data_stream: gapic_v1.method.wrap_method( - self.delete_web_data_stream, - default_timeout=None, - client_info=client_info, - ), - self.update_web_data_stream: gapic_v1.method.wrap_method( - self.update_web_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.create_web_data_stream: gapic_v1.method.wrap_method( - self.create_web_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.list_web_data_streams: gapic_v1.method.wrap_method( - self.list_web_data_streams, - default_timeout=60.0, - client_info=client_info, - ), - self.get_ios_app_data_stream: gapic_v1.method.wrap_method( - self.get_ios_app_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_ios_app_data_stream: gapic_v1.method.wrap_method( - self.delete_ios_app_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.update_ios_app_data_stream: gapic_v1.method.wrap_method( - self.update_ios_app_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.create_ios_app_data_stream: gapic_v1.method.wrap_method( - self.create_ios_app_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.list_ios_app_data_streams: gapic_v1.method.wrap_method( - self.list_ios_app_data_streams, - default_timeout=60.0, - client_info=client_info, - ), - self.get_android_app_data_stream: gapic_v1.method.wrap_method( - self.get_android_app_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_android_app_data_stream: gapic_v1.method.wrap_method( - self.delete_android_app_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.update_android_app_data_stream: gapic_v1.method.wrap_method( - self.update_android_app_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.create_android_app_data_stream: gapic_v1.method.wrap_method( - self.create_android_app_data_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.list_android_app_data_streams: gapic_v1.method.wrap_method( - self.list_android_app_data_streams, - default_timeout=60.0, - client_info=client_info, - ), - self.get_enhanced_measurement_settings: gapic_v1.method.wrap_method( - self.get_enhanced_measurement_settings, - default_timeout=60.0, - client_info=client_info, - ), - self.update_enhanced_measurement_settings: gapic_v1.method.wrap_method( - self.update_enhanced_measurement_settings, - default_timeout=60.0, - client_info=client_info, - ), - self.create_firebase_link: gapic_v1.method.wrap_method( - self.create_firebase_link, - default_timeout=60.0, - client_info=client_info, - ), - self.update_firebase_link: gapic_v1.method.wrap_method( - self.update_firebase_link, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_firebase_link: gapic_v1.method.wrap_method( - self.delete_firebase_link, - default_timeout=60.0, - client_info=client_info, - ), - self.list_firebase_links: gapic_v1.method.wrap_method( - self.list_firebase_links, - default_timeout=60.0, - client_info=client_info, - ), - self.get_global_site_tag: gapic_v1.method.wrap_method( - self.get_global_site_tag, - default_timeout=60.0, - client_info=client_info, - ), - self.create_google_ads_link: gapic_v1.method.wrap_method( - self.create_google_ads_link, - default_timeout=60.0, - client_info=client_info, - ), - self.update_google_ads_link: gapic_v1.method.wrap_method( - self.update_google_ads_link, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_google_ads_link: gapic_v1.method.wrap_method( - self.delete_google_ads_link, - default_timeout=60.0, - client_info=client_info, - ), - self.list_google_ads_links: gapic_v1.method.wrap_method( - self.list_google_ads_links, - default_timeout=60.0, - client_info=client_info, - ), - self.get_data_sharing_settings: gapic_v1.method.wrap_method( - self.get_data_sharing_settings, - default_timeout=None, - client_info=client_info, - ), - - } - - @property - def get_account(self) -> typing.Callable[ - [analytics_admin.GetAccountRequest], - typing.Union[ - resources.Account, - typing.Awaitable[resources.Account] - ]]: - raise NotImplementedError() - - @property - def list_accounts(self) -> typing.Callable[ - [analytics_admin.ListAccountsRequest], - typing.Union[ - analytics_admin.ListAccountsResponse, - typing.Awaitable[analytics_admin.ListAccountsResponse] - ]]: - raise NotImplementedError() - - @property - def delete_account(self) -> typing.Callable[ - [analytics_admin.DeleteAccountRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def update_account(self) -> typing.Callable[ - [analytics_admin.UpdateAccountRequest], - typing.Union[ - resources.Account, - typing.Awaitable[resources.Account] - ]]: - raise NotImplementedError() - - @property - def provision_account_ticket(self) -> typing.Callable[ - [analytics_admin.ProvisionAccountTicketRequest], - typing.Union[ - analytics_admin.ProvisionAccountTicketResponse, - typing.Awaitable[analytics_admin.ProvisionAccountTicketResponse] - ]]: - raise NotImplementedError() - - @property - def list_account_summaries(self) -> typing.Callable[ - [analytics_admin.ListAccountSummariesRequest], - typing.Union[ - analytics_admin.ListAccountSummariesResponse, - typing.Awaitable[analytics_admin.ListAccountSummariesResponse] - ]]: - raise NotImplementedError() - - @property - def get_property(self) -> typing.Callable[ - [analytics_admin.GetPropertyRequest], - typing.Union[ - resources.Property, - typing.Awaitable[resources.Property] - ]]: - raise NotImplementedError() - - @property - def list_properties(self) -> typing.Callable[ - [analytics_admin.ListPropertiesRequest], - typing.Union[ - analytics_admin.ListPropertiesResponse, - typing.Awaitable[analytics_admin.ListPropertiesResponse] - ]]: - raise NotImplementedError() - - @property - def create_property(self) -> typing.Callable[ - [analytics_admin.CreatePropertyRequest], - typing.Union[ - resources.Property, - typing.Awaitable[resources.Property] - ]]: - raise NotImplementedError() - - @property - def delete_property(self) -> typing.Callable[ - [analytics_admin.DeletePropertyRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def update_property(self) -> typing.Callable[ - [analytics_admin.UpdatePropertyRequest], - typing.Union[ - resources.Property, - typing.Awaitable[resources.Property] - ]]: - raise NotImplementedError() - - @property - def get_user_link(self) -> typing.Callable[ - [analytics_admin.GetUserLinkRequest], - typing.Union[ - resources.UserLink, - typing.Awaitable[resources.UserLink] - ]]: - raise NotImplementedError() - - @property - def batch_get_user_links(self) -> typing.Callable[ - [analytics_admin.BatchGetUserLinksRequest], - typing.Union[ - analytics_admin.BatchGetUserLinksResponse, - typing.Awaitable[analytics_admin.BatchGetUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def list_user_links(self) -> typing.Callable[ - [analytics_admin.ListUserLinksRequest], - typing.Union[ - analytics_admin.ListUserLinksResponse, - typing.Awaitable[analytics_admin.ListUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def audit_user_links(self) -> typing.Callable[ - [analytics_admin.AuditUserLinksRequest], - typing.Union[ - analytics_admin.AuditUserLinksResponse, - typing.Awaitable[analytics_admin.AuditUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def create_user_link(self) -> typing.Callable[ - [analytics_admin.CreateUserLinkRequest], - typing.Union[ - resources.UserLink, - typing.Awaitable[resources.UserLink] - ]]: - raise NotImplementedError() - - @property - def batch_create_user_links(self) -> typing.Callable[ - [analytics_admin.BatchCreateUserLinksRequest], - typing.Union[ - analytics_admin.BatchCreateUserLinksResponse, - typing.Awaitable[analytics_admin.BatchCreateUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def update_user_link(self) -> typing.Callable[ - [analytics_admin.UpdateUserLinkRequest], - typing.Union[ - resources.UserLink, - typing.Awaitable[resources.UserLink] - ]]: - raise NotImplementedError() - - @property - def batch_update_user_links(self) -> typing.Callable[ - [analytics_admin.BatchUpdateUserLinksRequest], - typing.Union[ - analytics_admin.BatchUpdateUserLinksResponse, - typing.Awaitable[analytics_admin.BatchUpdateUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def delete_user_link(self) -> typing.Callable[ - [analytics_admin.DeleteUserLinkRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def batch_delete_user_links(self) -> typing.Callable[ - [analytics_admin.BatchDeleteUserLinksRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def get_web_data_stream(self) -> typing.Callable[ - [analytics_admin.GetWebDataStreamRequest], - typing.Union[ - resources.WebDataStream, - typing.Awaitable[resources.WebDataStream] - ]]: - raise NotImplementedError() - - @property - def delete_web_data_stream(self) -> typing.Callable[ - [analytics_admin.DeleteWebDataStreamRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def update_web_data_stream(self) -> typing.Callable[ - [analytics_admin.UpdateWebDataStreamRequest], - typing.Union[ - resources.WebDataStream, - typing.Awaitable[resources.WebDataStream] - ]]: - raise NotImplementedError() - - @property - def create_web_data_stream(self) -> typing.Callable[ - [analytics_admin.CreateWebDataStreamRequest], - typing.Union[ - resources.WebDataStream, - typing.Awaitable[resources.WebDataStream] - ]]: - raise NotImplementedError() - - @property - def list_web_data_streams(self) -> typing.Callable[ - [analytics_admin.ListWebDataStreamsRequest], - typing.Union[ - analytics_admin.ListWebDataStreamsResponse, - typing.Awaitable[analytics_admin.ListWebDataStreamsResponse] - ]]: - raise NotImplementedError() - - @property - def get_ios_app_data_stream(self) -> typing.Callable[ - [analytics_admin.GetIosAppDataStreamRequest], - typing.Union[ - resources.IosAppDataStream, - typing.Awaitable[resources.IosAppDataStream] - ]]: - raise NotImplementedError() - - @property - def delete_ios_app_data_stream(self) -> typing.Callable[ - [analytics_admin.DeleteIosAppDataStreamRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def update_ios_app_data_stream(self) -> typing.Callable[ - [analytics_admin.UpdateIosAppDataStreamRequest], - typing.Union[ - resources.IosAppDataStream, - typing.Awaitable[resources.IosAppDataStream] - ]]: - raise NotImplementedError() - - @property - def create_ios_app_data_stream(self) -> typing.Callable[ - [analytics_admin.CreateIosAppDataStreamRequest], - typing.Union[ - resources.IosAppDataStream, - typing.Awaitable[resources.IosAppDataStream] - ]]: - raise NotImplementedError() - - @property - def list_ios_app_data_streams(self) -> typing.Callable[ - [analytics_admin.ListIosAppDataStreamsRequest], - typing.Union[ - analytics_admin.ListIosAppDataStreamsResponse, - typing.Awaitable[analytics_admin.ListIosAppDataStreamsResponse] - ]]: - raise NotImplementedError() - - @property - def get_android_app_data_stream(self) -> typing.Callable[ - [analytics_admin.GetAndroidAppDataStreamRequest], - typing.Union[ - resources.AndroidAppDataStream, - typing.Awaitable[resources.AndroidAppDataStream] - ]]: - raise NotImplementedError() - - @property - def delete_android_app_data_stream(self) -> typing.Callable[ - [analytics_admin.DeleteAndroidAppDataStreamRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def update_android_app_data_stream(self) -> typing.Callable[ - [analytics_admin.UpdateAndroidAppDataStreamRequest], - typing.Union[ - resources.AndroidAppDataStream, - typing.Awaitable[resources.AndroidAppDataStream] - ]]: - raise NotImplementedError() - - @property - def create_android_app_data_stream(self) -> typing.Callable[ - [analytics_admin.CreateAndroidAppDataStreamRequest], - typing.Union[ - resources.AndroidAppDataStream, - typing.Awaitable[resources.AndroidAppDataStream] - ]]: - raise NotImplementedError() - - @property - def list_android_app_data_streams(self) -> typing.Callable[ - [analytics_admin.ListAndroidAppDataStreamsRequest], - typing.Union[ - analytics_admin.ListAndroidAppDataStreamsResponse, - typing.Awaitable[analytics_admin.ListAndroidAppDataStreamsResponse] - ]]: - raise NotImplementedError() - - @property - def get_enhanced_measurement_settings(self) -> typing.Callable[ - [analytics_admin.GetEnhancedMeasurementSettingsRequest], - typing.Union[ - resources.EnhancedMeasurementSettings, - typing.Awaitable[resources.EnhancedMeasurementSettings] - ]]: - raise NotImplementedError() - - @property - def update_enhanced_measurement_settings(self) -> typing.Callable[ - [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], - typing.Union[ - resources.EnhancedMeasurementSettings, - typing.Awaitable[resources.EnhancedMeasurementSettings] - ]]: - raise NotImplementedError() - - @property - def create_firebase_link(self) -> typing.Callable[ - [analytics_admin.CreateFirebaseLinkRequest], - typing.Union[ - resources.FirebaseLink, - typing.Awaitable[resources.FirebaseLink] - ]]: - raise NotImplementedError() - - @property - def update_firebase_link(self) -> typing.Callable[ - [analytics_admin.UpdateFirebaseLinkRequest], - typing.Union[ - resources.FirebaseLink, - typing.Awaitable[resources.FirebaseLink] - ]]: - raise NotImplementedError() - - @property - def delete_firebase_link(self) -> typing.Callable[ - [analytics_admin.DeleteFirebaseLinkRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def list_firebase_links(self) -> typing.Callable[ - [analytics_admin.ListFirebaseLinksRequest], - typing.Union[ - analytics_admin.ListFirebaseLinksResponse, - typing.Awaitable[analytics_admin.ListFirebaseLinksResponse] - ]]: - raise NotImplementedError() - - @property - def get_global_site_tag(self) -> typing.Callable[ - [analytics_admin.GetGlobalSiteTagRequest], - typing.Union[ - resources.GlobalSiteTag, - typing.Awaitable[resources.GlobalSiteTag] - ]]: - raise NotImplementedError() - - @property - def create_google_ads_link(self) -> typing.Callable[ - [analytics_admin.CreateGoogleAdsLinkRequest], - typing.Union[ - resources.GoogleAdsLink, - typing.Awaitable[resources.GoogleAdsLink] - ]]: - raise NotImplementedError() - - @property - def update_google_ads_link(self) -> typing.Callable[ - [analytics_admin.UpdateGoogleAdsLinkRequest], - typing.Union[ - resources.GoogleAdsLink, - typing.Awaitable[resources.GoogleAdsLink] - ]]: - raise NotImplementedError() - - @property - def delete_google_ads_link(self) -> typing.Callable[ - [analytics_admin.DeleteGoogleAdsLinkRequest], - typing.Union[ - empty.Empty, - typing.Awaitable[empty.Empty] - ]]: - raise NotImplementedError() - - @property - def list_google_ads_links(self) -> typing.Callable[ - [analytics_admin.ListGoogleAdsLinksRequest], - typing.Union[ - analytics_admin.ListGoogleAdsLinksResponse, - typing.Awaitable[analytics_admin.ListGoogleAdsLinksResponse] - ]]: - raise NotImplementedError() - - @property - def get_data_sharing_settings(self) -> typing.Callable[ - [analytics_admin.GetDataSharingSettingsRequest], - typing.Union[ - resources.DataSharingSettings, - typing.Awaitable[resources.DataSharingSettings] - ]]: - raise NotImplementedError() - - -__all__ = ( - 'AnalyticsAdminServiceTransport', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py deleted file mode 100644 index 929e3ef6..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py +++ /dev/null @@ -1,1567 +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 - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources -from google.protobuf import empty_pb2 as empty # type: ignore - -from .base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO - - -class AnalyticsAdminServiceGrpcTransport(AnalyticsAdminServiceTransport): - """gRPC backend transport for AnalyticsAdminService. - - Service Interface for the Analytics Admin API (GA4). - - 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 = 'analyticsadmin.googleapis.com', - credentials: credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'analyticsadmin.googleapis.com', - credentials: 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. - """ - scopes = scopes or cls.AUTH_SCOPES - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def get_account(self) -> Callable[ - [analytics_admin.GetAccountRequest], - resources.Account]: - r"""Return a callable for the get account method over gRPC. - - Lookup for a single Account. - - Returns: - Callable[[~.GetAccountRequest], - ~.Account]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_account' not in self._stubs: - self._stubs['get_account'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccount', - request_serializer=analytics_admin.GetAccountRequest.serialize, - response_deserializer=resources.Account.deserialize, - ) - return self._stubs['get_account'] - - @property - def list_accounts(self) -> Callable[ - [analytics_admin.ListAccountsRequest], - analytics_admin.ListAccountsResponse]: - r"""Return a callable for the list accounts method over gRPC. - - Returns all accounts accessible by the caller. - Note that these accounts might not currently have GA4 - properties. Soft-deleted (ie: "trashed") accounts are - excluded by default. Returns an empty list if no - relevant accounts are found. - - Returns: - Callable[[~.ListAccountsRequest], - ~.ListAccountsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_accounts' not in self._stubs: - self._stubs['list_accounts'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccounts', - request_serializer=analytics_admin.ListAccountsRequest.serialize, - response_deserializer=analytics_admin.ListAccountsResponse.deserialize, - ) - return self._stubs['list_accounts'] - - @property - def delete_account(self) -> Callable[ - [analytics_admin.DeleteAccountRequest], - empty.Empty]: - r"""Return a callable for the delete account method over gRPC. - - Marks target Account as soft-deleted (ie: "trashed") - and returns it. - This API does not have a method to restore soft-deleted - accounts. However, they can be restored using the Trash - Can UI. - If the accounts are not restored before the expiration - time, the account and all child resources (eg: - Properties, GoogleAdsLinks, Streams, UserLinks) will be - permanently purged. - https://support.google.com/analytics/answer/6154772 - Returns an error if the target is not found. - - Returns: - Callable[[~.DeleteAccountRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_account' not in self._stubs: - self._stubs['delete_account'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccount', - request_serializer=analytics_admin.DeleteAccountRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_account'] - - @property - def update_account(self) -> Callable[ - [analytics_admin.UpdateAccountRequest], - resources.Account]: - r"""Return a callable for the update account method over gRPC. - - Updates an account. - - Returns: - Callable[[~.UpdateAccountRequest], - ~.Account]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_account' not in self._stubs: - self._stubs['update_account'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccount', - request_serializer=analytics_admin.UpdateAccountRequest.serialize, - response_deserializer=resources.Account.deserialize, - ) - return self._stubs['update_account'] - - @property - def provision_account_ticket(self) -> Callable[ - [analytics_admin.ProvisionAccountTicketRequest], - analytics_admin.ProvisionAccountTicketResponse]: - r"""Return a callable for the provision account ticket method over gRPC. - - Requests a ticket for creating an account. - - Returns: - Callable[[~.ProvisionAccountTicketRequest], - ~.ProvisionAccountTicketResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'provision_account_ticket' not in self._stubs: - self._stubs['provision_account_ticket'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ProvisionAccountTicket', - request_serializer=analytics_admin.ProvisionAccountTicketRequest.serialize, - response_deserializer=analytics_admin.ProvisionAccountTicketResponse.deserialize, - ) - return self._stubs['provision_account_ticket'] - - @property - def list_account_summaries(self) -> Callable[ - [analytics_admin.ListAccountSummariesRequest], - analytics_admin.ListAccountSummariesResponse]: - r"""Return a callable for the list account summaries method over gRPC. - - Returns summaries of all accounts accessible by the - caller. - - Returns: - Callable[[~.ListAccountSummariesRequest], - ~.ListAccountSummariesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_account_summaries' not in self._stubs: - self._stubs['list_account_summaries'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccountSummaries', - request_serializer=analytics_admin.ListAccountSummariesRequest.serialize, - response_deserializer=analytics_admin.ListAccountSummariesResponse.deserialize, - ) - return self._stubs['list_account_summaries'] - - @property - def get_property(self) -> Callable[ - [analytics_admin.GetPropertyRequest], - resources.Property]: - r"""Return a callable for the get property method over gRPC. - - Lookup for a single "GA4" Property. - - Returns: - Callable[[~.GetPropertyRequest], - ~.Property]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_property' not in self._stubs: - self._stubs['get_property'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetProperty', - request_serializer=analytics_admin.GetPropertyRequest.serialize, - response_deserializer=resources.Property.deserialize, - ) - return self._stubs['get_property'] - - @property - def list_properties(self) -> Callable[ - [analytics_admin.ListPropertiesRequest], - analytics_admin.ListPropertiesResponse]: - r"""Return a callable for the list properties method over gRPC. - - Returns child Properties under the specified parent - Account. - Only "GA4" properties will be returned. - Properties will be excluded if the caller does not have - access. Soft-deleted (ie: "trashed") properties are - excluded by default. Returns an empty list if no - relevant properties are found. - - Returns: - Callable[[~.ListPropertiesRequest], - ~.ListPropertiesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_properties' not in self._stubs: - self._stubs['list_properties'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListProperties', - request_serializer=analytics_admin.ListPropertiesRequest.serialize, - response_deserializer=analytics_admin.ListPropertiesResponse.deserialize, - ) - return self._stubs['list_properties'] - - @property - def create_property(self) -> Callable[ - [analytics_admin.CreatePropertyRequest], - resources.Property]: - r"""Return a callable for the create property method over gRPC. - - Creates an "GA4" property with the specified location - and attributes. - - Returns: - Callable[[~.CreatePropertyRequest], - ~.Property]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_property' not in self._stubs: - self._stubs['create_property'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateProperty', - request_serializer=analytics_admin.CreatePropertyRequest.serialize, - response_deserializer=resources.Property.deserialize, - ) - return self._stubs['create_property'] - - @property - def delete_property(self) -> Callable[ - [analytics_admin.DeletePropertyRequest], - empty.Empty]: - r"""Return a callable for the delete property method over gRPC. - - Marks target Property as soft-deleted (ie: "trashed") - and returns it. - This API does not have a method to restore soft-deleted - properties. However, they can be restored using the - Trash Can UI. - If the properties are not restored before the expiration - time, the Property and all child resources (eg: - GoogleAdsLinks, Streams, UserLinks) will be permanently - purged. - https://support.google.com/analytics/answer/6154772 - Returns an error if the target is not found, or is not - an GA4 Property. - - Returns: - Callable[[~.DeletePropertyRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_property' not in self._stubs: - self._stubs['delete_property'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteProperty', - request_serializer=analytics_admin.DeletePropertyRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_property'] - - @property - def update_property(self) -> Callable[ - [analytics_admin.UpdatePropertyRequest], - resources.Property]: - r"""Return a callable for the update property method over gRPC. - - Updates a property. - - Returns: - Callable[[~.UpdatePropertyRequest], - ~.Property]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_property' not in self._stubs: - self._stubs['update_property'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateProperty', - request_serializer=analytics_admin.UpdatePropertyRequest.serialize, - response_deserializer=resources.Property.deserialize, - ) - return self._stubs['update_property'] - - @property - def get_user_link(self) -> Callable[ - [analytics_admin.GetUserLinkRequest], - resources.UserLink]: - r"""Return a callable for the get user link method over gRPC. - - Gets information about a user's link to an account or - property. - - Returns: - Callable[[~.GetUserLinkRequest], - ~.UserLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_user_link' not in self._stubs: - self._stubs['get_user_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetUserLink', - request_serializer=analytics_admin.GetUserLinkRequest.serialize, - response_deserializer=resources.UserLink.deserialize, - ) - return self._stubs['get_user_link'] - - @property - def batch_get_user_links(self) -> Callable[ - [analytics_admin.BatchGetUserLinksRequest], - analytics_admin.BatchGetUserLinksResponse]: - r"""Return a callable for the batch get user links method over gRPC. - - Gets information about multiple users' links to an - account or property. - - Returns: - Callable[[~.BatchGetUserLinksRequest], - ~.BatchGetUserLinksResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'batch_get_user_links' not in self._stubs: - self._stubs['batch_get_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchGetUserLinks', - request_serializer=analytics_admin.BatchGetUserLinksRequest.serialize, - response_deserializer=analytics_admin.BatchGetUserLinksResponse.deserialize, - ) - return self._stubs['batch_get_user_links'] - - @property - def list_user_links(self) -> Callable[ - [analytics_admin.ListUserLinksRequest], - analytics_admin.ListUserLinksResponse]: - r"""Return a callable for the list user links method over gRPC. - - Lists all user links on an account or property. - - Returns: - Callable[[~.ListUserLinksRequest], - ~.ListUserLinksResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_user_links' not in self._stubs: - self._stubs['list_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListUserLinks', - request_serializer=analytics_admin.ListUserLinksRequest.serialize, - response_deserializer=analytics_admin.ListUserLinksResponse.deserialize, - ) - return self._stubs['list_user_links'] - - @property - def audit_user_links(self) -> Callable[ - [analytics_admin.AuditUserLinksRequest], - analytics_admin.AuditUserLinksResponse]: - r"""Return a callable for the audit user links method over gRPC. - - Lists all user links on an account or property, - including implicit ones that come from effective - permissions granted by groups or organization admin - roles. - - If a returned user link does not have direct - permissions, they cannot be removed from the account or - property directly with the DeleteUserLink command. They - have to be removed from the group/etc that gives them - permissions, which is currently only usable/discoverable - in the GA or GMP UIs. - - Returns: - Callable[[~.AuditUserLinksRequest], - ~.AuditUserLinksResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'audit_user_links' not in self._stubs: - self._stubs['audit_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/AuditUserLinks', - request_serializer=analytics_admin.AuditUserLinksRequest.serialize, - response_deserializer=analytics_admin.AuditUserLinksResponse.deserialize, - ) - return self._stubs['audit_user_links'] - - @property - def create_user_link(self) -> Callable[ - [analytics_admin.CreateUserLinkRequest], - resources.UserLink]: - r"""Return a callable for the create user link method over gRPC. - - Creates a user link on an account or property. - If the user with the specified email already has - permissions on the account or property, then the user's - existing permissions will be unioned with the - permissions specified in the new UserLink. - - Returns: - Callable[[~.CreateUserLinkRequest], - ~.UserLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_user_link' not in self._stubs: - self._stubs['create_user_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateUserLink', - request_serializer=analytics_admin.CreateUserLinkRequest.serialize, - response_deserializer=resources.UserLink.deserialize, - ) - return self._stubs['create_user_link'] - - @property - def batch_create_user_links(self) -> Callable[ - [analytics_admin.BatchCreateUserLinksRequest], - analytics_admin.BatchCreateUserLinksResponse]: - r"""Return a callable for the batch create user links method over gRPC. - - Creates information about multiple users' links to an - account or property. - This method is transactional. If any UserLink cannot be - created, none of the UserLinks will be created. - - Returns: - Callable[[~.BatchCreateUserLinksRequest], - ~.BatchCreateUserLinksResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'batch_create_user_links' not in self._stubs: - self._stubs['batch_create_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchCreateUserLinks', - request_serializer=analytics_admin.BatchCreateUserLinksRequest.serialize, - response_deserializer=analytics_admin.BatchCreateUserLinksResponse.deserialize, - ) - return self._stubs['batch_create_user_links'] - - @property - def update_user_link(self) -> Callable[ - [analytics_admin.UpdateUserLinkRequest], - resources.UserLink]: - r"""Return a callable for the update user link method over gRPC. - - Updates a user link on an account or property. - - Returns: - Callable[[~.UpdateUserLinkRequest], - ~.UserLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_user_link' not in self._stubs: - self._stubs['update_user_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateUserLink', - request_serializer=analytics_admin.UpdateUserLinkRequest.serialize, - response_deserializer=resources.UserLink.deserialize, - ) - return self._stubs['update_user_link'] - - @property - def batch_update_user_links(self) -> Callable[ - [analytics_admin.BatchUpdateUserLinksRequest], - analytics_admin.BatchUpdateUserLinksResponse]: - r"""Return a callable for the batch update user links method over gRPC. - - Updates information about multiple users' links to an - account or property. - - Returns: - Callable[[~.BatchUpdateUserLinksRequest], - ~.BatchUpdateUserLinksResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'batch_update_user_links' not in self._stubs: - self._stubs['batch_update_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchUpdateUserLinks', - request_serializer=analytics_admin.BatchUpdateUserLinksRequest.serialize, - response_deserializer=analytics_admin.BatchUpdateUserLinksResponse.deserialize, - ) - return self._stubs['batch_update_user_links'] - - @property - def delete_user_link(self) -> Callable[ - [analytics_admin.DeleteUserLinkRequest], - empty.Empty]: - r"""Return a callable for the delete user link method over gRPC. - - Deletes a user link on an account or property. - - Returns: - Callable[[~.DeleteUserLinkRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_user_link' not in self._stubs: - self._stubs['delete_user_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteUserLink', - request_serializer=analytics_admin.DeleteUserLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_user_link'] - - @property - def batch_delete_user_links(self) -> Callable[ - [analytics_admin.BatchDeleteUserLinksRequest], - empty.Empty]: - r"""Return a callable for the batch delete user links method over gRPC. - - Deletes information about multiple users' links to an - account or property. - - Returns: - Callable[[~.BatchDeleteUserLinksRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'batch_delete_user_links' not in self._stubs: - self._stubs['batch_delete_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteUserLinks', - request_serializer=analytics_admin.BatchDeleteUserLinksRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['batch_delete_user_links'] - - @property - def get_web_data_stream(self) -> Callable[ - [analytics_admin.GetWebDataStreamRequest], - resources.WebDataStream]: - r"""Return a callable for the get web data stream method over gRPC. - - Lookup for a single WebDataStream - - Returns: - Callable[[~.GetWebDataStreamRequest], - ~.WebDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: - self._stubs['get_web_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetWebDataStream', - request_serializer=analytics_admin.GetWebDataStreamRequest.serialize, - response_deserializer=resources.WebDataStream.deserialize, - ) - return self._stubs['get_web_data_stream'] - - @property - def delete_web_data_stream(self) -> Callable[ - [analytics_admin.DeleteWebDataStreamRequest], - empty.Empty]: - r"""Return a callable for the delete web data stream method over gRPC. - - Deletes a web stream on a property. - - Returns: - Callable[[~.DeleteWebDataStreamRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_web_data_stream' not in self._stubs: - self._stubs['delete_web_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteWebDataStream', - request_serializer=analytics_admin.DeleteWebDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_web_data_stream'] - - @property - def update_web_data_stream(self) -> Callable[ - [analytics_admin.UpdateWebDataStreamRequest], - resources.WebDataStream]: - r"""Return a callable for the update web data stream method over gRPC. - - Updates a web stream on a property. - - Returns: - Callable[[~.UpdateWebDataStreamRequest], - ~.WebDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: - self._stubs['update_web_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateWebDataStream', - request_serializer=analytics_admin.UpdateWebDataStreamRequest.serialize, - response_deserializer=resources.WebDataStream.deserialize, - ) - return self._stubs['update_web_data_stream'] - - @property - def create_web_data_stream(self) -> Callable[ - [analytics_admin.CreateWebDataStreamRequest], - resources.WebDataStream]: - r"""Return a callable for the create web data stream method over gRPC. - - Creates a web stream with the specified location and - attributes. - - Returns: - Callable[[~.CreateWebDataStreamRequest], - ~.WebDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: - self._stubs['create_web_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateWebDataStream', - request_serializer=analytics_admin.CreateWebDataStreamRequest.serialize, - response_deserializer=resources.WebDataStream.deserialize, - ) - return self._stubs['create_web_data_stream'] - - @property - def list_web_data_streams(self) -> Callable[ - [analytics_admin.ListWebDataStreamsRequest], - analytics_admin.ListWebDataStreamsResponse]: - r"""Return a callable for the list web data streams method over gRPC. - - Returns child web data streams under the specified - parent property. - Web data streams will be excluded if the caller does not - have access. Returns an empty list if no relevant web - data streams are found. - - Returns: - Callable[[~.ListWebDataStreamsRequest], - ~.ListWebDataStreamsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_web_data_streams' not in self._stubs: - self._stubs['list_web_data_streams'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListWebDataStreams', - request_serializer=analytics_admin.ListWebDataStreamsRequest.serialize, - response_deserializer=analytics_admin.ListWebDataStreamsResponse.deserialize, - ) - return self._stubs['list_web_data_streams'] - - @property - def get_ios_app_data_stream(self) -> Callable[ - [analytics_admin.GetIosAppDataStreamRequest], - resources.IosAppDataStream]: - r"""Return a callable for the get ios app data stream method over gRPC. - - Lookup for a single IosAppDataStream - - Returns: - Callable[[~.GetIosAppDataStreamRequest], - ~.IosAppDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: - self._stubs['get_ios_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetIosAppDataStream', - request_serializer=analytics_admin.GetIosAppDataStreamRequest.serialize, - response_deserializer=resources.IosAppDataStream.deserialize, - ) - return self._stubs['get_ios_app_data_stream'] - - @property - def delete_ios_app_data_stream(self) -> Callable[ - [analytics_admin.DeleteIosAppDataStreamRequest], - empty.Empty]: - r"""Return a callable for the delete ios app data stream method over gRPC. - - Deletes an iOS app stream on a property. - - Returns: - Callable[[~.DeleteIosAppDataStreamRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_ios_app_data_stream' not in self._stubs: - self._stubs['delete_ios_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteIosAppDataStream', - request_serializer=analytics_admin.DeleteIosAppDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_ios_app_data_stream'] - - @property - def update_ios_app_data_stream(self) -> Callable[ - [analytics_admin.UpdateIosAppDataStreamRequest], - resources.IosAppDataStream]: - r"""Return a callable for the update ios app data stream method over gRPC. - - Updates an iOS app stream on a property. - - Returns: - Callable[[~.UpdateIosAppDataStreamRequest], - ~.IosAppDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: - self._stubs['update_ios_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateIosAppDataStream', - request_serializer=analytics_admin.UpdateIosAppDataStreamRequest.serialize, - response_deserializer=resources.IosAppDataStream.deserialize, - ) - return self._stubs['update_ios_app_data_stream'] - - @property - def create_ios_app_data_stream(self) -> Callable[ - [analytics_admin.CreateIosAppDataStreamRequest], - resources.IosAppDataStream]: - r"""Return a callable for the create ios app data stream method over gRPC. - - Creates an iOS app stream with the specified location - and attributes. - Note that an iOS app stream must be linked to a Firebase - app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Returns: - Callable[[~.CreateIosAppDataStreamRequest], - ~.IosAppDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: - self._stubs['create_ios_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateIosAppDataStream', - request_serializer=analytics_admin.CreateIosAppDataStreamRequest.serialize, - response_deserializer=resources.IosAppDataStream.deserialize, - ) - return self._stubs['create_ios_app_data_stream'] - - @property - def list_ios_app_data_streams(self) -> Callable[ - [analytics_admin.ListIosAppDataStreamsRequest], - analytics_admin.ListIosAppDataStreamsResponse]: - r"""Return a callable for the list ios app data streams method over gRPC. - - Returns child iOS app data streams under the - specified parent property. - iOS app data streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - iOS app data streams are found. - - Returns: - Callable[[~.ListIosAppDataStreamsRequest], - ~.ListIosAppDataStreamsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_ios_app_data_streams' not in self._stubs: - self._stubs['list_ios_app_data_streams'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListIosAppDataStreams', - request_serializer=analytics_admin.ListIosAppDataStreamsRequest.serialize, - response_deserializer=analytics_admin.ListIosAppDataStreamsResponse.deserialize, - ) - return self._stubs['list_ios_app_data_streams'] - - @property - def get_android_app_data_stream(self) -> Callable[ - [analytics_admin.GetAndroidAppDataStreamRequest], - resources.AndroidAppDataStream]: - r"""Return a callable for the get android app data stream method over gRPC. - - Lookup for a single AndroidAppDataStream - - Returns: - Callable[[~.GetAndroidAppDataStreamRequest], - ~.AndroidAppDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: - self._stubs['get_android_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAndroidAppDataStream', - request_serializer=analytics_admin.GetAndroidAppDataStreamRequest.serialize, - response_deserializer=resources.AndroidAppDataStream.deserialize, - ) - return self._stubs['get_android_app_data_stream'] - - @property - def delete_android_app_data_stream(self) -> Callable[ - [analytics_admin.DeleteAndroidAppDataStreamRequest], - empty.Empty]: - r"""Return a callable for the delete android app data stream method over gRPC. - - Deletes an android app stream on a property. - - Returns: - Callable[[~.DeleteAndroidAppDataStreamRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_android_app_data_stream' not in self._stubs: - self._stubs['delete_android_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAndroidAppDataStream', - request_serializer=analytics_admin.DeleteAndroidAppDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_android_app_data_stream'] - - @property - def update_android_app_data_stream(self) -> Callable[ - [analytics_admin.UpdateAndroidAppDataStreamRequest], - resources.AndroidAppDataStream]: - r"""Return a callable for the update android app data stream method over gRPC. - - Updates an android app stream on a property. - - Returns: - Callable[[~.UpdateAndroidAppDataStreamRequest], - ~.AndroidAppDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: - self._stubs['update_android_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAndroidAppDataStream', - request_serializer=analytics_admin.UpdateAndroidAppDataStreamRequest.serialize, - response_deserializer=resources.AndroidAppDataStream.deserialize, - ) - return self._stubs['update_android_app_data_stream'] - - @property - def create_android_app_data_stream(self) -> Callable[ - [analytics_admin.CreateAndroidAppDataStreamRequest], - resources.AndroidAppDataStream]: - r"""Return a callable for the create android app data stream method over gRPC. - - Creates an Android app stream with the specified - location and attributes. - Note that an Android app stream must be linked to a - Firebase app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Returns: - Callable[[~.CreateAndroidAppDataStreamRequest], - ~.AndroidAppDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: - self._stubs['create_android_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAndroidAppDataStream', - request_serializer=analytics_admin.CreateAndroidAppDataStreamRequest.serialize, - response_deserializer=resources.AndroidAppDataStream.deserialize, - ) - return self._stubs['create_android_app_data_stream'] - - @property - def list_android_app_data_streams(self) -> Callable[ - [analytics_admin.ListAndroidAppDataStreamsRequest], - analytics_admin.ListAndroidAppDataStreamsResponse]: - r"""Return a callable for the list android app data streams method over gRPC. - - Returns child android app streams under the specified - parent property. - Android app streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - android app streams are found. - - Returns: - Callable[[~.ListAndroidAppDataStreamsRequest], - ~.ListAndroidAppDataStreamsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_android_app_data_streams' not in self._stubs: - self._stubs['list_android_app_data_streams'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAndroidAppDataStreams', - request_serializer=analytics_admin.ListAndroidAppDataStreamsRequest.serialize, - response_deserializer=analytics_admin.ListAndroidAppDataStreamsResponse.deserialize, - ) - return self._stubs['list_android_app_data_streams'] - - @property - def get_enhanced_measurement_settings(self) -> Callable[ - [analytics_admin.GetEnhancedMeasurementSettingsRequest], - resources.EnhancedMeasurementSettings]: - r"""Return a callable for the get enhanced measurement - settings method over gRPC. - - Returns the singleton enhanced measurement settings - for this web stream. Note that the stream must enable - enhanced measurement for these settings to take effect. - - Returns: - Callable[[~.GetEnhancedMeasurementSettingsRequest], - ~.EnhancedMeasurementSettings]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_enhanced_measurement_settings' not in self._stubs: - self._stubs['get_enhanced_measurement_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEnhancedMeasurementSettings', - request_serializer=analytics_admin.GetEnhancedMeasurementSettingsRequest.serialize, - response_deserializer=resources.EnhancedMeasurementSettings.deserialize, - ) - return self._stubs['get_enhanced_measurement_settings'] - - @property - def update_enhanced_measurement_settings(self) -> Callable[ - [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], - resources.EnhancedMeasurementSettings]: - r"""Return a callable for the update enhanced measurement - settings method over gRPC. - - Updates the singleton enhanced measurement settings - for this web stream. Note that the stream must enable - enhanced measurement for these settings to take effect. - - Returns: - Callable[[~.UpdateEnhancedMeasurementSettingsRequest], - ~.EnhancedMeasurementSettings]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_enhanced_measurement_settings' not in self._stubs: - self._stubs['update_enhanced_measurement_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEnhancedMeasurementSettings', - request_serializer=analytics_admin.UpdateEnhancedMeasurementSettingsRequest.serialize, - response_deserializer=resources.EnhancedMeasurementSettings.deserialize, - ) - return self._stubs['update_enhanced_measurement_settings'] - - @property - def create_firebase_link(self) -> Callable[ - [analytics_admin.CreateFirebaseLinkRequest], - resources.FirebaseLink]: - r"""Return a callable for the create firebase link method over gRPC. - - Creates a FirebaseLink. - Properties can have at most one FirebaseLink. - - Returns: - Callable[[~.CreateFirebaseLinkRequest], - ~.FirebaseLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_firebase_link' not in self._stubs: - self._stubs['create_firebase_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateFirebaseLink', - request_serializer=analytics_admin.CreateFirebaseLinkRequest.serialize, - response_deserializer=resources.FirebaseLink.deserialize, - ) - return self._stubs['create_firebase_link'] - - @property - def update_firebase_link(self) -> Callable[ - [analytics_admin.UpdateFirebaseLinkRequest], - resources.FirebaseLink]: - r"""Return a callable for the update firebase link method over gRPC. - - Updates a FirebaseLink on a property - - Returns: - Callable[[~.UpdateFirebaseLinkRequest], - ~.FirebaseLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_firebase_link' not in self._stubs: - self._stubs['update_firebase_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateFirebaseLink', - request_serializer=analytics_admin.UpdateFirebaseLinkRequest.serialize, - response_deserializer=resources.FirebaseLink.deserialize, - ) - return self._stubs['update_firebase_link'] - - @property - def delete_firebase_link(self) -> Callable[ - [analytics_admin.DeleteFirebaseLinkRequest], - empty.Empty]: - r"""Return a callable for the delete firebase link method over gRPC. - - Deletes a FirebaseLink on a property - - Returns: - Callable[[~.DeleteFirebaseLinkRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_firebase_link' not in self._stubs: - self._stubs['delete_firebase_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteFirebaseLink', - request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_firebase_link'] - - @property - def list_firebase_links(self) -> Callable[ - [analytics_admin.ListFirebaseLinksRequest], - analytics_admin.ListFirebaseLinksResponse]: - r"""Return a callable for the list firebase links method over gRPC. - - Lists FirebaseLinks on a property. - Properties can have at most one FirebaseLink. - - Returns: - Callable[[~.ListFirebaseLinksRequest], - ~.ListFirebaseLinksResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_firebase_links' not in self._stubs: - self._stubs['list_firebase_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListFirebaseLinks', - request_serializer=analytics_admin.ListFirebaseLinksRequest.serialize, - response_deserializer=analytics_admin.ListFirebaseLinksResponse.deserialize, - ) - return self._stubs['list_firebase_links'] - - @property - def get_global_site_tag(self) -> Callable[ - [analytics_admin.GetGlobalSiteTagRequest], - resources.GlobalSiteTag]: - r"""Return a callable for the get global site tag method over gRPC. - - Returns the Site Tag for the specified web stream. - Site Tags are immutable singletons. - - Returns: - Callable[[~.GetGlobalSiteTagRequest], - ~.GlobalSiteTag]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_global_site_tag' not in self._stubs: - self._stubs['get_global_site_tag'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGlobalSiteTag', - request_serializer=analytics_admin.GetGlobalSiteTagRequest.serialize, - response_deserializer=resources.GlobalSiteTag.deserialize, - ) - return self._stubs['get_global_site_tag'] - - @property - def create_google_ads_link(self) -> Callable[ - [analytics_admin.CreateGoogleAdsLinkRequest], - resources.GoogleAdsLink]: - r"""Return a callable for the create google ads link method over gRPC. - - Creates a GoogleAdsLink. - - Returns: - Callable[[~.CreateGoogleAdsLinkRequest], - ~.GoogleAdsLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_google_ads_link' not in self._stubs: - self._stubs['create_google_ads_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateGoogleAdsLink', - request_serializer=analytics_admin.CreateGoogleAdsLinkRequest.serialize, - response_deserializer=resources.GoogleAdsLink.deserialize, - ) - return self._stubs['create_google_ads_link'] - - @property - def update_google_ads_link(self) -> Callable[ - [analytics_admin.UpdateGoogleAdsLinkRequest], - resources.GoogleAdsLink]: - r"""Return a callable for the update google ads link method over gRPC. - - Updates a GoogleAdsLink on a property - - Returns: - Callable[[~.UpdateGoogleAdsLinkRequest], - ~.GoogleAdsLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_google_ads_link' not in self._stubs: - self._stubs['update_google_ads_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleAdsLink', - request_serializer=analytics_admin.UpdateGoogleAdsLinkRequest.serialize, - response_deserializer=resources.GoogleAdsLink.deserialize, - ) - return self._stubs['update_google_ads_link'] - - @property - def delete_google_ads_link(self) -> Callable[ - [analytics_admin.DeleteGoogleAdsLinkRequest], - empty.Empty]: - r"""Return a callable for the delete google ads link method over gRPC. - - Deletes a GoogleAdsLink on a property - - Returns: - Callable[[~.DeleteGoogleAdsLinkRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_google_ads_link' not in self._stubs: - self._stubs['delete_google_ads_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteGoogleAdsLink', - request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_google_ads_link'] - - @property - def list_google_ads_links(self) -> Callable[ - [analytics_admin.ListGoogleAdsLinksRequest], - analytics_admin.ListGoogleAdsLinksResponse]: - r"""Return a callable for the list google ads links method over gRPC. - - Lists GoogleAdsLinks on a property. - - Returns: - Callable[[~.ListGoogleAdsLinksRequest], - ~.ListGoogleAdsLinksResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_google_ads_links' not in self._stubs: - self._stubs['list_google_ads_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListGoogleAdsLinks', - request_serializer=analytics_admin.ListGoogleAdsLinksRequest.serialize, - response_deserializer=analytics_admin.ListGoogleAdsLinksResponse.deserialize, - ) - return self._stubs['list_google_ads_links'] - - @property - def get_data_sharing_settings(self) -> Callable[ - [analytics_admin.GetDataSharingSettingsRequest], - resources.DataSharingSettings]: - r"""Return a callable for the get data sharing settings method over gRPC. - - Get data sharing settings on an account. - Data sharing settings are singletons. - - Returns: - Callable[[~.GetDataSharingSettingsRequest], - ~.DataSharingSettings]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_data_sharing_settings' not in self._stubs: - self._stubs['get_data_sharing_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataSharingSettings', - request_serializer=analytics_admin.GetDataSharingSettingsRequest.serialize, - response_deserializer=resources.DataSharingSettings.deserialize, - ) - return self._stubs['get_data_sharing_settings'] - - -__all__ = ( - 'AnalyticsAdminServiceGrpcTransport', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py deleted file mode 100644 index 74aecae9..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,1572 +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 - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google import auth # type: ignore -from google.auth import 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.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources -from google.protobuf import empty_pb2 as empty # type: ignore - -from .base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import AnalyticsAdminServiceGrpcTransport - - -class AnalyticsAdminServiceGrpcAsyncIOTransport(AnalyticsAdminServiceTransport): - """gRPC AsyncIO backend transport for AnalyticsAdminService. - - Service Interface for the Analytics Admin API (GA4). - - 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 = 'analyticsadmin.googleapis.com', - credentials: 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. - """ - scopes = scopes or cls.AUTH_SCOPES - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - **kwargs - ) - - def __init__(self, *, - host: str = 'analyticsadmin.googleapis.com', - credentials: credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def get_account(self) -> Callable[ - [analytics_admin.GetAccountRequest], - Awaitable[resources.Account]]: - r"""Return a callable for the get account method over gRPC. - - Lookup for a single Account. - - Returns: - Callable[[~.GetAccountRequest], - Awaitable[~.Account]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_account' not in self._stubs: - self._stubs['get_account'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccount', - request_serializer=analytics_admin.GetAccountRequest.serialize, - response_deserializer=resources.Account.deserialize, - ) - return self._stubs['get_account'] - - @property - def list_accounts(self) -> Callable[ - [analytics_admin.ListAccountsRequest], - Awaitable[analytics_admin.ListAccountsResponse]]: - r"""Return a callable for the list accounts method over gRPC. - - Returns all accounts accessible by the caller. - Note that these accounts might not currently have GA4 - properties. Soft-deleted (ie: "trashed") accounts are - excluded by default. Returns an empty list if no - relevant accounts are found. - - Returns: - Callable[[~.ListAccountsRequest], - Awaitable[~.ListAccountsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_accounts' not in self._stubs: - self._stubs['list_accounts'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccounts', - request_serializer=analytics_admin.ListAccountsRequest.serialize, - response_deserializer=analytics_admin.ListAccountsResponse.deserialize, - ) - return self._stubs['list_accounts'] - - @property - def delete_account(self) -> Callable[ - [analytics_admin.DeleteAccountRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the delete account method over gRPC. - - Marks target Account as soft-deleted (ie: "trashed") - and returns it. - This API does not have a method to restore soft-deleted - accounts. However, they can be restored using the Trash - Can UI. - If the accounts are not restored before the expiration - time, the account and all child resources (eg: - Properties, GoogleAdsLinks, Streams, UserLinks) will be - permanently purged. - https://support.google.com/analytics/answer/6154772 - Returns an error if the target is not found. - - Returns: - Callable[[~.DeleteAccountRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_account' not in self._stubs: - self._stubs['delete_account'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccount', - request_serializer=analytics_admin.DeleteAccountRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_account'] - - @property - def update_account(self) -> Callable[ - [analytics_admin.UpdateAccountRequest], - Awaitable[resources.Account]]: - r"""Return a callable for the update account method over gRPC. - - Updates an account. - - Returns: - Callable[[~.UpdateAccountRequest], - Awaitable[~.Account]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_account' not in self._stubs: - self._stubs['update_account'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccount', - request_serializer=analytics_admin.UpdateAccountRequest.serialize, - response_deserializer=resources.Account.deserialize, - ) - return self._stubs['update_account'] - - @property - def provision_account_ticket(self) -> Callable[ - [analytics_admin.ProvisionAccountTicketRequest], - Awaitable[analytics_admin.ProvisionAccountTicketResponse]]: - r"""Return a callable for the provision account ticket method over gRPC. - - Requests a ticket for creating an account. - - Returns: - Callable[[~.ProvisionAccountTicketRequest], - Awaitable[~.ProvisionAccountTicketResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'provision_account_ticket' not in self._stubs: - self._stubs['provision_account_ticket'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ProvisionAccountTicket', - request_serializer=analytics_admin.ProvisionAccountTicketRequest.serialize, - response_deserializer=analytics_admin.ProvisionAccountTicketResponse.deserialize, - ) - return self._stubs['provision_account_ticket'] - - @property - def list_account_summaries(self) -> Callable[ - [analytics_admin.ListAccountSummariesRequest], - Awaitable[analytics_admin.ListAccountSummariesResponse]]: - r"""Return a callable for the list account summaries method over gRPC. - - Returns summaries of all accounts accessible by the - caller. - - Returns: - Callable[[~.ListAccountSummariesRequest], - Awaitable[~.ListAccountSummariesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_account_summaries' not in self._stubs: - self._stubs['list_account_summaries'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccountSummaries', - request_serializer=analytics_admin.ListAccountSummariesRequest.serialize, - response_deserializer=analytics_admin.ListAccountSummariesResponse.deserialize, - ) - return self._stubs['list_account_summaries'] - - @property - def get_property(self) -> Callable[ - [analytics_admin.GetPropertyRequest], - Awaitable[resources.Property]]: - r"""Return a callable for the get property method over gRPC. - - Lookup for a single "GA4" Property. - - Returns: - Callable[[~.GetPropertyRequest], - Awaitable[~.Property]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_property' not in self._stubs: - self._stubs['get_property'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetProperty', - request_serializer=analytics_admin.GetPropertyRequest.serialize, - response_deserializer=resources.Property.deserialize, - ) - return self._stubs['get_property'] - - @property - def list_properties(self) -> Callable[ - [analytics_admin.ListPropertiesRequest], - Awaitable[analytics_admin.ListPropertiesResponse]]: - r"""Return a callable for the list properties method over gRPC. - - Returns child Properties under the specified parent - Account. - Only "GA4" properties will be returned. - Properties will be excluded if the caller does not have - access. Soft-deleted (ie: "trashed") properties are - excluded by default. Returns an empty list if no - relevant properties are found. - - Returns: - Callable[[~.ListPropertiesRequest], - Awaitable[~.ListPropertiesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_properties' not in self._stubs: - self._stubs['list_properties'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListProperties', - request_serializer=analytics_admin.ListPropertiesRequest.serialize, - response_deserializer=analytics_admin.ListPropertiesResponse.deserialize, - ) - return self._stubs['list_properties'] - - @property - def create_property(self) -> Callable[ - [analytics_admin.CreatePropertyRequest], - Awaitable[resources.Property]]: - r"""Return a callable for the create property method over gRPC. - - Creates an "GA4" property with the specified location - and attributes. - - Returns: - Callable[[~.CreatePropertyRequest], - Awaitable[~.Property]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_property' not in self._stubs: - self._stubs['create_property'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateProperty', - request_serializer=analytics_admin.CreatePropertyRequest.serialize, - response_deserializer=resources.Property.deserialize, - ) - return self._stubs['create_property'] - - @property - def delete_property(self) -> Callable[ - [analytics_admin.DeletePropertyRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the delete property method over gRPC. - - Marks target Property as soft-deleted (ie: "trashed") - and returns it. - This API does not have a method to restore soft-deleted - properties. However, they can be restored using the - Trash Can UI. - If the properties are not restored before the expiration - time, the Property and all child resources (eg: - GoogleAdsLinks, Streams, UserLinks) will be permanently - purged. - https://support.google.com/analytics/answer/6154772 - Returns an error if the target is not found, or is not - an GA4 Property. - - Returns: - Callable[[~.DeletePropertyRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_property' not in self._stubs: - self._stubs['delete_property'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteProperty', - request_serializer=analytics_admin.DeletePropertyRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_property'] - - @property - def update_property(self) -> Callable[ - [analytics_admin.UpdatePropertyRequest], - Awaitable[resources.Property]]: - r"""Return a callable for the update property method over gRPC. - - Updates a property. - - Returns: - Callable[[~.UpdatePropertyRequest], - Awaitable[~.Property]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_property' not in self._stubs: - self._stubs['update_property'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateProperty', - request_serializer=analytics_admin.UpdatePropertyRequest.serialize, - response_deserializer=resources.Property.deserialize, - ) - return self._stubs['update_property'] - - @property - def get_user_link(self) -> Callable[ - [analytics_admin.GetUserLinkRequest], - Awaitable[resources.UserLink]]: - r"""Return a callable for the get user link method over gRPC. - - Gets information about a user's link to an account or - property. - - Returns: - Callable[[~.GetUserLinkRequest], - Awaitable[~.UserLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_user_link' not in self._stubs: - self._stubs['get_user_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetUserLink', - request_serializer=analytics_admin.GetUserLinkRequest.serialize, - response_deserializer=resources.UserLink.deserialize, - ) - return self._stubs['get_user_link'] - - @property - def batch_get_user_links(self) -> Callable[ - [analytics_admin.BatchGetUserLinksRequest], - Awaitable[analytics_admin.BatchGetUserLinksResponse]]: - r"""Return a callable for the batch get user links method over gRPC. - - Gets information about multiple users' links to an - account or property. - - Returns: - Callable[[~.BatchGetUserLinksRequest], - Awaitable[~.BatchGetUserLinksResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'batch_get_user_links' not in self._stubs: - self._stubs['batch_get_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchGetUserLinks', - request_serializer=analytics_admin.BatchGetUserLinksRequest.serialize, - response_deserializer=analytics_admin.BatchGetUserLinksResponse.deserialize, - ) - return self._stubs['batch_get_user_links'] - - @property - def list_user_links(self) -> Callable[ - [analytics_admin.ListUserLinksRequest], - Awaitable[analytics_admin.ListUserLinksResponse]]: - r"""Return a callable for the list user links method over gRPC. - - Lists all user links on an account or property. - - Returns: - Callable[[~.ListUserLinksRequest], - Awaitable[~.ListUserLinksResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_user_links' not in self._stubs: - self._stubs['list_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListUserLinks', - request_serializer=analytics_admin.ListUserLinksRequest.serialize, - response_deserializer=analytics_admin.ListUserLinksResponse.deserialize, - ) - return self._stubs['list_user_links'] - - @property - def audit_user_links(self) -> Callable[ - [analytics_admin.AuditUserLinksRequest], - Awaitable[analytics_admin.AuditUserLinksResponse]]: - r"""Return a callable for the audit user links method over gRPC. - - Lists all user links on an account or property, - including implicit ones that come from effective - permissions granted by groups or organization admin - roles. - - If a returned user link does not have direct - permissions, they cannot be removed from the account or - property directly with the DeleteUserLink command. They - have to be removed from the group/etc that gives them - permissions, which is currently only usable/discoverable - in the GA or GMP UIs. - - Returns: - Callable[[~.AuditUserLinksRequest], - Awaitable[~.AuditUserLinksResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'audit_user_links' not in self._stubs: - self._stubs['audit_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/AuditUserLinks', - request_serializer=analytics_admin.AuditUserLinksRequest.serialize, - response_deserializer=analytics_admin.AuditUserLinksResponse.deserialize, - ) - return self._stubs['audit_user_links'] - - @property - def create_user_link(self) -> Callable[ - [analytics_admin.CreateUserLinkRequest], - Awaitable[resources.UserLink]]: - r"""Return a callable for the create user link method over gRPC. - - Creates a user link on an account or property. - If the user with the specified email already has - permissions on the account or property, then the user's - existing permissions will be unioned with the - permissions specified in the new UserLink. - - Returns: - Callable[[~.CreateUserLinkRequest], - Awaitable[~.UserLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_user_link' not in self._stubs: - self._stubs['create_user_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateUserLink', - request_serializer=analytics_admin.CreateUserLinkRequest.serialize, - response_deserializer=resources.UserLink.deserialize, - ) - return self._stubs['create_user_link'] - - @property - def batch_create_user_links(self) -> Callable[ - [analytics_admin.BatchCreateUserLinksRequest], - Awaitable[analytics_admin.BatchCreateUserLinksResponse]]: - r"""Return a callable for the batch create user links method over gRPC. - - Creates information about multiple users' links to an - account or property. - This method is transactional. If any UserLink cannot be - created, none of the UserLinks will be created. - - Returns: - Callable[[~.BatchCreateUserLinksRequest], - Awaitable[~.BatchCreateUserLinksResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'batch_create_user_links' not in self._stubs: - self._stubs['batch_create_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchCreateUserLinks', - request_serializer=analytics_admin.BatchCreateUserLinksRequest.serialize, - response_deserializer=analytics_admin.BatchCreateUserLinksResponse.deserialize, - ) - return self._stubs['batch_create_user_links'] - - @property - def update_user_link(self) -> Callable[ - [analytics_admin.UpdateUserLinkRequest], - Awaitable[resources.UserLink]]: - r"""Return a callable for the update user link method over gRPC. - - Updates a user link on an account or property. - - Returns: - Callable[[~.UpdateUserLinkRequest], - Awaitable[~.UserLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_user_link' not in self._stubs: - self._stubs['update_user_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateUserLink', - request_serializer=analytics_admin.UpdateUserLinkRequest.serialize, - response_deserializer=resources.UserLink.deserialize, - ) - return self._stubs['update_user_link'] - - @property - def batch_update_user_links(self) -> Callable[ - [analytics_admin.BatchUpdateUserLinksRequest], - Awaitable[analytics_admin.BatchUpdateUserLinksResponse]]: - r"""Return a callable for the batch update user links method over gRPC. - - Updates information about multiple users' links to an - account or property. - - Returns: - Callable[[~.BatchUpdateUserLinksRequest], - Awaitable[~.BatchUpdateUserLinksResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'batch_update_user_links' not in self._stubs: - self._stubs['batch_update_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchUpdateUserLinks', - request_serializer=analytics_admin.BatchUpdateUserLinksRequest.serialize, - response_deserializer=analytics_admin.BatchUpdateUserLinksResponse.deserialize, - ) - return self._stubs['batch_update_user_links'] - - @property - def delete_user_link(self) -> Callable[ - [analytics_admin.DeleteUserLinkRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the delete user link method over gRPC. - - Deletes a user link on an account or property. - - Returns: - Callable[[~.DeleteUserLinkRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_user_link' not in self._stubs: - self._stubs['delete_user_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteUserLink', - request_serializer=analytics_admin.DeleteUserLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_user_link'] - - @property - def batch_delete_user_links(self) -> Callable[ - [analytics_admin.BatchDeleteUserLinksRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the batch delete user links method over gRPC. - - Deletes information about multiple users' links to an - account or property. - - Returns: - Callable[[~.BatchDeleteUserLinksRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'batch_delete_user_links' not in self._stubs: - self._stubs['batch_delete_user_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteUserLinks', - request_serializer=analytics_admin.BatchDeleteUserLinksRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['batch_delete_user_links'] - - @property - def get_web_data_stream(self) -> Callable[ - [analytics_admin.GetWebDataStreamRequest], - Awaitable[resources.WebDataStream]]: - r"""Return a callable for the get web data stream method over gRPC. - - Lookup for a single WebDataStream - - Returns: - Callable[[~.GetWebDataStreamRequest], - Awaitable[~.WebDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: - self._stubs['get_web_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetWebDataStream', - request_serializer=analytics_admin.GetWebDataStreamRequest.serialize, - response_deserializer=resources.WebDataStream.deserialize, - ) - return self._stubs['get_web_data_stream'] - - @property - def delete_web_data_stream(self) -> Callable[ - [analytics_admin.DeleteWebDataStreamRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the delete web data stream method over gRPC. - - Deletes a web stream on a property. - - Returns: - Callable[[~.DeleteWebDataStreamRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_web_data_stream' not in self._stubs: - self._stubs['delete_web_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteWebDataStream', - request_serializer=analytics_admin.DeleteWebDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_web_data_stream'] - - @property - def update_web_data_stream(self) -> Callable[ - [analytics_admin.UpdateWebDataStreamRequest], - Awaitable[resources.WebDataStream]]: - r"""Return a callable for the update web data stream method over gRPC. - - Updates a web stream on a property. - - Returns: - Callable[[~.UpdateWebDataStreamRequest], - Awaitable[~.WebDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: - self._stubs['update_web_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateWebDataStream', - request_serializer=analytics_admin.UpdateWebDataStreamRequest.serialize, - response_deserializer=resources.WebDataStream.deserialize, - ) - return self._stubs['update_web_data_stream'] - - @property - def create_web_data_stream(self) -> Callable[ - [analytics_admin.CreateWebDataStreamRequest], - Awaitable[resources.WebDataStream]]: - r"""Return a callable for the create web data stream method over gRPC. - - Creates a web stream with the specified location and - attributes. - - Returns: - Callable[[~.CreateWebDataStreamRequest], - Awaitable[~.WebDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_web_data_stream' not in self._stubs: - self._stubs['create_web_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateWebDataStream', - request_serializer=analytics_admin.CreateWebDataStreamRequest.serialize, - response_deserializer=resources.WebDataStream.deserialize, - ) - return self._stubs['create_web_data_stream'] - - @property - def list_web_data_streams(self) -> Callable[ - [analytics_admin.ListWebDataStreamsRequest], - Awaitable[analytics_admin.ListWebDataStreamsResponse]]: - r"""Return a callable for the list web data streams method over gRPC. - - Returns child web data streams under the specified - parent property. - Web data streams will be excluded if the caller does not - have access. Returns an empty list if no relevant web - data streams are found. - - Returns: - Callable[[~.ListWebDataStreamsRequest], - Awaitable[~.ListWebDataStreamsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_web_data_streams' not in self._stubs: - self._stubs['list_web_data_streams'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListWebDataStreams', - request_serializer=analytics_admin.ListWebDataStreamsRequest.serialize, - response_deserializer=analytics_admin.ListWebDataStreamsResponse.deserialize, - ) - return self._stubs['list_web_data_streams'] - - @property - def get_ios_app_data_stream(self) -> Callable[ - [analytics_admin.GetIosAppDataStreamRequest], - Awaitable[resources.IosAppDataStream]]: - r"""Return a callable for the get ios app data stream method over gRPC. - - Lookup for a single IosAppDataStream - - Returns: - Callable[[~.GetIosAppDataStreamRequest], - Awaitable[~.IosAppDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: - self._stubs['get_ios_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetIosAppDataStream', - request_serializer=analytics_admin.GetIosAppDataStreamRequest.serialize, - response_deserializer=resources.IosAppDataStream.deserialize, - ) - return self._stubs['get_ios_app_data_stream'] - - @property - def delete_ios_app_data_stream(self) -> Callable[ - [analytics_admin.DeleteIosAppDataStreamRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the delete ios app data stream method over gRPC. - - Deletes an iOS app stream on a property. - - Returns: - Callable[[~.DeleteIosAppDataStreamRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_ios_app_data_stream' not in self._stubs: - self._stubs['delete_ios_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteIosAppDataStream', - request_serializer=analytics_admin.DeleteIosAppDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_ios_app_data_stream'] - - @property - def update_ios_app_data_stream(self) -> Callable[ - [analytics_admin.UpdateIosAppDataStreamRequest], - Awaitable[resources.IosAppDataStream]]: - r"""Return a callable for the update ios app data stream method over gRPC. - - Updates an iOS app stream on a property. - - Returns: - Callable[[~.UpdateIosAppDataStreamRequest], - Awaitable[~.IosAppDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: - self._stubs['update_ios_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateIosAppDataStream', - request_serializer=analytics_admin.UpdateIosAppDataStreamRequest.serialize, - response_deserializer=resources.IosAppDataStream.deserialize, - ) - return self._stubs['update_ios_app_data_stream'] - - @property - def create_ios_app_data_stream(self) -> Callable[ - [analytics_admin.CreateIosAppDataStreamRequest], - Awaitable[resources.IosAppDataStream]]: - r"""Return a callable for the create ios app data stream method over gRPC. - - Creates an iOS app stream with the specified location - and attributes. - Note that an iOS app stream must be linked to a Firebase - app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Returns: - Callable[[~.CreateIosAppDataStreamRequest], - Awaitable[~.IosAppDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_ios_app_data_stream' not in self._stubs: - self._stubs['create_ios_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateIosAppDataStream', - request_serializer=analytics_admin.CreateIosAppDataStreamRequest.serialize, - response_deserializer=resources.IosAppDataStream.deserialize, - ) - return self._stubs['create_ios_app_data_stream'] - - @property - def list_ios_app_data_streams(self) -> Callable[ - [analytics_admin.ListIosAppDataStreamsRequest], - Awaitable[analytics_admin.ListIosAppDataStreamsResponse]]: - r"""Return a callable for the list ios app data streams method over gRPC. - - Returns child iOS app data streams under the - specified parent property. - iOS app data streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - iOS app data streams are found. - - Returns: - Callable[[~.ListIosAppDataStreamsRequest], - Awaitable[~.ListIosAppDataStreamsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_ios_app_data_streams' not in self._stubs: - self._stubs['list_ios_app_data_streams'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListIosAppDataStreams', - request_serializer=analytics_admin.ListIosAppDataStreamsRequest.serialize, - response_deserializer=analytics_admin.ListIosAppDataStreamsResponse.deserialize, - ) - return self._stubs['list_ios_app_data_streams'] - - @property - def get_android_app_data_stream(self) -> Callable[ - [analytics_admin.GetAndroidAppDataStreamRequest], - Awaitable[resources.AndroidAppDataStream]]: - r"""Return a callable for the get android app data stream method over gRPC. - - Lookup for a single AndroidAppDataStream - - Returns: - Callable[[~.GetAndroidAppDataStreamRequest], - Awaitable[~.AndroidAppDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: - self._stubs['get_android_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAndroidAppDataStream', - request_serializer=analytics_admin.GetAndroidAppDataStreamRequest.serialize, - response_deserializer=resources.AndroidAppDataStream.deserialize, - ) - return self._stubs['get_android_app_data_stream'] - - @property - def delete_android_app_data_stream(self) -> Callable[ - [analytics_admin.DeleteAndroidAppDataStreamRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the delete android app data stream method over gRPC. - - Deletes an android app stream on a property. - - Returns: - Callable[[~.DeleteAndroidAppDataStreamRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_android_app_data_stream' not in self._stubs: - self._stubs['delete_android_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAndroidAppDataStream', - request_serializer=analytics_admin.DeleteAndroidAppDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_android_app_data_stream'] - - @property - def update_android_app_data_stream(self) -> Callable[ - [analytics_admin.UpdateAndroidAppDataStreamRequest], - Awaitable[resources.AndroidAppDataStream]]: - r"""Return a callable for the update android app data stream method over gRPC. - - Updates an android app stream on a property. - - Returns: - Callable[[~.UpdateAndroidAppDataStreamRequest], - Awaitable[~.AndroidAppDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: - self._stubs['update_android_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAndroidAppDataStream', - request_serializer=analytics_admin.UpdateAndroidAppDataStreamRequest.serialize, - response_deserializer=resources.AndroidAppDataStream.deserialize, - ) - return self._stubs['update_android_app_data_stream'] - - @property - def create_android_app_data_stream(self) -> Callable[ - [analytics_admin.CreateAndroidAppDataStreamRequest], - Awaitable[resources.AndroidAppDataStream]]: - r"""Return a callable for the create android app data stream method over gRPC. - - Creates an Android app stream with the specified - location and attributes. - Note that an Android app stream must be linked to a - Firebase app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Returns: - Callable[[~.CreateAndroidAppDataStreamRequest], - Awaitable[~.AndroidAppDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_android_app_data_stream' not in self._stubs: - self._stubs['create_android_app_data_stream'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAndroidAppDataStream', - request_serializer=analytics_admin.CreateAndroidAppDataStreamRequest.serialize, - response_deserializer=resources.AndroidAppDataStream.deserialize, - ) - return self._stubs['create_android_app_data_stream'] - - @property - def list_android_app_data_streams(self) -> Callable[ - [analytics_admin.ListAndroidAppDataStreamsRequest], - Awaitable[analytics_admin.ListAndroidAppDataStreamsResponse]]: - r"""Return a callable for the list android app data streams method over gRPC. - - Returns child android app streams under the specified - parent property. - Android app streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - android app streams are found. - - Returns: - Callable[[~.ListAndroidAppDataStreamsRequest], - Awaitable[~.ListAndroidAppDataStreamsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_android_app_data_streams' not in self._stubs: - self._stubs['list_android_app_data_streams'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAndroidAppDataStreams', - request_serializer=analytics_admin.ListAndroidAppDataStreamsRequest.serialize, - response_deserializer=analytics_admin.ListAndroidAppDataStreamsResponse.deserialize, - ) - return self._stubs['list_android_app_data_streams'] - - @property - def get_enhanced_measurement_settings(self) -> Callable[ - [analytics_admin.GetEnhancedMeasurementSettingsRequest], - Awaitable[resources.EnhancedMeasurementSettings]]: - r"""Return a callable for the get enhanced measurement - settings method over gRPC. - - Returns the singleton enhanced measurement settings - for this web stream. Note that the stream must enable - enhanced measurement for these settings to take effect. - - Returns: - Callable[[~.GetEnhancedMeasurementSettingsRequest], - Awaitable[~.EnhancedMeasurementSettings]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_enhanced_measurement_settings' not in self._stubs: - self._stubs['get_enhanced_measurement_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEnhancedMeasurementSettings', - request_serializer=analytics_admin.GetEnhancedMeasurementSettingsRequest.serialize, - response_deserializer=resources.EnhancedMeasurementSettings.deserialize, - ) - return self._stubs['get_enhanced_measurement_settings'] - - @property - def update_enhanced_measurement_settings(self) -> Callable[ - [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], - Awaitable[resources.EnhancedMeasurementSettings]]: - r"""Return a callable for the update enhanced measurement - settings method over gRPC. - - Updates the singleton enhanced measurement settings - for this web stream. Note that the stream must enable - enhanced measurement for these settings to take effect. - - Returns: - Callable[[~.UpdateEnhancedMeasurementSettingsRequest], - Awaitable[~.EnhancedMeasurementSettings]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_enhanced_measurement_settings' not in self._stubs: - self._stubs['update_enhanced_measurement_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEnhancedMeasurementSettings', - request_serializer=analytics_admin.UpdateEnhancedMeasurementSettingsRequest.serialize, - response_deserializer=resources.EnhancedMeasurementSettings.deserialize, - ) - return self._stubs['update_enhanced_measurement_settings'] - - @property - def create_firebase_link(self) -> Callable[ - [analytics_admin.CreateFirebaseLinkRequest], - Awaitable[resources.FirebaseLink]]: - r"""Return a callable for the create firebase link method over gRPC. - - Creates a FirebaseLink. - Properties can have at most one FirebaseLink. - - Returns: - Callable[[~.CreateFirebaseLinkRequest], - Awaitable[~.FirebaseLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_firebase_link' not in self._stubs: - self._stubs['create_firebase_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateFirebaseLink', - request_serializer=analytics_admin.CreateFirebaseLinkRequest.serialize, - response_deserializer=resources.FirebaseLink.deserialize, - ) - return self._stubs['create_firebase_link'] - - @property - def update_firebase_link(self) -> Callable[ - [analytics_admin.UpdateFirebaseLinkRequest], - Awaitable[resources.FirebaseLink]]: - r"""Return a callable for the update firebase link method over gRPC. - - Updates a FirebaseLink on a property - - Returns: - Callable[[~.UpdateFirebaseLinkRequest], - Awaitable[~.FirebaseLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_firebase_link' not in self._stubs: - self._stubs['update_firebase_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateFirebaseLink', - request_serializer=analytics_admin.UpdateFirebaseLinkRequest.serialize, - response_deserializer=resources.FirebaseLink.deserialize, - ) - return self._stubs['update_firebase_link'] - - @property - def delete_firebase_link(self) -> Callable[ - [analytics_admin.DeleteFirebaseLinkRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the delete firebase link method over gRPC. - - Deletes a FirebaseLink on a property - - Returns: - Callable[[~.DeleteFirebaseLinkRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_firebase_link' not in self._stubs: - self._stubs['delete_firebase_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteFirebaseLink', - request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_firebase_link'] - - @property - def list_firebase_links(self) -> Callable[ - [analytics_admin.ListFirebaseLinksRequest], - Awaitable[analytics_admin.ListFirebaseLinksResponse]]: - r"""Return a callable for the list firebase links method over gRPC. - - Lists FirebaseLinks on a property. - Properties can have at most one FirebaseLink. - - Returns: - Callable[[~.ListFirebaseLinksRequest], - Awaitable[~.ListFirebaseLinksResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_firebase_links' not in self._stubs: - self._stubs['list_firebase_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListFirebaseLinks', - request_serializer=analytics_admin.ListFirebaseLinksRequest.serialize, - response_deserializer=analytics_admin.ListFirebaseLinksResponse.deserialize, - ) - return self._stubs['list_firebase_links'] - - @property - def get_global_site_tag(self) -> Callable[ - [analytics_admin.GetGlobalSiteTagRequest], - Awaitable[resources.GlobalSiteTag]]: - r"""Return a callable for the get global site tag method over gRPC. - - Returns the Site Tag for the specified web stream. - Site Tags are immutable singletons. - - Returns: - Callable[[~.GetGlobalSiteTagRequest], - Awaitable[~.GlobalSiteTag]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_global_site_tag' not in self._stubs: - self._stubs['get_global_site_tag'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGlobalSiteTag', - request_serializer=analytics_admin.GetGlobalSiteTagRequest.serialize, - response_deserializer=resources.GlobalSiteTag.deserialize, - ) - return self._stubs['get_global_site_tag'] - - @property - def create_google_ads_link(self) -> Callable[ - [analytics_admin.CreateGoogleAdsLinkRequest], - Awaitable[resources.GoogleAdsLink]]: - r"""Return a callable for the create google ads link method over gRPC. - - Creates a GoogleAdsLink. - - Returns: - Callable[[~.CreateGoogleAdsLinkRequest], - Awaitable[~.GoogleAdsLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_google_ads_link' not in self._stubs: - self._stubs['create_google_ads_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateGoogleAdsLink', - request_serializer=analytics_admin.CreateGoogleAdsLinkRequest.serialize, - response_deserializer=resources.GoogleAdsLink.deserialize, - ) - return self._stubs['create_google_ads_link'] - - @property - def update_google_ads_link(self) -> Callable[ - [analytics_admin.UpdateGoogleAdsLinkRequest], - Awaitable[resources.GoogleAdsLink]]: - r"""Return a callable for the update google ads link method over gRPC. - - Updates a GoogleAdsLink on a property - - Returns: - Callable[[~.UpdateGoogleAdsLinkRequest], - Awaitable[~.GoogleAdsLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_google_ads_link' not in self._stubs: - self._stubs['update_google_ads_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleAdsLink', - request_serializer=analytics_admin.UpdateGoogleAdsLinkRequest.serialize, - response_deserializer=resources.GoogleAdsLink.deserialize, - ) - return self._stubs['update_google_ads_link'] - - @property - def delete_google_ads_link(self) -> Callable[ - [analytics_admin.DeleteGoogleAdsLinkRequest], - Awaitable[empty.Empty]]: - r"""Return a callable for the delete google ads link method over gRPC. - - Deletes a GoogleAdsLink on a property - - Returns: - Callable[[~.DeleteGoogleAdsLinkRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_google_ads_link' not in self._stubs: - self._stubs['delete_google_ads_link'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteGoogleAdsLink', - request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, - ) - return self._stubs['delete_google_ads_link'] - - @property - def list_google_ads_links(self) -> Callable[ - [analytics_admin.ListGoogleAdsLinksRequest], - Awaitable[analytics_admin.ListGoogleAdsLinksResponse]]: - r"""Return a callable for the list google ads links method over gRPC. - - Lists GoogleAdsLinks on a property. - - Returns: - Callable[[~.ListGoogleAdsLinksRequest], - Awaitable[~.ListGoogleAdsLinksResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_google_ads_links' not in self._stubs: - self._stubs['list_google_ads_links'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListGoogleAdsLinks', - request_serializer=analytics_admin.ListGoogleAdsLinksRequest.serialize, - response_deserializer=analytics_admin.ListGoogleAdsLinksResponse.deserialize, - ) - return self._stubs['list_google_ads_links'] - - @property - def get_data_sharing_settings(self) -> Callable[ - [analytics_admin.GetDataSharingSettingsRequest], - Awaitable[resources.DataSharingSettings]]: - r"""Return a callable for the get data sharing settings method over gRPC. - - Get data sharing settings on an account. - Data sharing settings are singletons. - - Returns: - Callable[[~.GetDataSharingSettingsRequest], - Awaitable[~.DataSharingSettings]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_data_sharing_settings' not in self._stubs: - self._stubs['get_data_sharing_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataSharingSettings', - request_serializer=analytics_admin.GetDataSharingSettingsRequest.serialize, - response_deserializer=resources.DataSharingSettings.deserialize, - ) - return self._stubs['get_data_sharing_settings'] - - -__all__ = ( - 'AnalyticsAdminServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py deleted file mode 100644 index 25bc2282..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py +++ /dev/null @@ -1,180 +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 .analytics_admin import ( - AuditUserLinksRequest, - AuditUserLinksResponse, - BatchCreateUserLinksRequest, - BatchCreateUserLinksResponse, - BatchDeleteUserLinksRequest, - BatchGetUserLinksRequest, - BatchGetUserLinksResponse, - BatchUpdateUserLinksRequest, - BatchUpdateUserLinksResponse, - CreateAndroidAppDataStreamRequest, - CreateFirebaseLinkRequest, - CreateGoogleAdsLinkRequest, - CreateIosAppDataStreamRequest, - CreatePropertyRequest, - CreateUserLinkRequest, - CreateWebDataStreamRequest, - DeleteAccountRequest, - DeleteAndroidAppDataStreamRequest, - DeleteFirebaseLinkRequest, - DeleteGoogleAdsLinkRequest, - DeleteIosAppDataStreamRequest, - DeletePropertyRequest, - DeleteUserLinkRequest, - DeleteWebDataStreamRequest, - GetAccountRequest, - GetAndroidAppDataStreamRequest, - GetDataSharingSettingsRequest, - GetEnhancedMeasurementSettingsRequest, - GetGlobalSiteTagRequest, - GetIosAppDataStreamRequest, - GetPropertyRequest, - GetUserLinkRequest, - GetWebDataStreamRequest, - ListAccountsRequest, - ListAccountsResponse, - ListAccountSummariesRequest, - ListAccountSummariesResponse, - ListAndroidAppDataStreamsRequest, - ListAndroidAppDataStreamsResponse, - ListFirebaseLinksRequest, - ListFirebaseLinksResponse, - ListGoogleAdsLinksRequest, - ListGoogleAdsLinksResponse, - ListIosAppDataStreamsRequest, - ListIosAppDataStreamsResponse, - ListPropertiesRequest, - ListPropertiesResponse, - ListUserLinksRequest, - ListUserLinksResponse, - ListWebDataStreamsRequest, - ListWebDataStreamsResponse, - ProvisionAccountTicketRequest, - ProvisionAccountTicketResponse, - UpdateAccountRequest, - UpdateAndroidAppDataStreamRequest, - UpdateEnhancedMeasurementSettingsRequest, - UpdateFirebaseLinkRequest, - UpdateGoogleAdsLinkRequest, - UpdateIosAppDataStreamRequest, - UpdatePropertyRequest, - UpdateUserLinkRequest, - UpdateWebDataStreamRequest, -) -from .resources import ( - Account, - AccountSummary, - AndroidAppDataStream, - AuditUserLink, - DataSharingSettings, - EnhancedMeasurementSettings, - FirebaseLink, - GlobalSiteTag, - GoogleAdsLink, - IosAppDataStream, - Property, - PropertySummary, - UserLink, - WebDataStream, - IndustryCategory, - MaximumUserAccess, -) - -__all__ = ( - 'AuditUserLinksRequest', - 'AuditUserLinksResponse', - 'BatchCreateUserLinksRequest', - 'BatchCreateUserLinksResponse', - 'BatchDeleteUserLinksRequest', - 'BatchGetUserLinksRequest', - 'BatchGetUserLinksResponse', - 'BatchUpdateUserLinksRequest', - 'BatchUpdateUserLinksResponse', - 'CreateAndroidAppDataStreamRequest', - 'CreateFirebaseLinkRequest', - 'CreateGoogleAdsLinkRequest', - 'CreateIosAppDataStreamRequest', - 'CreatePropertyRequest', - 'CreateUserLinkRequest', - 'CreateWebDataStreamRequest', - 'DeleteAccountRequest', - 'DeleteAndroidAppDataStreamRequest', - 'DeleteFirebaseLinkRequest', - 'DeleteGoogleAdsLinkRequest', - 'DeleteIosAppDataStreamRequest', - 'DeletePropertyRequest', - 'DeleteUserLinkRequest', - 'DeleteWebDataStreamRequest', - 'GetAccountRequest', - 'GetAndroidAppDataStreamRequest', - 'GetDataSharingSettingsRequest', - 'GetEnhancedMeasurementSettingsRequest', - 'GetGlobalSiteTagRequest', - 'GetIosAppDataStreamRequest', - 'GetPropertyRequest', - 'GetUserLinkRequest', - 'GetWebDataStreamRequest', - 'ListAccountsRequest', - 'ListAccountsResponse', - 'ListAccountSummariesRequest', - 'ListAccountSummariesResponse', - 'ListAndroidAppDataStreamsRequest', - 'ListAndroidAppDataStreamsResponse', - 'ListFirebaseLinksRequest', - 'ListFirebaseLinksResponse', - 'ListGoogleAdsLinksRequest', - 'ListGoogleAdsLinksResponse', - 'ListIosAppDataStreamsRequest', - 'ListIosAppDataStreamsResponse', - 'ListPropertiesRequest', - 'ListPropertiesResponse', - 'ListUserLinksRequest', - 'ListUserLinksResponse', - 'ListWebDataStreamsRequest', - 'ListWebDataStreamsResponse', - 'ProvisionAccountTicketRequest', - 'ProvisionAccountTicketResponse', - 'UpdateAccountRequest', - 'UpdateAndroidAppDataStreamRequest', - 'UpdateEnhancedMeasurementSettingsRequest', - 'UpdateFirebaseLinkRequest', - 'UpdateGoogleAdsLinkRequest', - 'UpdateIosAppDataStreamRequest', - 'UpdatePropertyRequest', - 'UpdateUserLinkRequest', - 'UpdateWebDataStreamRequest', - 'Account', - 'AccountSummary', - 'AndroidAppDataStream', - 'AuditUserLink', - 'DataSharingSettings', - 'EnhancedMeasurementSettings', - 'FirebaseLink', - 'GlobalSiteTag', - 'GoogleAdsLink', - 'IosAppDataStream', - 'Property', - 'PropertySummary', - 'UserLink', - 'WebDataStream', - 'IndustryCategory', - 'MaximumUserAccess', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py deleted file mode 100644 index 7507779d..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py +++ /dev/null @@ -1,1354 +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.analytics.admin_v1alpha.types import resources -from google.protobuf import field_mask_pb2 as field_mask # type: ignore - - -__protobuf__ = proto.module( - package='google.analytics.admin.v1alpha', - manifest={ - 'GetAccountRequest', - 'ListAccountsRequest', - 'ListAccountsResponse', - 'DeleteAccountRequest', - 'UpdateAccountRequest', - 'ProvisionAccountTicketRequest', - 'ProvisionAccountTicketResponse', - 'GetPropertyRequest', - 'ListPropertiesRequest', - 'ListPropertiesResponse', - 'UpdatePropertyRequest', - 'CreatePropertyRequest', - 'DeletePropertyRequest', - 'GetUserLinkRequest', - 'BatchGetUserLinksRequest', - 'BatchGetUserLinksResponse', - 'ListUserLinksRequest', - 'ListUserLinksResponse', - 'AuditUserLinksRequest', - 'AuditUserLinksResponse', - 'CreateUserLinkRequest', - 'BatchCreateUserLinksRequest', - 'BatchCreateUserLinksResponse', - 'UpdateUserLinkRequest', - 'BatchUpdateUserLinksRequest', - 'BatchUpdateUserLinksResponse', - 'DeleteUserLinkRequest', - 'BatchDeleteUserLinksRequest', - 'GetWebDataStreamRequest', - 'DeleteWebDataStreamRequest', - 'UpdateWebDataStreamRequest', - 'CreateWebDataStreamRequest', - 'ListWebDataStreamsRequest', - 'ListWebDataStreamsResponse', - 'GetIosAppDataStreamRequest', - 'DeleteIosAppDataStreamRequest', - 'UpdateIosAppDataStreamRequest', - 'CreateIosAppDataStreamRequest', - 'ListIosAppDataStreamsRequest', - 'ListIosAppDataStreamsResponse', - 'GetAndroidAppDataStreamRequest', - 'DeleteAndroidAppDataStreamRequest', - 'UpdateAndroidAppDataStreamRequest', - 'CreateAndroidAppDataStreamRequest', - 'ListAndroidAppDataStreamsRequest', - 'ListAndroidAppDataStreamsResponse', - 'GetEnhancedMeasurementSettingsRequest', - 'UpdateEnhancedMeasurementSettingsRequest', - 'CreateFirebaseLinkRequest', - 'UpdateFirebaseLinkRequest', - 'DeleteFirebaseLinkRequest', - 'ListFirebaseLinksRequest', - 'ListFirebaseLinksResponse', - 'GetGlobalSiteTagRequest', - 'CreateGoogleAdsLinkRequest', - 'UpdateGoogleAdsLinkRequest', - 'DeleteGoogleAdsLinkRequest', - 'ListGoogleAdsLinksRequest', - 'ListGoogleAdsLinksResponse', - 'GetDataSharingSettingsRequest', - 'ListAccountSummariesRequest', - 'ListAccountSummariesResponse', - }, -) - - -class GetAccountRequest(proto.Message): - r"""Request message for GetAccount RPC. - - Attributes: - name (str): - Required. The name of the account to lookup. - Format: accounts/{account} - Example: "accounts/100". - """ - - name = proto.Field(proto.STRING, number=1) - - -class ListAccountsRequest(proto.Message): - r"""Request message for ListAccounts RPC. - - Attributes: - page_size (int): - The maximum number of resources to return. - The service may return fewer than this value, - even if there are additional pages. If - unspecified, at most 50 resources will be - returned. The maximum value is 200; (higher - values will be coerced to the maximum) - page_token (str): - A page token, received from a previous ``ListAccounts`` - call. Provide this to retrieve the subsequent page. When - paginating, all other parameters provided to - ``ListAccounts`` must match the call that provided the page - token. - show_deleted (bool): - Whether to include soft-deleted (ie: - "trashed") Accounts in the results. Accounts can - be inspected to determine whether they are - deleted or not. - """ - - page_size = proto.Field(proto.INT32, number=1) - - page_token = proto.Field(proto.STRING, number=2) - - show_deleted = proto.Field(proto.BOOL, number=3) - - -class ListAccountsResponse(proto.Message): - r"""Request message for ListAccounts RPC. - - Attributes: - accounts (Sequence[google.analytics.admin_v1alpha.types.Account]): - Results that were accessible to the caller. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - accounts = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.Account, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class DeleteAccountRequest(proto.Message): - r"""Request message for DeleteAccount RPC. - - Attributes: - name (str): - Required. The name of the Account to soft- - elete. Format: accounts/{account} - Example: "accounts/100". - """ - - name = proto.Field(proto.STRING, number=1) - - -class UpdateAccountRequest(proto.Message): - r"""Request message for UpdateAccount RPC. - - Attributes: - account (google.analytics.admin_v1alpha.types.Account): - Required. The account to update. The account's ``name`` - field is used to identify the account. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - account = proto.Field(proto.MESSAGE, number=1, - message=resources.Account, - ) - - update_mask = proto.Field(proto.MESSAGE, number=2, - message=field_mask.FieldMask, - ) - - -class ProvisionAccountTicketRequest(proto.Message): - r"""Request message for ProvisionAccountTicket RPC. - - Attributes: - account (google.analytics.admin_v1alpha.types.Account): - The account to create. - redirect_uri (str): - Redirect URI where the user will be sent - after accepting Terms of Service. Must be - configured in Developers Console as a Redirect - URI - """ - - account = proto.Field(proto.MESSAGE, number=1, - message=resources.Account, - ) - - redirect_uri = proto.Field(proto.STRING, number=2) - - -class ProvisionAccountTicketResponse(proto.Message): - r"""Response message for ProvisionAccountTicket RPC. - - Attributes: - account_ticket_id (str): - The param to be passed in the ToS link. - """ - - account_ticket_id = proto.Field(proto.STRING, number=1) - - -class GetPropertyRequest(proto.Message): - r"""Request message for GetProperty RPC. - - Attributes: - name (str): - Required. The name of the property to lookup. Format: - properties/{property_id} Example: "properties/1000". - """ - - name = proto.Field(proto.STRING, number=1) - - -class ListPropertiesRequest(proto.Message): - r"""Request message for ListProperties RPC. - - Attributes: - filter (str): - Required. An expression for filtering the results of the - request. Fields eligible for filtering are: - ``parent:``\ (The resource name of the parent account) or - ``firebase_project:``\ (The id or number of the linked - firebase project). Some examples of filters: - - :: - - | Filter | Description | - |-----------------------------|-------------------------------------------| - | parent:accounts/123 | The account with account id: 123. | - | firebase_project:project-id | The firebase project with id: project-id. | - | firebase_project:123 | The firebase project with number: 123. | - page_size (int): - The maximum number of resources to return. - The service may return fewer than this value, - even if there are additional pages. If - unspecified, at most 50 resources will be - returned. The maximum value is 200; (higher - values will be coerced to the maximum) - page_token (str): - A page token, received from a previous ``ListProperties`` - call. Provide this to retrieve the subsequent page. When - paginating, all other parameters provided to - ``ListProperties`` must match the call that provided the - page token. - show_deleted (bool): - Whether to include soft-deleted (ie: - "trashed") Properties in the results. Properties - can be inspected to determine whether they are - deleted or not. - """ - - filter = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - show_deleted = proto.Field(proto.BOOL, number=4) - - -class ListPropertiesResponse(proto.Message): - r"""Response message for ListProperties RPC. - - Attributes: - properties (Sequence[google.analytics.admin_v1alpha.types.Property]): - Results that matched the filter criteria and - were accessible to the caller. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - properties = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.Property, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class UpdatePropertyRequest(proto.Message): - r"""Request message for UpdateProperty RPC. - - Attributes: - property (google.analytics.admin_v1alpha.types.Property): - Required. The property to update. The property's ``name`` - field is used to identify the property to be updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - property = proto.Field(proto.MESSAGE, number=1, - message=resources.Property, - ) - - update_mask = proto.Field(proto.MESSAGE, number=2, - message=field_mask.FieldMask, - ) - - -class CreatePropertyRequest(proto.Message): - r"""Request message for CreateProperty RPC. - - Attributes: - property (google.analytics.admin_v1alpha.types.Property): - Required. The property to create. - Note: the supplied property must specify its - parent. - """ - - property = proto.Field(proto.MESSAGE, number=1, - message=resources.Property, - ) - - -class DeletePropertyRequest(proto.Message): - r"""Request message for DeleteProperty RPC. - - Attributes: - name (str): - Required. The name of the Property to soft-delete. Format: - properties/{property_id} Example: "properties/1000". - """ - - name = proto.Field(proto.STRING, number=1) - - -class GetUserLinkRequest(proto.Message): - r"""Request message for GetUserLink RPC. - - Attributes: - name (str): - Required. Example format: - accounts/1234/userLinks/5678 - """ - - name = proto.Field(proto.STRING, number=1) - - -class BatchGetUserLinksRequest(proto.Message): - r"""Request message for BatchGetUserLinks RPC. - - Attributes: - parent (str): - Required. The account or property that all - user links in the request are for. The parent of - all provided values for the 'names' field must - match this field. - Example format: accounts/1234 - names (Sequence[str]): - Required. The names of the user links to - retrieve. A maximum of 1000 user links can be - retrieved in a batch. Format: - accounts/{accountId}/userLinks/{userLinkId} - """ - - parent = proto.Field(proto.STRING, number=1) - - names = proto.RepeatedField(proto.STRING, number=2) - - -class BatchGetUserLinksResponse(proto.Message): - r"""Response message for BatchGetUserLinks RPC. - - Attributes: - user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): - The requested user links. - """ - - user_links = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.UserLink, - ) - - -class ListUserLinksRequest(proto.Message): - r"""Request message for ListUserLinks RPC. - - Attributes: - parent (str): - Required. Example format: accounts/1234 - page_size (int): - The maximum number of user links to return. - The service may return fewer than this value. If - unspecified, at most 200 user links will be - returned. The maximum value is 500; values above - 500 will be coerced to 500. - page_token (str): - A page token, received from a previous ``ListUserLinks`` - call. Provide this to retrieve the subsequent page. When - paginating, all other parameters provided to - ``ListUserLinks`` must match the call that provided the page - token. - """ - - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - -class ListUserLinksResponse(proto.Message): - r"""Response message for ListUserLinks RPC. - - Attributes: - user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): - List of UserLinks. These will be ordered - stably, but in an arbitrary order. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - user_links = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.UserLink, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class AuditUserLinksRequest(proto.Message): - r"""Request message for AuditUserLinks RPC. - - Attributes: - parent (str): - Required. Example format: accounts/1234 - page_size (int): - The maximum number of user links to return. - The service may return fewer than this value. If - unspecified, at most 1000 user links will be - returned. The maximum value is 5000; values - above 5000 will be coerced to 5000. - page_token (str): - A page token, received from a previous ``AuditUserLinks`` - call. Provide this to retrieve the subsequent page. When - paginating, all other parameters provided to - ``AuditUserLinks`` must match the call that provided the - page token. - """ - - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - -class AuditUserLinksResponse(proto.Message): - r"""Response message for AuditUserLinks RPC. - - Attributes: - user_links (Sequence[google.analytics.admin_v1alpha.types.AuditUserLink]): - List of AuditUserLinks. These will be ordered - stably, but in an arbitrary order. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - user_links = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.AuditUserLink, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class CreateUserLinkRequest(proto.Message): - r"""Request message for CreateUserLink RPC. - Users can have multiple email addresses associated with their - Google account, and one of these email addresses is the - "primary" email address. Any of the email addresses associated - with a Google account may be used for a new UserLink, but the - returned UserLink will always contain the "primary" email - address. As a result, the input and output email address for - this request may differ. - - Attributes: - parent (str): - Required. Example format: accounts/1234 - notify_new_user (bool): - Optional. If set, then email the new user - notifying them that they've been granted - permissions to the resource. - user_link (google.analytics.admin_v1alpha.types.UserLink): - Required. The user link to create. - """ - - parent = proto.Field(proto.STRING, number=1) - - notify_new_user = proto.Field(proto.BOOL, number=2) - - user_link = proto.Field(proto.MESSAGE, number=3, - message=resources.UserLink, - ) - - -class BatchCreateUserLinksRequest(proto.Message): - r"""Request message for BatchCreateUserLinks RPC. - - Attributes: - parent (str): - Required. The account or property that all - user links in the request are for. This field is - required. The parent field in the - CreateUserLinkRequest messages must either be - empty or match this field. Example format: - accounts/1234 - notify_new_users (bool): - Optional. If set, then email the new users notifying them - that they've been granted permissions to the resource. - Regardless of whether this is set or not, notify_new_user - field inside each individual request is ignored. - requests (Sequence[google.analytics.admin_v1alpha.types.CreateUserLinkRequest]): - Required. The requests specifying the user - links to create. A maximum of 1000 user links - can be created in a batch. - """ - - parent = proto.Field(proto.STRING, number=1) - - notify_new_users = proto.Field(proto.BOOL, number=2) - - requests = proto.RepeatedField(proto.MESSAGE, number=3, - message='CreateUserLinkRequest', - ) - - -class BatchCreateUserLinksResponse(proto.Message): - r"""Response message for BatchCreateUserLinks RPC. - - Attributes: - user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): - The user links created. - """ - - user_links = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.UserLink, - ) - - -class UpdateUserLinkRequest(proto.Message): - r"""Request message for UpdateUserLink RPC. - - Attributes: - user_link (google.analytics.admin_v1alpha.types.UserLink): - Required. The user link to update. - """ - - user_link = proto.Field(proto.MESSAGE, number=1, - message=resources.UserLink, - ) - - -class BatchUpdateUserLinksRequest(proto.Message): - r"""Request message for BatchUpdateUserLinks RPC. - - Attributes: - parent (str): - Required. The account or property that all - user links in the request are for. The parent - field in the UpdateUserLinkRequest messages must - either be empty or match this field. - Example format: accounts/1234 - requests (Sequence[google.analytics.admin_v1alpha.types.UpdateUserLinkRequest]): - Required. The requests specifying the user - links to update. A maximum of 1000 user links - can be updated in a batch. - """ - - parent = proto.Field(proto.STRING, number=1) - - requests = proto.RepeatedField(proto.MESSAGE, number=2, - message='UpdateUserLinkRequest', - ) - - -class BatchUpdateUserLinksResponse(proto.Message): - r"""Response message for BatchUpdateUserLinks RPC. - - Attributes: - user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): - The user links updated. - """ - - user_links = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.UserLink, - ) - - -class DeleteUserLinkRequest(proto.Message): - r"""Request message for DeleteUserLink RPC. - - Attributes: - name (str): - Required. Example format: - accounts/1234/userLinks/5678 - """ - - name = proto.Field(proto.STRING, number=1) - - -class BatchDeleteUserLinksRequest(proto.Message): - r"""Request message for BatchDeleteUserLinks RPC. - - Attributes: - parent (str): - Required. The account or property that all - user links in the request are for. The parent of - all values for user link names to delete must - match this field. - Example format: accounts/1234 - requests (Sequence[google.analytics.admin_v1alpha.types.DeleteUserLinkRequest]): - Required. The requests specifying the user - links to update. A maximum of 1000 user links - can be updated in a batch. - """ - - parent = proto.Field(proto.STRING, number=1) - - requests = proto.RepeatedField(proto.MESSAGE, number=2, - message='DeleteUserLinkRequest', - ) - - -class GetWebDataStreamRequest(proto.Message): - r"""Request message for GetWebDataStream RPC. - - Attributes: - name (str): - Required. The name of the web data stream to lookup. Format: - properties/{property_id}/webDataStreams/{stream_id} Example: - "properties/123/webDataStreams/456". - """ - - name = proto.Field(proto.STRING, number=1) - - -class DeleteWebDataStreamRequest(proto.Message): - r"""Request message for DeleteWebDataStream RPC. - - Attributes: - name (str): - Required. The name of the web data stream to delete. Format: - properties/{property_id}/webDataStreams/{stream_id} Example: - "properties/123/webDataStreams/456". - """ - - name = proto.Field(proto.STRING, number=1) - - -class UpdateWebDataStreamRequest(proto.Message): - r"""Request message for UpdateWebDataStream RPC. - - Attributes: - web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): - Required. The web stream to update. The ``name`` field is - used to identify the web stream to be updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - web_data_stream = proto.Field(proto.MESSAGE, number=1, - message=resources.WebDataStream, - ) - - update_mask = proto.Field(proto.MESSAGE, number=2, - message=field_mask.FieldMask, - ) - - -class CreateWebDataStreamRequest(proto.Message): - r"""Request message for CreateWebDataStream RPC. - - Attributes: - web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): - Required. The web stream to create. - parent (str): - Required. The parent resource where this web - data stream will be created. Format: - properties/123 - """ - - web_data_stream = proto.Field(proto.MESSAGE, number=1, - message=resources.WebDataStream, - ) - - parent = proto.Field(proto.STRING, number=2) - - -class ListWebDataStreamsRequest(proto.Message): - r"""Request message for ListWebDataStreams RPC. - - Attributes: - parent (str): - Required. The name of the parent property. - For example, to list results of web streams - under the property with Id 123: "properties/123". - page_size (int): - The maximum number of resources to return. - If unspecified, at most 50 resources will be - returned. The maximum value is 200; (higher - values will be coerced to the maximum) - page_token (str): - A page token, received from a previous - ``ListWebDataStreams`` call. Provide this to retrieve the - subsequent page. When paginating, all other parameters - provided to ``ListWebDataStreams`` must match the call that - provided the page token. - """ - - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - -class ListWebDataStreamsResponse(proto.Message): - r"""Request message for ListWebDataStreams RPC. - - Attributes: - web_data_streams (Sequence[google.analytics.admin_v1alpha.types.WebDataStream]): - Results that matched the filter criteria and - were accessible to the caller. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - web_data_streams = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.WebDataStream, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class GetIosAppDataStreamRequest(proto.Message): - r"""Request message for GetIosAppDataStream RPC. - - Attributes: - name (str): - Required. The name of the iOS app data stream to lookup. - Format: - properties/{property_id}/iosAppDataStreams/{stream_id} - Example: "properties/123/iosAppDataStreams/456". - """ - - name = proto.Field(proto.STRING, number=1) - - -class DeleteIosAppDataStreamRequest(proto.Message): - r"""Request message for DeleteIosAppDataStream RPC. - - Attributes: - name (str): - Required. The name of the iOS app data stream to delete. - Format: - properties/{property_id}/iosAppDataStreams/{stream_id} - Example: "properties/123/iosAppDataStreams/456". - """ - - name = proto.Field(proto.STRING, number=1) - - -class UpdateIosAppDataStreamRequest(proto.Message): - r"""Request message for UpdateIosAppDataStream RPC. - - Attributes: - ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): - Required. The iOS app stream to update. The ``name`` field - is used to identify the iOS app stream to be updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - ios_app_data_stream = proto.Field(proto.MESSAGE, number=1, - message=resources.IosAppDataStream, - ) - - update_mask = proto.Field(proto.MESSAGE, number=2, - message=field_mask.FieldMask, - ) - - -class CreateIosAppDataStreamRequest(proto.Message): - r"""Request message for CreateIosAppDataStream RPC. - - Attributes: - ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): - Required. The iOS app data stream to create. - parent (str): - Required. The parent resource where this ios - app data stream will be created. Format: - properties/123 - """ - - ios_app_data_stream = proto.Field(proto.MESSAGE, number=1, - message=resources.IosAppDataStream, - ) - - parent = proto.Field(proto.STRING, number=2) - - -class ListIosAppDataStreamsRequest(proto.Message): - r"""Request message for ListIosAppDataStreams RPC. - - Attributes: - parent (str): - Required. The name of the parent property. - For example, to list results of app streams - under the property with Id 123: "properties/123". - page_size (int): - The maximum number of resources to return. - If unspecified, at most 50 resources will be - returned. The maximum value is 200; (higher - values will be coerced to the maximum) - page_token (str): - A page token, received from a previous - ``ListIosAppDataStreams`` call. Provide this to retrieve the - subsequent page. When paginating, all other parameters - provided to ``ListIosAppDataStreams`` must match the call - that provided the page token. - """ - - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - -class ListIosAppDataStreamsResponse(proto.Message): - r"""Request message for ListIosAppDataStreams RPC. - - Attributes: - ios_app_data_streams (Sequence[google.analytics.admin_v1alpha.types.IosAppDataStream]): - Results that matched the filter criteria and - were accessible to the caller. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - ios_app_data_streams = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.IosAppDataStream, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class GetAndroidAppDataStreamRequest(proto.Message): - r"""Request message for GetAndroidAppDataStream RPC. - - Attributes: - name (str): - Required. The name of the android app data stream to lookup. - Format: - properties/{property_id}/androidAppDataStreams/{stream_id} - Example: "properties/123/androidAppDataStreams/456". - """ - - name = proto.Field(proto.STRING, number=1) - - -class DeleteAndroidAppDataStreamRequest(proto.Message): - r"""Request message for DeleteAndroidAppDataStream RPC. - - Attributes: - name (str): - Required. The name of the android app data stream to delete. - Format: - properties/{property_id}/androidAppDataStreams/{stream_id} - Example: "properties/123/androidAppDataStreams/456". - """ - - name = proto.Field(proto.STRING, number=1) - - -class UpdateAndroidAppDataStreamRequest(proto.Message): - r"""Request message for UpdateAndroidAppDataStream RPC. - - Attributes: - android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): - Required. The android app stream to update. The ``name`` - field is used to identify the android app stream to be - updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - android_app_data_stream = proto.Field(proto.MESSAGE, number=1, - message=resources.AndroidAppDataStream, - ) - - update_mask = proto.Field(proto.MESSAGE, number=2, - message=field_mask.FieldMask, - ) - - -class CreateAndroidAppDataStreamRequest(proto.Message): - r"""Request message for CreateAndroidAppDataStream RPC. - - Attributes: - android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): - Required. The android app stream to create. - parent (str): - Required. The parent resource where this - android app data stream will be created. Format: - properties/123 - """ - - android_app_data_stream = proto.Field(proto.MESSAGE, number=1, - message=resources.AndroidAppDataStream, - ) - - parent = proto.Field(proto.STRING, number=2) - - -class ListAndroidAppDataStreamsRequest(proto.Message): - r"""Request message for ListAndroidAppDataStreams RPC. - - Attributes: - parent (str): - Required. The name of the parent property. - For example, to limit results to app streams - under the property with Id 123: "properties/123". - page_size (int): - The maximum number of resources to return. - If unspecified, at most 50 resources will be - returned. The maximum value is 200; (higher - values will be coerced to the maximum) - page_token (str): - A page token, received from a previous call. Provide this to - retrieve the subsequent page. When paginating, all other - parameters provided to ``ListAndroidAppDataStreams`` must - match the call that provided the page token. - """ - - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - -class ListAndroidAppDataStreamsResponse(proto.Message): - r"""Request message for ListAndroidDataStreams RPC. - - Attributes: - android_app_data_streams (Sequence[google.analytics.admin_v1alpha.types.AndroidAppDataStream]): - Results that matched the filter criteria and - were accessible to the caller. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - android_app_data_streams = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.AndroidAppDataStream, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class GetEnhancedMeasurementSettingsRequest(proto.Message): - r"""Request message for GetEnhancedMeasurementSettings RPC. - - Attributes: - name (str): - Required. The name of the settings to lookup. Format: - properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings - Example: - "properties/1000/webDataStreams/2000/enhancedMeasurementSettings". - """ - - name = proto.Field(proto.STRING, number=1) - - -class UpdateEnhancedMeasurementSettingsRequest(proto.Message): - r"""Request message for UpdateEnhancedMeasurementSettings RPC. - - Attributes: - enhanced_measurement_settings (google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings): - Required. The settings to update. The ``name`` field is used - to identify the settings to be updated. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - enhanced_measurement_settings = proto.Field(proto.MESSAGE, number=1, - message=resources.EnhancedMeasurementSettings, - ) - - update_mask = proto.Field(proto.MESSAGE, number=2, - message=field_mask.FieldMask, - ) - - -class CreateFirebaseLinkRequest(proto.Message): - r"""Request message for CreateFirebaseLink RPC - - Attributes: - parent (str): - Required. Format: properties/{property_id} Example: - properties/1234 - firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): - Required. The Firebase link to create. - """ - - parent = proto.Field(proto.STRING, number=1) - - firebase_link = proto.Field(proto.MESSAGE, number=2, - message=resources.FirebaseLink, - ) - - -class UpdateFirebaseLinkRequest(proto.Message): - r"""Request message for UpdateFirebaseLink RPC - - Attributes: - firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): - Required. The Firebase link to update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - firebase_link = proto.Field(proto.MESSAGE, number=1, - message=resources.FirebaseLink, - ) - - update_mask = proto.Field(proto.MESSAGE, number=2, - message=field_mask.FieldMask, - ) - - -class DeleteFirebaseLinkRequest(proto.Message): - r"""Request message for DeleteFirebaseLink RPC - - Attributes: - name (str): - Required. Format: - properties/{property_id}/firebaseLinks/{firebase_link_id} - Example: properties/1234/firebaseLinks/5678 - """ - - name = proto.Field(proto.STRING, number=1) - - -class ListFirebaseLinksRequest(proto.Message): - r"""Request message for ListFirebaseLinks RPC - - Attributes: - parent (str): - Required. Format: properties/{property_id} Example: - properties/1234 - page_size (int): - The maximum number of resources to return. - The service may return fewer than this value, - even if there are additional pages. If - unspecified, at most 50 resources will be - returned. The maximum value is 200; (higher - values will be coerced to the maximum) - page_token (str): - A page token, received from a previous ``ListFirebaseLinks`` - call. Provide this to retrieve the subsequent page. When - paginating, all other parameters provided to - ``ListProperties`` must match the call that provided the - page token. - """ - - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - -class ListFirebaseLinksResponse(proto.Message): - r"""Response message for ListFirebaseLinks RPC - - Attributes: - firebase_links (Sequence[google.analytics.admin_v1alpha.types.FirebaseLink]): - List of FirebaseLinks. This will have at most - one value. - 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. Currently, Google Analytics supports only one - FirebaseLink per property, so this will never be populated. - """ - - @property - def raw_page(self): - return self - - firebase_links = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.FirebaseLink, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class GetGlobalSiteTagRequest(proto.Message): - r"""Request message for GetGlobalSiteTag RPC. - - Attributes: - name (str): - Required. The name of the site tag to lookup. Note that site - tags are singletons and do not have unique IDs. Format: - properties/{property_id}/webDataStreams/{stream_id}/globalSiteTag - Example: "properties/123/webDataStreams/456/globalSiteTag". - """ - - name = proto.Field(proto.STRING, number=1) - - -class CreateGoogleAdsLinkRequest(proto.Message): - r"""Request message for CreateGoogleAdsLink RPC - - Attributes: - parent (str): - Required. Example format: properties/1234 - google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): - Required. The GoogleAdsLink to create. - """ - - parent = proto.Field(proto.STRING, number=1) - - google_ads_link = proto.Field(proto.MESSAGE, number=2, - message=resources.GoogleAdsLink, - ) - - -class UpdateGoogleAdsLinkRequest(proto.Message): - r"""Request message for UpdateGoogleAdsLink RPC - - Attributes: - google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): - The GoogleAdsLink to update - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - google_ads_link = proto.Field(proto.MESSAGE, number=1, - message=resources.GoogleAdsLink, - ) - - update_mask = proto.Field(proto.MESSAGE, number=2, - message=field_mask.FieldMask, - ) - - -class DeleteGoogleAdsLinkRequest(proto.Message): - r"""Request message for DeleteGoogleAdsLink RPC. - - Attributes: - name (str): - Required. Example format: - properties/1234/googleAdsLinks/5678 - """ - - name = proto.Field(proto.STRING, number=1) - - -class ListGoogleAdsLinksRequest(proto.Message): - r"""Request message for ListGoogleAdsLinks RPC. - - Attributes: - parent (str): - Required. Example format: properties/1234 - page_size (int): - The maximum number of resources to return. - If unspecified, at most 50 resources will be - returned. The maximum value is 200 (higher - values will be coerced to the maximum). - page_token (str): - A page token, received from a previous - ``ListGoogleAdsLinks`` call. Provide this to retrieve the - subsequent page. - - When paginating, all other parameters provided to - ``ListGoogleAdsLinks`` must match the call that provided the - page token. - """ - - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - -class ListGoogleAdsLinksResponse(proto.Message): - r"""Response message for ListGoogleAdsLinks RPC. - - Attributes: - google_ads_links (Sequence[google.analytics.admin_v1alpha.types.GoogleAdsLink]): - List of GoogleAdsLinks. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - google_ads_links = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.GoogleAdsLink, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -class GetDataSharingSettingsRequest(proto.Message): - r"""Request message for GetDataSharingSettings RPC. - - Attributes: - name (str): - Required. The name of the settings to lookup. - Format: accounts/{account}/dataSharingSettings - Example: "accounts/1000/dataSharingSettings". - """ - - name = proto.Field(proto.STRING, number=1) - - -class ListAccountSummariesRequest(proto.Message): - r"""Request message for ListAccountSummaries RPC. - - Attributes: - page_size (int): - The maximum number of AccountSummary - resources to return. The service may return - fewer than this value, even if there are - additional pages. If unspecified, at most 50 - resources will be returned. The maximum value is - 200; (higher values will be coerced to the - maximum) - page_token (str): - A page token, received from a previous - ``ListAccountSummaries`` call. Provide this to retrieve the - subsequent page. When paginating, all other parameters - provided to ``ListAccountSummaries`` must match the call - that provided the page token. - """ - - page_size = proto.Field(proto.INT32, number=1) - - page_token = proto.Field(proto.STRING, number=2) - - -class ListAccountSummariesResponse(proto.Message): - r"""Response message for ListAccountSummaries RPC. - - Attributes: - account_summaries (Sequence[google.analytics.admin_v1alpha.types.AccountSummary]): - Account summaries of all accounts the caller - has access to. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - account_summaries = proto.RepeatedField(proto.MESSAGE, number=1, - message=resources.AccountSummary, - ) - - next_page_token = proto.Field(proto.STRING, number=2) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py deleted file mode 100644 index ad0d3296..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py +++ /dev/null @@ -1,712 +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 timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore - - -__protobuf__ = proto.module( - package='google.analytics.admin.v1alpha', - manifest={ - 'MaximumUserAccess', - 'IndustryCategory', - 'Account', - 'Property', - 'AndroidAppDataStream', - 'IosAppDataStream', - 'WebDataStream', - 'UserLink', - 'AuditUserLink', - 'EnhancedMeasurementSettings', - 'FirebaseLink', - 'GlobalSiteTag', - 'GoogleAdsLink', - 'DataSharingSettings', - 'AccountSummary', - 'PropertySummary', - }, -) - - -class MaximumUserAccess(proto.Enum): - r"""Maximum access settings that Firebase user receive on the - linked Analytics property. - """ - MAXIMUM_USER_ACCESS_UNSPECIFIED = 0 - NO_ACCESS = 1 - READ_AND_ANALYZE = 2 - EDITOR_WITHOUT_LINK_MANAGEMENT = 3 - EDITOR_INCLUDING_LINK_MANAGEMENT = 4 - - -class IndustryCategory(proto.Enum): - r"""The category selected for this property, used for industry - benchmarking. - """ - INDUSTRY_CATEGORY_UNSPECIFIED = 0 - AUTOMOTIVE = 1 - BUSINESS_AND_INDUSTRIAL_MARKETS = 2 - FINANCE = 3 - HEALTHCARE = 4 - TECHNOLOGY = 5 - TRAVEL = 6 - OTHER = 7 - ARTS_AND_ENTERTAINMENT = 8 - BEAUTY_AND_FITNESS = 9 - BOOKS_AND_LITERATURE = 10 - FOOD_AND_DRINK = 11 - GAMES = 12 - HOBBIES_AND_LEISURE = 13 - HOME_AND_GARDEN = 14 - INTERNET_AND_TELECOM = 15 - LAW_AND_GOVERNMENT = 16 - NEWS = 17 - ONLINE_COMMUNITIES = 18 - PEOPLE_AND_SOCIETY = 19 - PETS_AND_ANIMALS = 20 - REAL_ESTATE = 21 - REFERENCE = 22 - SCIENCE = 23 - SPORTS = 24 - JOBS_AND_EDUCATION = 25 - SHOPPING = 26 - - -class Account(proto.Message): - r"""A resource message representing a Google Analytics account. - - Attributes: - name (str): - Output only. Resource name of this account. - Format: accounts/{account} - Example: "accounts/100". - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when this account was - originally created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when account payload fields - were last updated. - display_name (str): - Required. Human-readable display name for - this account. - region_code (str): - Country of business. Must be a Unicode CLDR - region code. - deleted (bool): - Output only. Indicates whether this Account - is soft-deleted or not. Deleted accounts are - excluded from List results unless specifically - requested. - """ - - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=2, - message=timestamp.Timestamp, - ) - - update_time = proto.Field(proto.MESSAGE, number=3, - message=timestamp.Timestamp, - ) - - display_name = proto.Field(proto.STRING, number=4) - - region_code = proto.Field(proto.STRING, number=5) - - deleted = proto.Field(proto.BOOL, number=6) - - -class Property(proto.Message): - r"""A resource message representing a Google Analytics GA4 - property. - - Attributes: - name (str): - Output only. Resource name of this property. Format: - properties/{property_id} Example: "properties/1000". - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when the entity was - originally created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when entity payload fields - were last updated. - parent (str): - Immutable. Resource name of this property's - logical parent. - Note: The Property-Moving UI can be used to - change the parent. Format: accounts/{account} - Example: "accounts/100". - display_name (str): - Required. Human-readable display name for - this property. - The max allowed display name length is 100 - UTF-16 code units. - industry_category (google.analytics.admin_v1alpha.types.IndustryCategory): - Industry associated with this property Example: AUTOMOTIVE, - FOOD_AND_DRINK - time_zone (str): - Reporting Time Zone, used as the day boundary for reports, - regardless of where the data originates. If the time zone - honors DST, Analytics will automatically adjust for the - changes. - - NOTE: Changing the time zone only affects data going - forward, and is not applied retroactively. - - Format: https://www.iana.org/time-zones Example: - "America/Los_Angeles". - currency_code (str): - The currency type used in reports involving monetary values. - - Format: https://en.wikipedia.org/wiki/ISO_4217 Examples: - "USD", "EUR", "JPY". - deleted (bool): - Output only. Indicates whether this Property - is soft-deleted or not. Deleted properties are - excluded from List results unless specifically - requested. - """ - - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=3, - message=timestamp.Timestamp, - ) - - update_time = proto.Field(proto.MESSAGE, number=4, - message=timestamp.Timestamp, - ) - - parent = proto.Field(proto.STRING, number=2) - - display_name = proto.Field(proto.STRING, number=5) - - industry_category = proto.Field(proto.ENUM, number=6, - enum='IndustryCategory', - ) - - time_zone = proto.Field(proto.STRING, number=7) - - currency_code = proto.Field(proto.STRING, number=8) - - deleted = proto.Field(proto.BOOL, number=9) - - -class AndroidAppDataStream(proto.Message): - r"""A resource message representing a Google Analytics Android - app stream. - - Attributes: - name (str): - Output only. Resource name of this Data Stream. Format: - properties/{property_id}/androidAppDataStreams/{stream_id} - Example: "properties/1000/androidAppDataStreams/2000". - firebase_app_id (str): - Output only. ID of the corresponding Android - app in Firebase, if any. This ID can change if - the Android app is deleted and recreated. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when this stream was - originally created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when stream payload fields - were last updated. - package_name (str): - Immutable. The package name for the app being - measured. Example: "com.example.myandroidapp". - display_name (str): - Human-readable display name for the Data - Stream. - The max allowed display name length is 255 - UTF-16 code units. - """ - - name = proto.Field(proto.STRING, number=1) - - firebase_app_id = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, - message=timestamp.Timestamp, - ) - - update_time = proto.Field(proto.MESSAGE, number=4, - message=timestamp.Timestamp, - ) - - package_name = proto.Field(proto.STRING, number=5) - - display_name = proto.Field(proto.STRING, number=6) - - -class IosAppDataStream(proto.Message): - r"""A resource message representing a Google Analytics IOS app - stream. - - Attributes: - name (str): - Output only. Resource name of this Data Stream. Format: - properties/{property_id}/iosAppDataStreams/{stream_id} - Example: "properties/1000/iosAppDataStreams/2000". - firebase_app_id (str): - Output only. ID of the corresponding iOS app - in Firebase, if any. This ID can change if the - iOS app is deleted and recreated. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when this stream was - originally created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when stream payload fields - were last updated. - bundle_id (str): - Required. Immutable. The Apple App Store - Bundle ID for the app Example: - "com.example.myiosapp". - display_name (str): - Human-readable display name for the Data - Stream. - The max allowed display name length is 255 - UTF-16 code units. - """ - - name = proto.Field(proto.STRING, number=1) - - firebase_app_id = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, - message=timestamp.Timestamp, - ) - - update_time = proto.Field(proto.MESSAGE, number=4, - message=timestamp.Timestamp, - ) - - bundle_id = proto.Field(proto.STRING, number=5) - - display_name = proto.Field(proto.STRING, number=6) - - -class WebDataStream(proto.Message): - r"""A resource message representing a Google Analytics web - stream. - - Attributes: - name (str): - Output only. Resource name of this Data Stream. Format: - properties/{property_id}/webDataStreams/{stream_id} Example: - "properties/1000/webDataStreams/2000". - measurement_id (str): - Output only. Analytics "Measurement ID", - without the "G-" prefix. Example: "G-1A2BCD345E" - would just be "1A2BCD345E". - firebase_app_id (str): - Output only. ID of the corresponding web app - in Firebase, if any. This ID can change if the - web app is deleted and recreated. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when this stream was - originally created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when stream payload fields - were last updated. - default_uri (str): - Immutable. Domain name of the web app being - measured, or empty. Example: - "http://www.google.com", - "https://www.google.com". - display_name (str): - Required. Human-readable display name for the - Data Stream. - The max allowed display name length is 100 - UTF-16 code units. - """ - - name = proto.Field(proto.STRING, number=1) - - measurement_id = proto.Field(proto.STRING, number=2) - - firebase_app_id = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=4, - message=timestamp.Timestamp, - ) - - update_time = proto.Field(proto.MESSAGE, number=5, - message=timestamp.Timestamp, - ) - - default_uri = proto.Field(proto.STRING, number=6) - - display_name = proto.Field(proto.STRING, number=7) - - -class UserLink(proto.Message): - r"""A resource message representing a user's permissions on an - Account or Property resource. - - Attributes: - name (str): - Example format: - properties/1234/userLinks/5678 - email_address (str): - Email address of the user to link - direct_roles (Sequence[str]): - Roles directly assigned to this user for this account or - property. - - Valid values: predefinedRoles/read - predefinedRoles/collaborate predefinedRoles/edit - predefinedRoles/manage-users - - Excludes roles that are inherited from a higher-level - entity, group, or organization admin role. - - A UserLink that is updated to have an empty list of - direct_roles will be deleted. - """ - - name = proto.Field(proto.STRING, number=1) - - email_address = proto.Field(proto.STRING, number=2) - - direct_roles = proto.RepeatedField(proto.STRING, number=3) - - -class AuditUserLink(proto.Message): - r"""Read-only resource used to summarize a principal's effective - roles. - - Attributes: - name (str): - Example format: - properties/1234/userLinks/5678 - email_address (str): - Email address of the linked user - direct_roles (Sequence[str]): - Roles directly assigned to this user for this - entity. - Format: predefinedRoles/read - - Excludes roles that are inherited from an - account (if this is for a property), group, or - organization admin role. - effective_roles (Sequence[str]): - Union of all permissions a user has at this - account or property (includes direct - permissions, group-inherited permissions, etc.). - Format: predefinedRoles/read - """ - - name = proto.Field(proto.STRING, number=1) - - email_address = proto.Field(proto.STRING, number=2) - - direct_roles = proto.RepeatedField(proto.STRING, number=3) - - effective_roles = proto.RepeatedField(proto.STRING, number=4) - - -class EnhancedMeasurementSettings(proto.Message): - r"""Singleton resource under a WebDataStream, configuring - measurement of additional site interactions and content. - - Attributes: - name (str): - Output only. Resource name of this Data Stream. Format: - properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings - Example: - "properties/1000/webDataStreams/2000/enhancedMeasurementSettings". - stream_enabled (bool): - Indicates whether Enhanced Measurement - Settings will be used to automatically measure - interactions and content on this web stream. - Changing this value does not affect the settings - themselves, but determines whether they are - respected. - page_views_enabled (bool): - Output only. If enabled, capture a page view - event each time a page loads or the website - changes the browser history state. - scrolls_enabled (bool): - If enabled, capture scroll events each time a - visitor gets to the bottom of a page. - outbound_clicks_enabled (bool): - If enabled, capture an outbound click event - each time a visitor clicks a link that leads - them away from your domain. - site_search_enabled (bool): - If enabled, capture a view search results - event each time a visitor performs a search on - your site (based on a query parameter). - video_engagement_enabled (bool): - If enabled, capture video play, progress, and - complete events as visitors view embedded videos - on your site. - file_downloads_enabled (bool): - If enabled, capture a file download event - each time a link is clicked with a common - document, compressed file, application, video, - or audio extension. - page_loads_enabled (bool): - Output only. If enabled, capture a page view - event each time a page loads. - page_changes_enabled (bool): - If enabled, capture a page view event each - time the website changes the browser history - state. - search_query_parameter (str): - Required. URL query parameters to interpret - as site search parameters. Max length is 1024 - characters. Must not be empty. - uri_query_parameter (str): - Additional URL query parameters. - Max length is 1024 characters. - """ - - name = proto.Field(proto.STRING, number=1) - - stream_enabled = proto.Field(proto.BOOL, number=2) - - page_views_enabled = proto.Field(proto.BOOL, number=3) - - scrolls_enabled = proto.Field(proto.BOOL, number=4) - - outbound_clicks_enabled = proto.Field(proto.BOOL, number=5) - - site_search_enabled = proto.Field(proto.BOOL, number=7) - - video_engagement_enabled = proto.Field(proto.BOOL, number=9) - - file_downloads_enabled = proto.Field(proto.BOOL, number=10) - - page_loads_enabled = proto.Field(proto.BOOL, number=12) - - page_changes_enabled = proto.Field(proto.BOOL, number=13) - - search_query_parameter = proto.Field(proto.STRING, number=16) - - uri_query_parameter = proto.Field(proto.STRING, number=17) - - -class FirebaseLink(proto.Message): - r"""A link between an GA4 property and a Firebase project. - - Attributes: - name (str): - Output only. Example format: - properties/1234/firebaseLinks/5678 - project (str): - Immutable. Firebase project resource name. When creating a - FirebaseLink, you may provide this resource name using - either a project number or project ID. Once this resource - has been created, returned FirebaseLinks will always have a - project_name that contains a project number. - - Format: 'projects/{project number}' Example: 'projects/1234' - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when this FirebaseLink was - originally created. - maximum_user_access (google.analytics.admin_v1alpha.types.MaximumUserAccess): - Maximum user access to the GA4 property - allowed to admins of the linked Firebase - project. - """ - - name = proto.Field(proto.STRING, number=1) - - project = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, - message=timestamp.Timestamp, - ) - - maximum_user_access = proto.Field(proto.ENUM, number=4, - enum='MaximumUserAccess', - ) - - -class GlobalSiteTag(proto.Message): - r"""Read-only resource with the tag for sending data from a - website to a WebDataStream. - - Attributes: - name (str): - Output only. Resource name for this - GlobalSiteTag resource. Format: - properties/{propertyId}/globalSiteTag - snippet (str): - Immutable. JavaScript code snippet to be - pasted as the first item into the head tag of - every webpage to measure. - """ - - name = proto.Field(proto.STRING, number=1) - - snippet = proto.Field(proto.STRING, number=2) - - -class GoogleAdsLink(proto.Message): - r"""A link between an GA4 property and a Google Ads account. - - Attributes: - name (str): - Output only. Format: - properties/{propertyId}/googleAdsLinks/{googleAdsLinkId} - Note: googleAdsLinkId is not the Google Ads - customer ID. - customer_id (str): - Immutable. Google Ads customer ID. - can_manage_clients (bool): - Output only. If true, this link is for a - Google Ads manager account. - ads_personalization_enabled (google.protobuf.wrappers_pb2.BoolValue): - Enable personalized advertising features with - this integration. Automatically publish my - Google Analytics audience lists and Google - Analytics remarketing events/parameters to the - linked Google Ads account. If this field is not - set on create/update it will be defaulted to - true. - email_address (str): - Output only. Email address of the user that - created the link. An empty string will be - returned if the email address can't be - retrieved. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when this link was - originally created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when this link was last - updated. - """ - - name = proto.Field(proto.STRING, number=1) - - customer_id = proto.Field(proto.STRING, number=3) - - can_manage_clients = proto.Field(proto.BOOL, number=4) - - ads_personalization_enabled = proto.Field(proto.MESSAGE, number=5, - message=wrappers.BoolValue, - ) - - email_address = proto.Field(proto.STRING, number=6) - - create_time = proto.Field(proto.MESSAGE, number=7, - message=timestamp.Timestamp, - ) - - update_time = proto.Field(proto.MESSAGE, number=8, - message=timestamp.Timestamp, - ) - - -class DataSharingSettings(proto.Message): - r"""A resource message representing data sharing settings of a - Google Analytics account. - - Attributes: - name (str): - Output only. Resource name. - Format: accounts/{account}/dataSharingSettings - Example: "accounts/1000/dataSharingSettings". - sharing_with_google_support_enabled (bool): - Allows Google support to access the data in - order to help troubleshoot issues. - sharing_with_google_assigned_sales_enabled (bool): - Allows Google sales teams that are assigned - to the customer to access the data in order to - suggest configuration changes to improve - results. Sales team restrictions still apply - when enabled. - sharing_with_google_any_sales_enabled (bool): - Allows any of Google sales to access the data - in order to suggest configuration changes to - improve results. - sharing_with_google_products_enabled (bool): - Allows Google to use the data to improve - other Google products or services. - sharing_with_others_enabled (bool): - Allows Google to share the data anonymously - in aggregate form with others. - """ - - name = proto.Field(proto.STRING, number=1) - - sharing_with_google_support_enabled = proto.Field(proto.BOOL, number=2) - - sharing_with_google_assigned_sales_enabled = proto.Field(proto.BOOL, number=3) - - sharing_with_google_any_sales_enabled = proto.Field(proto.BOOL, number=4) - - sharing_with_google_products_enabled = proto.Field(proto.BOOL, number=5) - - sharing_with_others_enabled = proto.Field(proto.BOOL, number=6) - - -class AccountSummary(proto.Message): - r"""A virtual resource representing an overview of an account and - all its child GA4 properties. - - Attributes: - name (str): - Resource name for this account summary. Format: - accountSummaries/{account_id} Example: - "accountSummaries/1000". - account (str): - Resource name of account referred to by this account summary - Format: accounts/{account_id} Example: "accounts/1000". - display_name (str): - Display name for the account referred to in - this account summary. - property_summaries (Sequence[google.analytics.admin_v1alpha.types.PropertySummary]): - List of summaries for child accounts of this - account. - """ - - name = proto.Field(proto.STRING, number=1) - - account = proto.Field(proto.STRING, number=2) - - display_name = proto.Field(proto.STRING, number=3) - - property_summaries = proto.RepeatedField(proto.MESSAGE, number=4, - message='PropertySummary', - ) - - -class PropertySummary(proto.Message): - r"""A virtual resource representing metadata for an GA4 property. - - Attributes: - property (str): - Resource name of property referred to by this property - summary Format: properties/{property_id} Example: - "properties/1000". - display_name (str): - Display name for the property referred to in - this account summary. - """ - - property = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha/mypy.ini b/owl-bot-staging/v1alpha/mypy.ini deleted file mode 100644 index 4505b485..00000000 --- a/owl-bot-staging/v1alpha/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1alpha/noxfile.py b/owl-bot-staging/v1alpha/noxfile.py deleted file mode 100644 index 372f13ba..00000000 --- a/owl-bot-staging/v1alpha/noxfile.py +++ /dev/null @@ -1,72 +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 shutil - -import nox # type: ignore - - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/analytics/admin_v1alpha/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py deleted file mode 100644 index 4aaee832..00000000 --- a/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py +++ /dev/null @@ -1,226 +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 adminCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'audit_user_links': ('parent', 'page_size', 'page_token', ), - 'batch_create_user_links': ('parent', 'requests', 'notify_new_users', ), - 'batch_delete_user_links': ('parent', 'requests', ), - 'batch_get_user_links': ('parent', 'names', ), - 'batch_update_user_links': ('parent', 'requests', ), - 'create_android_app_data_stream': ('android_app_data_stream', 'parent', ), - 'create_firebase_link': ('parent', 'firebase_link', ), - 'create_google_ads_link': ('parent', 'google_ads_link', ), - 'create_ios_app_data_stream': ('ios_app_data_stream', 'parent', ), - 'create_property': ('property', ), - 'create_user_link': ('parent', 'user_link', 'notify_new_user', ), - 'create_web_data_stream': ('web_data_stream', 'parent', ), - 'delete_account': ('name', ), - 'delete_android_app_data_stream': ('name', ), - 'delete_firebase_link': ('name', ), - 'delete_google_ads_link': ('name', ), - 'delete_ios_app_data_stream': ('name', ), - 'delete_property': ('name', ), - 'delete_user_link': ('name', ), - 'delete_web_data_stream': ('name', ), - 'get_account': ('name', ), - 'get_android_app_data_stream': ('name', ), - 'get_data_sharing_settings': ('name', ), - 'get_enhanced_measurement_settings': ('name', ), - 'get_global_site_tag': ('name', ), - 'get_ios_app_data_stream': ('name', ), - 'get_property': ('name', ), - 'get_user_link': ('name', ), - 'get_web_data_stream': ('name', ), - 'list_accounts': ('page_size', 'page_token', 'show_deleted', ), - 'list_account_summaries': ('page_size', 'page_token', ), - 'list_android_app_data_streams': ('parent', 'page_size', 'page_token', ), - 'list_firebase_links': ('parent', 'page_size', 'page_token', ), - 'list_google_ads_links': ('parent', 'page_size', 'page_token', ), - 'list_ios_app_data_streams': ('parent', 'page_size', 'page_token', ), - 'list_properties': ('filter', 'page_size', 'page_token', 'show_deleted', ), - 'list_user_links': ('parent', 'page_size', 'page_token', ), - 'list_web_data_streams': ('parent', 'page_size', 'page_token', ), - 'provision_account_ticket': ('account', 'redirect_uri', ), - 'update_account': ('account', 'update_mask', ), - 'update_android_app_data_stream': ('android_app_data_stream', 'update_mask', ), - 'update_enhanced_measurement_settings': ('enhanced_measurement_settings', 'update_mask', ), - 'update_firebase_link': ('firebase_link', 'update_mask', ), - 'update_google_ads_link': ('update_mask', 'google_ads_link', ), - 'update_ios_app_data_stream': ('ios_app_data_stream', 'update_mask', ), - 'update_property': ('property', 'update_mask', ), - 'update_user_link': ('user_link', ), - 'update_web_data_stream': ('web_data_stream', 'update_mask', ), - - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=adminCallTransformer(), -): - """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 admin 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/v1alpha/setup.py b/owl-bot-staging/v1alpha/setup.py deleted file mode 100644 index 5882b1ac..00000000 --- a/owl-bot-staging/v1alpha/setup.py +++ /dev/null @@ -1,55 +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-analytics-admin', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.analytics'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.22.2, < 2.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__init__.py deleted file mode 100644 index 6a730153..00000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__init__.py +++ /dev/null @@ -1,17 +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/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py b/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py deleted file mode 100644 index 511e3fb9..00000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +++ /dev/null @@ -1,14201 +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 import auth -from google.analytics.admin_v1alpha.services.analytics_admin_service import AnalyticsAdminServiceAsyncClient -from google.analytics.admin_v1alpha.services.analytics_admin_service import AnalyticsAdminServiceClient -from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers -from google.analytics.admin_v1alpha.services.analytics_admin_service import transports -from google.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources -from google.api_core import client_options -from google.api_core import exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.auth import credentials -from google.auth.exceptions import MutualTLSChannelError -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore - - -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 AnalyticsAdminServiceClient._get_default_mtls_endpoint(None) is None - assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert AnalyticsAdminServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [ - AnalyticsAdminServiceClient, - AnalyticsAdminServiceAsyncClient, -]) -def test_analytics_admin_service_client_from_service_account_info(client_class): - creds = 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 == 'analyticsadmin.googleapis.com:443' - - -@pytest.mark.parametrize("client_class", [ - AnalyticsAdminServiceClient, - AnalyticsAdminServiceAsyncClient, -]) -def test_analytics_admin_service_client_from_service_account_file(client_class): - creds = 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 == 'analyticsadmin.googleapis.com:443' - - -def test_analytics_admin_service_client_get_transport_class(): - transport = AnalyticsAdminServiceClient.get_transport_class() - available_transports = [ - transports.AnalyticsAdminServiceGrpcTransport, - ] - assert transport in available_transports - - transport = AnalyticsAdminServiceClient.get_transport_class("grpc") - assert transport == transports.AnalyticsAdminServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc"), - (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(AnalyticsAdminServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AnalyticsAdminServiceClient)) -@mock.patch.object(AnalyticsAdminServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AnalyticsAdminServiceAsyncClient)) -def test_analytics_admin_service_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(AnalyticsAdminServiceClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=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(AnalyticsAdminServiceClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - - (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc", "true"), - (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc", "false"), - (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), - -]) -@mock.patch.object(AnalyticsAdminServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AnalyticsAdminServiceClient)) -@mock.patch.object(AnalyticsAdminServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AnalyticsAdminServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_analytics_admin_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc"), - (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_analytics_admin_service_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (AnalyticsAdminServiceClient, transports.AnalyticsAdminServiceGrpcTransport, "grpc"), - (AnalyticsAdminServiceAsyncClient, transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_analytics_admin_service_client_client_options_credentials_file(client_class, transport_class, transport_name): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_analytics_admin_service_client_client_options_from_dict(): - with mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = AnalyticsAdminServiceClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_get_account(transport: str = 'grpc', request_type=analytics_admin.GetAccountRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Account( - name='name_value', - - display_name='display_name_value', - - region_code='region_code_value', - - deleted=True, - - ) - - response = client.get_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetAccountRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.Account) - - assert response.name == 'name_value' - - assert response.display_name == 'display_name_value' - - assert response.region_code == 'region_code_value' - - assert response.deleted is True - - -def test_get_account_from_dict(): - test_get_account(request_type=dict) - - -def test_get_account_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_account), - '__call__') as call: - client.get_account() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetAccountRequest() - -@pytest.mark.asyncio -async def test_get_account_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetAccountRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account( - name='name_value', - display_name='display_name_value', - region_code='region_code_value', - deleted=True, - )) - - response = await client.get_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetAccountRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Account) - - assert response.name == 'name_value' - - assert response.display_name == 'display_name_value' - - assert response.region_code == 'region_code_value' - - assert response.deleted is True - - -@pytest.mark.asyncio -async def test_get_account_async_from_dict(): - await test_get_account_async(request_type=dict) - - -def test_get_account_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetAccountRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_account), - '__call__') as call: - call.return_value = resources.Account() - - client.get_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_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_account_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetAccountRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_account), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) - - await client.get_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_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_account_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Account() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_account( - 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_account_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_account( - analytics_admin.GetAccountRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_account_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Account() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_account( - 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_account_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_account( - analytics_admin.GetAccountRequest(), - name='name_value', - ) - - -def test_list_accounts(transport: str = 'grpc', request_type=analytics_admin.ListAccountsRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_accounts), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListAccountsResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_accounts(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListAccountsRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListAccountsPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_accounts_from_dict(): - test_list_accounts(request_type=dict) - - -def test_list_accounts_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_accounts), - '__call__') as call: - client.list_accounts() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListAccountsRequest() - -@pytest.mark.asyncio -async def test_list_accounts_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListAccountsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_accounts), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAccountsResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_accounts(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListAccountsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAccountsAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_accounts_async_from_dict(): - await test_list_accounts_async(request_type=dict) - - -def test_list_accounts_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_accounts), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - resources.Account(), - ], - next_page_token='abc', - ), - analytics_admin.ListAccountsResponse( - accounts=[], - next_page_token='def', - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - ], - ), - RuntimeError, - ) - - metadata = () - pager = client.list_accounts(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.Account) - for i in results) - -def test_list_accounts_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_accounts), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - resources.Account(), - ], - next_page_token='abc', - ), - analytics_admin.ListAccountsResponse( - accounts=[], - next_page_token='def', - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - ], - ), - RuntimeError, - ) - pages = list(client.list_accounts(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_accounts_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_accounts), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - resources.Account(), - ], - next_page_token='abc', - ), - analytics_admin.ListAccountsResponse( - accounts=[], - next_page_token='def', - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_accounts(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.Account) - for i in responses) - -@pytest.mark.asyncio -async def test_list_accounts_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_accounts), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - resources.Account(), - ], - next_page_token='abc', - ), - analytics_admin.ListAccountsResponse( - accounts=[], - next_page_token='def', - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_accounts(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_account(transport: str = 'grpc', request_type=analytics_admin.DeleteAccountRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteAccountRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_account_from_dict(): - test_delete_account(request_type=dict) - - -def test_delete_account_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_account), - '__call__') as call: - client.delete_account() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteAccountRequest() - -@pytest.mark.asyncio -async def test_delete_account_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteAccountRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.delete_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteAccountRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_account_async_from_dict(): - await test_delete_account_async(request_type=dict) - - -def test_delete_account_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteAccountRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_account), - '__call__') as call: - call.return_value = None - - client.delete_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_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_account_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteAccountRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_account), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.delete_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_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_account_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_account( - 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_account_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_account( - analytics_admin.DeleteAccountRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_account_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_account( - 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_account_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_account( - analytics_admin.DeleteAccountRequest(), - name='name_value', - ) - - -def test_update_account(transport: str = 'grpc', request_type=analytics_admin.UpdateAccountRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Account( - name='name_value', - - display_name='display_name_value', - - region_code='region_code_value', - - deleted=True, - - ) - - response = client.update_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateAccountRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.Account) - - assert response.name == 'name_value' - - assert response.display_name == 'display_name_value' - - assert response.region_code == 'region_code_value' - - assert response.deleted is True - - -def test_update_account_from_dict(): - test_update_account(request_type=dict) - - -def test_update_account_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_account), - '__call__') as call: - client.update_account() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateAccountRequest() - -@pytest.mark.asyncio -async def test_update_account_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateAccountRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account( - name='name_value', - display_name='display_name_value', - region_code='region_code_value', - deleted=True, - )) - - response = await client.update_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateAccountRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Account) - - assert response.name == 'name_value' - - assert response.display_name == 'display_name_value' - - assert response.region_code == 'region_code_value' - - assert response.deleted is True - - -@pytest.mark.asyncio -async def test_update_account_async_from_dict(): - await test_update_account_async(request_type=dict) - - -def test_update_account_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateAccountRequest() - request.account.name = 'account.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_account), - '__call__') as call: - call.return_value = resources.Account() - - client.update_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'account.name=account.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_account_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateAccountRequest() - request.account.name = 'account.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_account), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) - - await client.update_account(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'account.name=account.name/value', - ) in kw['metadata'] - - -def test_update_account_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Account() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_account( - account=resources.Account(name='name_value'), - update_mask=field_mask.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].account == resources.Account(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -def test_update_account_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_account( - analytics_admin.UpdateAccountRequest(), - account=resources.Account(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_account_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_account), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Account() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_account( - account=resources.Account(name='name_value'), - update_mask=field_mask.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].account == resources.Account(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_account_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_account( - analytics_admin.UpdateAccountRequest(), - account=resources.Account(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -def test_provision_account_ticket(transport: str = 'grpc', request_type=analytics_admin.ProvisionAccountTicketRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.provision_account_ticket), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ProvisionAccountTicketResponse( - account_ticket_id='account_ticket_id_value', - - ) - - response = client.provision_account_ticket(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ProvisionAccountTicketRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, analytics_admin.ProvisionAccountTicketResponse) - - assert response.account_ticket_id == 'account_ticket_id_value' - - -def test_provision_account_ticket_from_dict(): - test_provision_account_ticket(request_type=dict) - - -def test_provision_account_ticket_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.provision_account_ticket), - '__call__') as call: - client.provision_account_ticket() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ProvisionAccountTicketRequest() - -@pytest.mark.asyncio -async def test_provision_account_ticket_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ProvisionAccountTicketRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.provision_account_ticket), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ProvisionAccountTicketResponse( - account_ticket_id='account_ticket_id_value', - )) - - response = await client.provision_account_ticket(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ProvisionAccountTicketRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.ProvisionAccountTicketResponse) - - assert response.account_ticket_id == 'account_ticket_id_value' - - -@pytest.mark.asyncio -async def test_provision_account_ticket_async_from_dict(): - await test_provision_account_ticket_async(request_type=dict) - - -def test_list_account_summaries(transport: str = 'grpc', request_type=analytics_admin.ListAccountSummariesRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_account_summaries), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListAccountSummariesResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_account_summaries(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListAccountSummariesRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListAccountSummariesPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_account_summaries_from_dict(): - test_list_account_summaries(request_type=dict) - - -def test_list_account_summaries_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_account_summaries), - '__call__') as call: - client.list_account_summaries() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListAccountSummariesRequest() - -@pytest.mark.asyncio -async def test_list_account_summaries_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListAccountSummariesRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_account_summaries), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAccountSummariesResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_account_summaries(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListAccountSummariesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAccountSummariesAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_account_summaries_async_from_dict(): - await test_list_account_summaries_async(request_type=dict) - - -def test_list_account_summaries_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_account_summaries), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - resources.AccountSummary(), - ], - next_page_token='abc', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[], - next_page_token='def', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - ], - ), - RuntimeError, - ) - - metadata = () - pager = client.list_account_summaries(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.AccountSummary) - for i in results) - -def test_list_account_summaries_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_account_summaries), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - resources.AccountSummary(), - ], - next_page_token='abc', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[], - next_page_token='def', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - ], - ), - RuntimeError, - ) - pages = list(client.list_account_summaries(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_account_summaries_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_account_summaries), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - resources.AccountSummary(), - ], - next_page_token='abc', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[], - next_page_token='def', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_account_summaries(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.AccountSummary) - for i in responses) - -@pytest.mark.asyncio -async def test_list_account_summaries_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_account_summaries), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - resources.AccountSummary(), - ], - next_page_token='abc', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[], - next_page_token='def', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_account_summaries(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_property(transport: str = 'grpc', request_type=analytics_admin.GetPropertyRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property( - name='name_value', - - parent='parent_value', - - display_name='display_name_value', - - industry_category=resources.IndustryCategory.AUTOMOTIVE, - - time_zone='time_zone_value', - - currency_code='currency_code_value', - - deleted=True, - - ) - - response = client.get_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetPropertyRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.Property) - - assert response.name == 'name_value' - - assert response.parent == 'parent_value' - - assert response.display_name == 'display_name_value' - - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - - assert response.time_zone == 'time_zone_value' - - assert response.currency_code == 'currency_code_value' - - assert response.deleted is True - - -def test_get_property_from_dict(): - test_get_property(request_type=dict) - - -def test_get_property_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_property), - '__call__') as call: - client.get_property() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetPropertyRequest() - -@pytest.mark.asyncio -async def test_get_property_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetPropertyRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property( - name='name_value', - parent='parent_value', - display_name='display_name_value', - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone='time_zone_value', - currency_code='currency_code_value', - deleted=True, - )) - - response = await client.get_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetPropertyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) - - assert response.name == 'name_value' - - assert response.parent == 'parent_value' - - assert response.display_name == 'display_name_value' - - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - - assert response.time_zone == 'time_zone_value' - - assert response.currency_code == 'currency_code_value' - - assert response.deleted is True - - -@pytest.mark.asyncio -async def test_get_property_async_from_dict(): - await test_get_property_async(request_type=dict) - - -def test_get_property_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetPropertyRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_property), - '__call__') as call: - call.return_value = resources.Property() - - client.get_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_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_property_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetPropertyRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_property), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) - - await client.get_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_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_property_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_property( - 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_property_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_property( - analytics_admin.GetPropertyRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_property_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_property( - 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_property_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_property( - analytics_admin.GetPropertyRequest(), - name='name_value', - ) - - -def test_list_properties(transport: str = 'grpc', request_type=analytics_admin.ListPropertiesRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_properties), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListPropertiesResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_properties(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListPropertiesRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListPropertiesPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_properties_from_dict(): - test_list_properties(request_type=dict) - - -def test_list_properties_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_properties), - '__call__') as call: - client.list_properties() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListPropertiesRequest() - -@pytest.mark.asyncio -async def test_list_properties_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListPropertiesRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_properties), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListPropertiesResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_properties(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListPropertiesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPropertiesAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_properties_async_from_dict(): - await test_list_properties_async(request_type=dict) - - -def test_list_properties_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_properties), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - resources.Property(), - ], - next_page_token='abc', - ), - analytics_admin.ListPropertiesResponse( - properties=[], - next_page_token='def', - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - ], - next_page_token='ghi', - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - ], - ), - RuntimeError, - ) - - metadata = () - pager = client.list_properties(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.Property) - for i in results) - -def test_list_properties_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_properties), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - resources.Property(), - ], - next_page_token='abc', - ), - analytics_admin.ListPropertiesResponse( - properties=[], - next_page_token='def', - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - ], - next_page_token='ghi', - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - ], - ), - RuntimeError, - ) - pages = list(client.list_properties(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_properties_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_properties), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - resources.Property(), - ], - next_page_token='abc', - ), - analytics_admin.ListPropertiesResponse( - properties=[], - next_page_token='def', - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - ], - next_page_token='ghi', - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_properties(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.Property) - for i in responses) - -@pytest.mark.asyncio -async def test_list_properties_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_properties), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - resources.Property(), - ], - next_page_token='abc', - ), - analytics_admin.ListPropertiesResponse( - properties=[], - next_page_token='def', - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - ], - next_page_token='ghi', - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_properties(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_property(transport: str = 'grpc', request_type=analytics_admin.CreatePropertyRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property( - name='name_value', - - parent='parent_value', - - display_name='display_name_value', - - industry_category=resources.IndustryCategory.AUTOMOTIVE, - - time_zone='time_zone_value', - - currency_code='currency_code_value', - - deleted=True, - - ) - - response = client.create_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreatePropertyRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.Property) - - assert response.name == 'name_value' - - assert response.parent == 'parent_value' - - assert response.display_name == 'display_name_value' - - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - - assert response.time_zone == 'time_zone_value' - - assert response.currency_code == 'currency_code_value' - - assert response.deleted is True - - -def test_create_property_from_dict(): - test_create_property(request_type=dict) - - -def test_create_property_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_property), - '__call__') as call: - client.create_property() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreatePropertyRequest() - -@pytest.mark.asyncio -async def test_create_property_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreatePropertyRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property( - name='name_value', - parent='parent_value', - display_name='display_name_value', - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone='time_zone_value', - currency_code='currency_code_value', - deleted=True, - )) - - response = await client.create_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreatePropertyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) - - assert response.name == 'name_value' - - assert response.parent == 'parent_value' - - assert response.display_name == 'display_name_value' - - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - - assert response.time_zone == 'time_zone_value' - - assert response.currency_code == 'currency_code_value' - - assert response.deleted is True - - -@pytest.mark.asyncio -async def test_create_property_async_from_dict(): - await test_create_property_async(request_type=dict) - - -def test_create_property_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_property( - property=resources.Property(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].property == resources.Property(name='name_value') - - -def test_create_property_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_property( - analytics_admin.CreatePropertyRequest(), - property=resources.Property(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_property_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_property( - property=resources.Property(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].property == resources.Property(name='name_value') - - -@pytest.mark.asyncio -async def test_create_property_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_property( - analytics_admin.CreatePropertyRequest(), - property=resources.Property(name='name_value'), - ) - - -def test_delete_property(transport: str = 'grpc', request_type=analytics_admin.DeletePropertyRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeletePropertyRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_property_from_dict(): - test_delete_property(request_type=dict) - - -def test_delete_property_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_property), - '__call__') as call: - client.delete_property() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeletePropertyRequest() - -@pytest.mark.asyncio -async def test_delete_property_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeletePropertyRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.delete_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeletePropertyRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_property_async_from_dict(): - await test_delete_property_async(request_type=dict) - - -def test_delete_property_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeletePropertyRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_property), - '__call__') as call: - call.return_value = None - - client.delete_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_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_property_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeletePropertyRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_property), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.delete_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_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_property_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_property( - 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_property_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_property( - analytics_admin.DeletePropertyRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_property_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_property( - 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_property_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_property( - analytics_admin.DeletePropertyRequest(), - name='name_value', - ) - - -def test_update_property(transport: str = 'grpc', request_type=analytics_admin.UpdatePropertyRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property( - name='name_value', - - parent='parent_value', - - display_name='display_name_value', - - industry_category=resources.IndustryCategory.AUTOMOTIVE, - - time_zone='time_zone_value', - - currency_code='currency_code_value', - - deleted=True, - - ) - - response = client.update_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdatePropertyRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.Property) - - assert response.name == 'name_value' - - assert response.parent == 'parent_value' - - assert response.display_name == 'display_name_value' - - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - - assert response.time_zone == 'time_zone_value' - - assert response.currency_code == 'currency_code_value' - - assert response.deleted is True - - -def test_update_property_from_dict(): - test_update_property(request_type=dict) - - -def test_update_property_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_property), - '__call__') as call: - client.update_property() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdatePropertyRequest() - -@pytest.mark.asyncio -async def test_update_property_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdatePropertyRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property( - name='name_value', - parent='parent_value', - display_name='display_name_value', - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone='time_zone_value', - currency_code='currency_code_value', - deleted=True, - )) - - response = await client.update_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdatePropertyRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) - - assert response.name == 'name_value' - - assert response.parent == 'parent_value' - - assert response.display_name == 'display_name_value' - - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - - assert response.time_zone == 'time_zone_value' - - assert response.currency_code == 'currency_code_value' - - assert response.deleted is True - - -@pytest.mark.asyncio -async def test_update_property_async_from_dict(): - await test_update_property_async(request_type=dict) - - -def test_update_property_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdatePropertyRequest() - request.property.name = 'property.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_property), - '__call__') as call: - call.return_value = resources.Property() - - client.update_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'property.name=property.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_property_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdatePropertyRequest() - request.property.name = 'property.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_property), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) - - await client.update_property(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'property.name=property.name/value', - ) in kw['metadata'] - - -def test_update_property_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_property( - property=resources.Property(name='name_value'), - update_mask=field_mask.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].property == resources.Property(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -def test_update_property_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_property( - analytics_admin.UpdatePropertyRequest(), - property=resources.Property(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_property_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_property), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Property() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_property( - property=resources.Property(name='name_value'), - update_mask=field_mask.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].property == resources.Property(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_property_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_property( - analytics_admin.UpdatePropertyRequest(), - property=resources.Property(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -def test_get_user_link(transport: str = 'grpc', request_type=analytics_admin.GetUserLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink( - name='name_value', - - email_address='email_address_value', - - direct_roles=['direct_roles_value'], - - ) - - response = client.get_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetUserLinkRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.UserLink) - - assert response.name == 'name_value' - - assert response.email_address == 'email_address_value' - - assert response.direct_roles == ['direct_roles_value'] - - -def test_get_user_link_from_dict(): - test_get_user_link(request_type=dict) - - -def test_get_user_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_user_link), - '__call__') as call: - client.get_user_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetUserLinkRequest() - -@pytest.mark.asyncio -async def test_get_user_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetUserLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink( - name='name_value', - email_address='email_address_value', - direct_roles=['direct_roles_value'], - )) - - response = await client.get_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetUserLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.UserLink) - - assert response.name == 'name_value' - - assert response.email_address == 'email_address_value' - - assert response.direct_roles == ['direct_roles_value'] - - -@pytest.mark.asyncio -async def test_get_user_link_async_from_dict(): - await test_get_user_link_async(request_type=dict) - - -def test_get_user_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetUserLinkRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_user_link), - '__call__') as call: - call.return_value = resources.UserLink() - - client.get_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_user_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetUserLinkRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_user_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - - await client.get_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_get_user_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_user_link( - 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_user_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_user_link( - analytics_admin.GetUserLinkRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_user_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_user_link( - 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_user_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_user_link( - analytics_admin.GetUserLinkRequest(), - name='name_value', - ) - - -def test_batch_get_user_links(transport: str = 'grpc', request_type=analytics_admin.BatchGetUserLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_get_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.BatchGetUserLinksResponse( - ) - - response = client.batch_get_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchGetUserLinksRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) - - -def test_batch_get_user_links_from_dict(): - test_batch_get_user_links(request_type=dict) - - -def test_batch_get_user_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_get_user_links), - '__call__') as call: - client.batch_get_user_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchGetUserLinksRequest() - -@pytest.mark.asyncio -async def test_batch_get_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.BatchGetUserLinksRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_get_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchGetUserLinksResponse( - )) - - response = await client.batch_get_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchGetUserLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) - - -@pytest.mark.asyncio -async def test_batch_get_user_links_async_from_dict(): - await test_batch_get_user_links_async(request_type=dict) - - -def test_batch_get_user_links_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.BatchGetUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_get_user_links), - '__call__') as call: - call.return_value = analytics_admin.BatchGetUserLinksResponse() - - client.batch_get_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_batch_get_user_links_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.BatchGetUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_get_user_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchGetUserLinksResponse()) - - await client.batch_get_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_list_user_links(transport: str = 'grpc', request_type=analytics_admin.ListUserLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListUserLinksResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListUserLinksRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListUserLinksPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_user_links_from_dict(): - test_list_user_links(request_type=dict) - - -def test_list_user_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__') as call: - client.list_user_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListUserLinksRequest() - -@pytest.mark.asyncio -async def test_list_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListUserLinksRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListUserLinksResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListUserLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListUserLinksAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_user_links_async_from_dict(): - await test_list_user_links_async(request_type=dict) - - -def test_list_user_links_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__') as call: - call.return_value = analytics_admin.ListUserLinksResponse() - - client.list_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_user_links_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListUserLinksResponse()) - - await client.list_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_list_user_links_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListUserLinksResponse() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_user_links( - 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_user_links_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_user_links( - analytics_admin.ListUserLinksRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_user_links_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListUserLinksResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListUserLinksResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_user_links( - 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_user_links_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_user_links( - analytics_admin.ListUserLinksRequest(), - parent='parent_value', - ) - - -def test_list_user_links_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - resources.UserLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListUserLinksResponse( - user_links=[], - next_page_token='def', - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_user_links(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.UserLink) - for i in results) - -def test_list_user_links_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - resources.UserLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListUserLinksResponse( - user_links=[], - next_page_token='def', - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - ], - ), - RuntimeError, - ) - pages = list(client.list_user_links(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_user_links_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - resources.UserLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListUserLinksResponse( - user_links=[], - next_page_token='def', - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_user_links(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.UserLink) - for i in responses) - -@pytest.mark.asyncio -async def test_list_user_links_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_user_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - resources.UserLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListUserLinksResponse( - user_links=[], - next_page_token='def', - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_user_links(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_audit_user_links(transport: str = 'grpc', request_type=analytics_admin.AuditUserLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.AuditUserLinksResponse( - next_page_token='next_page_token_value', - - ) - - response = client.audit_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.AuditUserLinksRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.AuditUserLinksPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_audit_user_links_from_dict(): - test_audit_user_links(request_type=dict) - - -def test_audit_user_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__') as call: - client.audit_user_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.AuditUserLinksRequest() - -@pytest.mark.asyncio -async def test_audit_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.AuditUserLinksRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.AuditUserLinksResponse( - next_page_token='next_page_token_value', - )) - - response = await client.audit_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.AuditUserLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.AuditUserLinksAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_audit_user_links_async_from_dict(): - await test_audit_user_links_async(request_type=dict) - - -def test_audit_user_links_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.AuditUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__') as call: - call.return_value = analytics_admin.AuditUserLinksResponse() - - client.audit_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_audit_user_links_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.AuditUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.AuditUserLinksResponse()) - - await client.audit_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_audit_user_links_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - next_page_token='abc', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[], - next_page_token='def', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - ], - next_page_token='ghi', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.audit_user_links(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.AuditUserLink) - for i in results) - -def test_audit_user_links_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - next_page_token='abc', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[], - next_page_token='def', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - ], - next_page_token='ghi', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - ), - RuntimeError, - ) - pages = list(client.audit_user_links(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_audit_user_links_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - next_page_token='abc', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[], - next_page_token='def', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - ], - next_page_token='ghi', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - ), - RuntimeError, - ) - async_pager = await client.audit_user_links(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.AuditUserLink) - for i in responses) - -@pytest.mark.asyncio -async def test_audit_user_links_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.audit_user_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - next_page_token='abc', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[], - next_page_token='def', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - ], - next_page_token='ghi', - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.audit_user_links(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_create_user_link(transport: str = 'grpc', request_type=analytics_admin.CreateUserLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink( - name='name_value', - - email_address='email_address_value', - - direct_roles=['direct_roles_value'], - - ) - - response = client.create_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateUserLinkRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.UserLink) - - assert response.name == 'name_value' - - assert response.email_address == 'email_address_value' - - assert response.direct_roles == ['direct_roles_value'] - - -def test_create_user_link_from_dict(): - test_create_user_link(request_type=dict) - - -def test_create_user_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_user_link), - '__call__') as call: - client.create_user_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateUserLinkRequest() - -@pytest.mark.asyncio -async def test_create_user_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateUserLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink( - name='name_value', - email_address='email_address_value', - direct_roles=['direct_roles_value'], - )) - - response = await client.create_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateUserLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.UserLink) - - assert response.name == 'name_value' - - assert response.email_address == 'email_address_value' - - assert response.direct_roles == ['direct_roles_value'] - - -@pytest.mark.asyncio -async def test_create_user_link_async_from_dict(): - await test_create_user_link_async(request_type=dict) - - -def test_create_user_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateUserLinkRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_user_link), - '__call__') as call: - call.return_value = resources.UserLink() - - client.create_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_user_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateUserLinkRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_user_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - - await client.create_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_create_user_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_user_link( - parent='parent_value', - user_link=resources.UserLink(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].parent == 'parent_value' - - assert args[0].user_link == resources.UserLink(name='name_value') - - -def test_create_user_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_user_link( - analytics_admin.CreateUserLinkRequest(), - parent='parent_value', - user_link=resources.UserLink(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_user_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_user_link( - parent='parent_value', - user_link=resources.UserLink(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].parent == 'parent_value' - - assert args[0].user_link == resources.UserLink(name='name_value') - - -@pytest.mark.asyncio -async def test_create_user_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_user_link( - analytics_admin.CreateUserLinkRequest(), - parent='parent_value', - user_link=resources.UserLink(name='name_value'), - ) - - -def test_batch_create_user_links(transport: str = 'grpc', request_type=analytics_admin.BatchCreateUserLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.BatchCreateUserLinksResponse( - ) - - response = client.batch_create_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchCreateUserLinksRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) - - -def test_batch_create_user_links_from_dict(): - test_batch_create_user_links(request_type=dict) - - -def test_batch_create_user_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_user_links), - '__call__') as call: - client.batch_create_user_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchCreateUserLinksRequest() - -@pytest.mark.asyncio -async def test_batch_create_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.BatchCreateUserLinksRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchCreateUserLinksResponse( - )) - - response = await client.batch_create_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchCreateUserLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) - - -@pytest.mark.asyncio -async def test_batch_create_user_links_async_from_dict(): - await test_batch_create_user_links_async(request_type=dict) - - -def test_batch_create_user_links_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.BatchCreateUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_user_links), - '__call__') as call: - call.return_value = analytics_admin.BatchCreateUserLinksResponse() - - client.batch_create_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_batch_create_user_links_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.BatchCreateUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_create_user_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchCreateUserLinksResponse()) - - await client.batch_create_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_update_user_link(transport: str = 'grpc', request_type=analytics_admin.UpdateUserLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink( - name='name_value', - - email_address='email_address_value', - - direct_roles=['direct_roles_value'], - - ) - - response = client.update_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateUserLinkRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.UserLink) - - assert response.name == 'name_value' - - assert response.email_address == 'email_address_value' - - assert response.direct_roles == ['direct_roles_value'] - - -def test_update_user_link_from_dict(): - test_update_user_link(request_type=dict) - - -def test_update_user_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_user_link), - '__call__') as call: - client.update_user_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateUserLinkRequest() - -@pytest.mark.asyncio -async def test_update_user_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateUserLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink( - name='name_value', - email_address='email_address_value', - direct_roles=['direct_roles_value'], - )) - - response = await client.update_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateUserLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.UserLink) - - assert response.name == 'name_value' - - assert response.email_address == 'email_address_value' - - assert response.direct_roles == ['direct_roles_value'] - - -@pytest.mark.asyncio -async def test_update_user_link_async_from_dict(): - await test_update_user_link_async(request_type=dict) - - -def test_update_user_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateUserLinkRequest() - request.user_link.name = 'user_link.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_user_link), - '__call__') as call: - call.return_value = resources.UserLink() - - client.update_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'user_link.name=user_link.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_user_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateUserLinkRequest() - request.user_link.name = 'user_link.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_user_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - - await client.update_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'user_link.name=user_link.name/value', - ) in kw['metadata'] - - -def test_update_user_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_user_link( - user_link=resources.UserLink(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].user_link == resources.UserLink(name='name_value') - - -def test_update_user_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_user_link( - analytics_admin.UpdateUserLinkRequest(), - user_link=resources.UserLink(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_update_user_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.UserLink() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_user_link( - user_link=resources.UserLink(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].user_link == resources.UserLink(name='name_value') - - -@pytest.mark.asyncio -async def test_update_user_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_user_link( - analytics_admin.UpdateUserLinkRequest(), - user_link=resources.UserLink(name='name_value'), - ) - - -def test_batch_update_user_links(transport: str = 'grpc', request_type=analytics_admin.BatchUpdateUserLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.BatchUpdateUserLinksResponse( - ) - - response = client.batch_update_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) - - -def test_batch_update_user_links_from_dict(): - test_batch_update_user_links(request_type=dict) - - -def test_batch_update_user_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_user_links), - '__call__') as call: - client.batch_update_user_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() - -@pytest.mark.asyncio -async def test_batch_update_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.BatchUpdateUserLinksRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchUpdateUserLinksResponse( - )) - - response = await client.batch_update_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) - - -@pytest.mark.asyncio -async def test_batch_update_user_links_async_from_dict(): - await test_batch_update_user_links_async(request_type=dict) - - -def test_batch_update_user_links_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.BatchUpdateUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_user_links), - '__call__') as call: - call.return_value = analytics_admin.BatchUpdateUserLinksResponse() - - client.batch_update_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_batch_update_user_links_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.BatchUpdateUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_update_user_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.BatchUpdateUserLinksResponse()) - - await client.batch_update_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_delete_user_link(transport: str = 'grpc', request_type=analytics_admin.DeleteUserLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteUserLinkRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_user_link_from_dict(): - test_delete_user_link(request_type=dict) - - -def test_delete_user_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_user_link), - '__call__') as call: - client.delete_user_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteUserLinkRequest() - -@pytest.mark.asyncio -async def test_delete_user_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteUserLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.delete_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteUserLinkRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_user_link_async_from_dict(): - await test_delete_user_link_async(request_type=dict) - - -def test_delete_user_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteUserLinkRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_user_link), - '__call__') as call: - call.return_value = None - - client.delete_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_user_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteUserLinkRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_user_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.delete_user_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_delete_user_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_user_link( - 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_user_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_user_link( - analytics_admin.DeleteUserLinkRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_user_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_user_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_user_link( - 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_user_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_user_link( - analytics_admin.DeleteUserLinkRequest(), - name='name_value', - ) - - -def test_batch_delete_user_links(transport: str = 'grpc', request_type=analytics_admin.BatchDeleteUserLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.batch_delete_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_batch_delete_user_links_from_dict(): - test_batch_delete_user_links(request_type=dict) - - -def test_batch_delete_user_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_user_links), - '__call__') as call: - client.batch_delete_user_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() - -@pytest.mark.asyncio -async def test_batch_delete_user_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.BatchDeleteUserLinksRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_user_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.batch_delete_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_batch_delete_user_links_async_from_dict(): - await test_batch_delete_user_links_async(request_type=dict) - - -def test_batch_delete_user_links_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.BatchDeleteUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_user_links), - '__call__') as call: - call.return_value = None - - client.batch_delete_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_batch_delete_user_links_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.BatchDeleteUserLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_user_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.batch_delete_user_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_get_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.GetWebDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream( - name='name_value', - - measurement_id='measurement_id_value', - - firebase_app_id='firebase_app_id_value', - - default_uri='default_uri_value', - - display_name='display_name_value', - - ) - - response = client.get_web_data_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] == analytics_admin.GetWebDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.WebDataStream) - - assert response.name == 'name_value' - - assert response.measurement_id == 'measurement_id_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.default_uri == 'default_uri_value' - - assert response.display_name == 'display_name_value' - - -def test_get_web_data_stream_from_dict(): - test_get_web_data_stream(request_type=dict) - - -def test_get_web_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_web_data_stream), - '__call__') as call: - client.get_web_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetWebDataStreamRequest() - -@pytest.mark.asyncio -async def test_get_web_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetWebDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream( - name='name_value', - measurement_id='measurement_id_value', - firebase_app_id='firebase_app_id_value', - default_uri='default_uri_value', - display_name='display_name_value', - )) - - response = await client.get_web_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetWebDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.WebDataStream) - - assert response.name == 'name_value' - - assert response.measurement_id == 'measurement_id_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.default_uri == 'default_uri_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_get_web_data_stream_async_from_dict(): - await test_get_web_data_stream_async(request_type=dict) - - -def test_get_web_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetWebDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_web_data_stream), - '__call__') as call: - call.return_value = resources.WebDataStream() - - client.get_web_data_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_web_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetWebDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_web_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) - - await client.get_web_data_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_web_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_web_data_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_web_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_web_data_stream( - analytics_admin.GetWebDataStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_web_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_web_data_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_web_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_web_data_stream( - analytics_admin.GetWebDataStreamRequest(), - name='name_value', - ) - - -def test_delete_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.DeleteWebDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_web_data_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] == analytics_admin.DeleteWebDataStreamRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_web_data_stream_from_dict(): - test_delete_web_data_stream(request_type=dict) - - -def test_delete_web_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_web_data_stream), - '__call__') as call: - client.delete_web_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteWebDataStreamRequest() - -@pytest.mark.asyncio -async def test_delete_web_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteWebDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.delete_web_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteWebDataStreamRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_web_data_stream_async_from_dict(): - await test_delete_web_data_stream_async(request_type=dict) - - -def test_delete_web_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteWebDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_web_data_stream), - '__call__') as call: - call.return_value = None - - client.delete_web_data_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_web_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteWebDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_web_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.delete_web_data_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_web_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_web_data_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_web_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_web_data_stream( - analytics_admin.DeleteWebDataStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_web_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_web_data_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_web_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_web_data_stream( - analytics_admin.DeleteWebDataStreamRequest(), - name='name_value', - ) - - -def test_update_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.UpdateWebDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream( - name='name_value', - - measurement_id='measurement_id_value', - - firebase_app_id='firebase_app_id_value', - - default_uri='default_uri_value', - - display_name='display_name_value', - - ) - - response = client.update_web_data_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] == analytics_admin.UpdateWebDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.WebDataStream) - - assert response.name == 'name_value' - - assert response.measurement_id == 'measurement_id_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.default_uri == 'default_uri_value' - - assert response.display_name == 'display_name_value' - - -def test_update_web_data_stream_from_dict(): - test_update_web_data_stream(request_type=dict) - - -def test_update_web_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_web_data_stream), - '__call__') as call: - client.update_web_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateWebDataStreamRequest() - -@pytest.mark.asyncio -async def test_update_web_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateWebDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream( - name='name_value', - measurement_id='measurement_id_value', - firebase_app_id='firebase_app_id_value', - default_uri='default_uri_value', - display_name='display_name_value', - )) - - response = await client.update_web_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateWebDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.WebDataStream) - - assert response.name == 'name_value' - - assert response.measurement_id == 'measurement_id_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.default_uri == 'default_uri_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_update_web_data_stream_async_from_dict(): - await test_update_web_data_stream_async(request_type=dict) - - -def test_update_web_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateWebDataStreamRequest() - request.web_data_stream.name = 'web_data_stream.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_web_data_stream), - '__call__') as call: - call.return_value = resources.WebDataStream() - - client.update_web_data_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', - 'web_data_stream.name=web_data_stream.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_web_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateWebDataStreamRequest() - request.web_data_stream.name = 'web_data_stream.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_web_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) - - await client.update_web_data_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', - 'web_data_stream.name=web_data_stream.name/value', - ) in kw['metadata'] - - -def test_update_web_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_web_data_stream( - web_data_stream=resources.WebDataStream(name='name_value'), - update_mask=field_mask.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].web_data_stream == resources.WebDataStream(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -def test_update_web_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_web_data_stream( - analytics_admin.UpdateWebDataStreamRequest(), - web_data_stream=resources.WebDataStream(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_web_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_web_data_stream( - web_data_stream=resources.WebDataStream(name='name_value'), - update_mask=field_mask.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].web_data_stream == resources.WebDataStream(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_web_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_web_data_stream( - analytics_admin.UpdateWebDataStreamRequest(), - web_data_stream=resources.WebDataStream(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -def test_create_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.CreateWebDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream( - name='name_value', - - measurement_id='measurement_id_value', - - firebase_app_id='firebase_app_id_value', - - default_uri='default_uri_value', - - display_name='display_name_value', - - ) - - response = client.create_web_data_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] == analytics_admin.CreateWebDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.WebDataStream) - - assert response.name == 'name_value' - - assert response.measurement_id == 'measurement_id_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.default_uri == 'default_uri_value' - - assert response.display_name == 'display_name_value' - - -def test_create_web_data_stream_from_dict(): - test_create_web_data_stream(request_type=dict) - - -def test_create_web_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_web_data_stream), - '__call__') as call: - client.create_web_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateWebDataStreamRequest() - -@pytest.mark.asyncio -async def test_create_web_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateWebDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream( - name='name_value', - measurement_id='measurement_id_value', - firebase_app_id='firebase_app_id_value', - default_uri='default_uri_value', - display_name='display_name_value', - )) - - response = await client.create_web_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateWebDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.WebDataStream) - - assert response.name == 'name_value' - - assert response.measurement_id == 'measurement_id_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.default_uri == 'default_uri_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_create_web_data_stream_async_from_dict(): - await test_create_web_data_stream_async(request_type=dict) - - -def test_create_web_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateWebDataStreamRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_web_data_stream), - '__call__') as call: - call.return_value = resources.WebDataStream() - - client.create_web_data_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_web_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateWebDataStreamRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_web_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) - - await client.create_web_data_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_web_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_web_data_stream( - parent='parent_value', - web_data_stream=resources.WebDataStream(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].parent == 'parent_value' - - assert args[0].web_data_stream == resources.WebDataStream(name='name_value') - - -def test_create_web_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_web_data_stream( - analytics_admin.CreateWebDataStreamRequest(), - parent='parent_value', - web_data_stream=resources.WebDataStream(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_web_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_web_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.WebDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.WebDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_web_data_stream( - parent='parent_value', - web_data_stream=resources.WebDataStream(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].parent == 'parent_value' - - assert args[0].web_data_stream == resources.WebDataStream(name='name_value') - - -@pytest.mark.asyncio -async def test_create_web_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_web_data_stream( - analytics_admin.CreateWebDataStreamRequest(), - parent='parent_value', - web_data_stream=resources.WebDataStream(name='name_value'), - ) - - -def test_list_web_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListWebDataStreamsRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListWebDataStreamsResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_web_data_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] == analytics_admin.ListWebDataStreamsRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListWebDataStreamsPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_web_data_streams_from_dict(): - test_list_web_data_streams(request_type=dict) - - -def test_list_web_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__') as call: - client.list_web_data_streams() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListWebDataStreamsRequest() - -@pytest.mark.asyncio -async def test_list_web_data_streams_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListWebDataStreamsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_web_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListWebDataStreamsResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_web_data_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListWebDataStreamsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListWebDataStreamsAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_web_data_streams_async_from_dict(): - await test_list_web_data_streams_async(request_type=dict) - - -def test_list_web_data_streams_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListWebDataStreamsRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__') as call: - call.return_value = analytics_admin.ListWebDataStreamsResponse() - - client.list_web_data_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_web_data_streams_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListWebDataStreamsRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListWebDataStreamsResponse()) - - await client.list_web_data_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_web_data_streams_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListWebDataStreamsResponse() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_web_data_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_web_data_streams_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_web_data_streams( - analytics_admin.ListWebDataStreamsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_web_data_streams_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListWebDataStreamsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListWebDataStreamsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_web_data_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_web_data_streams_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_web_data_streams( - analytics_admin.ListWebDataStreamsRequest(), - parent='parent_value', - ) - - -def test_list_web_data_streams_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - resources.WebDataStream(), - resources.WebDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - resources.WebDataStream(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_web_data_streams(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.WebDataStream) - for i in results) - -def test_list_web_data_streams_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - resources.WebDataStream(), - resources.WebDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - resources.WebDataStream(), - ], - ), - RuntimeError, - ) - pages = list(client.list_web_data_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_web_data_streams_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - resources.WebDataStream(), - resources.WebDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - resources.WebDataStream(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_web_data_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, resources.WebDataStream) - for i in responses) - -@pytest.mark.asyncio -async def test_list_web_data_streams_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_web_data_streams), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - resources.WebDataStream(), - resources.WebDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListWebDataStreamsResponse( - web_data_streams=[ - resources.WebDataStream(), - resources.WebDataStream(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_web_data_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_ios_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.GetIosAppDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream( - name='name_value', - - firebase_app_id='firebase_app_id_value', - - bundle_id='bundle_id_value', - - display_name='display_name_value', - - ) - - response = client.get_ios_app_data_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] == analytics_admin.GetIosAppDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.IosAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.bundle_id == 'bundle_id_value' - - assert response.display_name == 'display_name_value' - - -def test_get_ios_app_data_stream_from_dict(): - test_get_ios_app_data_stream(request_type=dict) - - -def test_get_ios_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ios_app_data_stream), - '__call__') as call: - client.get_ios_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetIosAppDataStreamRequest() - -@pytest.mark.asyncio -async def test_get_ios_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetIosAppDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream( - name='name_value', - firebase_app_id='firebase_app_id_value', - bundle_id='bundle_id_value', - display_name='display_name_value', - )) - - response = await client.get_ios_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetIosAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IosAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.bundle_id == 'bundle_id_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_get_ios_app_data_stream_async_from_dict(): - await test_get_ios_app_data_stream_async(request_type=dict) - - -def test_get_ios_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetIosAppDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ios_app_data_stream), - '__call__') as call: - call.return_value = resources.IosAppDataStream() - - client.get_ios_app_data_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_ios_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetIosAppDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ios_app_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) - - await client.get_ios_app_data_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_ios_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_ios_app_data_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_ios_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_ios_app_data_stream( - analytics_admin.GetIosAppDataStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_ios_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_ios_app_data_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_ios_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_ios_app_data_stream( - analytics_admin.GetIosAppDataStreamRequest(), - name='name_value', - ) - - -def test_delete_ios_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.DeleteIosAppDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_ios_app_data_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] == analytics_admin.DeleteIosAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_ios_app_data_stream_from_dict(): - test_delete_ios_app_data_stream(request_type=dict) - - -def test_delete_ios_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ios_app_data_stream), - '__call__') as call: - client.delete_ios_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteIosAppDataStreamRequest() - -@pytest.mark.asyncio -async def test_delete_ios_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteIosAppDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.delete_ios_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteIosAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_ios_app_data_stream_async_from_dict(): - await test_delete_ios_app_data_stream_async(request_type=dict) - - -def test_delete_ios_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteIosAppDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ios_app_data_stream), - '__call__') as call: - call.return_value = None - - client.delete_ios_app_data_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_ios_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteIosAppDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ios_app_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.delete_ios_app_data_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_ios_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_ios_app_data_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_ios_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_ios_app_data_stream( - analytics_admin.DeleteIosAppDataStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_ios_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_ios_app_data_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_ios_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_ios_app_data_stream( - analytics_admin.DeleteIosAppDataStreamRequest(), - name='name_value', - ) - - -def test_update_ios_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.UpdateIosAppDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream( - name='name_value', - - firebase_app_id='firebase_app_id_value', - - bundle_id='bundle_id_value', - - display_name='display_name_value', - - ) - - response = client.update_ios_app_data_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] == analytics_admin.UpdateIosAppDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.IosAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.bundle_id == 'bundle_id_value' - - assert response.display_name == 'display_name_value' - - -def test_update_ios_app_data_stream_from_dict(): - test_update_ios_app_data_stream(request_type=dict) - - -def test_update_ios_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ios_app_data_stream), - '__call__') as call: - client.update_ios_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateIosAppDataStreamRequest() - -@pytest.mark.asyncio -async def test_update_ios_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateIosAppDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream( - name='name_value', - firebase_app_id='firebase_app_id_value', - bundle_id='bundle_id_value', - display_name='display_name_value', - )) - - response = await client.update_ios_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateIosAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IosAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.bundle_id == 'bundle_id_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_update_ios_app_data_stream_async_from_dict(): - await test_update_ios_app_data_stream_async(request_type=dict) - - -def test_update_ios_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateIosAppDataStreamRequest() - request.ios_app_data_stream.name = 'ios_app_data_stream.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ios_app_data_stream), - '__call__') as call: - call.return_value = resources.IosAppDataStream() - - client.update_ios_app_data_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', - 'ios_app_data_stream.name=ios_app_data_stream.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_ios_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateIosAppDataStreamRequest() - request.ios_app_data_stream.name = 'ios_app_data_stream.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ios_app_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) - - await client.update_ios_app_data_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', - 'ios_app_data_stream.name=ios_app_data_stream.name/value', - ) in kw['metadata'] - - -def test_update_ios_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_ios_app_data_stream( - ios_app_data_stream=resources.IosAppDataStream(name='name_value'), - update_mask=field_mask.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].ios_app_data_stream == resources.IosAppDataStream(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -def test_update_ios_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_ios_app_data_stream( - analytics_admin.UpdateIosAppDataStreamRequest(), - ios_app_data_stream=resources.IosAppDataStream(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_ios_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_ios_app_data_stream( - ios_app_data_stream=resources.IosAppDataStream(name='name_value'), - update_mask=field_mask.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].ios_app_data_stream == resources.IosAppDataStream(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_ios_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_ios_app_data_stream( - analytics_admin.UpdateIosAppDataStreamRequest(), - ios_app_data_stream=resources.IosAppDataStream(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -def test_create_ios_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.CreateIosAppDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream( - name='name_value', - - firebase_app_id='firebase_app_id_value', - - bundle_id='bundle_id_value', - - display_name='display_name_value', - - ) - - response = client.create_ios_app_data_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] == analytics_admin.CreateIosAppDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.IosAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.bundle_id == 'bundle_id_value' - - assert response.display_name == 'display_name_value' - - -def test_create_ios_app_data_stream_from_dict(): - test_create_ios_app_data_stream(request_type=dict) - - -def test_create_ios_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ios_app_data_stream), - '__call__') as call: - client.create_ios_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() - -@pytest.mark.asyncio -async def test_create_ios_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateIosAppDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream( - name='name_value', - firebase_app_id='firebase_app_id_value', - bundle_id='bundle_id_value', - display_name='display_name_value', - )) - - response = await client.create_ios_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IosAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.bundle_id == 'bundle_id_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_create_ios_app_data_stream_async_from_dict(): - await test_create_ios_app_data_stream_async(request_type=dict) - - -def test_create_ios_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateIosAppDataStreamRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ios_app_data_stream), - '__call__') as call: - call.return_value = resources.IosAppDataStream() - - client.create_ios_app_data_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_ios_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateIosAppDataStreamRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ios_app_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) - - await client.create_ios_app_data_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_ios_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_ios_app_data_stream( - parent='parent_value', - ios_app_data_stream=resources.IosAppDataStream(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].parent == 'parent_value' - - assert args[0].ios_app_data_stream == resources.IosAppDataStream(name='name_value') - - -def test_create_ios_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_ios_app_data_stream( - analytics_admin.CreateIosAppDataStreamRequest(), - parent='parent_value', - ios_app_data_stream=resources.IosAppDataStream(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_ios_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ios_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IosAppDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_ios_app_data_stream( - parent='parent_value', - ios_app_data_stream=resources.IosAppDataStream(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].parent == 'parent_value' - - assert args[0].ios_app_data_stream == resources.IosAppDataStream(name='name_value') - - -@pytest.mark.asyncio -async def test_create_ios_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_ios_app_data_stream( - analytics_admin.CreateIosAppDataStreamRequest(), - parent='parent_value', - ios_app_data_stream=resources.IosAppDataStream(name='name_value'), - ) - - -def test_list_ios_app_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListIosAppDataStreamsRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListIosAppDataStreamsResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_ios_app_data_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] == analytics_admin.ListIosAppDataStreamsRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListIosAppDataStreamsPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_ios_app_data_streams_from_dict(): - test_list_ios_app_data_streams(request_type=dict) - - -def test_list_ios_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__') as call: - client.list_ios_app_data_streams() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListIosAppDataStreamsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_ios_app_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListIosAppDataStreamsResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_ios_app_data_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListIosAppDataStreamsAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_async_from_dict(): - await test_list_ios_app_data_streams_async(request_type=dict) - - -def test_list_ios_app_data_streams_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListIosAppDataStreamsRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__') as call: - call.return_value = analytics_admin.ListIosAppDataStreamsResponse() - - client.list_ios_app_data_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_ios_app_data_streams_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListIosAppDataStreamsRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListIosAppDataStreamsResponse()) - - await client.list_ios_app_data_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_ios_app_data_streams_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListIosAppDataStreamsResponse() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_ios_app_data_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_ios_app_data_streams_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_ios_app_data_streams( - analytics_admin.ListIosAppDataStreamsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListIosAppDataStreamsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListIosAppDataStreamsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_ios_app_data_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_ios_app_data_streams_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_ios_app_data_streams( - analytics_admin.ListIosAppDataStreamsRequest(), - parent='parent_value', - ) - - -def test_list_ios_app_data_streams_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_ios_app_data_streams(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.IosAppDataStream) - for i in results) - -def test_list_ios_app_data_streams_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - ), - RuntimeError, - ) - pages = list(client.list_ios_app_data_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_ios_app_data_streams_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_ios_app_data_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, resources.IosAppDataStream) - for i in responses) - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_ios_app_data_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_android_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.GetAndroidAppDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream( - name='name_value', - - firebase_app_id='firebase_app_id_value', - - package_name='package_name_value', - - display_name='display_name_value', - - ) - - response = client.get_android_app_data_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] == analytics_admin.GetAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.AndroidAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.package_name == 'package_name_value' - - assert response.display_name == 'display_name_value' - - -def test_get_android_app_data_stream_from_dict(): - test_get_android_app_data_stream(request_type=dict) - - -def test_get_android_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_android_app_data_stream), - '__call__') as call: - client.get_android_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetAndroidAppDataStreamRequest() - -@pytest.mark.asyncio -async def test_get_android_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetAndroidAppDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream( - name='name_value', - firebase_app_id='firebase_app_id_value', - package_name='package_name_value', - display_name='display_name_value', - )) - - response = await client.get_android_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.AndroidAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.package_name == 'package_name_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_get_android_app_data_stream_async_from_dict(): - await test_get_android_app_data_stream_async(request_type=dict) - - -def test_get_android_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetAndroidAppDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_android_app_data_stream), - '__call__') as call: - call.return_value = resources.AndroidAppDataStream() - - client.get_android_app_data_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_android_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetAndroidAppDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_android_app_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) - - await client.get_android_app_data_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_android_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_android_app_data_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_android_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_android_app_data_stream( - analytics_admin.GetAndroidAppDataStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_android_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_android_app_data_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_android_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_android_app_data_stream( - analytics_admin.GetAndroidAppDataStreamRequest(), - name='name_value', - ) - - -def test_delete_android_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.DeleteAndroidAppDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_android_app_data_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] == analytics_admin.DeleteAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_android_app_data_stream_from_dict(): - test_delete_android_app_data_stream(request_type=dict) - - -def test_delete_android_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_android_app_data_stream), - '__call__') as call: - client.delete_android_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteAndroidAppDataStreamRequest() - -@pytest.mark.asyncio -async def test_delete_android_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteAndroidAppDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.delete_android_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_android_app_data_stream_async_from_dict(): - await test_delete_android_app_data_stream_async(request_type=dict) - - -def test_delete_android_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteAndroidAppDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_android_app_data_stream), - '__call__') as call: - call.return_value = None - - client.delete_android_app_data_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_android_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteAndroidAppDataStreamRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_android_app_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.delete_android_app_data_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_android_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_android_app_data_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_android_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_android_app_data_stream( - analytics_admin.DeleteAndroidAppDataStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_android_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_android_app_data_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_android_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_android_app_data_stream( - analytics_admin.DeleteAndroidAppDataStreamRequest(), - name='name_value', - ) - - -def test_update_android_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.UpdateAndroidAppDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream( - name='name_value', - - firebase_app_id='firebase_app_id_value', - - package_name='package_name_value', - - display_name='display_name_value', - - ) - - response = client.update_android_app_data_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] == analytics_admin.UpdateAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.AndroidAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.package_name == 'package_name_value' - - assert response.display_name == 'display_name_value' - - -def test_update_android_app_data_stream_from_dict(): - test_update_android_app_data_stream(request_type=dict) - - -def test_update_android_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_android_app_data_stream), - '__call__') as call: - client.update_android_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateAndroidAppDataStreamRequest() - -@pytest.mark.asyncio -async def test_update_android_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateAndroidAppDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream( - name='name_value', - firebase_app_id='firebase_app_id_value', - package_name='package_name_value', - display_name='display_name_value', - )) - - response = await client.update_android_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.AndroidAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.package_name == 'package_name_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_update_android_app_data_stream_async_from_dict(): - await test_update_android_app_data_stream_async(request_type=dict) - - -def test_update_android_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateAndroidAppDataStreamRequest() - request.android_app_data_stream.name = 'android_app_data_stream.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_android_app_data_stream), - '__call__') as call: - call.return_value = resources.AndroidAppDataStream() - - client.update_android_app_data_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', - 'android_app_data_stream.name=android_app_data_stream.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_android_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateAndroidAppDataStreamRequest() - request.android_app_data_stream.name = 'android_app_data_stream.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_android_app_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) - - await client.update_android_app_data_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', - 'android_app_data_stream.name=android_app_data_stream.name/value', - ) in kw['metadata'] - - -def test_update_android_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_android_app_data_stream( - android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), - update_mask=field_mask.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].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -def test_update_android_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_android_app_data_stream( - analytics_admin.UpdateAndroidAppDataStreamRequest(), - android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_android_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_android_app_data_stream( - android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), - update_mask=field_mask.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].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_android_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_android_app_data_stream( - analytics_admin.UpdateAndroidAppDataStreamRequest(), - android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -def test_create_android_app_data_stream(transport: str = 'grpc', request_type=analytics_admin.CreateAndroidAppDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream( - name='name_value', - - firebase_app_id='firebase_app_id_value', - - package_name='package_name_value', - - display_name='display_name_value', - - ) - - response = client.create_android_app_data_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] == analytics_admin.CreateAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.AndroidAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.package_name == 'package_name_value' - - assert response.display_name == 'display_name_value' - - -def test_create_android_app_data_stream_from_dict(): - test_create_android_app_data_stream(request_type=dict) - - -def test_create_android_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), - '__call__') as call: - client.create_android_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateAndroidAppDataStreamRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream( - name='name_value', - firebase_app_id='firebase_app_id_value', - package_name='package_name_value', - display_name='display_name_value', - )) - - response = await client.create_android_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.AndroidAppDataStream) - - assert response.name == 'name_value' - - assert response.firebase_app_id == 'firebase_app_id_value' - - assert response.package_name == 'package_name_value' - - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_async_from_dict(): - await test_create_android_app_data_stream_async(request_type=dict) - - -def test_create_android_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateAndroidAppDataStreamRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), - '__call__') as call: - call.return_value = resources.AndroidAppDataStream() - - client.create_android_app_data_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_android_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateAndroidAppDataStreamRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) - - await client.create_android_app_data_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_android_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_android_app_data_stream( - parent='parent_value', - android_app_data_stream=resources.AndroidAppDataStream(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].parent == 'parent_value' - - assert args[0].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') - - -def test_create_android_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_android_app_data_stream( - analytics_admin.CreateAndroidAppDataStreamRequest(), - parent='parent_value', - android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.AndroidAppDataStream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_android_app_data_stream( - parent='parent_value', - android_app_data_stream=resources.AndroidAppDataStream(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].parent == 'parent_value' - - assert args[0].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') - - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_android_app_data_stream( - analytics_admin.CreateAndroidAppDataStreamRequest(), - parent='parent_value', - android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), - ) - - -def test_list_android_app_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListAndroidAppDataStreamsRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_android_app_data_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] == analytics_admin.ListAndroidAppDataStreamsRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListAndroidAppDataStreamsPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_android_app_data_streams_from_dict(): - test_list_android_app_data_streams(request_type=dict) - - -def test_list_android_app_data_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 = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__') as call: - client.list_android_app_data_streams() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListAndroidAppDataStreamsRequest() - -@pytest.mark.asyncio -async def test_list_android_app_data_streams_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListAndroidAppDataStreamsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_android_app_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAndroidAppDataStreamsResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_android_app_data_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListAndroidAppDataStreamsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAndroidAppDataStreamsAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_android_app_data_streams_async_from_dict(): - await test_list_android_app_data_streams_async(request_type=dict) - - -def test_list_android_app_data_streams_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListAndroidAppDataStreamsRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__') as call: - call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() - - client.list_android_app_data_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_android_app_data_streams_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListAndroidAppDataStreamsRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAndroidAppDataStreamsResponse()) - - await client.list_android_app_data_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_android_app_data_streams_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_android_app_data_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_android_app_data_streams_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_android_app_data_streams( - analytics_admin.ListAndroidAppDataStreamsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_android_app_data_streams_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListAndroidAppDataStreamsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_android_app_data_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_android_app_data_streams_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_android_app_data_streams( - analytics_admin.ListAndroidAppDataStreamsRequest(), - parent='parent_value', - ) - - -def test_list_android_app_data_streams_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_android_app_data_streams(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.AndroidAppDataStream) - for i in results) - -def test_list_android_app_data_streams_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - ], - ), - RuntimeError, - ) - pages = list(client.list_android_app_data_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_android_app_data_streams_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_android_app_data_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, resources.AndroidAppDataStream) - for i in responses) - -@pytest.mark.asyncio -async def test_list_android_app_data_streams_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_android_app_data_streams), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - ], - next_page_token='abc', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[], - next_page_token='def', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - ], - next_page_token='ghi', - ), - analytics_admin.ListAndroidAppDataStreamsResponse( - android_app_data_streams=[ - resources.AndroidAppDataStream(), - resources.AndroidAppDataStream(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_android_app_data_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_enhanced_measurement_settings(transport: str = 'grpc', request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_enhanced_measurement_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.EnhancedMeasurementSettings( - name='name_value', - - stream_enabled=True, - - page_views_enabled=True, - - scrolls_enabled=True, - - outbound_clicks_enabled=True, - - site_search_enabled=True, - - video_engagement_enabled=True, - - file_downloads_enabled=True, - - page_loads_enabled=True, - - page_changes_enabled=True, - - search_query_parameter='search_query_parameter_value', - - uri_query_parameter='uri_query_parameter_value', - - ) - - response = client.get_enhanced_measurement_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.EnhancedMeasurementSettings) - - assert response.name == 'name_value' - - assert response.stream_enabled is True - - assert response.page_views_enabled is True - - assert response.scrolls_enabled is True - - assert response.outbound_clicks_enabled is True - - assert response.site_search_enabled is True - - assert response.video_engagement_enabled is True - - assert response.file_downloads_enabled is True - - assert response.page_loads_enabled is True - - assert response.page_changes_enabled is True - - assert response.search_query_parameter == 'search_query_parameter_value' - - assert response.uri_query_parameter == 'uri_query_parameter_value' - - -def test_get_enhanced_measurement_settings_from_dict(): - test_get_enhanced_measurement_settings(request_type=dict) - - -def test_get_enhanced_measurement_settings_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_enhanced_measurement_settings), - '__call__') as call: - client.get_enhanced_measurement_settings() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() - -@pytest.mark.asyncio -async def test_get_enhanced_measurement_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_enhanced_measurement_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings( - name='name_value', - stream_enabled=True, - page_views_enabled=True, - scrolls_enabled=True, - outbound_clicks_enabled=True, - site_search_enabled=True, - video_engagement_enabled=True, - file_downloads_enabled=True, - page_loads_enabled=True, - page_changes_enabled=True, - search_query_parameter='search_query_parameter_value', - uri_query_parameter='uri_query_parameter_value', - )) - - response = await client.get_enhanced_measurement_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.EnhancedMeasurementSettings) - - assert response.name == 'name_value' - - assert response.stream_enabled is True - - assert response.page_views_enabled is True - - assert response.scrolls_enabled is True - - assert response.outbound_clicks_enabled is True - - assert response.site_search_enabled is True - - assert response.video_engagement_enabled is True - - assert response.file_downloads_enabled is True - - assert response.page_loads_enabled is True - - assert response.page_changes_enabled is True - - assert response.search_query_parameter == 'search_query_parameter_value' - - assert response.uri_query_parameter == 'uri_query_parameter_value' - - -@pytest.mark.asyncio -async def test_get_enhanced_measurement_settings_async_from_dict(): - await test_get_enhanced_measurement_settings_async(request_type=dict) - - -def test_get_enhanced_measurement_settings_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetEnhancedMeasurementSettingsRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_enhanced_measurement_settings), - '__call__') as call: - call.return_value = resources.EnhancedMeasurementSettings() - - client.get_enhanced_measurement_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_enhanced_measurement_settings_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetEnhancedMeasurementSettingsRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_enhanced_measurement_settings), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings()) - - await client.get_enhanced_measurement_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_get_enhanced_measurement_settings_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_enhanced_measurement_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.EnhancedMeasurementSettings() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_enhanced_measurement_settings( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0].name == 'name_value' - - -def test_get_enhanced_measurement_settings_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_enhanced_measurement_settings( - analytics_admin.GetEnhancedMeasurementSettingsRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_enhanced_measurement_settings_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_enhanced_measurement_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.EnhancedMeasurementSettings() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_enhanced_measurement_settings( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_enhanced_measurement_settings_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_enhanced_measurement_settings( - analytics_admin.GetEnhancedMeasurementSettingsRequest(), - name='name_value', - ) - - -def test_update_enhanced_measurement_settings(transport: str = 'grpc', request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_enhanced_measurement_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.EnhancedMeasurementSettings( - name='name_value', - - stream_enabled=True, - - page_views_enabled=True, - - scrolls_enabled=True, - - outbound_clicks_enabled=True, - - site_search_enabled=True, - - video_engagement_enabled=True, - - file_downloads_enabled=True, - - page_loads_enabled=True, - - page_changes_enabled=True, - - search_query_parameter='search_query_parameter_value', - - uri_query_parameter='uri_query_parameter_value', - - ) - - response = client.update_enhanced_measurement_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.EnhancedMeasurementSettings) - - assert response.name == 'name_value' - - assert response.stream_enabled is True - - assert response.page_views_enabled is True - - assert response.scrolls_enabled is True - - assert response.outbound_clicks_enabled is True - - assert response.site_search_enabled is True - - assert response.video_engagement_enabled is True - - assert response.file_downloads_enabled is True - - assert response.page_loads_enabled is True - - assert response.page_changes_enabled is True - - assert response.search_query_parameter == 'search_query_parameter_value' - - assert response.uri_query_parameter == 'uri_query_parameter_value' - - -def test_update_enhanced_measurement_settings_from_dict(): - test_update_enhanced_measurement_settings(request_type=dict) - - -def test_update_enhanced_measurement_settings_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_enhanced_measurement_settings), - '__call__') as call: - client.update_enhanced_measurement_settings() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() - -@pytest.mark.asyncio -async def test_update_enhanced_measurement_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_enhanced_measurement_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings( - name='name_value', - stream_enabled=True, - page_views_enabled=True, - scrolls_enabled=True, - outbound_clicks_enabled=True, - site_search_enabled=True, - video_engagement_enabled=True, - file_downloads_enabled=True, - page_loads_enabled=True, - page_changes_enabled=True, - search_query_parameter='search_query_parameter_value', - uri_query_parameter='uri_query_parameter_value', - )) - - response = await client.update_enhanced_measurement_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.EnhancedMeasurementSettings) - - assert response.name == 'name_value' - - assert response.stream_enabled is True - - assert response.page_views_enabled is True - - assert response.scrolls_enabled is True - - assert response.outbound_clicks_enabled is True - - assert response.site_search_enabled is True - - assert response.video_engagement_enabled is True - - assert response.file_downloads_enabled is True - - assert response.page_loads_enabled is True - - assert response.page_changes_enabled is True - - assert response.search_query_parameter == 'search_query_parameter_value' - - assert response.uri_query_parameter == 'uri_query_parameter_value' - - -@pytest.mark.asyncio -async def test_update_enhanced_measurement_settings_async_from_dict(): - await test_update_enhanced_measurement_settings_async(request_type=dict) - - -def test_update_enhanced_measurement_settings_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() - request.enhanced_measurement_settings.name = 'enhanced_measurement_settings.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_enhanced_measurement_settings), - '__call__') as call: - call.return_value = resources.EnhancedMeasurementSettings() - - client.update_enhanced_measurement_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'enhanced_measurement_settings.name=enhanced_measurement_settings.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_enhanced_measurement_settings_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() - request.enhanced_measurement_settings.name = 'enhanced_measurement_settings.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_enhanced_measurement_settings), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings()) - - await client.update_enhanced_measurement_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'enhanced_measurement_settings.name=enhanced_measurement_settings.name/value', - ) in kw['metadata'] - - -def test_update_enhanced_measurement_settings_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_enhanced_measurement_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.EnhancedMeasurementSettings() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_enhanced_measurement_settings( - enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), - update_mask=field_mask.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].enhanced_measurement_settings == resources.EnhancedMeasurementSettings(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -def test_update_enhanced_measurement_settings_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_enhanced_measurement_settings( - analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), - enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_enhanced_measurement_settings_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_enhanced_measurement_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.EnhancedMeasurementSettings() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.EnhancedMeasurementSettings()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_enhanced_measurement_settings( - enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), - update_mask=field_mask.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].enhanced_measurement_settings == resources.EnhancedMeasurementSettings(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_enhanced_measurement_settings_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_enhanced_measurement_settings( - analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), - enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -def test_create_firebase_link(transport: str = 'grpc', request_type=analytics_admin.CreateFirebaseLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.FirebaseLink( - name='name_value', - - project='project_value', - - maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, - - ) - - response = client.create_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateFirebaseLinkRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.FirebaseLink) - - assert response.name == 'name_value' - - assert response.project == 'project_value' - - assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS - - -def test_create_firebase_link_from_dict(): - test_create_firebase_link(request_type=dict) - - -def test_create_firebase_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_firebase_link), - '__call__') as call: - client.create_firebase_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateFirebaseLinkRequest() - -@pytest.mark.asyncio -async def test_create_firebase_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateFirebaseLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink( - name='name_value', - project='project_value', - maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, - )) - - response = await client.create_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateFirebaseLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.FirebaseLink) - - assert response.name == 'name_value' - - assert response.project == 'project_value' - - assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS - - -@pytest.mark.asyncio -async def test_create_firebase_link_async_from_dict(): - await test_create_firebase_link_async(request_type=dict) - - -def test_create_firebase_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateFirebaseLinkRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_firebase_link), - '__call__') as call: - call.return_value = resources.FirebaseLink() - - client.create_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_firebase_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateFirebaseLinkRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_firebase_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink()) - - await client.create_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_create_firebase_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.FirebaseLink() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_firebase_link( - parent='parent_value', - firebase_link=resources.FirebaseLink(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].parent == 'parent_value' - - assert args[0].firebase_link == resources.FirebaseLink(name='name_value') - - -def test_create_firebase_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_firebase_link( - analytics_admin.CreateFirebaseLinkRequest(), - parent='parent_value', - firebase_link=resources.FirebaseLink(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_firebase_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.FirebaseLink() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_firebase_link( - parent='parent_value', - firebase_link=resources.FirebaseLink(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].parent == 'parent_value' - - assert args[0].firebase_link == resources.FirebaseLink(name='name_value') - - -@pytest.mark.asyncio -async def test_create_firebase_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_firebase_link( - analytics_admin.CreateFirebaseLinkRequest(), - parent='parent_value', - firebase_link=resources.FirebaseLink(name='name_value'), - ) - - -def test_update_firebase_link(transport: str = 'grpc', request_type=analytics_admin.UpdateFirebaseLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.FirebaseLink( - name='name_value', - - project='project_value', - - maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, - - ) - - response = client.update_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.FirebaseLink) - - assert response.name == 'name_value' - - assert response.project == 'project_value' - - assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS - - -def test_update_firebase_link_from_dict(): - test_update_firebase_link(request_type=dict) - - -def test_update_firebase_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_firebase_link), - '__call__') as call: - client.update_firebase_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() - -@pytest.mark.asyncio -async def test_update_firebase_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateFirebaseLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink( - name='name_value', - project='project_value', - maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, - )) - - response = await client.update_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.FirebaseLink) - - assert response.name == 'name_value' - - assert response.project == 'project_value' - - assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS - - -@pytest.mark.asyncio -async def test_update_firebase_link_async_from_dict(): - await test_update_firebase_link_async(request_type=dict) - - -def test_update_firebase_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateFirebaseLinkRequest() - request.firebase_link.name = 'firebase_link.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_firebase_link), - '__call__') as call: - call.return_value = resources.FirebaseLink() - - client.update_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'firebase_link.name=firebase_link.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_firebase_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateFirebaseLinkRequest() - request.firebase_link.name = 'firebase_link.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_firebase_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink()) - - await client.update_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'firebase_link.name=firebase_link.name/value', - ) in kw['metadata'] - - -def test_update_firebase_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.FirebaseLink() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_firebase_link( - firebase_link=resources.FirebaseLink(name='name_value'), - update_mask=field_mask.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].firebase_link == resources.FirebaseLink(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -def test_update_firebase_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_firebase_link( - analytics_admin.UpdateFirebaseLinkRequest(), - firebase_link=resources.FirebaseLink(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_firebase_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.FirebaseLink() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.FirebaseLink()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_firebase_link( - firebase_link=resources.FirebaseLink(name='name_value'), - update_mask=field_mask.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].firebase_link == resources.FirebaseLink(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_firebase_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_firebase_link( - analytics_admin.UpdateFirebaseLinkRequest(), - firebase_link=resources.FirebaseLink(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -def test_delete_firebase_link(transport: str = 'grpc', request_type=analytics_admin.DeleteFirebaseLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_firebase_link_from_dict(): - test_delete_firebase_link(request_type=dict) - - -def test_delete_firebase_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_firebase_link), - '__call__') as call: - client.delete_firebase_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() - -@pytest.mark.asyncio -async def test_delete_firebase_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteFirebaseLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.delete_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_firebase_link_async_from_dict(): - await test_delete_firebase_link_async(request_type=dict) - - -def test_delete_firebase_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteFirebaseLinkRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_firebase_link), - '__call__') as call: - call.return_value = None - - client.delete_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_firebase_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteFirebaseLinkRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_firebase_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.delete_firebase_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_delete_firebase_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_firebase_link( - 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_firebase_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_firebase_link( - analytics_admin.DeleteFirebaseLinkRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_firebase_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_firebase_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_firebase_link( - 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_firebase_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_firebase_link( - analytics_admin.DeleteFirebaseLinkRequest(), - name='name_value', - ) - - -def test_list_firebase_links(transport: str = 'grpc', request_type=analytics_admin.ListFirebaseLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_firebase_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListFirebaseLinksResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_firebase_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListFirebaseLinksRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListFirebaseLinksPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_firebase_links_from_dict(): - test_list_firebase_links(request_type=dict) - - -def test_list_firebase_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__') as call: - client.list_firebase_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListFirebaseLinksRequest() - -@pytest.mark.asyncio -async def test_list_firebase_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListFirebaseLinksRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_firebase_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListFirebaseLinksResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_firebase_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListFirebaseLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFirebaseLinksAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_firebase_links_async_from_dict(): - await test_list_firebase_links_async(request_type=dict) - - -def test_list_firebase_links_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListFirebaseLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__') as call: - call.return_value = analytics_admin.ListFirebaseLinksResponse() - - client.list_firebase_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_firebase_links_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListFirebaseLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListFirebaseLinksResponse()) - - await client.list_firebase_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_list_firebase_links_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListFirebaseLinksResponse() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_firebase_links( - 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_firebase_links_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_firebase_links( - analytics_admin.ListFirebaseLinksRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_firebase_links_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListFirebaseLinksResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListFirebaseLinksResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_firebase_links( - 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_firebase_links_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_firebase_links( - analytics_admin.ListFirebaseLinksRequest(), - parent='parent_value', - ) - - -def test_list_firebase_links_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[], - next_page_token='def', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_firebase_links(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.FirebaseLink) - for i in results) - -def test_list_firebase_links_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[], - next_page_token='def', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - ), - RuntimeError, - ) - pages = list(client.list_firebase_links(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_firebase_links_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[], - next_page_token='def', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_firebase_links(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.FirebaseLink) - for i in responses) - -@pytest.mark.asyncio -async def test_list_firebase_links_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_firebase_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[], - next_page_token='def', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_firebase_links(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_global_site_tag(transport: str = 'grpc', request_type=analytics_admin.GetGlobalSiteTagRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_global_site_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GlobalSiteTag( - name='name_value', - - snippet='snippet_value', - - ) - - response = client.get_global_site_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetGlobalSiteTagRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.GlobalSiteTag) - - assert response.name == 'name_value' - - assert response.snippet == 'snippet_value' - - -def test_get_global_site_tag_from_dict(): - test_get_global_site_tag(request_type=dict) - - -def test_get_global_site_tag_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_global_site_tag), - '__call__') as call: - client.get_global_site_tag() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetGlobalSiteTagRequest() - -@pytest.mark.asyncio -async def test_get_global_site_tag_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetGlobalSiteTagRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_global_site_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GlobalSiteTag( - name='name_value', - snippet='snippet_value', - )) - - response = await client.get_global_site_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetGlobalSiteTagRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.GlobalSiteTag) - - assert response.name == 'name_value' - - assert response.snippet == 'snippet_value' - - -@pytest.mark.asyncio -async def test_get_global_site_tag_async_from_dict(): - await test_get_global_site_tag_async(request_type=dict) - - -def test_get_global_site_tag_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetGlobalSiteTagRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_global_site_tag), - '__call__') as call: - call.return_value = resources.GlobalSiteTag() - - client.get_global_site_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_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_global_site_tag_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetGlobalSiteTagRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_global_site_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GlobalSiteTag()) - - await client.get_global_site_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_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_global_site_tag_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_global_site_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GlobalSiteTag() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_global_site_tag( - 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_global_site_tag_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_global_site_tag( - analytics_admin.GetGlobalSiteTagRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_global_site_tag_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_global_site_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GlobalSiteTag() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GlobalSiteTag()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_global_site_tag( - 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_global_site_tag_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_global_site_tag( - analytics_admin.GetGlobalSiteTagRequest(), - name='name_value', - ) - - -def test_create_google_ads_link(transport: str = 'grpc', request_type=analytics_admin.CreateGoogleAdsLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleAdsLink( - name='name_value', - - customer_id='customer_id_value', - - can_manage_clients=True, - - email_address='email_address_value', - - ) - - response = client.create_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.GoogleAdsLink) - - assert response.name == 'name_value' - - assert response.customer_id == 'customer_id_value' - - assert response.can_manage_clients is True - - assert response.email_address == 'email_address_value' - - -def test_create_google_ads_link_from_dict(): - test_create_google_ads_link(request_type=dict) - - -def test_create_google_ads_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_google_ads_link), - '__call__') as call: - client.create_google_ads_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() - -@pytest.mark.asyncio -async def test_create_google_ads_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateGoogleAdsLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink( - name='name_value', - customer_id='customer_id_value', - can_manage_clients=True, - email_address='email_address_value', - )) - - response = await client.create_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleAdsLink) - - assert response.name == 'name_value' - - assert response.customer_id == 'customer_id_value' - - assert response.can_manage_clients is True - - assert response.email_address == 'email_address_value' - - -@pytest.mark.asyncio -async def test_create_google_ads_link_async_from_dict(): - await test_create_google_ads_link_async(request_type=dict) - - -def test_create_google_ads_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateGoogleAdsLinkRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_google_ads_link), - '__call__') as call: - call.return_value = resources.GoogleAdsLink() - - client.create_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_google_ads_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateGoogleAdsLinkRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_google_ads_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink()) - - await client.create_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_create_google_ads_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleAdsLink() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_google_ads_link( - parent='parent_value', - google_ads_link=resources.GoogleAdsLink(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].parent == 'parent_value' - - assert args[0].google_ads_link == resources.GoogleAdsLink(name='name_value') - - -def test_create_google_ads_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_google_ads_link( - analytics_admin.CreateGoogleAdsLinkRequest(), - parent='parent_value', - google_ads_link=resources.GoogleAdsLink(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_google_ads_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleAdsLink() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_google_ads_link( - parent='parent_value', - google_ads_link=resources.GoogleAdsLink(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].parent == 'parent_value' - - assert args[0].google_ads_link == resources.GoogleAdsLink(name='name_value') - - -@pytest.mark.asyncio -async def test_create_google_ads_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_google_ads_link( - analytics_admin.CreateGoogleAdsLinkRequest(), - parent='parent_value', - google_ads_link=resources.GoogleAdsLink(name='name_value'), - ) - - -def test_update_google_ads_link(transport: str = 'grpc', request_type=analytics_admin.UpdateGoogleAdsLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleAdsLink( - name='name_value', - - customer_id='customer_id_value', - - can_manage_clients=True, - - email_address='email_address_value', - - ) - - response = client.update_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.GoogleAdsLink) - - assert response.name == 'name_value' - - assert response.customer_id == 'customer_id_value' - - assert response.can_manage_clients is True - - assert response.email_address == 'email_address_value' - - -def test_update_google_ads_link_from_dict(): - test_update_google_ads_link(request_type=dict) - - -def test_update_google_ads_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_ads_link), - '__call__') as call: - client.update_google_ads_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() - -@pytest.mark.asyncio -async def test_update_google_ads_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateGoogleAdsLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink( - name='name_value', - customer_id='customer_id_value', - can_manage_clients=True, - email_address='email_address_value', - )) - - response = await client.update_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleAdsLink) - - assert response.name == 'name_value' - - assert response.customer_id == 'customer_id_value' - - assert response.can_manage_clients is True - - assert response.email_address == 'email_address_value' - - -@pytest.mark.asyncio -async def test_update_google_ads_link_async_from_dict(): - await test_update_google_ads_link_async(request_type=dict) - - -def test_update_google_ads_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateGoogleAdsLinkRequest() - request.google_ads_link.name = 'google_ads_link.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_ads_link), - '__call__') as call: - call.return_value = resources.GoogleAdsLink() - - client.update_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'google_ads_link.name=google_ads_link.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_google_ads_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.UpdateGoogleAdsLinkRequest() - request.google_ads_link.name = 'google_ads_link.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_ads_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink()) - - await client.update_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'google_ads_link.name=google_ads_link.name/value', - ) in kw['metadata'] - - -def test_update_google_ads_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleAdsLink() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_google_ads_link( - google_ads_link=resources.GoogleAdsLink(name='name_value'), - update_mask=field_mask.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].google_ads_link == resources.GoogleAdsLink(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -def test_update_google_ads_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_google_ads_link( - analytics_admin.UpdateGoogleAdsLinkRequest(), - google_ads_link=resources.GoogleAdsLink(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_google_ads_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleAdsLink() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleAdsLink()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_google_ads_link( - google_ads_link=resources.GoogleAdsLink(name='name_value'), - update_mask=field_mask.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].google_ads_link == resources.GoogleAdsLink(name='name_value') - - assert args[0].update_mask == field_mask.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_google_ads_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_google_ads_link( - analytics_admin.UpdateGoogleAdsLinkRequest(), - google_ads_link=resources.GoogleAdsLink(name='name_value'), - update_mask=field_mask.FieldMask(paths=['paths_value']), - ) - - -def test_delete_google_ads_link(transport: str = 'grpc', request_type=analytics_admin.DeleteGoogleAdsLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_google_ads_link_from_dict(): - test_delete_google_ads_link(request_type=dict) - - -def test_delete_google_ads_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_google_ads_link), - '__call__') as call: - client.delete_google_ads_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() - -@pytest.mark.asyncio -async def test_delete_google_ads_link_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteGoogleAdsLinkRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - response = await client.delete_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_google_ads_link_async_from_dict(): - await test_delete_google_ads_link_async(request_type=dict) - - -def test_delete_google_ads_link_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteGoogleAdsLinkRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_google_ads_link), - '__call__') as call: - call.return_value = None - - client.delete_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_google_ads_link_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.DeleteGoogleAdsLinkRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_google_ads_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - - await client.delete_google_ads_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_delete_google_ads_link_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_google_ads_link( - 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_google_ads_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_google_ads_link( - analytics_admin.DeleteGoogleAdsLinkRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_google_ads_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_google_ads_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_google_ads_link( - 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_google_ads_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_google_ads_link( - analytics_admin.DeleteGoogleAdsLinkRequest(), - name='name_value', - ) - - -def test_list_google_ads_links(transport: str = 'grpc', request_type=analytics_admin.ListGoogleAdsLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_ads_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListGoogleAdsLinksResponse( - next_page_token='next_page_token_value', - - ) - - response = client.list_google_ads_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListGoogleAdsLinksPager) - - assert response.next_page_token == 'next_page_token_value' - - -def test_list_google_ads_links_from_dict(): - test_list_google_ads_links(request_type=dict) - - -def test_list_google_ads_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__') as call: - client.list_google_ads_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() - -@pytest.mark.asyncio -async def test_list_google_ads_links_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListGoogleAdsLinksRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_ads_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListGoogleAdsLinksResponse( - next_page_token='next_page_token_value', - )) - - response = await client.list_google_ads_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListGoogleAdsLinksAsyncPager) - - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_google_ads_links_async_from_dict(): - await test_list_google_ads_links_async(request_type=dict) - - -def test_list_google_ads_links_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListGoogleAdsLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__') as call: - call.return_value = analytics_admin.ListGoogleAdsLinksResponse() - - client.list_google_ads_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_google_ads_links_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListGoogleAdsLinksRequest() - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListGoogleAdsLinksResponse()) - - await client.list_google_ads_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent/value', - ) in kw['metadata'] - - -def test_list_google_ads_links_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListGoogleAdsLinksResponse() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_google_ads_links( - 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_google_ads_links_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_google_ads_links( - analytics_admin.ListGoogleAdsLinksRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_google_ads_links_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListGoogleAdsLinksResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListGoogleAdsLinksResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_google_ads_links( - 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_google_ads_links_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_google_ads_links( - analytics_admin.ListGoogleAdsLinksRequest(), - parent='parent_value', - ) - - -def test_list_google_ads_links_pager(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[], - next_page_token='def', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_google_ads_links(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.GoogleAdsLink) - for i in results) - -def test_list_google_ads_links_pages(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[], - next_page_token='def', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - ], - ), - RuntimeError, - ) - pages = list(client.list_google_ads_links(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_google_ads_links_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[], - next_page_token='def', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_google_ads_links(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.GoogleAdsLink) - for i in responses) - -@pytest.mark.asyncio -async def test_list_google_ads_links_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_google_ads_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - ], - next_page_token='abc', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[], - next_page_token='def', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - ], - next_page_token='ghi', - ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_google_ads_links(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_data_sharing_settings(transport: str = 'grpc', request_type=analytics_admin.GetDataSharingSettingsRequest): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_data_sharing_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.DataSharingSettings( - name='name_value', - - sharing_with_google_support_enabled=True, - - sharing_with_google_assigned_sales_enabled=True, - - sharing_with_google_any_sales_enabled=True, - - sharing_with_google_products_enabled=True, - - sharing_with_others_enabled=True, - - ) - - response = client.get_data_sharing_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetDataSharingSettingsRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.DataSharingSettings) - - assert response.name == 'name_value' - - assert response.sharing_with_google_support_enabled is True - - assert response.sharing_with_google_assigned_sales_enabled is True - - assert response.sharing_with_google_any_sales_enabled is True - - assert response.sharing_with_google_products_enabled is True - - assert response.sharing_with_others_enabled is True - - -def test_get_data_sharing_settings_from_dict(): - test_get_data_sharing_settings(request_type=dict) - - -def test_get_data_sharing_settings_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_data_sharing_settings), - '__call__') as call: - client.get_data_sharing_settings() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetDataSharingSettingsRequest() - -@pytest.mark.asyncio -async def test_get_data_sharing_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetDataSharingSettingsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_data_sharing_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.DataSharingSettings( - name='name_value', - sharing_with_google_support_enabled=True, - sharing_with_google_assigned_sales_enabled=True, - sharing_with_google_any_sales_enabled=True, - sharing_with_google_products_enabled=True, - sharing_with_others_enabled=True, - )) - - response = await client.get_data_sharing_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.GetDataSharingSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataSharingSettings) - - assert response.name == 'name_value' - - assert response.sharing_with_google_support_enabled is True - - assert response.sharing_with_google_assigned_sales_enabled is True - - assert response.sharing_with_google_any_sales_enabled is True - - assert response.sharing_with_google_products_enabled is True - - assert response.sharing_with_others_enabled is True - - -@pytest.mark.asyncio -async def test_get_data_sharing_settings_async_from_dict(): - await test_get_data_sharing_settings_async(request_type=dict) - - -def test_get_data_sharing_settings_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetDataSharingSettingsRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_data_sharing_settings), - '__call__') as call: - call.return_value = resources.DataSharingSettings() - - client.get_data_sharing_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_data_sharing_settings_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetDataSharingSettingsRequest() - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_data_sharing_settings), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.DataSharingSettings()) - - await client.get_data_sharing_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_get_data_sharing_settings_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_data_sharing_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.DataSharingSettings() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_data_sharing_settings( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0].name == 'name_value' - - -def test_get_data_sharing_settings_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_data_sharing_settings( - analytics_admin.GetDataSharingSettingsRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_data_sharing_settings_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_data_sharing_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.DataSharingSettings() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.DataSharingSettings()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_data_sharing_settings( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_data_sharing_settings_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=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_data_sharing_settings( - analytics_admin.GetDataSharingSettingsRequest(), - name='name_value', - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = AnalyticsAdminServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = AnalyticsAdminServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), - ) - client = AnalyticsAdminServiceClient(transport=transport) - assert client.transport is transport - - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - -@pytest.mark.parametrize("transport_class", [ - transports.AnalyticsAdminServiceGrpcTransport, - transports.AnalyticsAdminServiceGrpcAsyncIOTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(auth, 'default') as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.AnalyticsAdminServiceGrpcTransport, - ) - - -def test_analytics_admin_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): - transport = transports.AnalyticsAdminServiceTransport( - credentials=credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_analytics_admin_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.AnalyticsAdminServiceTransport( - credentials=credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'get_account', - 'list_accounts', - 'delete_account', - 'update_account', - 'provision_account_ticket', - 'list_account_summaries', - 'get_property', - 'list_properties', - 'create_property', - 'delete_property', - 'update_property', - 'get_user_link', - 'batch_get_user_links', - 'list_user_links', - 'audit_user_links', - 'create_user_link', - 'batch_create_user_links', - 'update_user_link', - 'batch_update_user_links', - 'delete_user_link', - 'batch_delete_user_links', - 'get_web_data_stream', - 'delete_web_data_stream', - 'update_web_data_stream', - 'create_web_data_stream', - 'list_web_data_streams', - 'get_ios_app_data_stream', - 'delete_ios_app_data_stream', - 'update_ios_app_data_stream', - 'create_ios_app_data_stream', - 'list_ios_app_data_streams', - 'get_android_app_data_stream', - 'delete_android_app_data_stream', - 'update_android_app_data_stream', - 'create_android_app_data_stream', - 'list_android_app_data_streams', - 'get_enhanced_measurement_settings', - 'update_enhanced_measurement_settings', - 'create_firebase_link', - 'update_firebase_link', - 'delete_firebase_link', - 'list_firebase_links', - 'get_global_site_tag', - 'create_google_ads_link', - 'update_google_ads_link', - 'delete_google_ads_link', - 'list_google_ads_links', - 'get_data_sharing_settings', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - -def test_analytics_admin_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(auth, 'load_credentials_from_file') as load_creds, mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) - transport = transports.AnalyticsAdminServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/analytics.edit', - 'https://www.googleapis.com/auth/analytics.manage.users', - 'https://www.googleapis.com/auth/analytics.manage.users.readonly', - 'https://www.googleapis.com/auth/analytics.readonly', - ), - quota_project_id="octopus", - ) - - -def test_analytics_admin_service_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, 'default') as adc, mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) - transport = transports.AnalyticsAdminServiceTransport() - adc.assert_called_once() - - -def test_analytics_admin_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, 'default') as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - AnalyticsAdminServiceClient() - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/analytics.edit', - 'https://www.googleapis.com/auth/analytics.manage.users', - 'https://www.googleapis.com/auth/analytics.manage.users.readonly', - 'https://www.googleapis.com/auth/analytics.readonly',), - quota_project_id=None, - ) - - -def test_analytics_admin_service_transport_auth_adc(): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(auth, 'default') as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.AnalyticsAdminServiceGrpcTransport(host="squid.clam.whelk", quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/analytics.edit', - 'https://www.googleapis.com/auth/analytics.manage.users', - 'https://www.googleapis.com/auth/analytics.manage.users.readonly', - 'https://www.googleapis.com/auth/analytics.readonly',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize("transport_class", [transports.AnalyticsAdminServiceGrpcTransport, transports.AnalyticsAdminServiceGrpcAsyncIOTransport]) -def test_analytics_admin_service_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/analytics.edit', - 'https://www.googleapis.com/auth/analytics.manage.users', - 'https://www.googleapis.com/auth/analytics.manage.users.readonly', - 'https://www.googleapis.com/auth/analytics.readonly', - ), - 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_analytics_admin_service_host_no_port(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='analyticsadmin.googleapis.com'), - ) - assert client.transport._host == 'analyticsadmin.googleapis.com:443' - - -def test_analytics_admin_service_host_with_port(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='analyticsadmin.googleapis.com:8000'), - ) - assert client.transport._host == 'analyticsadmin.googleapis.com:8000' - - -def test_analytics_admin_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.AnalyticsAdminServiceGrpcTransport( - 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_analytics_admin_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( - 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.AnalyticsAdminServiceGrpcTransport, transports.AnalyticsAdminServiceGrpcAsyncIOTransport]) -def test_analytics_admin_service_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/analytics.edit', - 'https://www.googleapis.com/auth/analytics.manage.users', - 'https://www.googleapis.com/auth/analytics.manage.users.readonly', - 'https://www.googleapis.com/auth/analytics.readonly', - ), - 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.AnalyticsAdminServiceGrpcTransport, transports.AnalyticsAdminServiceGrpcAsyncIOTransport]) -def test_analytics_admin_service_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/analytics.edit', - 'https://www.googleapis.com/auth/analytics.manage.users', - 'https://www.googleapis.com/auth/analytics.manage.users.readonly', - 'https://www.googleapis.com/auth/analytics.readonly', - ), - 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_account_path(): - account = "squid" - - expected = "accounts/{account}".format(account=account, ) - actual = AnalyticsAdminServiceClient.account_path(account) - assert expected == actual - - -def test_parse_account_path(): - expected = { - "account": "clam", - - } - path = AnalyticsAdminServiceClient.account_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_account_path(path) - assert expected == actual - -def test_account_summary_path(): - account_summary = "whelk" - - expected = "accountSummaries/{account_summary}".format(account_summary=account_summary, ) - actual = AnalyticsAdminServiceClient.account_summary_path(account_summary) - assert expected == actual - - -def test_parse_account_summary_path(): - expected = { - "account_summary": "octopus", - - } - path = AnalyticsAdminServiceClient.account_summary_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_account_summary_path(path) - assert expected == actual - -def test_android_app_data_stream_path(): - property = "oyster" - android_app_data_stream = "nudibranch" - - expected = "properties/{property}/androidAppDataStreams/{android_app_data_stream}".format(property=property, android_app_data_stream=android_app_data_stream, ) - actual = AnalyticsAdminServiceClient.android_app_data_stream_path(property, android_app_data_stream) - assert expected == actual - - -def test_parse_android_app_data_stream_path(): - expected = { - "property": "cuttlefish", - "android_app_data_stream": "mussel", - - } - path = AnalyticsAdminServiceClient.android_app_data_stream_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_android_app_data_stream_path(path) - assert expected == actual - -def test_data_sharing_settings_path(): - account = "winkle" - - expected = "accounts/{account}/dataSharingSettings".format(account=account, ) - actual = AnalyticsAdminServiceClient.data_sharing_settings_path(account) - assert expected == actual - - -def test_parse_data_sharing_settings_path(): - expected = { - "account": "nautilus", - - } - path = AnalyticsAdminServiceClient.data_sharing_settings_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_data_sharing_settings_path(path) - assert expected == actual - -def test_enhanced_measurement_settings_path(): - property = "scallop" - web_data_stream = "abalone" - - expected = "properties/{property}/webDataStreams/{web_data_stream}/enhancedMeasurementSettings".format(property=property, web_data_stream=web_data_stream, ) - actual = AnalyticsAdminServiceClient.enhanced_measurement_settings_path(property, web_data_stream) - assert expected == actual - - -def test_parse_enhanced_measurement_settings_path(): - expected = { - "property": "squid", - "web_data_stream": "clam", - - } - path = AnalyticsAdminServiceClient.enhanced_measurement_settings_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_enhanced_measurement_settings_path(path) - assert expected == actual - -def test_firebase_link_path(): - property = "whelk" - firebase_link = "octopus" - - expected = "properties/{property}/firebaseLinks/{firebase_link}".format(property=property, firebase_link=firebase_link, ) - actual = AnalyticsAdminServiceClient.firebase_link_path(property, firebase_link) - assert expected == actual - - -def test_parse_firebase_link_path(): - expected = { - "property": "oyster", - "firebase_link": "nudibranch", - - } - path = AnalyticsAdminServiceClient.firebase_link_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_firebase_link_path(path) - assert expected == actual - -def test_global_site_tag_path(): - property = "cuttlefish" - - expected = "properties/{property}/globalSiteTag".format(property=property, ) - actual = AnalyticsAdminServiceClient.global_site_tag_path(property) - assert expected == actual - - -def test_parse_global_site_tag_path(): - expected = { - "property": "mussel", - - } - path = AnalyticsAdminServiceClient.global_site_tag_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_global_site_tag_path(path) - assert expected == actual - -def test_google_ads_link_path(): - property = "winkle" - google_ads_link = "nautilus" - - expected = "properties/{property}/googleAdsLinks/{google_ads_link}".format(property=property, google_ads_link=google_ads_link, ) - actual = AnalyticsAdminServiceClient.google_ads_link_path(property, google_ads_link) - assert expected == actual - - -def test_parse_google_ads_link_path(): - expected = { - "property": "scallop", - "google_ads_link": "abalone", - - } - path = AnalyticsAdminServiceClient.google_ads_link_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_google_ads_link_path(path) - assert expected == actual - -def test_ios_app_data_stream_path(): - property = "squid" - ios_app_data_stream = "clam" - - expected = "properties/{property}/iosAppDataStreams/{ios_app_data_stream}".format(property=property, ios_app_data_stream=ios_app_data_stream, ) - actual = AnalyticsAdminServiceClient.ios_app_data_stream_path(property, ios_app_data_stream) - assert expected == actual - - -def test_parse_ios_app_data_stream_path(): - expected = { - "property": "whelk", - "ios_app_data_stream": "octopus", - - } - path = AnalyticsAdminServiceClient.ios_app_data_stream_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_ios_app_data_stream_path(path) - assert expected == actual - -def test_property_path(): - property = "oyster" - - expected = "properties/{property}".format(property=property, ) - actual = AnalyticsAdminServiceClient.property_path(property) - assert expected == actual - - -def test_parse_property_path(): - expected = { - "property": "nudibranch", - - } - path = AnalyticsAdminServiceClient.property_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_property_path(path) - assert expected == actual - -def test_user_link_path(): - account = "cuttlefish" - user_link = "mussel" - - expected = "accounts/{account}/userLinks/{user_link}".format(account=account, user_link=user_link, ) - actual = AnalyticsAdminServiceClient.user_link_path(account, user_link) - assert expected == actual - - -def test_parse_user_link_path(): - expected = { - "account": "winkle", - "user_link": "nautilus", - - } - path = AnalyticsAdminServiceClient.user_link_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_user_link_path(path) - assert expected == actual - -def test_web_data_stream_path(): - property = "scallop" - web_data_stream = "abalone" - - expected = "properties/{property}/webDataStreams/{web_data_stream}".format(property=property, web_data_stream=web_data_stream, ) - actual = AnalyticsAdminServiceClient.web_data_stream_path(property, web_data_stream) - assert expected == actual - - -def test_parse_web_data_stream_path(): - expected = { - "property": "squid", - "web_data_stream": "clam", - - } - path = AnalyticsAdminServiceClient.web_data_stream_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_web_data_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 = AnalyticsAdminServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "octopus", - - } - path = AnalyticsAdminServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "oyster" - - expected = "folders/{folder}".format(folder=folder, ) - actual = AnalyticsAdminServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nudibranch", - - } - path = AnalyticsAdminServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "cuttlefish" - - expected = "organizations/{organization}".format(organization=organization, ) - actual = AnalyticsAdminServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "mussel", - - } - path = AnalyticsAdminServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "winkle" - - expected = "projects/{project}".format(project=project, ) - actual = AnalyticsAdminServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nautilus", - - } - path = AnalyticsAdminServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.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 = AnalyticsAdminServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "squid", - "location": "clam", - - } - path = AnalyticsAdminServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.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.AnalyticsAdminServiceTransport, '_prep_wrapped_messages') as prep: - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.AnalyticsAdminServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = AnalyticsAdminServiceClient.get_transport_class() - transport = transport_class( - credentials=credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info)