From c21c1e2ed0619ea6c05a89c2f10ae82c9f4f6391 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 23 Jul 2021 21:31:01 +0000 Subject: [PATCH 1/2] fix: enable self signed jwt for grpc chore: use gapic-generator-python 0.50.5 PiperOrigin-RevId: 386504689 Source-Link: https://github.com/googleapis/googleapis/commit/762094a99ac6e03a17516b13dfbef37927267a70 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6bfc480e1a161d5de121c2bcc3745885d33b265a --- owl-bot-staging/v1alpha/.coveragerc | 17 + owl-bot-staging/v1alpha/MANIFEST.in | 2 + owl-bot-staging/v1alpha/README.rst | 49 + .../admin_v1alpha/analytics_admin_service.rst | 10 + .../v1alpha/docs/admin_v1alpha/services.rst | 6 + .../v1alpha/docs/admin_v1alpha/types.rst | 7 + owl-bot-staging/v1alpha/docs/conf.py | 376 + owl-bot-staging/v1alpha/docs/index.rst | 7 + .../google/analytics/admin/__init__.py | 253 + .../v1alpha/google/analytics/admin/py.typed | 2 + .../analytics/admin_v1alpha/__init__.py | 254 + .../admin_v1alpha/gapic_metadata.json | 703 + .../google/analytics/admin_v1alpha/py.typed | 2 + .../admin_v1alpha/services/__init__.py | 15 + .../analytics_admin_service/__init__.py | 22 + .../analytics_admin_service/async_client.py | 5495 +++++ .../analytics_admin_service/client.py | 5840 +++++ .../analytics_admin_service/pagers.py | 1849 ++ .../transports/__init__.py | 33 + .../transports/base.py | 1111 + .../transports/grpc.py | 2083 ++ .../transports/grpc_asyncio.py | 2087 ++ .../analytics/admin_v1alpha/types/__init__.py | 252 + .../admin_v1alpha/types/analytics_admin.py | 2195 ++ .../admin_v1alpha/types/resources.py | 1408 ++ owl-bot-staging/v1alpha/mypy.ini | 3 + owl-bot-staging/v1alpha/noxfile.py | 132 + .../scripts/fixup_admin_v1alpha_keywords.py | 243 + owl-bot-staging/v1alpha/setup.py | 54 + owl-bot-staging/v1alpha/tests/__init__.py | 16 + .../v1alpha/tests/unit/__init__.py | 16 + .../v1alpha/tests/unit/gapic/__init__.py | 16 + .../unit/gapic/admin_v1alpha/__init__.py | 16 + .../test_analytics_admin_service.py | 19266 ++++++++++++++++ 34 files changed, 43840 insertions(+) create mode 100644 owl-bot-staging/v1alpha/.coveragerc 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/gapic_metadata.json 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/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/__init__.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/.coveragerc b/owl-bot-staging/v1alpha/.coveragerc new file mode 100644 index 00000000..e02b8f0e --- /dev/null +++ b/owl-bot-staging/v1alpha/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/analytics/admin/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/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..d771e00c --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst @@ -0,0 +1,10 @@ +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..b7010958 --- /dev/null +++ b/owl-bot-staging/v1alpha/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# google-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..18c53507 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin/__init__.py @@ -0,0 +1,253 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.client import AnalyticsAdminServiceClient +from google.analytics.admin_v1alpha.services.analytics_admin_service.async_client import AnalyticsAdminServiceAsyncClient + +from google.analytics.admin_v1alpha.types.analytics_admin import ArchiveCustomDimensionRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ArchiveCustomMetricRequest +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 CreateConversionEventRequest +from google.analytics.admin_v1alpha.types.analytics_admin import CreateCustomDimensionRequest +from google.analytics.admin_v1alpha.types.analytics_admin import CreateCustomMetricRequest +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 CreateMeasurementProtocolSecretRequest +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 DeleteConversionEventRequest +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 DeleteMeasurementProtocolSecretRequest +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 GetConversionEventRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetCustomDimensionRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetCustomMetricRequest +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 GetGoogleSignalsSettingsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetIosAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import GetMeasurementProtocolSecretRequest +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 ListAccountsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsResponse +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 ListAndroidAppDataStreamsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListAndroidAppDataStreamsResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListConversionEventsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListConversionEventsResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListCustomDimensionsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListCustomDimensionsResponse +from google.analytics.admin_v1alpha.types.analytics_admin import ListCustomMetricsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListCustomMetricsResponse +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 ListMeasurementProtocolSecretsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListMeasurementProtocolSecretsResponse +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 SearchChangeHistoryEventsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import SearchChangeHistoryEventsResponse +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 UpdateCustomDimensionRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateCustomMetricRequest +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 UpdateGoogleSignalsSettingsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateIosAppDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import UpdateMeasurementProtocolSecretRequest +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 ChangeHistoryChange +from google.analytics.admin_v1alpha.types.resources import ChangeHistoryEvent +from google.analytics.admin_v1alpha.types.resources import ConversionEvent +from google.analytics.admin_v1alpha.types.resources import CustomDimension +from google.analytics.admin_v1alpha.types.resources import CustomMetric +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 GoogleSignalsSettings +from google.analytics.admin_v1alpha.types.resources import IosAppDataStream +from google.analytics.admin_v1alpha.types.resources import MeasurementProtocolSecret +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 +from google.analytics.admin_v1alpha.types.resources import ActionType +from google.analytics.admin_v1alpha.types.resources import ActorType +from google.analytics.admin_v1alpha.types.resources import ChangeHistoryResourceType +from google.analytics.admin_v1alpha.types.resources import GoogleSignalsConsent +from google.analytics.admin_v1alpha.types.resources import GoogleSignalsState +from google.analytics.admin_v1alpha.types.resources import IndustryCategory +from google.analytics.admin_v1alpha.types.resources import MaximumUserAccess + +__all__ = ('AnalyticsAdminServiceClient', + 'AnalyticsAdminServiceAsyncClient', + 'ArchiveCustomDimensionRequest', + 'ArchiveCustomMetricRequest', + 'AuditUserLinksRequest', + 'AuditUserLinksResponse', + 'BatchCreateUserLinksRequest', + 'BatchCreateUserLinksResponse', + 'BatchDeleteUserLinksRequest', + 'BatchGetUserLinksRequest', + 'BatchGetUserLinksResponse', + 'BatchUpdateUserLinksRequest', + 'BatchUpdateUserLinksResponse', + 'CreateConversionEventRequest', + 'CreateCustomDimensionRequest', + 'CreateCustomMetricRequest', + 'CreateFirebaseLinkRequest', + 'CreateGoogleAdsLinkRequest', + 'CreateMeasurementProtocolSecretRequest', + 'CreatePropertyRequest', + 'CreateUserLinkRequest', + 'CreateWebDataStreamRequest', + 'DeleteAccountRequest', + 'DeleteAndroidAppDataStreamRequest', + 'DeleteConversionEventRequest', + 'DeleteFirebaseLinkRequest', + 'DeleteGoogleAdsLinkRequest', + 'DeleteIosAppDataStreamRequest', + 'DeleteMeasurementProtocolSecretRequest', + 'DeletePropertyRequest', + 'DeleteUserLinkRequest', + 'DeleteWebDataStreamRequest', + 'GetAccountRequest', + 'GetAndroidAppDataStreamRequest', + 'GetConversionEventRequest', + 'GetCustomDimensionRequest', + 'GetCustomMetricRequest', + 'GetDataSharingSettingsRequest', + 'GetEnhancedMeasurementSettingsRequest', + 'GetGlobalSiteTagRequest', + 'GetGoogleSignalsSettingsRequest', + 'GetIosAppDataStreamRequest', + 'GetMeasurementProtocolSecretRequest', + 'GetPropertyRequest', + 'GetUserLinkRequest', + 'GetWebDataStreamRequest', + 'ListAccountsRequest', + 'ListAccountsResponse', + 'ListAccountSummariesRequest', + 'ListAccountSummariesResponse', + 'ListAndroidAppDataStreamsRequest', + 'ListAndroidAppDataStreamsResponse', + 'ListConversionEventsRequest', + 'ListConversionEventsResponse', + 'ListCustomDimensionsRequest', + 'ListCustomDimensionsResponse', + 'ListCustomMetricsRequest', + 'ListCustomMetricsResponse', + 'ListFirebaseLinksRequest', + 'ListFirebaseLinksResponse', + 'ListGoogleAdsLinksRequest', + 'ListGoogleAdsLinksResponse', + 'ListIosAppDataStreamsRequest', + 'ListIosAppDataStreamsResponse', + 'ListMeasurementProtocolSecretsRequest', + 'ListMeasurementProtocolSecretsResponse', + 'ListPropertiesRequest', + 'ListPropertiesResponse', + 'ListUserLinksRequest', + 'ListUserLinksResponse', + 'ListWebDataStreamsRequest', + 'ListWebDataStreamsResponse', + 'ProvisionAccountTicketRequest', + 'ProvisionAccountTicketResponse', + 'SearchChangeHistoryEventsRequest', + 'SearchChangeHistoryEventsResponse', + 'UpdateAccountRequest', + 'UpdateAndroidAppDataStreamRequest', + 'UpdateCustomDimensionRequest', + 'UpdateCustomMetricRequest', + 'UpdateEnhancedMeasurementSettingsRequest', + 'UpdateFirebaseLinkRequest', + 'UpdateGoogleAdsLinkRequest', + 'UpdateGoogleSignalsSettingsRequest', + 'UpdateIosAppDataStreamRequest', + 'UpdateMeasurementProtocolSecretRequest', + 'UpdatePropertyRequest', + 'UpdateUserLinkRequest', + 'UpdateWebDataStreamRequest', + 'Account', + 'AccountSummary', + 'AndroidAppDataStream', + 'AuditUserLink', + 'ChangeHistoryChange', + 'ChangeHistoryEvent', + 'ConversionEvent', + 'CustomDimension', + 'CustomMetric', + 'DataSharingSettings', + 'EnhancedMeasurementSettings', + 'FirebaseLink', + 'GlobalSiteTag', + 'GoogleAdsLink', + 'GoogleSignalsSettings', + 'IosAppDataStream', + 'MeasurementProtocolSecret', + 'Property', + 'PropertySummary', + 'UserLink', + 'WebDataStream', + 'ActionType', + 'ActorType', + 'ChangeHistoryResourceType', + 'GoogleSignalsConsent', + 'GoogleSignalsState', + 'IndustryCategory', + 'MaximumUserAccess', +) 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..0b253fca --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py @@ -0,0 +1,254 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 .services.analytics_admin_service import AnalyticsAdminServiceAsyncClient + +from .types.analytics_admin import ArchiveCustomDimensionRequest +from .types.analytics_admin import ArchiveCustomMetricRequest +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 CreateConversionEventRequest +from .types.analytics_admin import CreateCustomDimensionRequest +from .types.analytics_admin import CreateCustomMetricRequest +from .types.analytics_admin import CreateFirebaseLinkRequest +from .types.analytics_admin import CreateGoogleAdsLinkRequest +from .types.analytics_admin import CreateMeasurementProtocolSecretRequest +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 DeleteConversionEventRequest +from .types.analytics_admin import DeleteFirebaseLinkRequest +from .types.analytics_admin import DeleteGoogleAdsLinkRequest +from .types.analytics_admin import DeleteIosAppDataStreamRequest +from .types.analytics_admin import DeleteMeasurementProtocolSecretRequest +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 GetConversionEventRequest +from .types.analytics_admin import GetCustomDimensionRequest +from .types.analytics_admin import GetCustomMetricRequest +from .types.analytics_admin import GetDataSharingSettingsRequest +from .types.analytics_admin import GetEnhancedMeasurementSettingsRequest +from .types.analytics_admin import GetGlobalSiteTagRequest +from .types.analytics_admin import GetGoogleSignalsSettingsRequest +from .types.analytics_admin import GetIosAppDataStreamRequest +from .types.analytics_admin import GetMeasurementProtocolSecretRequest +from .types.analytics_admin import GetPropertyRequest +from .types.analytics_admin import GetUserLinkRequest +from .types.analytics_admin import GetWebDataStreamRequest +from .types.analytics_admin import ListAccountsRequest +from .types.analytics_admin import ListAccountsResponse +from .types.analytics_admin import ListAccountSummariesRequest +from .types.analytics_admin import ListAccountSummariesResponse +from .types.analytics_admin import ListAndroidAppDataStreamsRequest +from .types.analytics_admin import ListAndroidAppDataStreamsResponse +from .types.analytics_admin import ListConversionEventsRequest +from .types.analytics_admin import ListConversionEventsResponse +from .types.analytics_admin import ListCustomDimensionsRequest +from .types.analytics_admin import ListCustomDimensionsResponse +from .types.analytics_admin import ListCustomMetricsRequest +from .types.analytics_admin import ListCustomMetricsResponse +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 ListMeasurementProtocolSecretsRequest +from .types.analytics_admin import ListMeasurementProtocolSecretsResponse +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 SearchChangeHistoryEventsRequest +from .types.analytics_admin import SearchChangeHistoryEventsResponse +from .types.analytics_admin import UpdateAccountRequest +from .types.analytics_admin import UpdateAndroidAppDataStreamRequest +from .types.analytics_admin import UpdateCustomDimensionRequest +from .types.analytics_admin import UpdateCustomMetricRequest +from .types.analytics_admin import UpdateEnhancedMeasurementSettingsRequest +from .types.analytics_admin import UpdateFirebaseLinkRequest +from .types.analytics_admin import UpdateGoogleAdsLinkRequest +from .types.analytics_admin import UpdateGoogleSignalsSettingsRequest +from .types.analytics_admin import UpdateIosAppDataStreamRequest +from .types.analytics_admin import UpdateMeasurementProtocolSecretRequest +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 ChangeHistoryChange +from .types.resources import ChangeHistoryEvent +from .types.resources import ConversionEvent +from .types.resources import CustomDimension +from .types.resources import CustomMetric +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 GoogleSignalsSettings +from .types.resources import IosAppDataStream +from .types.resources import MeasurementProtocolSecret +from .types.resources import Property +from .types.resources import PropertySummary +from .types.resources import UserLink +from .types.resources import WebDataStream +from .types.resources import ActionType +from .types.resources import ActorType +from .types.resources import ChangeHistoryResourceType +from .types.resources import GoogleSignalsConsent +from .types.resources import GoogleSignalsState +from .types.resources import IndustryCategory +from .types.resources import MaximumUserAccess + +__all__ = ( + 'AnalyticsAdminServiceAsyncClient', +'Account', +'AccountSummary', +'ActionType', +'ActorType', +'AnalyticsAdminServiceClient', +'AndroidAppDataStream', +'ArchiveCustomDimensionRequest', +'ArchiveCustomMetricRequest', +'AuditUserLink', +'AuditUserLinksRequest', +'AuditUserLinksResponse', +'BatchCreateUserLinksRequest', +'BatchCreateUserLinksResponse', +'BatchDeleteUserLinksRequest', +'BatchGetUserLinksRequest', +'BatchGetUserLinksResponse', +'BatchUpdateUserLinksRequest', +'BatchUpdateUserLinksResponse', +'ChangeHistoryChange', +'ChangeHistoryEvent', +'ChangeHistoryResourceType', +'ConversionEvent', +'CreateConversionEventRequest', +'CreateCustomDimensionRequest', +'CreateCustomMetricRequest', +'CreateFirebaseLinkRequest', +'CreateGoogleAdsLinkRequest', +'CreateMeasurementProtocolSecretRequest', +'CreatePropertyRequest', +'CreateUserLinkRequest', +'CreateWebDataStreamRequest', +'CustomDimension', +'CustomMetric', +'DataSharingSettings', +'DeleteAccountRequest', +'DeleteAndroidAppDataStreamRequest', +'DeleteConversionEventRequest', +'DeleteFirebaseLinkRequest', +'DeleteGoogleAdsLinkRequest', +'DeleteIosAppDataStreamRequest', +'DeleteMeasurementProtocolSecretRequest', +'DeletePropertyRequest', +'DeleteUserLinkRequest', +'DeleteWebDataStreamRequest', +'EnhancedMeasurementSettings', +'FirebaseLink', +'GetAccountRequest', +'GetAndroidAppDataStreamRequest', +'GetConversionEventRequest', +'GetCustomDimensionRequest', +'GetCustomMetricRequest', +'GetDataSharingSettingsRequest', +'GetEnhancedMeasurementSettingsRequest', +'GetGlobalSiteTagRequest', +'GetGoogleSignalsSettingsRequest', +'GetIosAppDataStreamRequest', +'GetMeasurementProtocolSecretRequest', +'GetPropertyRequest', +'GetUserLinkRequest', +'GetWebDataStreamRequest', +'GlobalSiteTag', +'GoogleAdsLink', +'GoogleSignalsConsent', +'GoogleSignalsSettings', +'GoogleSignalsState', +'IndustryCategory', +'IosAppDataStream', +'ListAccountSummariesRequest', +'ListAccountSummariesResponse', +'ListAccountsRequest', +'ListAccountsResponse', +'ListAndroidAppDataStreamsRequest', +'ListAndroidAppDataStreamsResponse', +'ListConversionEventsRequest', +'ListConversionEventsResponse', +'ListCustomDimensionsRequest', +'ListCustomDimensionsResponse', +'ListCustomMetricsRequest', +'ListCustomMetricsResponse', +'ListFirebaseLinksRequest', +'ListFirebaseLinksResponse', +'ListGoogleAdsLinksRequest', +'ListGoogleAdsLinksResponse', +'ListIosAppDataStreamsRequest', +'ListIosAppDataStreamsResponse', +'ListMeasurementProtocolSecretsRequest', +'ListMeasurementProtocolSecretsResponse', +'ListPropertiesRequest', +'ListPropertiesResponse', +'ListUserLinksRequest', +'ListUserLinksResponse', +'ListWebDataStreamsRequest', +'ListWebDataStreamsResponse', +'MaximumUserAccess', +'MeasurementProtocolSecret', +'Property', +'PropertySummary', +'ProvisionAccountTicketRequest', +'ProvisionAccountTicketResponse', +'SearchChangeHistoryEventsRequest', +'SearchChangeHistoryEventsResponse', +'UpdateAccountRequest', +'UpdateAndroidAppDataStreamRequest', +'UpdateCustomDimensionRequest', +'UpdateCustomMetricRequest', +'UpdateEnhancedMeasurementSettingsRequest', +'UpdateFirebaseLinkRequest', +'UpdateGoogleAdsLinkRequest', +'UpdateGoogleSignalsSettingsRequest', +'UpdateIosAppDataStreamRequest', +'UpdateMeasurementProtocolSecretRequest', +'UpdatePropertyRequest', +'UpdateUserLinkRequest', +'UpdateWebDataStreamRequest', +'UserLink', +'WebDataStream', +) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/gapic_metadata.json new file mode 100644 index 00000000..fb4e612c --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/gapic_metadata.json @@ -0,0 +1,703 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.analytics.admin_v1alpha", + "protoPackage": "google.analytics.admin.v1alpha", + "schema": "1.0", + "services": { + "AnalyticsAdminService": { + "clients": { + "grpc": { + "libraryClient": "AnalyticsAdminServiceClient", + "rpcs": { + "ArchiveCustomDimension": { + "methods": [ + "archive_custom_dimension" + ] + }, + "ArchiveCustomMetric": { + "methods": [ + "archive_custom_metric" + ] + }, + "AuditUserLinks": { + "methods": [ + "audit_user_links" + ] + }, + "BatchCreateUserLinks": { + "methods": [ + "batch_create_user_links" + ] + }, + "BatchDeleteUserLinks": { + "methods": [ + "batch_delete_user_links" + ] + }, + "BatchGetUserLinks": { + "methods": [ + "batch_get_user_links" + ] + }, + "BatchUpdateUserLinks": { + "methods": [ + "batch_update_user_links" + ] + }, + "CreateConversionEvent": { + "methods": [ + "create_conversion_event" + ] + }, + "CreateCustomDimension": { + "methods": [ + "create_custom_dimension" + ] + }, + "CreateCustomMetric": { + "methods": [ + "create_custom_metric" + ] + }, + "CreateFirebaseLink": { + "methods": [ + "create_firebase_link" + ] + }, + "CreateGoogleAdsLink": { + "methods": [ + "create_google_ads_link" + ] + }, + "CreateMeasurementProtocolSecret": { + "methods": [ + "create_measurement_protocol_secret" + ] + }, + "CreateProperty": { + "methods": [ + "create_property" + ] + }, + "CreateUserLink": { + "methods": [ + "create_user_link" + ] + }, + "CreateWebDataStream": { + "methods": [ + "create_web_data_stream" + ] + }, + "DeleteAccount": { + "methods": [ + "delete_account" + ] + }, + "DeleteAndroidAppDataStream": { + "methods": [ + "delete_android_app_data_stream" + ] + }, + "DeleteConversionEvent": { + "methods": [ + "delete_conversion_event" + ] + }, + "DeleteFirebaseLink": { + "methods": [ + "delete_firebase_link" + ] + }, + "DeleteGoogleAdsLink": { + "methods": [ + "delete_google_ads_link" + ] + }, + "DeleteIosAppDataStream": { + "methods": [ + "delete_ios_app_data_stream" + ] + }, + "DeleteMeasurementProtocolSecret": { + "methods": [ + "delete_measurement_protocol_secret" + ] + }, + "DeleteProperty": { + "methods": [ + "delete_property" + ] + }, + "DeleteUserLink": { + "methods": [ + "delete_user_link" + ] + }, + "DeleteWebDataStream": { + "methods": [ + "delete_web_data_stream" + ] + }, + "GetAccount": { + "methods": [ + "get_account" + ] + }, + "GetAndroidAppDataStream": { + "methods": [ + "get_android_app_data_stream" + ] + }, + "GetConversionEvent": { + "methods": [ + "get_conversion_event" + ] + }, + "GetCustomDimension": { + "methods": [ + "get_custom_dimension" + ] + }, + "GetCustomMetric": { + "methods": [ + "get_custom_metric" + ] + }, + "GetDataSharingSettings": { + "methods": [ + "get_data_sharing_settings" + ] + }, + "GetEnhancedMeasurementSettings": { + "methods": [ + "get_enhanced_measurement_settings" + ] + }, + "GetGlobalSiteTag": { + "methods": [ + "get_global_site_tag" + ] + }, + "GetGoogleSignalsSettings": { + "methods": [ + "get_google_signals_settings" + ] + }, + "GetIosAppDataStream": { + "methods": [ + "get_ios_app_data_stream" + ] + }, + "GetMeasurementProtocolSecret": { + "methods": [ + "get_measurement_protocol_secret" + ] + }, + "GetProperty": { + "methods": [ + "get_property" + ] + }, + "GetUserLink": { + "methods": [ + "get_user_link" + ] + }, + "GetWebDataStream": { + "methods": [ + "get_web_data_stream" + ] + }, + "ListAccountSummaries": { + "methods": [ + "list_account_summaries" + ] + }, + "ListAccounts": { + "methods": [ + "list_accounts" + ] + }, + "ListAndroidAppDataStreams": { + "methods": [ + "list_android_app_data_streams" + ] + }, + "ListConversionEvents": { + "methods": [ + "list_conversion_events" + ] + }, + "ListCustomDimensions": { + "methods": [ + "list_custom_dimensions" + ] + }, + "ListCustomMetrics": { + "methods": [ + "list_custom_metrics" + ] + }, + "ListFirebaseLinks": { + "methods": [ + "list_firebase_links" + ] + }, + "ListGoogleAdsLinks": { + "methods": [ + "list_google_ads_links" + ] + }, + "ListIosAppDataStreams": { + "methods": [ + "list_ios_app_data_streams" + ] + }, + "ListMeasurementProtocolSecrets": { + "methods": [ + "list_measurement_protocol_secrets" + ] + }, + "ListProperties": { + "methods": [ + "list_properties" + ] + }, + "ListUserLinks": { + "methods": [ + "list_user_links" + ] + }, + "ListWebDataStreams": { + "methods": [ + "list_web_data_streams" + ] + }, + "ProvisionAccountTicket": { + "methods": [ + "provision_account_ticket" + ] + }, + "SearchChangeHistoryEvents": { + "methods": [ + "search_change_history_events" + ] + }, + "UpdateAccount": { + "methods": [ + "update_account" + ] + }, + "UpdateAndroidAppDataStream": { + "methods": [ + "update_android_app_data_stream" + ] + }, + "UpdateCustomDimension": { + "methods": [ + "update_custom_dimension" + ] + }, + "UpdateCustomMetric": { + "methods": [ + "update_custom_metric" + ] + }, + "UpdateEnhancedMeasurementSettings": { + "methods": [ + "update_enhanced_measurement_settings" + ] + }, + "UpdateFirebaseLink": { + "methods": [ + "update_firebase_link" + ] + }, + "UpdateGoogleAdsLink": { + "methods": [ + "update_google_ads_link" + ] + }, + "UpdateGoogleSignalsSettings": { + "methods": [ + "update_google_signals_settings" + ] + }, + "UpdateIosAppDataStream": { + "methods": [ + "update_ios_app_data_stream" + ] + }, + "UpdateMeasurementProtocolSecret": { + "methods": [ + "update_measurement_protocol_secret" + ] + }, + "UpdateProperty": { + "methods": [ + "update_property" + ] + }, + "UpdateUserLink": { + "methods": [ + "update_user_link" + ] + }, + "UpdateWebDataStream": { + "methods": [ + "update_web_data_stream" + ] + } + } + }, + "grpc-async": { + "libraryClient": "AnalyticsAdminServiceAsyncClient", + "rpcs": { + "ArchiveCustomDimension": { + "methods": [ + "archive_custom_dimension" + ] + }, + "ArchiveCustomMetric": { + "methods": [ + "archive_custom_metric" + ] + }, + "AuditUserLinks": { + "methods": [ + "audit_user_links" + ] + }, + "BatchCreateUserLinks": { + "methods": [ + "batch_create_user_links" + ] + }, + "BatchDeleteUserLinks": { + "methods": [ + "batch_delete_user_links" + ] + }, + "BatchGetUserLinks": { + "methods": [ + "batch_get_user_links" + ] + }, + "BatchUpdateUserLinks": { + "methods": [ + "batch_update_user_links" + ] + }, + "CreateConversionEvent": { + "methods": [ + "create_conversion_event" + ] + }, + "CreateCustomDimension": { + "methods": [ + "create_custom_dimension" + ] + }, + "CreateCustomMetric": { + "methods": [ + "create_custom_metric" + ] + }, + "CreateFirebaseLink": { + "methods": [ + "create_firebase_link" + ] + }, + "CreateGoogleAdsLink": { + "methods": [ + "create_google_ads_link" + ] + }, + "CreateMeasurementProtocolSecret": { + "methods": [ + "create_measurement_protocol_secret" + ] + }, + "CreateProperty": { + "methods": [ + "create_property" + ] + }, + "CreateUserLink": { + "methods": [ + "create_user_link" + ] + }, + "CreateWebDataStream": { + "methods": [ + "create_web_data_stream" + ] + }, + "DeleteAccount": { + "methods": [ + "delete_account" + ] + }, + "DeleteAndroidAppDataStream": { + "methods": [ + "delete_android_app_data_stream" + ] + }, + "DeleteConversionEvent": { + "methods": [ + "delete_conversion_event" + ] + }, + "DeleteFirebaseLink": { + "methods": [ + "delete_firebase_link" + ] + }, + "DeleteGoogleAdsLink": { + "methods": [ + "delete_google_ads_link" + ] + }, + "DeleteIosAppDataStream": { + "methods": [ + "delete_ios_app_data_stream" + ] + }, + "DeleteMeasurementProtocolSecret": { + "methods": [ + "delete_measurement_protocol_secret" + ] + }, + "DeleteProperty": { + "methods": [ + "delete_property" + ] + }, + "DeleteUserLink": { + "methods": [ + "delete_user_link" + ] + }, + "DeleteWebDataStream": { + "methods": [ + "delete_web_data_stream" + ] + }, + "GetAccount": { + "methods": [ + "get_account" + ] + }, + "GetAndroidAppDataStream": { + "methods": [ + "get_android_app_data_stream" + ] + }, + "GetConversionEvent": { + "methods": [ + "get_conversion_event" + ] + }, + "GetCustomDimension": { + "methods": [ + "get_custom_dimension" + ] + }, + "GetCustomMetric": { + "methods": [ + "get_custom_metric" + ] + }, + "GetDataSharingSettings": { + "methods": [ + "get_data_sharing_settings" + ] + }, + "GetEnhancedMeasurementSettings": { + "methods": [ + "get_enhanced_measurement_settings" + ] + }, + "GetGlobalSiteTag": { + "methods": [ + "get_global_site_tag" + ] + }, + "GetGoogleSignalsSettings": { + "methods": [ + "get_google_signals_settings" + ] + }, + "GetIosAppDataStream": { + "methods": [ + "get_ios_app_data_stream" + ] + }, + "GetMeasurementProtocolSecret": { + "methods": [ + "get_measurement_protocol_secret" + ] + }, + "GetProperty": { + "methods": [ + "get_property" + ] + }, + "GetUserLink": { + "methods": [ + "get_user_link" + ] + }, + "GetWebDataStream": { + "methods": [ + "get_web_data_stream" + ] + }, + "ListAccountSummaries": { + "methods": [ + "list_account_summaries" + ] + }, + "ListAccounts": { + "methods": [ + "list_accounts" + ] + }, + "ListAndroidAppDataStreams": { + "methods": [ + "list_android_app_data_streams" + ] + }, + "ListConversionEvents": { + "methods": [ + "list_conversion_events" + ] + }, + "ListCustomDimensions": { + "methods": [ + "list_custom_dimensions" + ] + }, + "ListCustomMetrics": { + "methods": [ + "list_custom_metrics" + ] + }, + "ListFirebaseLinks": { + "methods": [ + "list_firebase_links" + ] + }, + "ListGoogleAdsLinks": { + "methods": [ + "list_google_ads_links" + ] + }, + "ListIosAppDataStreams": { + "methods": [ + "list_ios_app_data_streams" + ] + }, + "ListMeasurementProtocolSecrets": { + "methods": [ + "list_measurement_protocol_secrets" + ] + }, + "ListProperties": { + "methods": [ + "list_properties" + ] + }, + "ListUserLinks": { + "methods": [ + "list_user_links" + ] + }, + "ListWebDataStreams": { + "methods": [ + "list_web_data_streams" + ] + }, + "ProvisionAccountTicket": { + "methods": [ + "provision_account_ticket" + ] + }, + "SearchChangeHistoryEvents": { + "methods": [ + "search_change_history_events" + ] + }, + "UpdateAccount": { + "methods": [ + "update_account" + ] + }, + "UpdateAndroidAppDataStream": { + "methods": [ + "update_android_app_data_stream" + ] + }, + "UpdateCustomDimension": { + "methods": [ + "update_custom_dimension" + ] + }, + "UpdateCustomMetric": { + "methods": [ + "update_custom_metric" + ] + }, + "UpdateEnhancedMeasurementSettings": { + "methods": [ + "update_enhanced_measurement_settings" + ] + }, + "UpdateFirebaseLink": { + "methods": [ + "update_firebase_link" + ] + }, + "UpdateGoogleAdsLink": { + "methods": [ + "update_google_ads_link" + ] + }, + "UpdateGoogleSignalsSettings": { + "methods": [ + "update_google_signals_settings" + ] + }, + "UpdateIosAppDataStream": { + "methods": [ + "update_ios_app_data_stream" + ] + }, + "UpdateMeasurementProtocolSecret": { + "methods": [ + "update_measurement_protocol_secret" + ] + }, + "UpdateProperty": { + "methods": [ + "update_property" + ] + }, + "UpdateUserLink": { + "methods": [ + "update_user_link" + ] + }, + "UpdateWebDataStream": { + "methods": [ + "update_web_data_stream" + ] + } + } + } + } + } + } +} 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..4de65971 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/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..4d8bff41 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from .client import 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..cc2c3af0 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py @@ -0,0 +1,5495 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.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 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # 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) + conversion_event_path = staticmethod(AnalyticsAdminServiceClient.conversion_event_path) + parse_conversion_event_path = staticmethod(AnalyticsAdminServiceClient.parse_conversion_event_path) + custom_dimension_path = staticmethod(AnalyticsAdminServiceClient.custom_dimension_path) + parse_custom_dimension_path = staticmethod(AnalyticsAdminServiceClient.parse_custom_dimension_path) + custom_metric_path = staticmethod(AnalyticsAdminServiceClient.custom_metric_path) + parse_custom_metric_path = staticmethod(AnalyticsAdminServiceClient.parse_custom_metric_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) + google_signals_settings_path = staticmethod(AnalyticsAdminServiceClient.google_signals_settings_path) + parse_google_signals_settings_path = staticmethod(AnalyticsAdminServiceClient.parse_google_signals_settings_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) + measurement_protocol_secret_path = staticmethod(AnalyticsAdminServiceClient.measurement_protocol_secret_path) + parse_measurement_protocol_secret_path = staticmethod(AnalyticsAdminServiceClient.parse_measurement_protocol_secret_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: + """Returns 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: ga_credentials.Credentials = None, + transport: Union[str, AnalyticsAdminServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates 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_pb2.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]] = (), + ) -> resources.Property: + 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. + + 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.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. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_property(self, + request: analytics_admin.UpdatePropertyRequest = None, + *, + property: resources.Property = None, + update_mask: field_mask_pb2.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_pb2.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_pb2.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 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_pb2.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 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_pb2.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_pb2.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_pb2.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 + + async def get_measurement_protocol_secret(self, + request: analytics_admin.GetMeasurementProtocolSecretRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Lookup for a single "GA4" MeasurementProtocolSecret. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetMeasurementProtocolSecretRequest`): + The request object. Request message for + GetMeasurementProtocolSecret RPC. + name (:class:`str`): + Required. The name of the measurement + protocol secret to lookup. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) + may be a parent. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity 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.GetMeasurementProtocolSecretRequest(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_measurement_protocol_secret, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_measurement_protocol_secrets(self, + request: analytics_admin.ListMeasurementProtocolSecretsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMeasurementProtocolSecretsAsyncPager: + r"""Returns child MeasurementProtocolSecrets under the + specified parent Property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest`): + The request object. Request message for + ListMeasurementProtocolSecret RPC + parent (:class:`str`): + Required. The resource name of the + parent stream. Any type of stream + (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets + + 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.ListMeasurementProtocolSecretsAsyncPager: + Response message for + ListMeasurementProtocolSecret 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.ListMeasurementProtocolSecretsRequest(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_measurement_protocol_secrets, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListMeasurementProtocolSecretsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_measurement_protocol_secret(self, + request: analytics_admin.CreateMeasurementProtocolSecretRequest = None, + *, + parent: str = None, + measurement_protocol_secret: resources.MeasurementProtocolSecret = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Creates a measurement protocol secret. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest`): + The request object. Request message for + CreateMeasurementProtocolSecret RPC + parent (:class:`str`): + Required. The parent resource where + this secret will be created. Any type of + stream (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream} + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + measurement_protocol_secret (:class:`google.analytics.admin_v1alpha.types.MeasurementProtocolSecret`): + Required. The measurement protocol + secret to create. + + This corresponds to the ``measurement_protocol_secret`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, measurement_protocol_secret]) + if request is 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.CreateMeasurementProtocolSecretRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if measurement_protocol_secret is not None: + request.measurement_protocol_secret = measurement_protocol_secret + + # 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_measurement_protocol_secret, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_measurement_protocol_secret(self, + request: analytics_admin.DeleteMeasurementProtocolSecretRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes target MeasurementProtocolSecret. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteMeasurementProtocolSecretRequest`): + The request object. Request message for + DeleteMeasurementProtocolSecret RPC + name (:class:`str`): + Required. The name of the + MeasurementProtocolSecret to delete. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) + may be a parent. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be 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.DeleteMeasurementProtocolSecretRequest(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_measurement_protocol_secret, + 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_measurement_protocol_secret(self, + request: analytics_admin.UpdateMeasurementProtocolSecretRequest = None, + *, + measurement_protocol_secret: resources.MeasurementProtocolSecret = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Updates a measurement protocol secret. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateMeasurementProtocolSecretRequest`): + The request object. Request message for + UpdateMeasurementProtocolSecret RPC + measurement_protocol_secret (:class:`google.analytics.admin_v1alpha.types.MeasurementProtocolSecret`): + Required. The measurement protocol + secret to update. + + This corresponds to the ``measurement_protocol_secret`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + Omitted fields will not be updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([measurement_protocol_secret, 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.UpdateMeasurementProtocolSecretRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if measurement_protocol_secret is not None: + request.measurement_protocol_secret = measurement_protocol_secret + 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_measurement_protocol_secret, + 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(( + ("measurement_protocol_secret.name", request.measurement_protocol_secret.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def search_change_history_events(self, + request: analytics_admin.SearchChangeHistoryEventsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.SearchChangeHistoryEventsAsyncPager: + r"""Searches through all changes to an account or its + children given the specified set of filters. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest`): + The request object. Request message for + SearchChangeHistoryEvents 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.SearchChangeHistoryEventsAsyncPager: + Response message for SearchAccounts + RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = analytics_admin.SearchChangeHistoryEventsRequest(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.search_change_history_events, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("account", request.account), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.SearchChangeHistoryEventsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_google_signals_settings(self, + request: analytics_admin.GetGoogleSignalsSettingsRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleSignalsSettings: + r"""Lookup for Google Signals settings for a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetGoogleSignalsSettingsRequest`): + The request object. Request message for + GetGoogleSignalsSettings RPC + name (:class:`str`): + Required. The name of the google + signals settings to retrieve. Format: + properties/{property}/googleSignalsSettings + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.GoogleSignalsSettings: + Settings values for Google Signals. + This is a singleton 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.GetGoogleSignalsSettingsRequest(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_google_signals_settings, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_google_signals_settings(self, + request: analytics_admin.UpdateGoogleSignalsSettingsRequest = None, + *, + google_signals_settings: resources.GoogleSignalsSettings = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleSignalsSettings: + r"""Updates Google Signals settings for a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateGoogleSignalsSettingsRequest`): + The request object. Request message for + UpdateGoogleSignalsSettings RPC + google_signals_settings (:class:`google.analytics.admin_v1alpha.types.GoogleSignalsSettings`): + Required. The settings to update. The ``name`` field is + used to identify the settings to be updated. + + This corresponds to the ``google_signals_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.GoogleSignalsSettings: + Settings values for Google Signals. + This is a singleton 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([google_signals_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.UpdateGoogleSignalsSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if google_signals_settings is not None: + request.google_signals_settings = google_signals_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_google_signals_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(( + ("google_signals_settings.name", request.google_signals_settings.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_conversion_event(self, + request: analytics_admin.CreateConversionEventRequest = None, + *, + parent: str = None, + conversion_event: resources.ConversionEvent = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ConversionEvent: + r"""Creates a conversion event with the specified + attributes. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateConversionEventRequest`): + The request object. Request message for + CreateConversionEvent RPC + parent (:class:`str`): + Required. The resource name of the + parent property where this conversion + event 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. + conversion_event (:class:`google.analytics.admin_v1alpha.types.ConversionEvent`): + Required. The conversion event to + create. + + This corresponds to the ``conversion_event`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.ConversionEvent: + A conversion event in a Google + Analytics 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([parent, conversion_event]) + if request is 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.CreateConversionEventRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if conversion_event is not None: + request.conversion_event = conversion_event + + # 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_conversion_event, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_conversion_event(self, + request: analytics_admin.GetConversionEventRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ConversionEvent: + r"""Retrieve a single conversion event. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetConversionEventRequest`): + The request object. Request message for + GetConversionEvent RPC + name (:class:`str`): + Required. The resource name of the conversion event to + retrieve. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/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.ConversionEvent: + A conversion event in a Google + Analytics 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.GetConversionEventRequest(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_conversion_event, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_conversion_event(self, + request: analytics_admin.DeleteConversionEventRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a conversion event in a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteConversionEventRequest`): + The request object. Request message for + DeleteConversionEvent RPC + name (:class:`str`): + Required. The resource name of the conversion event to + delete. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/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.DeleteConversionEventRequest(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_conversion_event, + 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 list_conversion_events(self, + request: analytics_admin.ListConversionEventsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConversionEventsAsyncPager: + r"""Returns a list of conversion events in the specified + parent property. + Returns an empty list if no conversion events are found. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListConversionEventsRequest`): + The request object. Request message for + ListConversionEvents RPC + parent (:class:`str`): + Required. The resource name of the + parent property. Example: + '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.ListConversionEventsAsyncPager: + Response message for + ListConversionEvents 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.ListConversionEventsRequest(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_conversion_events, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListConversionEventsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_custom_dimension(self, + request: analytics_admin.CreateCustomDimensionRequest = None, + *, + parent: str = None, + custom_dimension: resources.CustomDimension = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Creates a CustomDimension. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest`): + The request object. Request message for + CreateCustomDimension 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. + custom_dimension (:class:`google.analytics.admin_v1alpha.types.CustomDimension`): + Required. The CustomDimension to + create. + + This corresponds to the ``custom_dimension`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity 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, custom_dimension]) + if request is 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.CreateCustomDimensionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_dimension is not None: + request.custom_dimension = custom_dimension + + # 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_custom_dimension, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_custom_dimension(self, + request: analytics_admin.UpdateCustomDimensionRequest = None, + *, + custom_dimension: resources.CustomDimension = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Updates a CustomDimension on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateCustomDimensionRequest`): + The request object. Request message for + UpdateCustomDimension RPC. + custom_dimension (:class:`google.analytics.admin_v1alpha.types.CustomDimension`): + The CustomDimension to update + This corresponds to the ``custom_dimension`` 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. 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.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([custom_dimension, 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.UpdateCustomDimensionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if custom_dimension is not None: + request.custom_dimension = custom_dimension + 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_custom_dimension, + 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(( + ("custom_dimension.name", request.custom_dimension.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_custom_dimensions(self, + request: analytics_admin.ListCustomDimensionsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomDimensionsAsyncPager: + r"""Lists CustomDimensions on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest`): + The request object. Request message for + ListCustomDimensions 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.ListCustomDimensionsAsyncPager: + Response message for + ListCustomDimensions 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.ListCustomDimensionsRequest(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_custom_dimensions, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCustomDimensionsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def archive_custom_dimension(self, + request: analytics_admin.ArchiveCustomDimensionRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Archives a CustomDimension on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ArchiveCustomDimensionRequest`): + The request object. Request message for + ArchiveCustomDimension RPC. + name (:class:`str`): + Required. The name of the + CustomDimension to archive. Example + format: + properties/1234/customDimensions/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.ArchiveCustomDimensionRequest(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.archive_custom_dimension, + 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 get_custom_dimension(self, + request: analytics_admin.GetCustomDimensionRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Lookup for a single CustomDimension. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetCustomDimensionRequest`): + The request object. Request message for + GetCustomDimension RPC. + name (:class:`str`): + Required. The name of the + CustomDimension to get. Example format: + properties/1234/customDimensions/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.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity 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.GetCustomDimensionRequest(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_custom_dimension, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_custom_metric(self, + request: analytics_admin.CreateCustomMetricRequest = None, + *, + parent: str = None, + custom_metric: resources.CustomMetric = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Creates a CustomMetric. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateCustomMetricRequest`): + The request object. Request message for + CreateCustomMetric 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. + custom_metric (:class:`google.analytics.admin_v1alpha.types.CustomMetric`): + Required. The CustomMetric to create. + This corresponds to the ``custom_metric`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity 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, custom_metric]) + if request is 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.CreateCustomMetricRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_metric is not None: + request.custom_metric = custom_metric + + # 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_custom_metric, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_custom_metric(self, + request: analytics_admin.UpdateCustomMetricRequest = None, + *, + custom_metric: resources.CustomMetric = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Updates a CustomMetric on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateCustomMetricRequest`): + The request object. Request message for + UpdateCustomMetric RPC. + custom_metric (:class:`google.analytics.admin_v1alpha.types.CustomMetric`): + The CustomMetric to update + This corresponds to the ``custom_metric`` 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. 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.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([custom_metric, 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.UpdateCustomMetricRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if custom_metric is not None: + request.custom_metric = custom_metric + 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_custom_metric, + 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(( + ("custom_metric.name", request.custom_metric.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_custom_metrics(self, + request: analytics_admin.ListCustomMetricsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomMetricsAsyncPager: + r"""Lists CustomMetrics on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListCustomMetricsRequest`): + The request object. Request message for + ListCustomMetrics 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.ListCustomMetricsAsyncPager: + Response message for + ListCustomMetrics 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.ListCustomMetricsRequest(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_custom_metrics, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCustomMetricsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def archive_custom_metric(self, + request: analytics_admin.ArchiveCustomMetricRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Archives a CustomMetric on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ArchiveCustomMetricRequest`): + The request object. Request message for + ArchiveCustomMetric RPC. + name (:class:`str`): + Required. The name of the + CustomMetric to archive. Example format: + properties/1234/customMetrics/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.ArchiveCustomMetricRequest(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.archive_custom_metric, + 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 get_custom_metric(self, + request: analytics_admin.GetCustomMetricRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Lookup for a single CustomMetric. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetCustomMetricRequest`): + The request object. Request message for GetCustomMetric + RPC. + name (:class:`str`): + Required. The name of the + CustomMetric to get. Example format: + properties/1234/customMetrics/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.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity 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.GetCustomMetricRequest(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_custom_metric, + 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..0e73ca1e --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py @@ -0,0 +1,5840 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.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 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # 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]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta): + """Service Interface for the Analytics Admin API (GA4).""" + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "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: + """Returns 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: + """Returns a fully-qualified account string.""" + return "accounts/{account}".format(account=account, ) + + @staticmethod + def parse_account_path(path: str) -> Dict[str,str]: + """Parses 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: + """Returns 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]: + """Parses 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: + """Returns 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]: + """Parses 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 conversion_event_path(property: str,conversion_event: str,) -> str: + """Returns a fully-qualified conversion_event string.""" + return "properties/{property}/conversionEvents/{conversion_event}".format(property=property, conversion_event=conversion_event, ) + + @staticmethod + def parse_conversion_event_path(path: str) -> Dict[str,str]: + """Parses a conversion_event path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/conversionEvents/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def custom_dimension_path(property: str,) -> str: + """Returns a fully-qualified custom_dimension string.""" + return "properties/{property}/customDimensions".format(property=property, ) + + @staticmethod + def parse_custom_dimension_path(path: str) -> Dict[str,str]: + """Parses a custom_dimension path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/customDimensions$", path) + return m.groupdict() if m else {} + + @staticmethod + def custom_metric_path(property: str,) -> str: + """Returns a fully-qualified custom_metric string.""" + return "properties/{property}/customMetrics".format(property=property, ) + + @staticmethod + def parse_custom_metric_path(path: str) -> Dict[str,str]: + """Parses a custom_metric path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/customMetrics$", path) + return m.groupdict() if m else {} + + @staticmethod + def data_sharing_settings_path(account: str,) -> str: + """Returns 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]: + """Parses 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: + """Returns 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]: + """Parses 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: + """Returns 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]: + """Parses 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: + """Returns 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]: + """Parses 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: + """Returns 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]: + """Parses 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 google_signals_settings_path(property: str,) -> str: + """Returns a fully-qualified google_signals_settings string.""" + return "properties/{property}/googleSignalsSettings".format(property=property, ) + + @staticmethod + def parse_google_signals_settings_path(path: str) -> Dict[str,str]: + """Parses a google_signals_settings path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/googleSignalsSettings$", path) + return m.groupdict() if m else {} + + @staticmethod + def ios_app_data_stream_path(property: str,ios_app_data_stream: str,) -> str: + """Returns 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]: + """Parses 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 measurement_protocol_secret_path(property: str,web_data_stream: str,measurement_protocol_secret: str,) -> str: + """Returns a fully-qualified measurement_protocol_secret string.""" + return "properties/{property}/webDataStreams/{web_data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}".format(property=property, web_data_stream=web_data_stream, measurement_protocol_secret=measurement_protocol_secret, ) + + @staticmethod + def parse_measurement_protocol_secret_path(path: str) -> Dict[str,str]: + """Parses a measurement_protocol_secret path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/webDataStreams/(?P.+?)/measurementProtocolSecrets/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def property_path(property: str,) -> str: + """Returns a fully-qualified property string.""" + return "properties/{property}".format(property=property, ) + + @staticmethod + def parse_property_path(path: str) -> Dict[str,str]: + """Parses 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: + """Returns 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]: + """Parses 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: + """Returns 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]: + """Parses 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: + """Returns a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str, ) -> str: + """Returns a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format(project=project, location=location, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, AnalyticsAdminServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates 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() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, 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, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), + ) + + 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_pb2.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]] = (), + ) -> resources.Property: + 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. + + 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.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. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_property(self, + request: analytics_admin.UpdatePropertyRequest = None, + *, + property: resources.Property = None, + update_mask: field_mask_pb2.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_pb2.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_pb2.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 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_pb2.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 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_pb2.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_pb2.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_pb2.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 + + def get_measurement_protocol_secret(self, + request: analytics_admin.GetMeasurementProtocolSecretRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Lookup for a single "GA4" MeasurementProtocolSecret. + + Args: + request (google.analytics.admin_v1alpha.types.GetMeasurementProtocolSecretRequest): + The request object. Request message for + GetMeasurementProtocolSecret RPC. + name (str): + Required. The name of the measurement + protocol secret to lookup. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) + may be a parent. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity 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.GetMeasurementProtocolSecretRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetMeasurementProtocolSecretRequest): + request = analytics_admin.GetMeasurementProtocolSecretRequest(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_measurement_protocol_secret] + + # Certain fields should be 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_measurement_protocol_secrets(self, + request: analytics_admin.ListMeasurementProtocolSecretsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMeasurementProtocolSecretsPager: + r"""Returns child MeasurementProtocolSecrets under the + specified parent Property. + + Args: + request (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest): + The request object. Request message for + ListMeasurementProtocolSecret RPC + parent (str): + Required. The resource name of the + parent stream. Any type of stream + (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets + + 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.ListMeasurementProtocolSecretsPager: + Response message for + ListMeasurementProtocolSecret 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.ListMeasurementProtocolSecretsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListMeasurementProtocolSecretsRequest): + request = analytics_admin.ListMeasurementProtocolSecretsRequest(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_measurement_protocol_secrets] + + # 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.ListMeasurementProtocolSecretsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_measurement_protocol_secret(self, + request: analytics_admin.CreateMeasurementProtocolSecretRequest = None, + *, + parent: str = None, + measurement_protocol_secret: resources.MeasurementProtocolSecret = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Creates a measurement protocol secret. + + Args: + request (google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest): + The request object. Request message for + CreateMeasurementProtocolSecret RPC + parent (str): + Required. The parent resource where + this secret will be created. Any type of + stream (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream} + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + Required. The measurement protocol + secret to create. + + This corresponds to the ``measurement_protocol_secret`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, measurement_protocol_secret]) + if request is 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.CreateMeasurementProtocolSecretRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateMeasurementProtocolSecretRequest): + request = analytics_admin.CreateMeasurementProtocolSecretRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if measurement_protocol_secret is not None: + request.measurement_protocol_secret = measurement_protocol_secret + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_measurement_protocol_secret] + + # 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_measurement_protocol_secret(self, + request: analytics_admin.DeleteMeasurementProtocolSecretRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes target MeasurementProtocolSecret. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteMeasurementProtocolSecretRequest): + The request object. Request message for + DeleteMeasurementProtocolSecret RPC + name (str): + Required. The name of the + MeasurementProtocolSecret to delete. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) + may be a parent. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be 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.DeleteMeasurementProtocolSecretRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteMeasurementProtocolSecretRequest): + request = analytics_admin.DeleteMeasurementProtocolSecretRequest(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_measurement_protocol_secret] + + # Certain fields should be 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_measurement_protocol_secret(self, + request: analytics_admin.UpdateMeasurementProtocolSecretRequest = None, + *, + measurement_protocol_secret: resources.MeasurementProtocolSecret = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Updates a measurement protocol secret. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateMeasurementProtocolSecretRequest): + The request object. Request message for + UpdateMeasurementProtocolSecret RPC + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + Required. The measurement protocol + secret to update. + + This corresponds to the ``measurement_protocol_secret`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + Omitted fields will not be updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([measurement_protocol_secret, 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.UpdateMeasurementProtocolSecretRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateMeasurementProtocolSecretRequest): + request = analytics_admin.UpdateMeasurementProtocolSecretRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if measurement_protocol_secret is not None: + request.measurement_protocol_secret = measurement_protocol_secret + 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_measurement_protocol_secret] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("measurement_protocol_secret.name", request.measurement_protocol_secret.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def search_change_history_events(self, + request: analytics_admin.SearchChangeHistoryEventsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.SearchChangeHistoryEventsPager: + r"""Searches through all changes to an account or its + children given the specified set of filters. + + Args: + request (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest): + The request object. Request message for + SearchChangeHistoryEvents 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.SearchChangeHistoryEventsPager: + Response message for SearchAccounts + 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.SearchChangeHistoryEventsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.SearchChangeHistoryEventsRequest): + request = analytics_admin.SearchChangeHistoryEventsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.search_change_history_events] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("account", request.account), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.SearchChangeHistoryEventsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_google_signals_settings(self, + request: analytics_admin.GetGoogleSignalsSettingsRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleSignalsSettings: + r"""Lookup for Google Signals settings for a property. + + Args: + request (google.analytics.admin_v1alpha.types.GetGoogleSignalsSettingsRequest): + The request object. Request message for + GetGoogleSignalsSettings RPC + name (str): + Required. The name of the google + signals settings to retrieve. Format: + properties/{property}/googleSignalsSettings + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.GoogleSignalsSettings: + Settings values for Google Signals. + This is a singleton 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.GetGoogleSignalsSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetGoogleSignalsSettingsRequest): + request = analytics_admin.GetGoogleSignalsSettingsRequest(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_google_signals_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_google_signals_settings(self, + request: analytics_admin.UpdateGoogleSignalsSettingsRequest = None, + *, + google_signals_settings: resources.GoogleSignalsSettings = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleSignalsSettings: + r"""Updates Google Signals settings for a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateGoogleSignalsSettingsRequest): + The request object. Request message for + UpdateGoogleSignalsSettings RPC + google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): + Required. The settings to update. The ``name`` field is + used to identify the settings to be updated. + + This corresponds to the ``google_signals_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.GoogleSignalsSettings: + Settings values for Google Signals. + This is a singleton 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([google_signals_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.UpdateGoogleSignalsSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateGoogleSignalsSettingsRequest): + request = analytics_admin.UpdateGoogleSignalsSettingsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if google_signals_settings is not None: + request.google_signals_settings = google_signals_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_google_signals_settings] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("google_signals_settings.name", request.google_signals_settings.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_conversion_event(self, + request: analytics_admin.CreateConversionEventRequest = None, + *, + parent: str = None, + conversion_event: resources.ConversionEvent = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ConversionEvent: + r"""Creates a conversion event with the specified + attributes. + + Args: + request (google.analytics.admin_v1alpha.types.CreateConversionEventRequest): + The request object. Request message for + CreateConversionEvent RPC + parent (str): + Required. The resource name of the + parent property where this conversion + event 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. + conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): + Required. The conversion event to + create. + + This corresponds to the ``conversion_event`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.ConversionEvent: + A conversion event in a Google + Analytics 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([parent, conversion_event]) + if request is 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.CreateConversionEventRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateConversionEventRequest): + request = analytics_admin.CreateConversionEventRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if conversion_event is not None: + request.conversion_event = conversion_event + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_conversion_event] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_conversion_event(self, + request: analytics_admin.GetConversionEventRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ConversionEvent: + r"""Retrieve a single conversion event. + + Args: + request (google.analytics.admin_v1alpha.types.GetConversionEventRequest): + The request object. Request message for + GetConversionEvent RPC + name (str): + Required. The resource name of the conversion event to + retrieve. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/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.ConversionEvent: + A conversion event in a Google + Analytics 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.GetConversionEventRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetConversionEventRequest): + request = analytics_admin.GetConversionEventRequest(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_conversion_event] + + # Certain fields should be 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_conversion_event(self, + request: analytics_admin.DeleteConversionEventRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a conversion event in a property. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteConversionEventRequest): + The request object. Request message for + DeleteConversionEvent RPC + name (str): + Required. The resource name of the conversion event to + delete. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/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.DeleteConversionEventRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteConversionEventRequest): + request = analytics_admin.DeleteConversionEventRequest(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_conversion_event] + + # Certain fields should be 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_conversion_events(self, + request: analytics_admin.ListConversionEventsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConversionEventsPager: + r"""Returns a list of conversion events in the specified + parent property. + Returns an empty list if no conversion events are found. + + Args: + request (google.analytics.admin_v1alpha.types.ListConversionEventsRequest): + The request object. Request message for + ListConversionEvents RPC + parent (str): + Required. The resource name of the + parent property. Example: + '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.ListConversionEventsPager: + Response message for + ListConversionEvents 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.ListConversionEventsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListConversionEventsRequest): + request = analytics_admin.ListConversionEventsRequest(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_conversion_events] + + # 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.ListConversionEventsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_custom_dimension(self, + request: analytics_admin.CreateCustomDimensionRequest = None, + *, + parent: str = None, + custom_dimension: resources.CustomDimension = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Creates a CustomDimension. + + Args: + request (google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest): + The request object. Request message for + CreateCustomDimension 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. + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + Required. The CustomDimension to + create. + + This corresponds to the ``custom_dimension`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity 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, custom_dimension]) + if request is 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.CreateCustomDimensionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateCustomDimensionRequest): + request = analytics_admin.CreateCustomDimensionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_dimension is not None: + request.custom_dimension = custom_dimension + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_custom_dimension] + + # 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_custom_dimension(self, + request: analytics_admin.UpdateCustomDimensionRequest = None, + *, + custom_dimension: resources.CustomDimension = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Updates a CustomDimension on a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateCustomDimensionRequest): + The request object. Request message for + UpdateCustomDimension RPC. + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + The CustomDimension to update + This corresponds to the ``custom_dimension`` 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. 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.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([custom_dimension, 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.UpdateCustomDimensionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateCustomDimensionRequest): + request = analytics_admin.UpdateCustomDimensionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if custom_dimension is not None: + request.custom_dimension = custom_dimension + 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_custom_dimension] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("custom_dimension.name", request.custom_dimension.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_custom_dimensions(self, + request: analytics_admin.ListCustomDimensionsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomDimensionsPager: + r"""Lists CustomDimensions on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest): + The request object. Request message for + ListCustomDimensions 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.ListCustomDimensionsPager: + Response message for + ListCustomDimensions 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.ListCustomDimensionsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListCustomDimensionsRequest): + request = analytics_admin.ListCustomDimensionsRequest(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_custom_dimensions] + + # 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.ListCustomDimensionsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def archive_custom_dimension(self, + request: analytics_admin.ArchiveCustomDimensionRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Archives a CustomDimension on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ArchiveCustomDimensionRequest): + The request object. Request message for + ArchiveCustomDimension RPC. + name (str): + Required. The name of the + CustomDimension to archive. Example + format: + properties/1234/customDimensions/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.ArchiveCustomDimensionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ArchiveCustomDimensionRequest): + request = analytics_admin.ArchiveCustomDimensionRequest(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.archive_custom_dimension] + + # Certain fields should be 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 get_custom_dimension(self, + request: analytics_admin.GetCustomDimensionRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Lookup for a single CustomDimension. + + Args: + request (google.analytics.admin_v1alpha.types.GetCustomDimensionRequest): + The request object. Request message for + GetCustomDimension RPC. + name (str): + Required. The name of the + CustomDimension to get. Example format: + properties/1234/customDimensions/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.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity 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.GetCustomDimensionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetCustomDimensionRequest): + request = analytics_admin.GetCustomDimensionRequest(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_custom_dimension] + + # Certain fields should be 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_custom_metric(self, + request: analytics_admin.CreateCustomMetricRequest = None, + *, + parent: str = None, + custom_metric: resources.CustomMetric = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Creates a CustomMetric. + + Args: + request (google.analytics.admin_v1alpha.types.CreateCustomMetricRequest): + The request object. Request message for + CreateCustomMetric 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. + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + Required. The CustomMetric to create. + This corresponds to the ``custom_metric`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity 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, custom_metric]) + if request is 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.CreateCustomMetricRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateCustomMetricRequest): + request = analytics_admin.CreateCustomMetricRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_metric is not None: + request.custom_metric = custom_metric + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_custom_metric] + + # 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_custom_metric(self, + request: analytics_admin.UpdateCustomMetricRequest = None, + *, + custom_metric: resources.CustomMetric = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Updates a CustomMetric on a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateCustomMetricRequest): + The request object. Request message for + UpdateCustomMetric RPC. + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + The CustomMetric to update + This corresponds to the ``custom_metric`` 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. 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.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([custom_metric, 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.UpdateCustomMetricRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateCustomMetricRequest): + request = analytics_admin.UpdateCustomMetricRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if custom_metric is not None: + request.custom_metric = custom_metric + 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_custom_metric] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("custom_metric.name", request.custom_metric.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_custom_metrics(self, + request: analytics_admin.ListCustomMetricsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomMetricsPager: + r"""Lists CustomMetrics on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ListCustomMetricsRequest): + The request object. Request message for + ListCustomMetrics 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.ListCustomMetricsPager: + Response message for + ListCustomMetrics 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.ListCustomMetricsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListCustomMetricsRequest): + request = analytics_admin.ListCustomMetricsRequest(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_custom_metrics] + + # 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.ListCustomMetricsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def archive_custom_metric(self, + request: analytics_admin.ArchiveCustomMetricRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Archives a CustomMetric on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ArchiveCustomMetricRequest): + The request object. Request message for + ArchiveCustomMetric RPC. + name (str): + Required. The name of the + CustomMetric to archive. Example format: + properties/1234/customMetrics/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.ArchiveCustomMetricRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ArchiveCustomMetricRequest): + request = analytics_admin.ArchiveCustomMetricRequest(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.archive_custom_metric] + + # Certain fields should be 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 get_custom_metric(self, + request: analytics_admin.GetCustomMetricRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Lookup for a single CustomMetric. + + Args: + request (google.analytics.admin_v1alpha.types.GetCustomMetricRequest): + The request object. Request message for GetCustomMetric + RPC. + name (str): + Required. The name of the + CustomMetric to get. Example format: + properties/1234/customMetrics/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.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity 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.GetCustomMetricRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetCustomMetricRequest): + request = analytics_admin.GetCustomMetricRequest(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_custom_metric] + + # Certain fields should be 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..9dbd5071 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py @@ -0,0 +1,1849 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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]] = ()): + """Instantiates 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) + + +class ListMeasurementProtocolSecretsPager: + """A pager for iterating through ``list_measurement_protocol_secrets`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``measurement_protocol_secrets`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListMeasurementProtocolSecrets`` requests and continue to iterate + through the ``measurement_protocol_secrets`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` + 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.ListMeasurementProtocolSecretsResponse], + request: analytics_admin.ListMeasurementProtocolSecretsRequest, + response: analytics_admin.ListMeasurementProtocolSecretsResponse, + *, + 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.ListMeasurementProtocolSecretsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse): + 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.ListMeasurementProtocolSecretsRequest(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.ListMeasurementProtocolSecretsResponse]: + 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.MeasurementProtocolSecret]: + for page in self.pages: + yield from page.measurement_protocol_secrets + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListMeasurementProtocolSecretsAsyncPager: + """A pager for iterating through ``list_measurement_protocol_secrets`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``measurement_protocol_secrets`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListMeasurementProtocolSecrets`` requests and continue to iterate + through the ``measurement_protocol_secrets`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` + 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.ListMeasurementProtocolSecretsResponse]], + request: analytics_admin.ListMeasurementProtocolSecretsRequest, + response: analytics_admin.ListMeasurementProtocolSecretsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse): + 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.ListMeasurementProtocolSecretsRequest(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.ListMeasurementProtocolSecretsResponse]: + 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.MeasurementProtocolSecret]: + async def async_generator(): + async for page in self.pages: + for response in page.measurement_protocol_secrets: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class SearchChangeHistoryEventsPager: + """A pager for iterating through ``search_change_history_events`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``change_history_events`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``SearchChangeHistoryEvents`` requests and continue to iterate + through the ``change_history_events`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` + 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.SearchChangeHistoryEventsResponse], + request: analytics_admin.SearchChangeHistoryEventsRequest, + response: analytics_admin.SearchChangeHistoryEventsResponse, + *, + 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.SearchChangeHistoryEventsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse): + 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.SearchChangeHistoryEventsRequest(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.SearchChangeHistoryEventsResponse]: + 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.ChangeHistoryEvent]: + for page in self.pages: + yield from page.change_history_events + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class SearchChangeHistoryEventsAsyncPager: + """A pager for iterating through ``search_change_history_events`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``change_history_events`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``SearchChangeHistoryEvents`` requests and continue to iterate + through the ``change_history_events`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` + 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.SearchChangeHistoryEventsResponse]], + request: analytics_admin.SearchChangeHistoryEventsRequest, + response: analytics_admin.SearchChangeHistoryEventsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse): + 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.SearchChangeHistoryEventsRequest(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.SearchChangeHistoryEventsResponse]: + 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.ChangeHistoryEvent]: + async def async_generator(): + async for page in self.pages: + for response in page.change_history_events: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListConversionEventsPager: + """A pager for iterating through ``list_conversion_events`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``conversion_events`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListConversionEvents`` requests and continue to iterate + through the ``conversion_events`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` + 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.ListConversionEventsResponse], + request: analytics_admin.ListConversionEventsRequest, + response: analytics_admin.ListConversionEventsResponse, + *, + 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.ListConversionEventsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListConversionEventsResponse): + 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.ListConversionEventsRequest(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.ListConversionEventsResponse]: + 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.ConversionEvent]: + for page in self.pages: + yield from page.conversion_events + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListConversionEventsAsyncPager: + """A pager for iterating through ``list_conversion_events`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``conversion_events`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListConversionEvents`` requests and continue to iterate + through the ``conversion_events`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` + 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.ListConversionEventsResponse]], + request: analytics_admin.ListConversionEventsRequest, + response: analytics_admin.ListConversionEventsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListConversionEventsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListConversionEventsResponse): + 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.ListConversionEventsRequest(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.ListConversionEventsResponse]: + 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.ConversionEvent]: + async def async_generator(): + async for page in self.pages: + for response in page.conversion_events: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCustomDimensionsPager: + """A pager for iterating through ``list_custom_dimensions`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``custom_dimensions`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCustomDimensions`` requests and continue to iterate + through the ``custom_dimensions`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` + 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.ListCustomDimensionsResponse], + request: analytics_admin.ListCustomDimensionsRequest, + response: analytics_admin.ListCustomDimensionsResponse, + *, + 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.ListCustomDimensionsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse): + 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.ListCustomDimensionsRequest(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.ListCustomDimensionsResponse]: + 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.CustomDimension]: + for page in self.pages: + yield from page.custom_dimensions + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCustomDimensionsAsyncPager: + """A pager for iterating through ``list_custom_dimensions`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``custom_dimensions`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCustomDimensions`` requests and continue to iterate + through the ``custom_dimensions`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` + 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.ListCustomDimensionsResponse]], + request: analytics_admin.ListCustomDimensionsRequest, + response: analytics_admin.ListCustomDimensionsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse): + 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.ListCustomDimensionsRequest(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.ListCustomDimensionsResponse]: + 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.CustomDimension]: + async def async_generator(): + async for page in self.pages: + for response in page.custom_dimensions: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCustomMetricsPager: + """A pager for iterating through ``list_custom_metrics`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``custom_metrics`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCustomMetrics`` requests and continue to iterate + through the ``custom_metrics`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` + 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.ListCustomMetricsResponse], + request: analytics_admin.ListCustomMetricsRequest, + response: analytics_admin.ListCustomMetricsResponse, + *, + 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.ListCustomMetricsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListCustomMetricsResponse): + 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.ListCustomMetricsRequest(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.ListCustomMetricsResponse]: + 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.CustomMetric]: + for page in self.pages: + yield from page.custom_metrics + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCustomMetricsAsyncPager: + """A pager for iterating through ``list_custom_metrics`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``custom_metrics`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCustomMetrics`` requests and continue to iterate + through the ``custom_metrics`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` + 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.ListCustomMetricsResponse]], + request: analytics_admin.ListCustomMetricsRequest, + response: analytics_admin.ListCustomMetricsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListCustomMetricsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListCustomMetricsResponse): + 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.ListCustomMetricsRequest(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.ListCustomMetricsResponse]: + 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.CustomMetric]: + async def async_generator(): + async for page in self.pages: + for response in page.custom_metrics: + 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..0ed7784f --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from typing import Dict, Type + +from .base import 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..9a92228f --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py @@ -0,0 +1,1111 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # 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 # 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() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + + +class 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', + ) + + DEFAULT_HOST: str = 'analyticsadmin.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ':' not in host: + host += ':443' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + + # If the credentials is service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): This method is in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-auth is increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.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.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.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, + ), + self.get_measurement_protocol_secret: gapic_v1.method.wrap_method( + self.get_measurement_protocol_secret, + default_timeout=None, + client_info=client_info, + ), + self.list_measurement_protocol_secrets: gapic_v1.method.wrap_method( + self.list_measurement_protocol_secrets, + default_timeout=None, + client_info=client_info, + ), + self.create_measurement_protocol_secret: gapic_v1.method.wrap_method( + self.create_measurement_protocol_secret, + default_timeout=None, + client_info=client_info, + ), + self.delete_measurement_protocol_secret: gapic_v1.method.wrap_method( + self.delete_measurement_protocol_secret, + default_timeout=None, + client_info=client_info, + ), + self.update_measurement_protocol_secret: gapic_v1.method.wrap_method( + self.update_measurement_protocol_secret, + default_timeout=None, + client_info=client_info, + ), + self.search_change_history_events: gapic_v1.method.wrap_method( + self.search_change_history_events, + default_timeout=None, + client_info=client_info, + ), + self.get_google_signals_settings: gapic_v1.method.wrap_method( + self.get_google_signals_settings, + default_timeout=None, + client_info=client_info, + ), + self.update_google_signals_settings: gapic_v1.method.wrap_method( + self.update_google_signals_settings, + default_timeout=None, + client_info=client_info, + ), + self.create_conversion_event: gapic_v1.method.wrap_method( + self.create_conversion_event, + default_timeout=None, + client_info=client_info, + ), + self.get_conversion_event: gapic_v1.method.wrap_method( + self.get_conversion_event, + default_timeout=None, + client_info=client_info, + ), + self.delete_conversion_event: gapic_v1.method.wrap_method( + self.delete_conversion_event, + default_timeout=None, + client_info=client_info, + ), + self.list_conversion_events: gapic_v1.method.wrap_method( + self.list_conversion_events, + default_timeout=None, + client_info=client_info, + ), + self.create_custom_dimension: gapic_v1.method.wrap_method( + self.create_custom_dimension, + default_timeout=None, + client_info=client_info, + ), + self.update_custom_dimension: gapic_v1.method.wrap_method( + self.update_custom_dimension, + default_timeout=None, + client_info=client_info, + ), + self.list_custom_dimensions: gapic_v1.method.wrap_method( + self.list_custom_dimensions, + default_timeout=None, + client_info=client_info, + ), + self.archive_custom_dimension: gapic_v1.method.wrap_method( + self.archive_custom_dimension, + default_timeout=None, + client_info=client_info, + ), + self.get_custom_dimension: gapic_v1.method.wrap_method( + self.get_custom_dimension, + default_timeout=None, + client_info=client_info, + ), + self.create_custom_metric: gapic_v1.method.wrap_method( + self.create_custom_metric, + default_timeout=None, + client_info=client_info, + ), + self.update_custom_metric: gapic_v1.method.wrap_method( + self.update_custom_metric, + default_timeout=None, + client_info=client_info, + ), + self.list_custom_metrics: gapic_v1.method.wrap_method( + self.list_custom_metrics, + default_timeout=None, + client_info=client_info, + ), + self.archive_custom_metric: gapic_v1.method.wrap_method( + self.archive_custom_metric, + default_timeout=None, + client_info=client_info, + ), + self.get_custom_metric: gapic_v1.method.wrap_method( + self.get_custom_metric, + default_timeout=None, + client_info=client_info, + ), + } + + @property + def get_account(self) -> Callable[ + [analytics_admin.GetAccountRequest], + Union[ + resources.Account, + Awaitable[resources.Account] + ]]: + raise NotImplementedError() + + @property + def list_accounts(self) -> Callable[ + [analytics_admin.ListAccountsRequest], + Union[ + analytics_admin.ListAccountsResponse, + Awaitable[analytics_admin.ListAccountsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_account(self) -> Callable[ + [analytics_admin.DeleteAccountRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def update_account(self) -> Callable[ + [analytics_admin.UpdateAccountRequest], + Union[ + resources.Account, + Awaitable[resources.Account] + ]]: + raise NotImplementedError() + + @property + def provision_account_ticket(self) -> Callable[ + [analytics_admin.ProvisionAccountTicketRequest], + Union[ + analytics_admin.ProvisionAccountTicketResponse, + Awaitable[analytics_admin.ProvisionAccountTicketResponse] + ]]: + raise NotImplementedError() + + @property + def list_account_summaries(self) -> Callable[ + [analytics_admin.ListAccountSummariesRequest], + Union[ + analytics_admin.ListAccountSummariesResponse, + Awaitable[analytics_admin.ListAccountSummariesResponse] + ]]: + raise NotImplementedError() + + @property + def get_property(self) -> Callable[ + [analytics_admin.GetPropertyRequest], + Union[ + resources.Property, + Awaitable[resources.Property] + ]]: + raise NotImplementedError() + + @property + def list_properties(self) -> Callable[ + [analytics_admin.ListPropertiesRequest], + Union[ + analytics_admin.ListPropertiesResponse, + Awaitable[analytics_admin.ListPropertiesResponse] + ]]: + raise NotImplementedError() + + @property + def create_property(self) -> Callable[ + [analytics_admin.CreatePropertyRequest], + Union[ + resources.Property, + Awaitable[resources.Property] + ]]: + raise NotImplementedError() + + @property + def delete_property(self) -> Callable[ + [analytics_admin.DeletePropertyRequest], + Union[ + resources.Property, + Awaitable[resources.Property] + ]]: + raise NotImplementedError() + + @property + def update_property(self) -> Callable[ + [analytics_admin.UpdatePropertyRequest], + Union[ + resources.Property, + Awaitable[resources.Property] + ]]: + raise NotImplementedError() + + @property + def get_user_link(self) -> Callable[ + [analytics_admin.GetUserLinkRequest], + Union[ + resources.UserLink, + Awaitable[resources.UserLink] + ]]: + raise NotImplementedError() + + @property + def batch_get_user_links(self) -> Callable[ + [analytics_admin.BatchGetUserLinksRequest], + Union[ + analytics_admin.BatchGetUserLinksResponse, + Awaitable[analytics_admin.BatchGetUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def list_user_links(self) -> Callable[ + [analytics_admin.ListUserLinksRequest], + Union[ + analytics_admin.ListUserLinksResponse, + Awaitable[analytics_admin.ListUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def audit_user_links(self) -> Callable[ + [analytics_admin.AuditUserLinksRequest], + Union[ + analytics_admin.AuditUserLinksResponse, + Awaitable[analytics_admin.AuditUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def create_user_link(self) -> Callable[ + [analytics_admin.CreateUserLinkRequest], + Union[ + resources.UserLink, + Awaitable[resources.UserLink] + ]]: + raise NotImplementedError() + + @property + def batch_create_user_links(self) -> Callable[ + [analytics_admin.BatchCreateUserLinksRequest], + Union[ + analytics_admin.BatchCreateUserLinksResponse, + Awaitable[analytics_admin.BatchCreateUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def update_user_link(self) -> Callable[ + [analytics_admin.UpdateUserLinkRequest], + Union[ + resources.UserLink, + Awaitable[resources.UserLink] + ]]: + raise NotImplementedError() + + @property + def batch_update_user_links(self) -> Callable[ + [analytics_admin.BatchUpdateUserLinksRequest], + Union[ + analytics_admin.BatchUpdateUserLinksResponse, + Awaitable[analytics_admin.BatchUpdateUserLinksResponse] + ]]: + raise NotImplementedError() + + @property + def delete_user_link(self) -> Callable[ + [analytics_admin.DeleteUserLinkRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def batch_delete_user_links(self) -> Callable[ + [analytics_admin.BatchDeleteUserLinksRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def get_web_data_stream(self) -> Callable[ + [analytics_admin.GetWebDataStreamRequest], + Union[ + resources.WebDataStream, + Awaitable[resources.WebDataStream] + ]]: + raise NotImplementedError() + + @property + def delete_web_data_stream(self) -> Callable[ + [analytics_admin.DeleteWebDataStreamRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def update_web_data_stream(self) -> Callable[ + [analytics_admin.UpdateWebDataStreamRequest], + Union[ + resources.WebDataStream, + Awaitable[resources.WebDataStream] + ]]: + raise NotImplementedError() + + @property + def create_web_data_stream(self) -> Callable[ + [analytics_admin.CreateWebDataStreamRequest], + Union[ + resources.WebDataStream, + Awaitable[resources.WebDataStream] + ]]: + raise NotImplementedError() + + @property + def list_web_data_streams(self) -> Callable[ + [analytics_admin.ListWebDataStreamsRequest], + Union[ + analytics_admin.ListWebDataStreamsResponse, + Awaitable[analytics_admin.ListWebDataStreamsResponse] + ]]: + raise NotImplementedError() + + @property + def get_ios_app_data_stream(self) -> Callable[ + [analytics_admin.GetIosAppDataStreamRequest], + Union[ + resources.IosAppDataStream, + Awaitable[resources.IosAppDataStream] + ]]: + raise NotImplementedError() + + @property + def delete_ios_app_data_stream(self) -> Callable[ + [analytics_admin.DeleteIosAppDataStreamRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def update_ios_app_data_stream(self) -> Callable[ + [analytics_admin.UpdateIosAppDataStreamRequest], + Union[ + resources.IosAppDataStream, + Awaitable[resources.IosAppDataStream] + ]]: + raise NotImplementedError() + + @property + def list_ios_app_data_streams(self) -> Callable[ + [analytics_admin.ListIosAppDataStreamsRequest], + Union[ + analytics_admin.ListIosAppDataStreamsResponse, + Awaitable[analytics_admin.ListIosAppDataStreamsResponse] + ]]: + raise NotImplementedError() + + @property + def get_android_app_data_stream(self) -> Callable[ + [analytics_admin.GetAndroidAppDataStreamRequest], + Union[ + resources.AndroidAppDataStream, + Awaitable[resources.AndroidAppDataStream] + ]]: + raise NotImplementedError() + + @property + def delete_android_app_data_stream(self) -> Callable[ + [analytics_admin.DeleteAndroidAppDataStreamRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def update_android_app_data_stream(self) -> Callable[ + [analytics_admin.UpdateAndroidAppDataStreamRequest], + Union[ + resources.AndroidAppDataStream, + Awaitable[resources.AndroidAppDataStream] + ]]: + raise NotImplementedError() + + @property + def list_android_app_data_streams(self) -> Callable[ + [analytics_admin.ListAndroidAppDataStreamsRequest], + Union[ + analytics_admin.ListAndroidAppDataStreamsResponse, + Awaitable[analytics_admin.ListAndroidAppDataStreamsResponse] + ]]: + raise NotImplementedError() + + @property + def get_enhanced_measurement_settings(self) -> Callable[ + [analytics_admin.GetEnhancedMeasurementSettingsRequest], + Union[ + resources.EnhancedMeasurementSettings, + Awaitable[resources.EnhancedMeasurementSettings] + ]]: + raise NotImplementedError() + + @property + def update_enhanced_measurement_settings(self) -> Callable[ + [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], + Union[ + resources.EnhancedMeasurementSettings, + Awaitable[resources.EnhancedMeasurementSettings] + ]]: + raise NotImplementedError() + + @property + def create_firebase_link(self) -> Callable[ + [analytics_admin.CreateFirebaseLinkRequest], + Union[ + resources.FirebaseLink, + Awaitable[resources.FirebaseLink] + ]]: + raise NotImplementedError() + + @property + def update_firebase_link(self) -> Callable[ + [analytics_admin.UpdateFirebaseLinkRequest], + Union[ + resources.FirebaseLink, + Awaitable[resources.FirebaseLink] + ]]: + raise NotImplementedError() + + @property + def delete_firebase_link(self) -> Callable[ + [analytics_admin.DeleteFirebaseLinkRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_firebase_links(self) -> Callable[ + [analytics_admin.ListFirebaseLinksRequest], + Union[ + analytics_admin.ListFirebaseLinksResponse, + Awaitable[analytics_admin.ListFirebaseLinksResponse] + ]]: + raise NotImplementedError() + + @property + def get_global_site_tag(self) -> Callable[ + [analytics_admin.GetGlobalSiteTagRequest], + Union[ + resources.GlobalSiteTag, + Awaitable[resources.GlobalSiteTag] + ]]: + raise NotImplementedError() + + @property + def create_google_ads_link(self) -> Callable[ + [analytics_admin.CreateGoogleAdsLinkRequest], + Union[ + resources.GoogleAdsLink, + Awaitable[resources.GoogleAdsLink] + ]]: + raise NotImplementedError() + + @property + def update_google_ads_link(self) -> Callable[ + [analytics_admin.UpdateGoogleAdsLinkRequest], + Union[ + resources.GoogleAdsLink, + Awaitable[resources.GoogleAdsLink] + ]]: + raise NotImplementedError() + + @property + def delete_google_ads_link(self) -> Callable[ + [analytics_admin.DeleteGoogleAdsLinkRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_google_ads_links(self) -> Callable[ + [analytics_admin.ListGoogleAdsLinksRequest], + Union[ + analytics_admin.ListGoogleAdsLinksResponse, + Awaitable[analytics_admin.ListGoogleAdsLinksResponse] + ]]: + raise NotImplementedError() + + @property + def get_data_sharing_settings(self) -> Callable[ + [analytics_admin.GetDataSharingSettingsRequest], + Union[ + resources.DataSharingSettings, + Awaitable[resources.DataSharingSettings] + ]]: + raise NotImplementedError() + + @property + def get_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.GetMeasurementProtocolSecretRequest], + Union[ + resources.MeasurementProtocolSecret, + Awaitable[resources.MeasurementProtocolSecret] + ]]: + raise NotImplementedError() + + @property + def list_measurement_protocol_secrets(self) -> Callable[ + [analytics_admin.ListMeasurementProtocolSecretsRequest], + Union[ + analytics_admin.ListMeasurementProtocolSecretsResponse, + Awaitable[analytics_admin.ListMeasurementProtocolSecretsResponse] + ]]: + raise NotImplementedError() + + @property + def create_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.CreateMeasurementProtocolSecretRequest], + Union[ + resources.MeasurementProtocolSecret, + Awaitable[resources.MeasurementProtocolSecret] + ]]: + raise NotImplementedError() + + @property + def delete_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.DeleteMeasurementProtocolSecretRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def update_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.UpdateMeasurementProtocolSecretRequest], + Union[ + resources.MeasurementProtocolSecret, + Awaitable[resources.MeasurementProtocolSecret] + ]]: + raise NotImplementedError() + + @property + def search_change_history_events(self) -> Callable[ + [analytics_admin.SearchChangeHistoryEventsRequest], + Union[ + analytics_admin.SearchChangeHistoryEventsResponse, + Awaitable[analytics_admin.SearchChangeHistoryEventsResponse] + ]]: + raise NotImplementedError() + + @property + def get_google_signals_settings(self) -> Callable[ + [analytics_admin.GetGoogleSignalsSettingsRequest], + Union[ + resources.GoogleSignalsSettings, + Awaitable[resources.GoogleSignalsSettings] + ]]: + raise NotImplementedError() + + @property + def update_google_signals_settings(self) -> Callable[ + [analytics_admin.UpdateGoogleSignalsSettingsRequest], + Union[ + resources.GoogleSignalsSettings, + Awaitable[resources.GoogleSignalsSettings] + ]]: + raise NotImplementedError() + + @property + def create_conversion_event(self) -> Callable[ + [analytics_admin.CreateConversionEventRequest], + Union[ + resources.ConversionEvent, + Awaitable[resources.ConversionEvent] + ]]: + raise NotImplementedError() + + @property + def get_conversion_event(self) -> Callable[ + [analytics_admin.GetConversionEventRequest], + Union[ + resources.ConversionEvent, + Awaitable[resources.ConversionEvent] + ]]: + raise NotImplementedError() + + @property + def delete_conversion_event(self) -> Callable[ + [analytics_admin.DeleteConversionEventRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_conversion_events(self) -> Callable[ + [analytics_admin.ListConversionEventsRequest], + Union[ + analytics_admin.ListConversionEventsResponse, + Awaitable[analytics_admin.ListConversionEventsResponse] + ]]: + raise NotImplementedError() + + @property + def create_custom_dimension(self) -> Callable[ + [analytics_admin.CreateCustomDimensionRequest], + Union[ + resources.CustomDimension, + Awaitable[resources.CustomDimension] + ]]: + raise NotImplementedError() + + @property + def update_custom_dimension(self) -> Callable[ + [analytics_admin.UpdateCustomDimensionRequest], + Union[ + resources.CustomDimension, + Awaitable[resources.CustomDimension] + ]]: + raise NotImplementedError() + + @property + def list_custom_dimensions(self) -> Callable[ + [analytics_admin.ListCustomDimensionsRequest], + Union[ + analytics_admin.ListCustomDimensionsResponse, + Awaitable[analytics_admin.ListCustomDimensionsResponse] + ]]: + raise NotImplementedError() + + @property + def archive_custom_dimension(self) -> Callable[ + [analytics_admin.ArchiveCustomDimensionRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def get_custom_dimension(self) -> Callable[ + [analytics_admin.GetCustomDimensionRequest], + Union[ + resources.CustomDimension, + Awaitable[resources.CustomDimension] + ]]: + raise NotImplementedError() + + @property + def create_custom_metric(self) -> Callable[ + [analytics_admin.CreateCustomMetricRequest], + Union[ + resources.CustomMetric, + Awaitable[resources.CustomMetric] + ]]: + raise NotImplementedError() + + @property + def update_custom_metric(self) -> Callable[ + [analytics_admin.UpdateCustomMetricRequest], + Union[ + resources.CustomMetric, + Awaitable[resources.CustomMetric] + ]]: + raise NotImplementedError() + + @property + def list_custom_metrics(self) -> Callable[ + [analytics_admin.ListCustomMetricsRequest], + Union[ + analytics_admin.ListCustomMetricsResponse, + Awaitable[analytics_admin.ListCustomMetricsResponse] + ]]: + raise NotImplementedError() + + @property + def archive_custom_metric(self) -> Callable[ + [analytics_admin.ArchiveCustomMetricRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def get_custom_metric(self) -> Callable[ + [analytics_admin.GetCustomMetricRequest], + Union[ + resources.CustomMetric, + Awaitable[resources.CustomMetric] + ]]: + 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..0a250678 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py @@ -0,0 +1,2083 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources +from google.protobuf import empty_pb2 # 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: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or 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. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'analyticsadmin.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def 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_pb2.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_pb2.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], + resources.Property]: + 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], + ~.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 '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=resources.Property.deserialize, + ) + 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_pb2.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_pb2.Empty.FromString, + ) + return self._stubs['delete_user_link'] + + @property + def batch_delete_user_links(self) -> Callable[ + [analytics_admin.BatchDeleteUserLinksRequest], + empty_pb2.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_pb2.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_pb2.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_pb2.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_pb2.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_pb2.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 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_pb2.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_pb2.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 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_pb2.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_pb2.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_pb2.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_pb2.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'] + + @property + def get_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.GetMeasurementProtocolSecretRequest], + resources.MeasurementProtocolSecret]: + r"""Return a callable for the get measurement protocol + secret method over gRPC. + + Lookup for a single "GA4" MeasurementProtocolSecret. + + Returns: + Callable[[~.GetMeasurementProtocolSecretRequest], + ~.MeasurementProtocolSecret]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: + self._stubs['get_measurement_protocol_secret'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetMeasurementProtocolSecret', + request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs['get_measurement_protocol_secret'] + + @property + def list_measurement_protocol_secrets(self) -> Callable[ + [analytics_admin.ListMeasurementProtocolSecretsRequest], + analytics_admin.ListMeasurementProtocolSecretsResponse]: + r"""Return a callable for the list measurement protocol + secrets method over gRPC. + + Returns child MeasurementProtocolSecrets under the + specified parent Property. + + Returns: + Callable[[~.ListMeasurementProtocolSecretsRequest], + ~.ListMeasurementProtocolSecretsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_measurement_protocol_secrets' not in self._stubs: + self._stubs['list_measurement_protocol_secrets'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListMeasurementProtocolSecrets', + request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, + response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, + ) + return self._stubs['list_measurement_protocol_secrets'] + + @property + def create_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.CreateMeasurementProtocolSecretRequest], + resources.MeasurementProtocolSecret]: + r"""Return a callable for the create measurement protocol + secret method over gRPC. + + Creates a measurement protocol secret. + + Returns: + Callable[[~.CreateMeasurementProtocolSecretRequest], + ~.MeasurementProtocolSecret]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: + self._stubs['create_measurement_protocol_secret'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateMeasurementProtocolSecret', + request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs['create_measurement_protocol_secret'] + + @property + def delete_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.DeleteMeasurementProtocolSecretRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete measurement protocol + secret method over gRPC. + + Deletes target MeasurementProtocolSecret. + + Returns: + Callable[[~.DeleteMeasurementProtocolSecretRequest], + ~.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_measurement_protocol_secret' not in self._stubs: + self._stubs['delete_measurement_protocol_secret'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteMeasurementProtocolSecret', + request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_measurement_protocol_secret'] + + @property + def update_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.UpdateMeasurementProtocolSecretRequest], + resources.MeasurementProtocolSecret]: + r"""Return a callable for the update measurement protocol + secret method over gRPC. + + Updates a measurement protocol secret. + + Returns: + Callable[[~.UpdateMeasurementProtocolSecretRequest], + ~.MeasurementProtocolSecret]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: + self._stubs['update_measurement_protocol_secret'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateMeasurementProtocolSecret', + request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs['update_measurement_protocol_secret'] + + @property + def search_change_history_events(self) -> Callable[ + [analytics_admin.SearchChangeHistoryEventsRequest], + analytics_admin.SearchChangeHistoryEventsResponse]: + r"""Return a callable for the search change history events method over gRPC. + + Searches through all changes to an account or its + children given the specified set of filters. + + Returns: + Callable[[~.SearchChangeHistoryEventsRequest], + ~.SearchChangeHistoryEventsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'search_change_history_events' not in self._stubs: + self._stubs['search_change_history_events'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/SearchChangeHistoryEvents', + request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, + response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, + ) + return self._stubs['search_change_history_events'] + + @property + def get_google_signals_settings(self) -> Callable[ + [analytics_admin.GetGoogleSignalsSettingsRequest], + resources.GoogleSignalsSettings]: + r"""Return a callable for the get google signals settings method over gRPC. + + Lookup for Google Signals settings for a property. + + Returns: + Callable[[~.GetGoogleSignalsSettingsRequest], + ~.GoogleSignalsSettings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_google_signals_settings' not in self._stubs: + self._stubs['get_google_signals_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGoogleSignalsSettings', + request_serializer=analytics_admin.GetGoogleSignalsSettingsRequest.serialize, + response_deserializer=resources.GoogleSignalsSettings.deserialize, + ) + return self._stubs['get_google_signals_settings'] + + @property + def update_google_signals_settings(self) -> Callable[ + [analytics_admin.UpdateGoogleSignalsSettingsRequest], + resources.GoogleSignalsSettings]: + r"""Return a callable for the update google signals settings method over gRPC. + + Updates Google Signals settings for a property. + + Returns: + Callable[[~.UpdateGoogleSignalsSettingsRequest], + ~.GoogleSignalsSettings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_signals_settings' not in self._stubs: + self._stubs['update_google_signals_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleSignalsSettings', + request_serializer=analytics_admin.UpdateGoogleSignalsSettingsRequest.serialize, + response_deserializer=resources.GoogleSignalsSettings.deserialize, + ) + return self._stubs['update_google_signals_settings'] + + @property + def create_conversion_event(self) -> Callable[ + [analytics_admin.CreateConversionEventRequest], + resources.ConversionEvent]: + r"""Return a callable for the create conversion event method over gRPC. + + Creates a conversion event with the specified + attributes. + + Returns: + Callable[[~.CreateConversionEventRequest], + ~.ConversionEvent]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversion_event' not in self._stubs: + self._stubs['create_conversion_event'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConversionEvent', + request_serializer=analytics_admin.CreateConversionEventRequest.serialize, + response_deserializer=resources.ConversionEvent.deserialize, + ) + return self._stubs['create_conversion_event'] + + @property + def get_conversion_event(self) -> Callable[ + [analytics_admin.GetConversionEventRequest], + resources.ConversionEvent]: + r"""Return a callable for the get conversion event method over gRPC. + + Retrieve a single conversion event. + + Returns: + Callable[[~.GetConversionEventRequest], + ~.ConversionEvent]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversion_event' not in self._stubs: + self._stubs['get_conversion_event'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetConversionEvent', + request_serializer=analytics_admin.GetConversionEventRequest.serialize, + response_deserializer=resources.ConversionEvent.deserialize, + ) + return self._stubs['get_conversion_event'] + + @property + def delete_conversion_event(self) -> Callable[ + [analytics_admin.DeleteConversionEventRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete conversion event method over gRPC. + + Deletes a conversion event in a property. + + Returns: + Callable[[~.DeleteConversionEventRequest], + ~.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_conversion_event' not in self._stubs: + self._stubs['delete_conversion_event'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConversionEvent', + request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_conversion_event'] + + @property + def list_conversion_events(self) -> Callable[ + [analytics_admin.ListConversionEventsRequest], + analytics_admin.ListConversionEventsResponse]: + r"""Return a callable for the list conversion events method over gRPC. + + Returns a list of conversion events in the specified + parent property. + Returns an empty list if no conversion events are found. + + Returns: + Callable[[~.ListConversionEventsRequest], + ~.ListConversionEventsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversion_events' not in self._stubs: + self._stubs['list_conversion_events'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConversionEvents', + request_serializer=analytics_admin.ListConversionEventsRequest.serialize, + response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, + ) + return self._stubs['list_conversion_events'] + + @property + def create_custom_dimension(self) -> Callable[ + [analytics_admin.CreateCustomDimensionRequest], + resources.CustomDimension]: + r"""Return a callable for the create custom dimension method over gRPC. + + Creates a CustomDimension. + + Returns: + Callable[[~.CreateCustomDimensionRequest], + ~.CustomDimension]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: + self._stubs['create_custom_dimension'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomDimension', + request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs['create_custom_dimension'] + + @property + def update_custom_dimension(self) -> Callable[ + [analytics_admin.UpdateCustomDimensionRequest], + resources.CustomDimension]: + r"""Return a callable for the update custom dimension method over gRPC. + + Updates a CustomDimension on a property. + + Returns: + Callable[[~.UpdateCustomDimensionRequest], + ~.CustomDimension]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: + self._stubs['update_custom_dimension'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomDimension', + request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs['update_custom_dimension'] + + @property + def list_custom_dimensions(self) -> Callable[ + [analytics_admin.ListCustomDimensionsRequest], + analytics_admin.ListCustomDimensionsResponse]: + r"""Return a callable for the list custom dimensions method over gRPC. + + Lists CustomDimensions on a property. + + Returns: + Callable[[~.ListCustomDimensionsRequest], + ~.ListCustomDimensionsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_dimensions' not in self._stubs: + self._stubs['list_custom_dimensions'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomDimensions', + request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, + response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, + ) + return self._stubs['list_custom_dimensions'] + + @property + def archive_custom_dimension(self) -> Callable[ + [analytics_admin.ArchiveCustomDimensionRequest], + empty_pb2.Empty]: + r"""Return a callable for the archive custom dimension method over gRPC. + + Archives a CustomDimension on a property. + + Returns: + Callable[[~.ArchiveCustomDimensionRequest], + ~.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 'archive_custom_dimension' not in self._stubs: + self._stubs['archive_custom_dimension'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomDimension', + request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['archive_custom_dimension'] + + @property + def get_custom_dimension(self) -> Callable[ + [analytics_admin.GetCustomDimensionRequest], + resources.CustomDimension]: + r"""Return a callable for the get custom dimension method over gRPC. + + Lookup for a single CustomDimension. + + Returns: + Callable[[~.GetCustomDimensionRequest], + ~.CustomDimension]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: + self._stubs['get_custom_dimension'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomDimension', + request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs['get_custom_dimension'] + + @property + def create_custom_metric(self) -> Callable[ + [analytics_admin.CreateCustomMetricRequest], + resources.CustomMetric]: + r"""Return a callable for the create custom metric method over gRPC. + + Creates a CustomMetric. + + Returns: + Callable[[~.CreateCustomMetricRequest], + ~.CustomMetric]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: + self._stubs['create_custom_metric'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomMetric', + request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs['create_custom_metric'] + + @property + def update_custom_metric(self) -> Callable[ + [analytics_admin.UpdateCustomMetricRequest], + resources.CustomMetric]: + r"""Return a callable for the update custom metric method over gRPC. + + Updates a CustomMetric on a property. + + Returns: + Callable[[~.UpdateCustomMetricRequest], + ~.CustomMetric]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: + self._stubs['update_custom_metric'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomMetric', + request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs['update_custom_metric'] + + @property + def list_custom_metrics(self) -> Callable[ + [analytics_admin.ListCustomMetricsRequest], + analytics_admin.ListCustomMetricsResponse]: + r"""Return a callable for the list custom metrics method over gRPC. + + Lists CustomMetrics on a property. + + Returns: + Callable[[~.ListCustomMetricsRequest], + ~.ListCustomMetricsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_metrics' not in self._stubs: + self._stubs['list_custom_metrics'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomMetrics', + request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, + response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, + ) + return self._stubs['list_custom_metrics'] + + @property + def archive_custom_metric(self) -> Callable[ + [analytics_admin.ArchiveCustomMetricRequest], + empty_pb2.Empty]: + r"""Return a callable for the archive custom metric method over gRPC. + + Archives a CustomMetric on a property. + + Returns: + Callable[[~.ArchiveCustomMetricRequest], + ~.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 'archive_custom_metric' not in self._stubs: + self._stubs['archive_custom_metric'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomMetric', + request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['archive_custom_metric'] + + @property + def get_custom_metric(self) -> Callable[ + [analytics_admin.GetCustomMetricRequest], + resources.CustomMetric]: + r"""Return a callable for the get custom metric method over gRPC. + + Lookup for a single CustomMetric. + + Returns: + Callable[[~.GetCustomMetricRequest], + ~.CustomMetric]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: + self._stubs['get_custom_metric'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomMetric', + request_serializer=analytics_admin.GetCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs['get_custom_metric'] + + +__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..54c05583 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py @@ -0,0 +1,2087 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.analytics.admin_v1alpha.types import analytics_admin +from google.analytics.admin_v1alpha.types import resources +from google.protobuf import empty_pb2 # 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: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'analyticsadmin.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or 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. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def 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_pb2.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_pb2.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[resources.Property]]: + 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[~.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 '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=resources.Property.deserialize, + ) + 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_pb2.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_pb2.Empty.FromString, + ) + return self._stubs['delete_user_link'] + + @property + def batch_delete_user_links(self) -> Callable[ + [analytics_admin.BatchDeleteUserLinksRequest], + Awaitable[empty_pb2.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_pb2.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_pb2.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_pb2.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_pb2.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_pb2.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 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_pb2.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_pb2.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 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_pb2.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_pb2.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_pb2.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_pb2.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'] + + @property + def get_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.GetMeasurementProtocolSecretRequest], + Awaitable[resources.MeasurementProtocolSecret]]: + r"""Return a callable for the get measurement protocol + secret method over gRPC. + + Lookup for a single "GA4" MeasurementProtocolSecret. + + Returns: + Callable[[~.GetMeasurementProtocolSecretRequest], + Awaitable[~.MeasurementProtocolSecret]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: + self._stubs['get_measurement_protocol_secret'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetMeasurementProtocolSecret', + request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs['get_measurement_protocol_secret'] + + @property + def list_measurement_protocol_secrets(self) -> Callable[ + [analytics_admin.ListMeasurementProtocolSecretsRequest], + Awaitable[analytics_admin.ListMeasurementProtocolSecretsResponse]]: + r"""Return a callable for the list measurement protocol + secrets method over gRPC. + + Returns child MeasurementProtocolSecrets under the + specified parent Property. + + Returns: + Callable[[~.ListMeasurementProtocolSecretsRequest], + Awaitable[~.ListMeasurementProtocolSecretsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_measurement_protocol_secrets' not in self._stubs: + self._stubs['list_measurement_protocol_secrets'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListMeasurementProtocolSecrets', + request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, + response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, + ) + return self._stubs['list_measurement_protocol_secrets'] + + @property + def create_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.CreateMeasurementProtocolSecretRequest], + Awaitable[resources.MeasurementProtocolSecret]]: + r"""Return a callable for the create measurement protocol + secret method over gRPC. + + Creates a measurement protocol secret. + + Returns: + Callable[[~.CreateMeasurementProtocolSecretRequest], + Awaitable[~.MeasurementProtocolSecret]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: + self._stubs['create_measurement_protocol_secret'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateMeasurementProtocolSecret', + request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs['create_measurement_protocol_secret'] + + @property + def delete_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.DeleteMeasurementProtocolSecretRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete measurement protocol + secret method over gRPC. + + Deletes target MeasurementProtocolSecret. + + Returns: + Callable[[~.DeleteMeasurementProtocolSecretRequest], + 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_measurement_protocol_secret' not in self._stubs: + self._stubs['delete_measurement_protocol_secret'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteMeasurementProtocolSecret', + request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_measurement_protocol_secret'] + + @property + def update_measurement_protocol_secret(self) -> Callable[ + [analytics_admin.UpdateMeasurementProtocolSecretRequest], + Awaitable[resources.MeasurementProtocolSecret]]: + r"""Return a callable for the update measurement protocol + secret method over gRPC. + + Updates a measurement protocol secret. + + Returns: + Callable[[~.UpdateMeasurementProtocolSecretRequest], + Awaitable[~.MeasurementProtocolSecret]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: + self._stubs['update_measurement_protocol_secret'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateMeasurementProtocolSecret', + request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs['update_measurement_protocol_secret'] + + @property + def search_change_history_events(self) -> Callable[ + [analytics_admin.SearchChangeHistoryEventsRequest], + Awaitable[analytics_admin.SearchChangeHistoryEventsResponse]]: + r"""Return a callable for the search change history events method over gRPC. + + Searches through all changes to an account or its + children given the specified set of filters. + + Returns: + Callable[[~.SearchChangeHistoryEventsRequest], + Awaitable[~.SearchChangeHistoryEventsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'search_change_history_events' not in self._stubs: + self._stubs['search_change_history_events'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/SearchChangeHistoryEvents', + request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, + response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, + ) + return self._stubs['search_change_history_events'] + + @property + def get_google_signals_settings(self) -> Callable[ + [analytics_admin.GetGoogleSignalsSettingsRequest], + Awaitable[resources.GoogleSignalsSettings]]: + r"""Return a callable for the get google signals settings method over gRPC. + + Lookup for Google Signals settings for a property. + + Returns: + Callable[[~.GetGoogleSignalsSettingsRequest], + Awaitable[~.GoogleSignalsSettings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_google_signals_settings' not in self._stubs: + self._stubs['get_google_signals_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGoogleSignalsSettings', + request_serializer=analytics_admin.GetGoogleSignalsSettingsRequest.serialize, + response_deserializer=resources.GoogleSignalsSettings.deserialize, + ) + return self._stubs['get_google_signals_settings'] + + @property + def update_google_signals_settings(self) -> Callable[ + [analytics_admin.UpdateGoogleSignalsSettingsRequest], + Awaitable[resources.GoogleSignalsSettings]]: + r"""Return a callable for the update google signals settings method over gRPC. + + Updates Google Signals settings for a property. + + Returns: + Callable[[~.UpdateGoogleSignalsSettingsRequest], + Awaitable[~.GoogleSignalsSettings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_signals_settings' not in self._stubs: + self._stubs['update_google_signals_settings'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleSignalsSettings', + request_serializer=analytics_admin.UpdateGoogleSignalsSettingsRequest.serialize, + response_deserializer=resources.GoogleSignalsSettings.deserialize, + ) + return self._stubs['update_google_signals_settings'] + + @property + def create_conversion_event(self) -> Callable[ + [analytics_admin.CreateConversionEventRequest], + Awaitable[resources.ConversionEvent]]: + r"""Return a callable for the create conversion event method over gRPC. + + Creates a conversion event with the specified + attributes. + + Returns: + Callable[[~.CreateConversionEventRequest], + Awaitable[~.ConversionEvent]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversion_event' not in self._stubs: + self._stubs['create_conversion_event'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConversionEvent', + request_serializer=analytics_admin.CreateConversionEventRequest.serialize, + response_deserializer=resources.ConversionEvent.deserialize, + ) + return self._stubs['create_conversion_event'] + + @property + def get_conversion_event(self) -> Callable[ + [analytics_admin.GetConversionEventRequest], + Awaitable[resources.ConversionEvent]]: + r"""Return a callable for the get conversion event method over gRPC. + + Retrieve a single conversion event. + + Returns: + Callable[[~.GetConversionEventRequest], + Awaitable[~.ConversionEvent]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversion_event' not in self._stubs: + self._stubs['get_conversion_event'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetConversionEvent', + request_serializer=analytics_admin.GetConversionEventRequest.serialize, + response_deserializer=resources.ConversionEvent.deserialize, + ) + return self._stubs['get_conversion_event'] + + @property + def delete_conversion_event(self) -> Callable[ + [analytics_admin.DeleteConversionEventRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete conversion event method over gRPC. + + Deletes a conversion event in a property. + + Returns: + Callable[[~.DeleteConversionEventRequest], + 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_conversion_event' not in self._stubs: + self._stubs['delete_conversion_event'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConversionEvent', + request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_conversion_event'] + + @property + def list_conversion_events(self) -> Callable[ + [analytics_admin.ListConversionEventsRequest], + Awaitable[analytics_admin.ListConversionEventsResponse]]: + r"""Return a callable for the list conversion events method over gRPC. + + Returns a list of conversion events in the specified + parent property. + Returns an empty list if no conversion events are found. + + Returns: + Callable[[~.ListConversionEventsRequest], + Awaitable[~.ListConversionEventsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversion_events' not in self._stubs: + self._stubs['list_conversion_events'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConversionEvents', + request_serializer=analytics_admin.ListConversionEventsRequest.serialize, + response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, + ) + return self._stubs['list_conversion_events'] + + @property + def create_custom_dimension(self) -> Callable[ + [analytics_admin.CreateCustomDimensionRequest], + Awaitable[resources.CustomDimension]]: + r"""Return a callable for the create custom dimension method over gRPC. + + Creates a CustomDimension. + + Returns: + Callable[[~.CreateCustomDimensionRequest], + Awaitable[~.CustomDimension]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: + self._stubs['create_custom_dimension'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomDimension', + request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs['create_custom_dimension'] + + @property + def update_custom_dimension(self) -> Callable[ + [analytics_admin.UpdateCustomDimensionRequest], + Awaitable[resources.CustomDimension]]: + r"""Return a callable for the update custom dimension method over gRPC. + + Updates a CustomDimension on a property. + + Returns: + Callable[[~.UpdateCustomDimensionRequest], + Awaitable[~.CustomDimension]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: + self._stubs['update_custom_dimension'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomDimension', + request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs['update_custom_dimension'] + + @property + def list_custom_dimensions(self) -> Callable[ + [analytics_admin.ListCustomDimensionsRequest], + Awaitable[analytics_admin.ListCustomDimensionsResponse]]: + r"""Return a callable for the list custom dimensions method over gRPC. + + Lists CustomDimensions on a property. + + Returns: + Callable[[~.ListCustomDimensionsRequest], + Awaitable[~.ListCustomDimensionsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_dimensions' not in self._stubs: + self._stubs['list_custom_dimensions'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomDimensions', + request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, + response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, + ) + return self._stubs['list_custom_dimensions'] + + @property + def archive_custom_dimension(self) -> Callable[ + [analytics_admin.ArchiveCustomDimensionRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the archive custom dimension method over gRPC. + + Archives a CustomDimension on a property. + + Returns: + Callable[[~.ArchiveCustomDimensionRequest], + 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 'archive_custom_dimension' not in self._stubs: + self._stubs['archive_custom_dimension'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomDimension', + request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['archive_custom_dimension'] + + @property + def get_custom_dimension(self) -> Callable[ + [analytics_admin.GetCustomDimensionRequest], + Awaitable[resources.CustomDimension]]: + r"""Return a callable for the get custom dimension method over gRPC. + + Lookup for a single CustomDimension. + + Returns: + Callable[[~.GetCustomDimensionRequest], + Awaitable[~.CustomDimension]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: + self._stubs['get_custom_dimension'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomDimension', + request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs['get_custom_dimension'] + + @property + def create_custom_metric(self) -> Callable[ + [analytics_admin.CreateCustomMetricRequest], + Awaitable[resources.CustomMetric]]: + r"""Return a callable for the create custom metric method over gRPC. + + Creates a CustomMetric. + + Returns: + Callable[[~.CreateCustomMetricRequest], + Awaitable[~.CustomMetric]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: + self._stubs['create_custom_metric'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomMetric', + request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs['create_custom_metric'] + + @property + def update_custom_metric(self) -> Callable[ + [analytics_admin.UpdateCustomMetricRequest], + Awaitable[resources.CustomMetric]]: + r"""Return a callable for the update custom metric method over gRPC. + + Updates a CustomMetric on a property. + + Returns: + Callable[[~.UpdateCustomMetricRequest], + Awaitable[~.CustomMetric]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: + self._stubs['update_custom_metric'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomMetric', + request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs['update_custom_metric'] + + @property + def list_custom_metrics(self) -> Callable[ + [analytics_admin.ListCustomMetricsRequest], + Awaitable[analytics_admin.ListCustomMetricsResponse]]: + r"""Return a callable for the list custom metrics method over gRPC. + + Lists CustomMetrics on a property. + + Returns: + Callable[[~.ListCustomMetricsRequest], + Awaitable[~.ListCustomMetricsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_metrics' not in self._stubs: + self._stubs['list_custom_metrics'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomMetrics', + request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, + response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, + ) + return self._stubs['list_custom_metrics'] + + @property + def archive_custom_metric(self) -> Callable[ + [analytics_admin.ArchiveCustomMetricRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the archive custom metric method over gRPC. + + Archives a CustomMetric on a property. + + Returns: + Callable[[~.ArchiveCustomMetricRequest], + 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 'archive_custom_metric' not in self._stubs: + self._stubs['archive_custom_metric'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomMetric', + request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['archive_custom_metric'] + + @property + def get_custom_metric(self) -> Callable[ + [analytics_admin.GetCustomMetricRequest], + Awaitable[resources.CustomMetric]]: + r"""Return a callable for the get custom metric method over gRPC. + + Lookup for a single CustomMetric. + + Returns: + Callable[[~.GetCustomMetricRequest], + Awaitable[~.CustomMetric]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: + self._stubs['get_custom_metric'] = self.grpc_channel.unary_unary( + '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomMetric', + request_serializer=analytics_admin.GetCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs['get_custom_metric'] + + +__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..53dd3618 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py @@ -0,0 +1,252 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ( + ArchiveCustomDimensionRequest, + ArchiveCustomMetricRequest, + AuditUserLinksRequest, + AuditUserLinksResponse, + BatchCreateUserLinksRequest, + BatchCreateUserLinksResponse, + BatchDeleteUserLinksRequest, + BatchGetUserLinksRequest, + BatchGetUserLinksResponse, + BatchUpdateUserLinksRequest, + BatchUpdateUserLinksResponse, + CreateConversionEventRequest, + CreateCustomDimensionRequest, + CreateCustomMetricRequest, + CreateFirebaseLinkRequest, + CreateGoogleAdsLinkRequest, + CreateMeasurementProtocolSecretRequest, + CreatePropertyRequest, + CreateUserLinkRequest, + CreateWebDataStreamRequest, + DeleteAccountRequest, + DeleteAndroidAppDataStreamRequest, + DeleteConversionEventRequest, + DeleteFirebaseLinkRequest, + DeleteGoogleAdsLinkRequest, + DeleteIosAppDataStreamRequest, + DeleteMeasurementProtocolSecretRequest, + DeletePropertyRequest, + DeleteUserLinkRequest, + DeleteWebDataStreamRequest, + GetAccountRequest, + GetAndroidAppDataStreamRequest, + GetConversionEventRequest, + GetCustomDimensionRequest, + GetCustomMetricRequest, + GetDataSharingSettingsRequest, + GetEnhancedMeasurementSettingsRequest, + GetGlobalSiteTagRequest, + GetGoogleSignalsSettingsRequest, + GetIosAppDataStreamRequest, + GetMeasurementProtocolSecretRequest, + GetPropertyRequest, + GetUserLinkRequest, + GetWebDataStreamRequest, + ListAccountsRequest, + ListAccountsResponse, + ListAccountSummariesRequest, + ListAccountSummariesResponse, + ListAndroidAppDataStreamsRequest, + ListAndroidAppDataStreamsResponse, + ListConversionEventsRequest, + ListConversionEventsResponse, + ListCustomDimensionsRequest, + ListCustomDimensionsResponse, + ListCustomMetricsRequest, + ListCustomMetricsResponse, + ListFirebaseLinksRequest, + ListFirebaseLinksResponse, + ListGoogleAdsLinksRequest, + ListGoogleAdsLinksResponse, + ListIosAppDataStreamsRequest, + ListIosAppDataStreamsResponse, + ListMeasurementProtocolSecretsRequest, + ListMeasurementProtocolSecretsResponse, + ListPropertiesRequest, + ListPropertiesResponse, + ListUserLinksRequest, + ListUserLinksResponse, + ListWebDataStreamsRequest, + ListWebDataStreamsResponse, + ProvisionAccountTicketRequest, + ProvisionAccountTicketResponse, + SearchChangeHistoryEventsRequest, + SearchChangeHistoryEventsResponse, + UpdateAccountRequest, + UpdateAndroidAppDataStreamRequest, + UpdateCustomDimensionRequest, + UpdateCustomMetricRequest, + UpdateEnhancedMeasurementSettingsRequest, + UpdateFirebaseLinkRequest, + UpdateGoogleAdsLinkRequest, + UpdateGoogleSignalsSettingsRequest, + UpdateIosAppDataStreamRequest, + UpdateMeasurementProtocolSecretRequest, + UpdatePropertyRequest, + UpdateUserLinkRequest, + UpdateWebDataStreamRequest, +) +from .resources import ( + Account, + AccountSummary, + AndroidAppDataStream, + AuditUserLink, + ChangeHistoryChange, + ChangeHistoryEvent, + ConversionEvent, + CustomDimension, + CustomMetric, + DataSharingSettings, + EnhancedMeasurementSettings, + FirebaseLink, + GlobalSiteTag, + GoogleAdsLink, + GoogleSignalsSettings, + IosAppDataStream, + MeasurementProtocolSecret, + Property, + PropertySummary, + UserLink, + WebDataStream, + ActionType, + ActorType, + ChangeHistoryResourceType, + GoogleSignalsConsent, + GoogleSignalsState, + IndustryCategory, + MaximumUserAccess, +) + +__all__ = ( + 'ArchiveCustomDimensionRequest', + 'ArchiveCustomMetricRequest', + 'AuditUserLinksRequest', + 'AuditUserLinksResponse', + 'BatchCreateUserLinksRequest', + 'BatchCreateUserLinksResponse', + 'BatchDeleteUserLinksRequest', + 'BatchGetUserLinksRequest', + 'BatchGetUserLinksResponse', + 'BatchUpdateUserLinksRequest', + 'BatchUpdateUserLinksResponse', + 'CreateConversionEventRequest', + 'CreateCustomDimensionRequest', + 'CreateCustomMetricRequest', + 'CreateFirebaseLinkRequest', + 'CreateGoogleAdsLinkRequest', + 'CreateMeasurementProtocolSecretRequest', + 'CreatePropertyRequest', + 'CreateUserLinkRequest', + 'CreateWebDataStreamRequest', + 'DeleteAccountRequest', + 'DeleteAndroidAppDataStreamRequest', + 'DeleteConversionEventRequest', + 'DeleteFirebaseLinkRequest', + 'DeleteGoogleAdsLinkRequest', + 'DeleteIosAppDataStreamRequest', + 'DeleteMeasurementProtocolSecretRequest', + 'DeletePropertyRequest', + 'DeleteUserLinkRequest', + 'DeleteWebDataStreamRequest', + 'GetAccountRequest', + 'GetAndroidAppDataStreamRequest', + 'GetConversionEventRequest', + 'GetCustomDimensionRequest', + 'GetCustomMetricRequest', + 'GetDataSharingSettingsRequest', + 'GetEnhancedMeasurementSettingsRequest', + 'GetGlobalSiteTagRequest', + 'GetGoogleSignalsSettingsRequest', + 'GetIosAppDataStreamRequest', + 'GetMeasurementProtocolSecretRequest', + 'GetPropertyRequest', + 'GetUserLinkRequest', + 'GetWebDataStreamRequest', + 'ListAccountsRequest', + 'ListAccountsResponse', + 'ListAccountSummariesRequest', + 'ListAccountSummariesResponse', + 'ListAndroidAppDataStreamsRequest', + 'ListAndroidAppDataStreamsResponse', + 'ListConversionEventsRequest', + 'ListConversionEventsResponse', + 'ListCustomDimensionsRequest', + 'ListCustomDimensionsResponse', + 'ListCustomMetricsRequest', + 'ListCustomMetricsResponse', + 'ListFirebaseLinksRequest', + 'ListFirebaseLinksResponse', + 'ListGoogleAdsLinksRequest', + 'ListGoogleAdsLinksResponse', + 'ListIosAppDataStreamsRequest', + 'ListIosAppDataStreamsResponse', + 'ListMeasurementProtocolSecretsRequest', + 'ListMeasurementProtocolSecretsResponse', + 'ListPropertiesRequest', + 'ListPropertiesResponse', + 'ListUserLinksRequest', + 'ListUserLinksResponse', + 'ListWebDataStreamsRequest', + 'ListWebDataStreamsResponse', + 'ProvisionAccountTicketRequest', + 'ProvisionAccountTicketResponse', + 'SearchChangeHistoryEventsRequest', + 'SearchChangeHistoryEventsResponse', + 'UpdateAccountRequest', + 'UpdateAndroidAppDataStreamRequest', + 'UpdateCustomDimensionRequest', + 'UpdateCustomMetricRequest', + 'UpdateEnhancedMeasurementSettingsRequest', + 'UpdateFirebaseLinkRequest', + 'UpdateGoogleAdsLinkRequest', + 'UpdateGoogleSignalsSettingsRequest', + 'UpdateIosAppDataStreamRequest', + 'UpdateMeasurementProtocolSecretRequest', + 'UpdatePropertyRequest', + 'UpdateUserLinkRequest', + 'UpdateWebDataStreamRequest', + 'Account', + 'AccountSummary', + 'AndroidAppDataStream', + 'AuditUserLink', + 'ChangeHistoryChange', + 'ChangeHistoryEvent', + 'ConversionEvent', + 'CustomDimension', + 'CustomMetric', + 'DataSharingSettings', + 'EnhancedMeasurementSettings', + 'FirebaseLink', + 'GlobalSiteTag', + 'GoogleAdsLink', + 'GoogleSignalsSettings', + 'IosAppDataStream', + 'MeasurementProtocolSecret', + 'Property', + 'PropertySummary', + 'UserLink', + 'WebDataStream', + 'ActionType', + 'ActorType', + 'ChangeHistoryResourceType', + 'GoogleSignalsConsent', + 'GoogleSignalsState', + '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..6ae00c0e --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py @@ -0,0 +1,2195 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 # type: ignore +from google.protobuf import timestamp_pb2 # 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', + 'ListIosAppDataStreamsRequest', + 'ListIosAppDataStreamsResponse', + 'GetAndroidAppDataStreamRequest', + 'DeleteAndroidAppDataStreamRequest', + 'UpdateAndroidAppDataStreamRequest', + 'ListAndroidAppDataStreamsRequest', + 'ListAndroidAppDataStreamsResponse', + 'GetEnhancedMeasurementSettingsRequest', + 'UpdateEnhancedMeasurementSettingsRequest', + 'CreateFirebaseLinkRequest', + 'UpdateFirebaseLinkRequest', + 'DeleteFirebaseLinkRequest', + 'ListFirebaseLinksRequest', + 'ListFirebaseLinksResponse', + 'GetGlobalSiteTagRequest', + 'CreateGoogleAdsLinkRequest', + 'UpdateGoogleAdsLinkRequest', + 'DeleteGoogleAdsLinkRequest', + 'ListGoogleAdsLinksRequest', + 'ListGoogleAdsLinksResponse', + 'GetDataSharingSettingsRequest', + 'ListAccountSummariesRequest', + 'ListAccountSummariesResponse', + 'SearchChangeHistoryEventsRequest', + 'SearchChangeHistoryEventsResponse', + 'GetMeasurementProtocolSecretRequest', + 'CreateMeasurementProtocolSecretRequest', + 'DeleteMeasurementProtocolSecretRequest', + 'UpdateMeasurementProtocolSecretRequest', + 'ListMeasurementProtocolSecretsRequest', + 'ListMeasurementProtocolSecretsResponse', + 'GetGoogleSignalsSettingsRequest', + 'UpdateGoogleSignalsSettingsRequest', + 'CreateConversionEventRequest', + 'GetConversionEventRequest', + 'DeleteConversionEventRequest', + 'ListConversionEventsRequest', + 'ListConversionEventsResponse', + 'CreateCustomDimensionRequest', + 'UpdateCustomDimensionRequest', + 'ListCustomDimensionsRequest', + 'ListCustomDimensionsResponse', + 'ArchiveCustomDimensionRequest', + 'GetCustomDimensionRequest', + 'CreateCustomMetricRequest', + 'UpdateCustomMetricRequest', + 'ListCustomMetricsRequest', + 'ListCustomMetricsResponse', + 'ArchiveCustomMetricRequest', + 'GetCustomMetricRequest', + }, +) + + +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_pb2.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_pb2.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_pb2.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_pb2.FieldMask, + ) + + +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_pb2.FieldMask, + ) + + +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_pb2.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_pb2.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_pb2.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, + ) + + +class SearchChangeHistoryEventsRequest(proto.Message): + r"""Request message for SearchChangeHistoryEvents RPC. + Attributes: + account (str): + Required. The account resource for which to + return change history resources. + property (str): + Optional. Resource name for a child property. + If set, only return changes made to this + property or its child resources. + resource_type (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryResourceType]): + Optional. If set, only return changes if they + are for a resource that matches at least one of + these types. + action (Sequence[google.analytics.admin_v1alpha.types.ActionType]): + Optional. If set, only return changes that + match one or more of these types of actions. + actor_email (Sequence[str]): + Optional. If set, only return changes if they + are made by a user in this list. + earliest_change_time (google.protobuf.timestamp_pb2.Timestamp): + Optional. If set, only return changes made + after this time (inclusive). + latest_change_time (google.protobuf.timestamp_pb2.Timestamp): + Optional. If set, only return changes made + before this time (inclusive). + page_size (int): + Optional. The maximum number of + ChangeHistoryEvent items to return. The service + may return fewer than this value, even if there + are additional pages. If unspecified, at most 50 + items will be returned. The maximum value is 200 + (higher values will be coerced to the maximum). + page_token (str): + Optional. A page token, received from a previous + ``SearchChangeHistoryEvents`` call. Provide this to retrieve + the subsequent page. When paginating, all other parameters + provided to ``SearchChangeHistoryEvents`` must match the + call that provided the page token. + """ + + account = proto.Field( + proto.STRING, + number=1, + ) + property = proto.Field( + proto.STRING, + number=2, + ) + resource_type = proto.RepeatedField( + proto.ENUM, + number=3, + enum=resources.ChangeHistoryResourceType, + ) + action = proto.RepeatedField( + proto.ENUM, + number=4, + enum=resources.ActionType, + ) + actor_email = proto.RepeatedField( + proto.STRING, + number=5, + ) + earliest_change_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + latest_change_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + page_size = proto.Field( + proto.INT32, + number=8, + ) + page_token = proto.Field( + proto.STRING, + number=9, + ) + + +class SearchChangeHistoryEventsResponse(proto.Message): + r"""Response message for SearchAccounts RPC. + Attributes: + change_history_events (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryEvent]): + 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 + + change_history_events = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.ChangeHistoryEvent, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetMeasurementProtocolSecretRequest(proto.Message): + r"""Request message for GetMeasurementProtocolSecret RPC. + Attributes: + name (str): + Required. The name of the measurement + protocol secret to lookup. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) may be a + parent. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateMeasurementProtocolSecretRequest(proto.Message): + r"""Request message for CreateMeasurementProtocolSecret RPC + Attributes: + parent (str): + Required. The parent resource where this + secret will be created. Any type of stream + (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream} + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + Required. The measurement protocol secret to + create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + measurement_protocol_secret = proto.Field( + proto.MESSAGE, + number=2, + message=resources.MeasurementProtocolSecret, + ) + + +class DeleteMeasurementProtocolSecretRequest(proto.Message): + r"""Request message for DeleteMeasurementProtocolSecret RPC + Attributes: + name (str): + Required. The name of the + MeasurementProtocolSecret to delete. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) may be a + parent. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateMeasurementProtocolSecretRequest(proto.Message): + r"""Request message for UpdateMeasurementProtocolSecret RPC + Attributes: + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + Required. The measurement protocol secret to + update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. Omitted + fields will not be updated. + """ + + measurement_protocol_secret = proto.Field( + proto.MESSAGE, + number=1, + message=resources.MeasurementProtocolSecret, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class ListMeasurementProtocolSecretsRequest(proto.Message): + r"""Request message for ListMeasurementProtocolSecret RPC + Attributes: + parent (str): + Required. The resource name of the parent + stream. Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) may be a + parent. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets + page_size (int): + The maximum number of resources to return. + If unspecified, at most 10 resources will be + returned. The maximum value is 10. Higher values + will be coerced to the maximum. + page_token (str): + A page token, received from a previous + ``ListMeasurementProtocolSecrets`` call. Provide this to + retrieve the subsequent page. When paginating, all other + parameters provided to ``ListMeasurementProtocolSecrets`` + 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 ListMeasurementProtocolSecretsResponse(proto.Message): + r"""Response message for ListMeasurementProtocolSecret RPC + Attributes: + measurement_protocol_secrets (Sequence[google.analytics.admin_v1alpha.types.MeasurementProtocolSecret]): + A list of secrets for the parent stream + specified in the request. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + measurement_protocol_secrets = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.MeasurementProtocolSecret, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetGoogleSignalsSettingsRequest(proto.Message): + r"""Request message for GetGoogleSignalsSettings RPC + Attributes: + name (str): + Required. The name of the google signals + settings to retrieve. Format: + properties/{property}/googleSignalsSettings + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateGoogleSignalsSettingsRequest(proto.Message): + r"""Request message for UpdateGoogleSignalsSettings RPC + Attributes: + google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): + 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. + """ + + google_signals_settings = proto.Field( + proto.MESSAGE, + number=1, + message=resources.GoogleSignalsSettings, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class CreateConversionEventRequest(proto.Message): + r"""Request message for CreateConversionEvent RPC + Attributes: + conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): + Required. The conversion event to create. + parent (str): + Required. The resource name of the parent + property where this conversion event will be + created. Format: properties/123 + """ + + conversion_event = proto.Field( + proto.MESSAGE, + number=1, + message=resources.ConversionEvent, + ) + parent = proto.Field( + proto.STRING, + number=2, + ) + + +class GetConversionEventRequest(proto.Message): + r"""Request message for GetConversionEvent RPC + Attributes: + name (str): + Required. The resource name of the conversion event to + retrieve. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/456". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteConversionEventRequest(proto.Message): + r"""Request message for DeleteConversionEvent RPC + Attributes: + name (str): + Required. The resource name of the conversion event to + delete. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/456". + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListConversionEventsRequest(proto.Message): + r"""Request message for ListConversionEvents RPC + Attributes: + parent (str): + Required. The resource name of the parent + property. Example: '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 + ``ListConversionEvents`` call. Provide this to retrieve the + subsequent page. When paginating, all other parameters + provided to ``ListConversionEvents`` 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 ListConversionEventsResponse(proto.Message): + r"""Response message for ListConversionEvents RPC. + Attributes: + conversion_events (Sequence[google.analytics.admin_v1alpha.types.ConversionEvent]): + The requested conversion events + 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 + + conversion_events = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.ConversionEvent, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class CreateCustomDimensionRequest(proto.Message): + r"""Request message for CreateCustomDimension RPC. + Attributes: + parent (str): + Required. Example format: properties/1234 + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + Required. The CustomDimension to create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + custom_dimension = proto.Field( + proto.MESSAGE, + number=2, + message=resources.CustomDimension, + ) + + +class UpdateCustomDimensionRequest(proto.Message): + r"""Request message for UpdateCustomDimension RPC. + Attributes: + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + The CustomDimension to update + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + custom_dimension = proto.Field( + proto.MESSAGE, + number=1, + message=resources.CustomDimension, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class ListCustomDimensionsRequest(proto.Message): + r"""Request message for ListCustomDimensions 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 + ``ListCustomDimensions`` call. Provide this to retrieve the + subsequent page. + + When paginating, all other parameters provided to + ``ListCustomDimensions`` 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 ListCustomDimensionsResponse(proto.Message): + r"""Response message for ListCustomDimensions RPC. + Attributes: + custom_dimensions (Sequence[google.analytics.admin_v1alpha.types.CustomDimension]): + List of CustomDimensions. + 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 + + custom_dimensions = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.CustomDimension, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class ArchiveCustomDimensionRequest(proto.Message): + r"""Request message for ArchiveCustomDimension RPC. + Attributes: + name (str): + Required. The name of the CustomDimension to + archive. Example format: + properties/1234/customDimensions/5678 + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class GetCustomDimensionRequest(proto.Message): + r"""Request message for GetCustomDimension RPC. + Attributes: + name (str): + Required. The name of the CustomDimension to + get. Example format: + properties/1234/customDimensions/5678 + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateCustomMetricRequest(proto.Message): + r"""Request message for CreateCustomMetric RPC. + Attributes: + parent (str): + Required. Example format: properties/1234 + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + Required. The CustomMetric to create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + custom_metric = proto.Field( + proto.MESSAGE, + number=2, + message=resources.CustomMetric, + ) + + +class UpdateCustomMetricRequest(proto.Message): + r"""Request message for UpdateCustomMetric RPC. + Attributes: + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + The CustomMetric to update + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + custom_metric = proto.Field( + proto.MESSAGE, + number=1, + message=resources.CustomMetric, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class ListCustomMetricsRequest(proto.Message): + r"""Request message for ListCustomMetrics 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 ``ListCustomMetrics`` + call. Provide this to retrieve the subsequent page. + + When paginating, all other parameters provided to + ``ListCustomMetrics`` 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 ListCustomMetricsResponse(proto.Message): + r"""Response message for ListCustomMetrics RPC. + Attributes: + custom_metrics (Sequence[google.analytics.admin_v1alpha.types.CustomMetric]): + List of CustomMetrics. + 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 + + custom_metrics = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.CustomMetric, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class ArchiveCustomMetricRequest(proto.Message): + r"""Request message for ArchiveCustomMetric RPC. + Attributes: + name (str): + Required. The name of the CustomMetric to + archive. Example format: + properties/1234/customMetrics/5678 + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class GetCustomMetricRequest(proto.Message): + r"""Request message for GetCustomMetric RPC. + Attributes: + name (str): + Required. The name of the CustomMetric to + get. Example format: + properties/1234/customMetrics/5678 + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +__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..62dc4410 --- /dev/null +++ b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py @@ -0,0 +1,1408 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.analytics.admin.v1alpha', + manifest={ + 'MaximumUserAccess', + 'IndustryCategory', + 'ActorType', + 'ActionType', + 'ChangeHistoryResourceType', + 'GoogleSignalsState', + 'GoogleSignalsConsent', + 'Account', + 'Property', + 'AndroidAppDataStream', + 'IosAppDataStream', + 'WebDataStream', + 'UserLink', + 'AuditUserLink', + 'EnhancedMeasurementSettings', + 'FirebaseLink', + 'GlobalSiteTag', + 'GoogleAdsLink', + 'DataSharingSettings', + 'AccountSummary', + 'PropertySummary', + 'MeasurementProtocolSecret', + 'ChangeHistoryEvent', + 'ChangeHistoryChange', + 'ConversionEvent', + 'GoogleSignalsSettings', + 'CustomDimension', + 'CustomMetric', + }, +) + + +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 ActorType(proto.Enum): + r"""Different kinds of actors that can make changes to Google + Analytics resources. + """ + ACTOR_TYPE_UNSPECIFIED = 0 + USER = 1 + SYSTEM = 2 + SUPPORT = 3 + + +class ActionType(proto.Enum): + r"""Types of actions that may change a resource.""" + ACTION_TYPE_UNSPECIFIED = 0 + CREATED = 1 + UPDATED = 2 + DELETED = 3 + + +class ChangeHistoryResourceType(proto.Enum): + r"""Types of resources whose changes may be returned from change + history. + """ + CHANGE_HISTORY_RESOURCE_TYPE_UNSPECIFIED = 0 + ACCOUNT = 1 + PROPERTY = 2 + WEB_DATA_STREAM = 3 + ANDROID_APP_DATA_STREAM = 4 + IOS_APP_DATA_STREAM = 5 + FIREBASE_LINK = 6 + GOOGLE_ADS_LINK = 7 + GOOGLE_SIGNALS_SETTINGS = 8 + CONVERSION_EVENT = 9 + MEASUREMENT_PROTOCOL_SECRET = 10 + CUSTOM_DIMENSION = 11 + CUSTOM_METRIC = 12 + + +class GoogleSignalsState(proto.Enum): + r"""Status of the Google Signals settings (i.e., whether this + feature has been enabled for the property). + """ + GOOGLE_SIGNALS_STATE_UNSPECIFIED = 0 + GOOGLE_SIGNALS_ENABLED = 1 + GOOGLE_SIGNALS_DISABLED = 2 + + +class GoogleSignalsConsent(proto.Enum): + r"""Consent field of the Google Signals settings (i.e., whether + the user has consented to the Google Signals terms of service.) + """ + GOOGLE_SIGNALS_CONSENT_UNSPECIFIED = 0 + GOOGLE_SIGNALS_CONSENT_CONSENTED = 2 + GOOGLE_SIGNALS_CONSENT_NOT_CONSENTED = 1 + + +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_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.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): + Required. 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". + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. If set, the time at which this + property was trashed. If not set, then this + property is not currently in the trash can. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. If set, the time at which this + trashed property will be permanently deleted. If + not set, then this property is not currently in + the trash can and is not slated to be deleted. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.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, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, + ) + expire_time = proto.Field( + proto.MESSAGE, + number=12, + message=timestamp_pb2.Timestamp, + ) + + +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_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.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_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.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_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.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): + Output only. Example format: + properties/1234/userLinks/5678 + email_address (str): + Immutable. 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_pb2.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_pb2.BoolValue, + ) + email_address = proto.Field( + proto.STRING, + number=6, + ) + create_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + + +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, + ) + + +class MeasurementProtocolSecret(proto.Message): + r"""A secret value used for sending hits to Measurement Protocol. + Attributes: + name (str): + Output only. Resource name of this secret. + This secret may be a child of any type of + stream. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + display_name (str): + Required. Human-readable display name for + this secret. + secret_value (str): + Output only. The measurement protocol secret value. Pass + this value to the api_secret field of the Measurement + Protocol API when sending hits to this secret's parent + property. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + secret_value = proto.Field( + proto.STRING, + number=3, + ) + + +class ChangeHistoryEvent(proto.Message): + r"""A set of changes within a Google Analytics account or its + child properties that resulted from the same cause. Common + causes would be updates made in the Google Analytics UI, changes + from customer support, or automatic Google Analytics system + changes. + + Attributes: + id (str): + ID of this change history event. This ID is + unique across Google Analytics. + change_time (google.protobuf.timestamp_pb2.Timestamp): + Time when change was made. + actor_type (google.analytics.admin_v1alpha.types.ActorType): + The type of actor that made this change. + user_actor_email (str): + Email address of the Google account that made + the change. This will be a valid email address + if the actor field is set to USER, and empty + otherwise. Google accounts that have been + deleted will cause an error. + changes_filtered (bool): + If true, then the list of changes returned + was filtered, and does not represent all changes + that occurred in this event. + changes (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryChange]): + A list of changes made in this change history + event that fit the filters specified in + SearchChangeHistoryEventsRequest. + """ + + id = proto.Field( + proto.STRING, + number=1, + ) + change_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + actor_type = proto.Field( + proto.ENUM, + number=3, + enum='ActorType', + ) + user_actor_email = proto.Field( + proto.STRING, + number=4, + ) + changes_filtered = proto.Field( + proto.BOOL, + number=5, + ) + changes = proto.RepeatedField( + proto.MESSAGE, + number=6, + message='ChangeHistoryChange', + ) + + +class ChangeHistoryChange(proto.Message): + r"""A description of a change to a single Google Analytics + resource. + + Attributes: + resource (str): + Resource name of the resource whose changes + are described by this entry. + action (google.analytics.admin_v1alpha.types.ActionType): + The type of action that changed this + resource. + resource_before_change (google.analytics.admin_v1alpha.types.ChangeHistoryChange.ChangeHistoryResource): + Resource contents from before the change was + made. If this resource was created in this + change, this field will be missing. + resource_after_change (google.analytics.admin_v1alpha.types.ChangeHistoryChange.ChangeHistoryResource): + Resource contents from after the change was + made. If this resource was deleted in this + change, this field will be missing. + """ + + class ChangeHistoryResource(proto.Message): + r"""A snapshot of a resource as before or after the result of a + change in change history. + + Attributes: + account (google.analytics.admin_v1alpha.types.Account): + A snapshot of an Account resource in change + history. + property (google.analytics.admin_v1alpha.types.Property): + A snapshot of a Property resource in change + history. + web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): + A snapshot of a WebDataStream resource in + change history. + android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): + A snapshot of an AndroidAppDataStream + resource in change history. + ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): + A snapshot of an IosAppDataStream resource in + change history. + firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): + A snapshot of a FirebaseLink resource in + change history. + google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): + A snapshot of a GoogleAdsLink resource in + change history. + google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): + A snapshot of a GoogleSignalsSettings + resource in change history. + conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): + A snapshot of a ConversionEvent resource in + change history. + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + A snapshot of a MeasurementProtocolSecret + resource in change history. + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + A snapshot of a CustomDimension resource in + change history. + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + A snapshot of a CustomMetric resource in + change history. + """ + + account = proto.Field( + proto.MESSAGE, + number=1, + oneof='resource', + message='Account', + ) + property = proto.Field( + proto.MESSAGE, + number=2, + oneof='resource', + message='Property', + ) + web_data_stream = proto.Field( + proto.MESSAGE, + number=3, + oneof='resource', + message='WebDataStream', + ) + android_app_data_stream = proto.Field( + proto.MESSAGE, + number=4, + oneof='resource', + message='AndroidAppDataStream', + ) + ios_app_data_stream = proto.Field( + proto.MESSAGE, + number=5, + oneof='resource', + message='IosAppDataStream', + ) + firebase_link = proto.Field( + proto.MESSAGE, + number=6, + oneof='resource', + message='FirebaseLink', + ) + google_ads_link = proto.Field( + proto.MESSAGE, + number=7, + oneof='resource', + message='GoogleAdsLink', + ) + google_signals_settings = proto.Field( + proto.MESSAGE, + number=8, + oneof='resource', + message='GoogleSignalsSettings', + ) + conversion_event = proto.Field( + proto.MESSAGE, + number=11, + oneof='resource', + message='ConversionEvent', + ) + measurement_protocol_secret = proto.Field( + proto.MESSAGE, + number=12, + oneof='resource', + message='MeasurementProtocolSecret', + ) + custom_dimension = proto.Field( + proto.MESSAGE, + number=13, + oneof='resource', + message='CustomDimension', + ) + custom_metric = proto.Field( + proto.MESSAGE, + number=14, + oneof='resource', + message='CustomMetric', + ) + + resource = proto.Field( + proto.STRING, + number=1, + ) + action = proto.Field( + proto.ENUM, + number=2, + enum='ActionType', + ) + resource_before_change = proto.Field( + proto.MESSAGE, + number=3, + message=ChangeHistoryResource, + ) + resource_after_change = proto.Field( + proto.MESSAGE, + number=4, + message=ChangeHistoryResource, + ) + + +class ConversionEvent(proto.Message): + r"""A conversion event in a Google Analytics property. + Attributes: + name (str): + Output only. Resource name of this conversion event. Format: + properties/{property}/conversionEvents/{conversion_event} + event_name (str): + Immutable. The event name for this conversion + event. Examples: 'click', 'purchase' + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this conversion event + was created in the property. + is_deletable (bool): + Output only. If set, this event can currently + be deleted via DeleteConversionEvent. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + event_name = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + is_deletable = proto.Field( + proto.BOOL, + number=4, + ) + + +class GoogleSignalsSettings(proto.Message): + r"""Settings values for Google Signals. This is a singleton + resource. + + Attributes: + name (str): + Output only. Resource name of this setting. Format: + properties/{property_id}/googleSignalsSettings Example: + "properties/1000/googleSignalsSettings". + state (google.analytics.admin_v1alpha.types.GoogleSignalsState): + Status of this setting. + consent (google.analytics.admin_v1alpha.types.GoogleSignalsConsent): + Output only. Terms of Service acceptance. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + state = proto.Field( + proto.ENUM, + number=3, + enum='GoogleSignalsState', + ) + consent = proto.Field( + proto.ENUM, + number=4, + enum='GoogleSignalsConsent', + ) + + +class CustomDimension(proto.Message): + r"""A definition for a CustomDimension. + Attributes: + name (str): + Output only. Resource name for this + CustomDimension resource. Format: + properties/{property}/customDimensions/{customDimension} + parameter_name (str): + Required. Immutable. Tagging parameter name + for this custom dimension. + If this is a user-scoped dimension, then this is + the user property name. If this is an event- + scoped dimension, then this is the event + parameter name. + + May only contain alphanumeric and underscore + characters, starting with a letter. Max length + of 24 characters for user-scoped dimensions, 40 + characters for event-scoped dimensions. + display_name (str): + Required. Display name for this custom + dimension as shown in the Analytics UI. Max + length of 82 characters, alphanumeric plus space + and underscore starting with a letter. Legacy + system-generated display names may contain + square brackets, but updates to this field will + never permit square brackets. + description (str): + Optional. Description for this custom + dimension. Max length of 150 characters. + scope (google.analytics.admin_v1alpha.types.CustomDimension.DimensionScope): + Required. Immutable. The scope of this + dimension. + disallow_ads_personalization (bool): + Optional. If set to true, sets this dimension + as NPA and excludes it from ads personalization. + This is currently only supported by user-scoped + custom dimensions. + """ + class DimensionScope(proto.Enum): + r"""Valid values for the scope of this dimension.""" + DIMENSION_SCOPE_UNSPECIFIED = 0 + EVENT = 1 + USER = 2 + + name = proto.Field( + proto.STRING, + number=1, + ) + parameter_name = proto.Field( + proto.STRING, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + description = proto.Field( + proto.STRING, + number=4, + ) + scope = proto.Field( + proto.ENUM, + number=5, + enum=DimensionScope, + ) + disallow_ads_personalization = proto.Field( + proto.BOOL, + number=6, + ) + + +class CustomMetric(proto.Message): + r"""A definition for a custom metric. + Attributes: + name (str): + Output only. Resource name for this + CustomMetric resource. Format: + properties/{property}/customMetrics/{customMetric} + parameter_name (str): + Required. Immutable. Tagging name for this + custom metric. + If this is an event-scoped metric, then this is + the event parameter name. + + May only contain alphanumeric and underscore + charactes, starting with a letter. Max length of + 40 characters for event-scoped metrics. + display_name (str): + Required. Display name for this custom metric + as shown in the Analytics UI. Max length of 82 + characters, alphanumeric plus space and + underscore starting with a letter. Legacy + system-generated display names may contain + square brackets, but updates to this field will + never permit square brackets. + description (str): + Optional. Description for this custom + dimension. Max length of 150 characters. + measurement_unit (google.analytics.admin_v1alpha.types.CustomMetric.MeasurementUnit): + Required. Immutable. The type for the custom + metric's value. + scope (google.analytics.admin_v1alpha.types.CustomMetric.MetricScope): + Required. Immutable. The scope of this custom + metric. + """ + class MeasurementUnit(proto.Enum): + r"""Possible types of representing the custom metric's value. + Currency representation may change in the future, requiring a + breaking API change. + """ + MEASUREMENT_UNIT_UNSPECIFIED = 0 + STANDARD = 1 + CURRENCY = 2 + FEET = 3 + METERS = 4 + KILOMETERS = 5 + MILES = 6 + MILLISECONDS = 7 + SECONDS = 8 + MINUTES = 9 + HOURS = 10 + + class MetricScope(proto.Enum): + r"""The scope of this metric.""" + METRIC_SCOPE_UNSPECIFIED = 0 + EVENT = 1 + + name = proto.Field( + proto.STRING, + number=1, + ) + parameter_name = proto.Field( + proto.STRING, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + description = proto.Field( + proto.STRING, + number=4, + ) + measurement_unit = proto.Field( + proto.ENUM, + number=5, + enum=MeasurementUnit, + ) + scope = proto.Field( + proto.ENUM, + number=6, + enum=MetricScope, + ) + + +__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..af3f21b7 --- /dev/null +++ b/owl-bot-staging/v1alpha/noxfile.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", +] + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/analytics/admin_v1alpha/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py new file mode 100644 index 00000000..24c3b61f --- /dev/null +++ b/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py @@ -0,0 +1,243 @@ +#! /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]] = { + 'archive_custom_dimension': ('name', ), + 'archive_custom_metric': ('name', ), + '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_conversion_event': ('conversion_event', 'parent', ), + 'create_custom_dimension': ('parent', 'custom_dimension', ), + 'create_custom_metric': ('parent', 'custom_metric', ), + 'create_firebase_link': ('parent', 'firebase_link', ), + 'create_google_ads_link': ('parent', 'google_ads_link', ), + 'create_measurement_protocol_secret': ('parent', 'measurement_protocol_secret', ), + '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_conversion_event': ('name', ), + 'delete_firebase_link': ('name', ), + 'delete_google_ads_link': ('name', ), + 'delete_ios_app_data_stream': ('name', ), + 'delete_measurement_protocol_secret': ('name', ), + 'delete_property': ('name', ), + 'delete_user_link': ('name', ), + 'delete_web_data_stream': ('name', ), + 'get_account': ('name', ), + 'get_android_app_data_stream': ('name', ), + 'get_conversion_event': ('name', ), + 'get_custom_dimension': ('name', ), + 'get_custom_metric': ('name', ), + 'get_data_sharing_settings': ('name', ), + 'get_enhanced_measurement_settings': ('name', ), + 'get_global_site_tag': ('name', ), + 'get_google_signals_settings': ('name', ), + 'get_ios_app_data_stream': ('name', ), + 'get_measurement_protocol_secret': ('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_conversion_events': ('parent', 'page_size', 'page_token', ), + 'list_custom_dimensions': ('parent', 'page_size', 'page_token', ), + 'list_custom_metrics': ('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_measurement_protocol_secrets': ('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', ), + 'search_change_history_events': ('account', 'property', 'resource_type', 'action', 'actor_email', 'earliest_change_time', 'latest_change_time', 'page_size', 'page_token', ), + 'update_account': ('account', 'update_mask', ), + 'update_android_app_data_stream': ('android_app_data_stream', 'update_mask', ), + 'update_custom_dimension': ('update_mask', 'custom_dimension', ), + 'update_custom_metric': ('update_mask', 'custom_metric', ), + '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_google_signals_settings': ('google_signals_settings', 'update_mask', ), + 'update_ios_app_data_stream': ('ios_app_data_stream', 'update_mask', ), + 'update_measurement_protocol_secret': ('measurement_protocol_secret', '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..a9698642 --- /dev/null +++ b/owl-bot-staging/v1alpha/setup.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-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.27.0, < 3.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + 'packaging >= 14.3', ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1alpha/tests/__init__.py b/owl-bot-staging/v1alpha/tests/__init__.py new file mode 100644 index 00000000..b54a5fcc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/__init__.py b/owl-bot-staging/v1alpha/tests/unit/__init__.py new file mode 100644 index 00000000..b54a5fcc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py new file mode 100644 index 00000000..b54a5fcc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/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..b54a5fcc --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__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/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..8eda4f6e --- /dev/null +++ b/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py @@ -0,0 +1,19266 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.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.services.analytics_admin_service.transports.base import _GOOGLE_AUTH_VERSION +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 as core_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 as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert 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 = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'analyticsadmin.googleapis.com:443' + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.AnalyticsAdminServiceGrpcTransport, "grpc"), + (transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_analytics_admin_service_client_service_account_always_use_jwt(transport_class, transport_name): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) + + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize("client_class", [ + AnalyticsAdminServiceClient, + AnalyticsAdminServiceAsyncClient, +]) +def test_analytics_admin_service_client_from_service_account_file(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == '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=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(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, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (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, + always_use_jwt_access=True, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (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, + always_use_jwt_access=True, + ) + +@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, + always_use_jwt_access=True, + ) + + +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, + always_use_jwt_access=True, + ) + + +def test_get_account(transport: str = 'grpc', request_type=analytics_admin.GetAccountRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_account( + analytics_admin.GetAccountRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_account_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_account( + analytics_admin.GetAccountRequest(), + name='name_value', + ) + + +def test_list_accounts(transport: str = 'grpc', request_type=analytics_admin.ListAccountsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_account( + analytics_admin.DeleteAccountRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_account_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_account( + analytics_admin.DeleteAccountRequest(), + name='name_value', + ) + + +def test_update_account(transport: str = 'grpc', request_type=analytics_admin.UpdateAccountRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].account == resources.Account(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_account_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_account( + analytics_admin.UpdateAccountRequest(), + account=resources.Account(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_account_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].account == resources.Account(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_account_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_account( + analytics_admin.UpdateAccountRequest(), + account=resources.Account(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_provision_account_ticket(transport: str = 'grpc', request_type=analytics_admin.ProvisionAccountTicketRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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', + ) + 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' + + +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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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', + )) + 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' + + +@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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_property( + analytics_admin.GetPropertyRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_property_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_property( + analytics_admin.GetPropertyRequest(), + name='name_value', + ) + + +def test_list_properties(transport: str = 'grpc', request_type=analytics_admin.ListPropertiesRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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', + ) + 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' + + +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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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', + )) + 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' + + +@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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_property( + analytics_admin.CreatePropertyRequest(), + property=resources.Property(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_property_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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 = 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', + ) + 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 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' + + +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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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(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', + )) + 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 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' + + +@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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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 = resources.Property() + 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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(resources.Property()) + 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=ga_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 = resources.Property() + # 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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_property( + analytics_admin.DeletePropertyRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_property_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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 = 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.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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_property( + analytics_admin.DeletePropertyRequest(), + name='name_value', + ) + + +def test_update_property(transport: str = 'grpc', request_type=analytics_admin.UpdatePropertyRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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', + ) + 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' + + +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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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', + )) + 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' + + +@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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].property == resources.Property(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_property_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_property( + analytics_admin.UpdatePropertyRequest(), + property=resources.Property(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_property_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].property == resources.Property(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_property_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_property( + analytics_admin.UpdatePropertyRequest(), + property=resources.Property(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_get_user_link(transport: str = 'grpc', request_type=analytics_admin.GetUserLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_user_link( + analytics_admin.GetUserLinkRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_user_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_user_links( + analytics_admin.ListUserLinksRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_user_links_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_user_links( + analytics_admin.ListUserLinksRequest(), + parent='parent_value', + ) + + +def test_list_user_links_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_user_link( + analytics_admin.DeleteUserLinkRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_user_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_web_data_stream( + analytics_admin.GetWebDataStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_web_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_web_data_stream( + analytics_admin.DeleteWebDataStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_web_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].web_data_stream == resources.WebDataStream(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_web_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_web_data_stream( + analytics_admin.UpdateWebDataStreamRequest(), + web_data_stream=resources.WebDataStream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_web_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].web_data_stream == resources.WebDataStream(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_web_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_web_data_stream( + analytics_admin.UpdateWebDataStreamRequest(), + web_data_stream=resources.WebDataStream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.CreateWebDataStreamRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_web_data_streams( + analytics_admin.ListWebDataStreamsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_web_data_streams_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_web_data_streams( + analytics_admin.ListWebDataStreamsRequest(), + parent='parent_value', + ) + + +def test_list_web_data_streams_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].ios_app_data_stream == resources.IosAppDataStream(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_ios_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_ios_app_data_stream( + analytics_admin.UpdateIosAppDataStreamRequest(), + ios_app_data_stream=resources.IosAppDataStream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_ios_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].ios_app_data_stream == resources.IosAppDataStream(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_ios_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_ios_app_data_stream( + analytics_admin.UpdateIosAppDataStreamRequest(), + ios_app_data_stream=resources.IosAppDataStream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_list_ios_app_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListIosAppDataStreamsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_ios_app_data_streams( + analytics_admin.ListIosAppDataStreamsRequest(), + parent='parent_value', + ) + + +def test_list_ios_app_data_streams_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_android_app_data_stream_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_android_app_data_stream( + analytics_admin.UpdateAndroidAppDataStreamRequest(), + android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_android_app_data_stream_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_android_app_data_stream_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_android_app_data_stream( + analytics_admin.UpdateAndroidAppDataStreamRequest(), + android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_list_android_app_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListAndroidAppDataStreamsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_android_app_data_streams( + analytics_admin.ListAndroidAppDataStreamsRequest(), + parent='parent_value', + ) + + +def test_list_android_app_data_streams_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_enhanced_measurement_settings( + analytics_admin.GetEnhancedMeasurementSettingsRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_enhanced_measurement_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].enhanced_measurement_settings == resources.EnhancedMeasurementSettings(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_enhanced_measurement_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_enhanced_measurement_settings( + analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), + enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_enhanced_measurement_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].enhanced_measurement_settings == resources.EnhancedMeasurementSettings(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_enhanced_measurement_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_enhanced_measurement_settings( + analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), + enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_firebase_link(transport: str = 'grpc', request_type=analytics_admin.CreateFirebaseLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].firebase_link == resources.FirebaseLink(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_firebase_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_firebase_link( + analytics_admin.UpdateFirebaseLinkRequest(), + firebase_link=resources.FirebaseLink(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_firebase_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].firebase_link == resources.FirebaseLink(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_firebase_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_firebase_link( + analytics_admin.UpdateFirebaseLinkRequest(), + firebase_link=resources.FirebaseLink(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_firebase_link(transport: str = 'grpc', request_type=analytics_admin.DeleteFirebaseLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_firebase_link( + analytics_admin.DeleteFirebaseLinkRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_firebase_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_firebase_link( + analytics_admin.DeleteFirebaseLinkRequest(), + name='name_value', + ) + + +def test_list_firebase_links(transport: str = 'grpc', request_type=analytics_admin.ListFirebaseLinksRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_firebase_links( + analytics_admin.ListFirebaseLinksRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_firebase_links_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_firebase_links( + analytics_admin.ListFirebaseLinksRequest(), + parent='parent_value', + ) + + +def test_list_firebase_links_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_global_site_tag( + analytics_admin.GetGlobalSiteTagRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_global_site_tag_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].google_ads_link == resources.GoogleAdsLink(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_google_ads_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_google_ads_link( + analytics_admin.UpdateGoogleAdsLinkRequest(), + google_ads_link=resources.GoogleAdsLink(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_google_ads_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].google_ads_link == resources.GoogleAdsLink(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_google_ads_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_google_ads_link( + analytics_admin.UpdateGoogleAdsLinkRequest(), + google_ads_link=resources.GoogleAdsLink(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_google_ads_link(transport: str = 'grpc', request_type=analytics_admin.DeleteGoogleAdsLinkRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_google_ads_link( + analytics_admin.DeleteGoogleAdsLinkRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_google_ads_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_google_ads_links( + analytics_admin.ListGoogleAdsLinksRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_google_ads_links_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_google_ads_links( + analytics_admin.ListGoogleAdsLinksRequest(), + parent='parent_value', + ) + + +def test_list_google_ads_links_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_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=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_data_sharing_settings( + analytics_admin.GetDataSharingSettingsRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_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=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_data_sharing_settings( + analytics_admin.GetDataSharingSettingsRequest(), + name='name_value', + ) + + +def test_get_measurement_protocol_secret(transport: str = 'grpc', request_type=analytics_admin.GetMeasurementProtocolSecretRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret( + name='name_value', + display_name='display_name_value', + secret_value='secret_value_value', + ) + response = client.get_measurement_protocol_secret(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.GetMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.secret_value == 'secret_value_value' + + +def test_get_measurement_protocol_secret_from_dict(): + test_get_measurement_protocol_secret(request_type=dict) + + +def test_get_measurement_protocol_secret_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), + '__call__') as call: + client.get_measurement_protocol_secret() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetMeasurementProtocolSecretRequest() + + +@pytest.mark.asyncio +async def test_get_measurement_protocol_secret_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetMeasurementProtocolSecretRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret( + name='name_value', + display_name='display_name_value', + secret_value='secret_value_value', + )) + response = await client.get_measurement_protocol_secret(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.GetMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.secret_value == 'secret_value_value' + + +@pytest.mark.asyncio +async def test_get_measurement_protocol_secret_async_from_dict(): + await test_get_measurement_protocol_secret_async(request_type=dict) + + +def test_get_measurement_protocol_secret_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetMeasurementProtocolSecretRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), + '__call__') as call: + call.return_value = resources.MeasurementProtocolSecret() + client.get_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_measurement_protocol_secret_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetMeasurementProtocolSecretRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) + await client.get_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_measurement_protocol_secret_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_measurement_protocol_secret( + 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_measurement_protocol_secret_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_measurement_protocol_secret( + analytics_admin.GetMeasurementProtocolSecretRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_measurement_protocol_secret_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_measurement_protocol_secret( + 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_measurement_protocol_secret_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_measurement_protocol_secret( + analytics_admin.GetMeasurementProtocolSecretRequest(), + name='name_value', + ) + + +def test_list_measurement_protocol_secrets(transport: str = 'grpc', request_type=analytics_admin.ListMeasurementProtocolSecretsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secrets), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_measurement_protocol_secrets(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.ListMeasurementProtocolSecretsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMeasurementProtocolSecretsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_measurement_protocol_secrets_from_dict(): + test_list_measurement_protocol_secrets(request_type=dict) + + +def test_list_measurement_protocol_secrets_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__') as call: + client.list_measurement_protocol_secrets() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListMeasurementProtocolSecretsRequest() + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListMeasurementProtocolSecretsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secrets), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListMeasurementProtocolSecretsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_measurement_protocol_secrets(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.ListMeasurementProtocolSecretsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMeasurementProtocolSecretsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_async_from_dict(): + await test_list_measurement_protocol_secrets_async(request_type=dict) + + +def test_list_measurement_protocol_secrets_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ListMeasurementProtocolSecretsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__') as call: + call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + client.list_measurement_protocol_secrets(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_measurement_protocol_secrets_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ListMeasurementProtocolSecretsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListMeasurementProtocolSecretsResponse()) + await client.list_measurement_protocol_secrets(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_measurement_protocol_secrets_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_measurement_protocol_secrets( + 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_measurement_protocol_secrets_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_measurement_protocol_secrets( + analytics_admin.ListMeasurementProtocolSecretsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListMeasurementProtocolSecretsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_measurement_protocol_secrets( + 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_measurement_protocol_secrets_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_measurement_protocol_secrets( + analytics_admin.ListMeasurementProtocolSecretsRequest(), + parent='parent_value', + ) + + +def test_list_measurement_protocol_secrets_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + next_page_token='abc', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], + next_page_token='def', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + ], + next_page_token='ghi', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_measurement_protocol_secrets(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.MeasurementProtocolSecret) + for i in results) + +def test_list_measurement_protocol_secrets_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + next_page_token='abc', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], + next_page_token='def', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + ], + next_page_token='ghi', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + ), + RuntimeError, + ) + pages = list(client.list_measurement_protocol_secrets(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_measurement_protocol_secrets_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + next_page_token='abc', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], + next_page_token='def', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + ], + next_page_token='ghi', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_measurement_protocol_secrets(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.MeasurementProtocolSecret) + for i in responses) + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + next_page_token='abc', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], + next_page_token='def', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + ], + next_page_token='ghi', + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_measurement_protocol_secrets(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_measurement_protocol_secret(transport: str = 'grpc', request_type=analytics_admin.CreateMeasurementProtocolSecretRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret( + name='name_value', + display_name='display_name_value', + secret_value='secret_value_value', + ) + response = client.create_measurement_protocol_secret(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.CreateMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.secret_value == 'secret_value_value' + + +def test_create_measurement_protocol_secret_from_dict(): + test_create_measurement_protocol_secret(request_type=dict) + + +def test_create_measurement_protocol_secret_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), + '__call__') as call: + client.create_measurement_protocol_secret() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateMeasurementProtocolSecretRequest() + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateMeasurementProtocolSecretRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret( + name='name_value', + display_name='display_name_value', + secret_value='secret_value_value', + )) + response = await client.create_measurement_protocol_secret(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.CreateMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.secret_value == 'secret_value_value' + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_async_from_dict(): + await test_create_measurement_protocol_secret_async(request_type=dict) + + +def test_create_measurement_protocol_secret_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CreateMeasurementProtocolSecretRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), + '__call__') as call: + call.return_value = resources.MeasurementProtocolSecret() + client.create_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_measurement_protocol_secret_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CreateMeasurementProtocolSecretRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) + await client.create_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_measurement_protocol_secret_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_measurement_protocol_secret( + parent='parent_value', + measurement_protocol_secret=resources.MeasurementProtocolSecret(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].measurement_protocol_secret == resources.MeasurementProtocolSecret(name='name_value') + + +def test_create_measurement_protocol_secret_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_measurement_protocol_secret( + analytics_admin.CreateMeasurementProtocolSecretRequest(), + parent='parent_value', + measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_measurement_protocol_secret( + parent='parent_value', + measurement_protocol_secret=resources.MeasurementProtocolSecret(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].measurement_protocol_secret == resources.MeasurementProtocolSecret(name='name_value') + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_measurement_protocol_secret( + analytics_admin.CreateMeasurementProtocolSecretRequest(), + parent='parent_value', + measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), + ) + + +def test_delete_measurement_protocol_secret(transport: str = 'grpc', request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_measurement_protocol_secret(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.DeleteMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_measurement_protocol_secret_from_dict(): + test_delete_measurement_protocol_secret(request_type=dict) + + +def test_delete_measurement_protocol_secret_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), + '__call__') as call: + client.delete_measurement_protocol_secret() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteMeasurementProtocolSecretRequest() + + +@pytest.mark.asyncio +async def test_delete_measurement_protocol_secret_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_measurement_protocol_secret(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.DeleteMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_measurement_protocol_secret_async_from_dict(): + await test_delete_measurement_protocol_secret_async(request_type=dict) + + +def test_delete_measurement_protocol_secret_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.DeleteMeasurementProtocolSecretRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), + '__call__') as call: + call.return_value = None + client.delete_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_measurement_protocol_secret_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.DeleteMeasurementProtocolSecretRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_measurement_protocol_secret_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), + '__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_measurement_protocol_secret( + 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_measurement_protocol_secret_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_measurement_protocol_secret( + analytics_admin.DeleteMeasurementProtocolSecretRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_measurement_protocol_secret_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), + '__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_measurement_protocol_secret( + 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_measurement_protocol_secret_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_measurement_protocol_secret( + analytics_admin.DeleteMeasurementProtocolSecretRequest(), + name='name_value', + ) + + +def test_update_measurement_protocol_secret(transport: str = 'grpc', request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret( + name='name_value', + display_name='display_name_value', + secret_value='secret_value_value', + ) + response = client.update_measurement_protocol_secret(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.UpdateMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.secret_value == 'secret_value_value' + + +def test_update_measurement_protocol_secret_from_dict(): + test_update_measurement_protocol_secret(request_type=dict) + + +def test_update_measurement_protocol_secret_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), + '__call__') as call: + client.update_measurement_protocol_secret() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateMeasurementProtocolSecretRequest() + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret( + name='name_value', + display_name='display_name_value', + secret_value='secret_value_value', + )) + response = await client.update_measurement_protocol_secret(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.UpdateMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.secret_value == 'secret_value_value' + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_async_from_dict(): + await test_update_measurement_protocol_secret_async(request_type=dict) + + +def test_update_measurement_protocol_secret_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.UpdateMeasurementProtocolSecretRequest() + + request.measurement_protocol_secret.name = 'measurement_protocol_secret.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), + '__call__') as call: + call.return_value = resources.MeasurementProtocolSecret() + client.update_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'measurement_protocol_secret.name=measurement_protocol_secret.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.UpdateMeasurementProtocolSecretRequest() + + request.measurement_protocol_secret.name = 'measurement_protocol_secret.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) + await client.update_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'measurement_protocol_secret.name=measurement_protocol_secret.name/value', + ) in kw['metadata'] + + +def test_update_measurement_protocol_secret_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_measurement_protocol_secret( + measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].measurement_protocol_secret == resources.MeasurementProtocolSecret(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_measurement_protocol_secret_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_measurement_protocol_secret( + analytics_admin.UpdateMeasurementProtocolSecretRequest(), + measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_measurement_protocol_secret( + measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].measurement_protocol_secret == resources.MeasurementProtocolSecret(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_measurement_protocol_secret( + analytics_admin.UpdateMeasurementProtocolSecretRequest(), + measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_search_change_history_events(transport: str = 'grpc', request_type=analytics_admin.SearchChangeHistoryEventsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.SearchChangeHistoryEventsResponse( + next_page_token='next_page_token_value', + ) + response = client.search_change_history_events(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.SearchChangeHistoryEventsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchChangeHistoryEventsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_search_change_history_events_from_dict(): + test_search_change_history_events(request_type=dict) + + +def test_search_change_history_events_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__') as call: + client.search_change_history_events() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.SearchChangeHistoryEventsRequest() + + +@pytest.mark.asyncio +async def test_search_change_history_events_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.SearchChangeHistoryEventsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.SearchChangeHistoryEventsResponse( + next_page_token='next_page_token_value', + )) + response = await client.search_change_history_events(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.SearchChangeHistoryEventsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchChangeHistoryEventsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_search_change_history_events_async_from_dict(): + await test_search_change_history_events_async(request_type=dict) + + +def test_search_change_history_events_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.SearchChangeHistoryEventsRequest() + + request.account = 'account/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__') as call: + call.return_value = analytics_admin.SearchChangeHistoryEventsResponse() + client.search_change_history_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'account=account/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_search_change_history_events_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.SearchChangeHistoryEventsRequest() + + request.account = 'account/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.SearchChangeHistoryEventsResponse()) + await client.search_change_history_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'account=account/value', + ) in kw['metadata'] + + +def test_search_change_history_events_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + next_page_token='abc', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], + next_page_token='def', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + ], + next_page_token='ghi', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('account', ''), + )), + ) + pager = client.search_change_history_events(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.ChangeHistoryEvent) + for i in results) + +def test_search_change_history_events_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + next_page_token='abc', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], + next_page_token='def', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + ], + next_page_token='ghi', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + ), + RuntimeError, + ) + pages = list(client.search_change_history_events(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_search_change_history_events_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + next_page_token='abc', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], + next_page_token='def', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + ], + next_page_token='ghi', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + ), + RuntimeError, + ) + async_pager = await client.search_change_history_events(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.ChangeHistoryEvent) + for i in responses) + +@pytest.mark.asyncio +async def test_search_change_history_events_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + next_page_token='abc', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], + next_page_token='def', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + ], + next_page_token='ghi', + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.search_change_history_events(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_google_signals_settings(transport: str = 'grpc', request_type=analytics_admin.GetGoogleSignalsSettingsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_signals_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings( + name='name_value', + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + ) + response = client.get_google_signals_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.GetGoogleSignalsSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleSignalsSettings) + assert response.name == 'name_value' + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert response.consent == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + + +def test_get_google_signals_settings_from_dict(): + test_get_google_signals_settings(request_type=dict) + + +def test_get_google_signals_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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), + '__call__') as call: + client.get_google_signals_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetGoogleSignalsSettingsRequest() + + +@pytest.mark.asyncio +async def test_get_google_signals_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetGoogleSignalsSettingsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_google_signals_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings( + name='name_value', + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + )) + response = await client.get_google_signals_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.GetGoogleSignalsSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleSignalsSettings) + assert response.name == 'name_value' + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert response.consent == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + + +@pytest.mark.asyncio +async def test_get_google_signals_settings_async_from_dict(): + await test_get_google_signals_settings_async(request_type=dict) + + +def test_get_google_signals_settings_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetGoogleSignalsSettingsRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), + '__call__') as call: + call.return_value = resources.GoogleSignalsSettings() + client.get_google_signals_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_google_signals_settings_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetGoogleSignalsSettingsRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings()) + await client.get_google_signals_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_google_signals_settings_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_google_signals_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_google_signals_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_google_signals_settings( + analytics_admin.GetGoogleSignalsSettingsRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_google_signals_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_google_signals_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_google_signals_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_google_signals_settings( + analytics_admin.GetGoogleSignalsSettingsRequest(), + name='name_value', + ) + + +def test_update_google_signals_settings(transport: str = 'grpc', request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_signals_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings( + name='name_value', + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + ) + response = client.update_google_signals_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.UpdateGoogleSignalsSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleSignalsSettings) + assert response.name == 'name_value' + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert response.consent == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + + +def test_update_google_signals_settings_from_dict(): + test_update_google_signals_settings(request_type=dict) + + +def test_update_google_signals_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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), + '__call__') as call: + client.update_google_signals_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateGoogleSignalsSettingsRequest() + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_signals_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings( + name='name_value', + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + )) + response = await client.update_google_signals_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.UpdateGoogleSignalsSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleSignalsSettings) + assert response.name == 'name_value' + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert response.consent == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_async_from_dict(): + await test_update_google_signals_settings_async(request_type=dict) + + +def test_update_google_signals_settings_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.UpdateGoogleSignalsSettingsRequest() + + request.google_signals_settings.name = 'google_signals_settings.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), + '__call__') as call: + call.return_value = resources.GoogleSignalsSettings() + client.update_google_signals_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', + 'google_signals_settings.name=google_signals_settings.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.UpdateGoogleSignalsSettingsRequest() + + request.google_signals_settings.name = 'google_signals_settings.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings()) + await client.update_google_signals_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', + 'google_signals_settings.name=google_signals_settings.name/value', + ) in kw['metadata'] + + +def test_update_google_signals_settings_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_google_signals_settings( + google_signals_settings=resources.GoogleSignalsSettings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].google_signals_settings == resources.GoogleSignalsSettings(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_google_signals_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_google_signals_settings( + analytics_admin.UpdateGoogleSignalsSettingsRequest(), + google_signals_settings=resources.GoogleSignalsSettings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_google_signals_settings( + google_signals_settings=resources.GoogleSignalsSettings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].google_signals_settings == resources.GoogleSignalsSettings(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_google_signals_settings( + analytics_admin.UpdateGoogleSignalsSettingsRequest(), + google_signals_settings=resources.GoogleSignalsSettings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_conversion_event(transport: str = 'grpc', request_type=analytics_admin.CreateConversionEventRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent( + name='name_value', + event_name='event_name_value', + is_deletable=True, + ) + response = client.create_conversion_event(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.CreateConversionEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ConversionEvent) + assert response.name == 'name_value' + assert response.event_name == 'event_name_value' + assert response.is_deletable is True + + +def test_create_conversion_event_from_dict(): + test_create_conversion_event(request_type=dict) + + +def test_create_conversion_event_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), + '__call__') as call: + client.create_conversion_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateConversionEventRequest() + + +@pytest.mark.asyncio +async def test_create_conversion_event_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateConversionEventRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent( + name='name_value', + event_name='event_name_value', + is_deletable=True, + )) + response = await client.create_conversion_event(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.CreateConversionEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ConversionEvent) + assert response.name == 'name_value' + assert response.event_name == 'event_name_value' + assert response.is_deletable is True + + +@pytest.mark.asyncio +async def test_create_conversion_event_async_from_dict(): + await test_create_conversion_event_async(request_type=dict) + + +def test_create_conversion_event_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CreateConversionEventRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), + '__call__') as call: + call.return_value = resources.ConversionEvent() + client.create_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_conversion_event_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CreateConversionEventRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent()) + await client.create_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_conversion_event_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_conversion_event( + parent='parent_value', + conversion_event=resources.ConversionEvent(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].conversion_event == resources.ConversionEvent(name='name_value') + + +def test_create_conversion_event_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_conversion_event( + analytics_admin.CreateConversionEventRequest(), + parent='parent_value', + conversion_event=resources.ConversionEvent(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_conversion_event_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_conversion_event( + parent='parent_value', + conversion_event=resources.ConversionEvent(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].conversion_event == resources.ConversionEvent(name='name_value') + + +@pytest.mark.asyncio +async def test_create_conversion_event_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_conversion_event( + analytics_admin.CreateConversionEventRequest(), + parent='parent_value', + conversion_event=resources.ConversionEvent(name='name_value'), + ) + + +def test_get_conversion_event(transport: str = 'grpc', request_type=analytics_admin.GetConversionEventRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent( + name='name_value', + event_name='event_name_value', + is_deletable=True, + ) + response = client.get_conversion_event(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.GetConversionEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ConversionEvent) + assert response.name == 'name_value' + assert response.event_name == 'event_name_value' + assert response.is_deletable is True + + +def test_get_conversion_event_from_dict(): + test_get_conversion_event(request_type=dict) + + +def test_get_conversion_event_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), + '__call__') as call: + client.get_conversion_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetConversionEventRequest() + + +@pytest.mark.asyncio +async def test_get_conversion_event_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetConversionEventRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent( + name='name_value', + event_name='event_name_value', + is_deletable=True, + )) + response = await client.get_conversion_event(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.GetConversionEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ConversionEvent) + assert response.name == 'name_value' + assert response.event_name == 'event_name_value' + assert response.is_deletable is True + + +@pytest.mark.asyncio +async def test_get_conversion_event_async_from_dict(): + await test_get_conversion_event_async(request_type=dict) + + +def test_get_conversion_event_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetConversionEventRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), + '__call__') as call: + call.return_value = resources.ConversionEvent() + client.get_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_conversion_event_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetConversionEventRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent()) + await client.get_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_conversion_event_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_conversion_event( + 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_conversion_event_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_conversion_event( + analytics_admin.GetConversionEventRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_conversion_event_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_conversion_event( + 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_conversion_event_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_conversion_event( + analytics_admin.GetConversionEventRequest(), + name='name_value', + ) + + +def test_delete_conversion_event(transport: str = 'grpc', request_type=analytics_admin.DeleteConversionEventRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_conversion_event(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.DeleteConversionEventRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_conversion_event_from_dict(): + test_delete_conversion_event(request_type=dict) + + +def test_delete_conversion_event_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), + '__call__') as call: + client.delete_conversion_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteConversionEventRequest() + + +@pytest.mark.asyncio +async def test_delete_conversion_event_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteConversionEventRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversion_event), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_conversion_event(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.DeleteConversionEventRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_conversion_event_async_from_dict(): + await test_delete_conversion_event_async(request_type=dict) + + +def test_delete_conversion_event_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.DeleteConversionEventRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), + '__call__') as call: + call.return_value = None + client.delete_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_conversion_event_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.DeleteConversionEventRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_conversion_event_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), + '__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_conversion_event( + 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_conversion_event_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_conversion_event( + analytics_admin.DeleteConversionEventRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_conversion_event_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), + '__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_conversion_event( + 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_conversion_event_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_conversion_event( + analytics_admin.DeleteConversionEventRequest(), + name='name_value', + ) + + +def test_list_conversion_events(transport: str = 'grpc', request_type=analytics_admin.ListConversionEventsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversion_events), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListConversionEventsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_conversion_events(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.ListConversionEventsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversionEventsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_conversion_events_from_dict(): + test_list_conversion_events(request_type=dict) + + +def test_list_conversion_events_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__') as call: + client.list_conversion_events() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListConversionEventsRequest() + + +@pytest.mark.asyncio +async def test_list_conversion_events_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListConversionEventsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversion_events), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListConversionEventsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_conversion_events(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.ListConversionEventsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversionEventsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_conversion_events_async_from_dict(): + await test_list_conversion_events_async(request_type=dict) + + +def test_list_conversion_events_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ListConversionEventsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__') as call: + call.return_value = analytics_admin.ListConversionEventsResponse() + client.list_conversion_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_conversion_events_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ListConversionEventsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListConversionEventsResponse()) + await client.list_conversion_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_conversion_events_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListConversionEventsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_conversion_events( + 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_conversion_events_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_conversion_events( + analytics_admin.ListConversionEventsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_conversion_events_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListConversionEventsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListConversionEventsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_conversion_events( + 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_conversion_events_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_conversion_events( + analytics_admin.ListConversionEventsRequest(), + parent='parent_value', + ) + + +def test_list_conversion_events_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token='abc', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], + next_page_token='def', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + ], + next_page_token='ghi', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_conversion_events(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.ConversionEvent) + for i in results) + +def test_list_conversion_events_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token='abc', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], + next_page_token='def', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + ], + next_page_token='ghi', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + RuntimeError, + ) + pages = list(client.list_conversion_events(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_conversion_events_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token='abc', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], + next_page_token='def', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + ], + next_page_token='ghi', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_conversion_events(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.ConversionEvent) + for i in responses) + +@pytest.mark.asyncio +async def test_list_conversion_events_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token='abc', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], + next_page_token='def', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + ], + next_page_token='ghi', + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_conversion_events(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_custom_dimension(transport: str = 'grpc', request_type=analytics_admin.CreateCustomDimensionRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + response = client.create_custom_dimension(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.CreateCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +def test_create_custom_dimension_from_dict(): + test_create_custom_dimension(request_type=dict) + + +def test_create_custom_dimension_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), + '__call__') as call: + client.create_custom_dimension() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateCustomDimensionRequest() + + +@pytest.mark.asyncio +async def test_create_custom_dimension_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateCustomDimensionRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + )) + response = await client.create_custom_dimension(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.CreateCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +@pytest.mark.asyncio +async def test_create_custom_dimension_async_from_dict(): + await test_create_custom_dimension_async(request_type=dict) + + +def test_create_custom_dimension_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CreateCustomDimensionRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), + '__call__') as call: + call.return_value = resources.CustomDimension() + client.create_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_custom_dimension_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CreateCustomDimensionRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) + await client.create_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_custom_dimension_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_custom_dimension( + parent='parent_value', + custom_dimension=resources.CustomDimension(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].custom_dimension == resources.CustomDimension(name='name_value') + + +def test_create_custom_dimension_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_custom_dimension( + analytics_admin.CreateCustomDimensionRequest(), + parent='parent_value', + custom_dimension=resources.CustomDimension(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_custom_dimension_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_custom_dimension( + parent='parent_value', + custom_dimension=resources.CustomDimension(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].custom_dimension == resources.CustomDimension(name='name_value') + + +@pytest.mark.asyncio +async def test_create_custom_dimension_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_custom_dimension( + analytics_admin.CreateCustomDimensionRequest(), + parent='parent_value', + custom_dimension=resources.CustomDimension(name='name_value'), + ) + + +def test_update_custom_dimension(transport: str = 'grpc', request_type=analytics_admin.UpdateCustomDimensionRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + response = client.update_custom_dimension(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.UpdateCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +def test_update_custom_dimension_from_dict(): + test_update_custom_dimension(request_type=dict) + + +def test_update_custom_dimension_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), + '__call__') as call: + client.update_custom_dimension() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateCustomDimensionRequest() + + +@pytest.mark.asyncio +async def test_update_custom_dimension_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateCustomDimensionRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + )) + response = await client.update_custom_dimension(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.UpdateCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +@pytest.mark.asyncio +async def test_update_custom_dimension_async_from_dict(): + await test_update_custom_dimension_async(request_type=dict) + + +def test_update_custom_dimension_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.UpdateCustomDimensionRequest() + + request.custom_dimension.name = 'custom_dimension.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), + '__call__') as call: + call.return_value = resources.CustomDimension() + client.update_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'custom_dimension.name=custom_dimension.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_custom_dimension_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.UpdateCustomDimensionRequest() + + request.custom_dimension.name = 'custom_dimension.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) + await client.update_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'custom_dimension.name=custom_dimension.name/value', + ) in kw['metadata'] + + +def test_update_custom_dimension_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_custom_dimension( + custom_dimension=resources.CustomDimension(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].custom_dimension == resources.CustomDimension(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_custom_dimension_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_custom_dimension( + analytics_admin.UpdateCustomDimensionRequest(), + custom_dimension=resources.CustomDimension(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_custom_dimension_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_custom_dimension( + custom_dimension=resources.CustomDimension(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].custom_dimension == resources.CustomDimension(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_custom_dimension_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_custom_dimension( + analytics_admin.UpdateCustomDimensionRequest(), + custom_dimension=resources.CustomDimension(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_list_custom_dimensions(transport: str = 'grpc', request_type=analytics_admin.ListCustomDimensionsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_dimensions), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomDimensionsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_custom_dimensions(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.ListCustomDimensionsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomDimensionsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_custom_dimensions_from_dict(): + test_list_custom_dimensions(request_type=dict) + + +def test_list_custom_dimensions_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__') as call: + client.list_custom_dimensions() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListCustomDimensionsRequest() + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListCustomDimensionsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_dimensions), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomDimensionsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_custom_dimensions(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.ListCustomDimensionsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomDimensionsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_async_from_dict(): + await test_list_custom_dimensions_async(request_type=dict) + + +def test_list_custom_dimensions_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ListCustomDimensionsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__') as call: + call.return_value = analytics_admin.ListCustomDimensionsResponse() + client.list_custom_dimensions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_custom_dimensions_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ListCustomDimensionsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomDimensionsResponse()) + await client.list_custom_dimensions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_custom_dimensions_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomDimensionsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_custom_dimensions( + 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_custom_dimensions_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_custom_dimensions( + analytics_admin.ListCustomDimensionsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomDimensionsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomDimensionsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_custom_dimensions( + 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_custom_dimensions_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_custom_dimensions( + analytics_admin.ListCustomDimensionsRequest(), + parent='parent_value', + ) + + +def test_list_custom_dimensions_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), + ], + next_page_token='abc', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], + next_page_token='def', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + ], + next_page_token='ghi', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_custom_dimensions(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CustomDimension) + for i in results) + +def test_list_custom_dimensions_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), + ], + next_page_token='abc', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], + next_page_token='def', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + ], + next_page_token='ghi', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + ], + ), + RuntimeError, + ) + pages = list(client.list_custom_dimensions(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_custom_dimensions_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), + ], + next_page_token='abc', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], + next_page_token='def', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + ], + next_page_token='ghi', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_custom_dimensions(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.CustomDimension) + for i in responses) + +@pytest.mark.asyncio +async def test_list_custom_dimensions_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), + ], + next_page_token='abc', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], + next_page_token='def', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + ], + next_page_token='ghi', + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_custom_dimensions(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_archive_custom_dimension(transport: str = 'grpc', request_type=analytics_admin.ArchiveCustomDimensionRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.archive_custom_dimension(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.ArchiveCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_archive_custom_dimension_from_dict(): + test_archive_custom_dimension(request_type=dict) + + +def test_archive_custom_dimension_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), + '__call__') as call: + client.archive_custom_dimension() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ArchiveCustomDimensionRequest() + + +@pytest.mark.asyncio +async def test_archive_custom_dimension_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ArchiveCustomDimensionRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.archive_custom_dimension(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.ArchiveCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_archive_custom_dimension_async_from_dict(): + await test_archive_custom_dimension_async(request_type=dict) + + +def test_archive_custom_dimension_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ArchiveCustomDimensionRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), + '__call__') as call: + call.return_value = None + client.archive_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_archive_custom_dimension_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ArchiveCustomDimensionRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.archive_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_archive_custom_dimension_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), + '__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.archive_custom_dimension( + 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_archive_custom_dimension_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.archive_custom_dimension( + analytics_admin.ArchiveCustomDimensionRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_archive_custom_dimension_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), + '__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.archive_custom_dimension( + 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_archive_custom_dimension_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.archive_custom_dimension( + analytics_admin.ArchiveCustomDimensionRequest(), + name='name_value', + ) + + +def test_get_custom_dimension(transport: str = 'grpc', request_type=analytics_admin.GetCustomDimensionRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + response = client.get_custom_dimension(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.GetCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +def test_get_custom_dimension_from_dict(): + test_get_custom_dimension(request_type=dict) + + +def test_get_custom_dimension_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), + '__call__') as call: + client.get_custom_dimension() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetCustomDimensionRequest() + + +@pytest.mark.asyncio +async def test_get_custom_dimension_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetCustomDimensionRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + )) + response = await client.get_custom_dimension(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.GetCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +@pytest.mark.asyncio +async def test_get_custom_dimension_async_from_dict(): + await test_get_custom_dimension_async(request_type=dict) + + +def test_get_custom_dimension_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetCustomDimensionRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), + '__call__') as call: + call.return_value = resources.CustomDimension() + client.get_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_custom_dimension_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetCustomDimensionRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) + await client.get_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_custom_dimension_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_custom_dimension( + 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_custom_dimension_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_custom_dimension( + analytics_admin.GetCustomDimensionRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_custom_dimension_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_custom_dimension( + 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_custom_dimension_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_custom_dimension( + analytics_admin.GetCustomDimensionRequest(), + name='name_value', + ) + + +def test_create_custom_metric(transport: str = 'grpc', request_type=analytics_admin.CreateCustomMetricRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + response = client.create_custom_metric(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.CreateCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +def test_create_custom_metric_from_dict(): + test_create_custom_metric(request_type=dict) + + +def test_create_custom_metric_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), + '__call__') as call: + client.create_custom_metric() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateCustomMetricRequest() + + +@pytest.mark.asyncio +async def test_create_custom_metric_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateCustomMetricRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + )) + response = await client.create_custom_metric(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.CreateCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +@pytest.mark.asyncio +async def test_create_custom_metric_async_from_dict(): + await test_create_custom_metric_async(request_type=dict) + + +def test_create_custom_metric_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CreateCustomMetricRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), + '__call__') as call: + call.return_value = resources.CustomMetric() + client.create_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_custom_metric_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CreateCustomMetricRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) + await client.create_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_custom_metric_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_custom_metric( + parent='parent_value', + custom_metric=resources.CustomMetric(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].custom_metric == resources.CustomMetric(name='name_value') + + +def test_create_custom_metric_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_custom_metric( + analytics_admin.CreateCustomMetricRequest(), + parent='parent_value', + custom_metric=resources.CustomMetric(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_custom_metric_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_custom_metric( + parent='parent_value', + custom_metric=resources.CustomMetric(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].custom_metric == resources.CustomMetric(name='name_value') + + +@pytest.mark.asyncio +async def test_create_custom_metric_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_custom_metric( + analytics_admin.CreateCustomMetricRequest(), + parent='parent_value', + custom_metric=resources.CustomMetric(name='name_value'), + ) + + +def test_update_custom_metric(transport: str = 'grpc', request_type=analytics_admin.UpdateCustomMetricRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + response = client.update_custom_metric(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.UpdateCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +def test_update_custom_metric_from_dict(): + test_update_custom_metric(request_type=dict) + + +def test_update_custom_metric_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), + '__call__') as call: + client.update_custom_metric() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateCustomMetricRequest() + + +@pytest.mark.asyncio +async def test_update_custom_metric_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateCustomMetricRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + )) + response = await client.update_custom_metric(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.UpdateCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +@pytest.mark.asyncio +async def test_update_custom_metric_async_from_dict(): + await test_update_custom_metric_async(request_type=dict) + + +def test_update_custom_metric_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.UpdateCustomMetricRequest() + + request.custom_metric.name = 'custom_metric.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), + '__call__') as call: + call.return_value = resources.CustomMetric() + client.update_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'custom_metric.name=custom_metric.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_custom_metric_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.UpdateCustomMetricRequest() + + request.custom_metric.name = 'custom_metric.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) + await client.update_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'custom_metric.name=custom_metric.name/value', + ) in kw['metadata'] + + +def test_update_custom_metric_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_custom_metric( + custom_metric=resources.CustomMetric(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].custom_metric == resources.CustomMetric(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_custom_metric_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_custom_metric( + analytics_admin.UpdateCustomMetricRequest(), + custom_metric=resources.CustomMetric(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_custom_metric_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_custom_metric( + custom_metric=resources.CustomMetric(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].custom_metric == resources.CustomMetric(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_custom_metric_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_custom_metric( + analytics_admin.UpdateCustomMetricRequest(), + custom_metric=resources.CustomMetric(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_list_custom_metrics(transport: str = 'grpc', request_type=analytics_admin.ListCustomMetricsRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_metrics), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomMetricsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_custom_metrics(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.ListCustomMetricsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomMetricsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_custom_metrics_from_dict(): + test_list_custom_metrics(request_type=dict) + + +def test_list_custom_metrics_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__') as call: + client.list_custom_metrics() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListCustomMetricsRequest() + + +@pytest.mark.asyncio +async def test_list_custom_metrics_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListCustomMetricsRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_metrics), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomMetricsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_custom_metrics(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.ListCustomMetricsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomMetricsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_custom_metrics_async_from_dict(): + await test_list_custom_metrics_async(request_type=dict) + + +def test_list_custom_metrics_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ListCustomMetricsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__') as call: + call.return_value = analytics_admin.ListCustomMetricsResponse() + client.list_custom_metrics(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_custom_metrics_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ListCustomMetricsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomMetricsResponse()) + await client.list_custom_metrics(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_custom_metrics_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomMetricsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_custom_metrics( + 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_custom_metrics_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_custom_metrics( + analytics_admin.ListCustomMetricsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_custom_metrics_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomMetricsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomMetricsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_custom_metrics( + 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_custom_metrics_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_custom_metrics( + analytics_admin.ListCustomMetricsRequest(), + parent='parent_value', + ) + + +def test_list_custom_metrics_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + resources.CustomMetric(), + ], + next_page_token='abc', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[], + next_page_token='def', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + ], + next_page_token='ghi', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_custom_metrics(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CustomMetric) + for i in results) + +def test_list_custom_metrics_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + resources.CustomMetric(), + ], + next_page_token='abc', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[], + next_page_token='def', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + ], + next_page_token='ghi', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + ], + ), + RuntimeError, + ) + pages = list(client.list_custom_metrics(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_custom_metrics_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + resources.CustomMetric(), + ], + next_page_token='abc', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[], + next_page_token='def', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + ], + next_page_token='ghi', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_custom_metrics(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.CustomMetric) + for i in responses) + +@pytest.mark.asyncio +async def test_list_custom_metrics_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + resources.CustomMetric(), + ], + next_page_token='abc', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[], + next_page_token='def', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + ], + next_page_token='ghi', + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_custom_metrics(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_archive_custom_metric(transport: str = 'grpc', request_type=analytics_admin.ArchiveCustomMetricRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.archive_custom_metric(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.ArchiveCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_archive_custom_metric_from_dict(): + test_archive_custom_metric(request_type=dict) + + +def test_archive_custom_metric_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), + '__call__') as call: + client.archive_custom_metric() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ArchiveCustomMetricRequest() + + +@pytest.mark.asyncio +async def test_archive_custom_metric_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ArchiveCustomMetricRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.archive_custom_metric(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.ArchiveCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_archive_custom_metric_async_from_dict(): + await test_archive_custom_metric_async(request_type=dict) + + +def test_archive_custom_metric_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ArchiveCustomMetricRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), + '__call__') as call: + call.return_value = None + client.archive_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_archive_custom_metric_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.ArchiveCustomMetricRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.archive_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_archive_custom_metric_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), + '__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.archive_custom_metric( + 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_archive_custom_metric_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.archive_custom_metric( + analytics_admin.ArchiveCustomMetricRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_archive_custom_metric_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), + '__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.archive_custom_metric( + 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_archive_custom_metric_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.archive_custom_metric( + analytics_admin.ArchiveCustomMetricRequest(), + name='name_value', + ) + + +def test_get_custom_metric(transport: str = 'grpc', request_type=analytics_admin.GetCustomMetricRequest): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + response = client.get_custom_metric(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.GetCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +def test_get_custom_metric_from_dict(): + test_get_custom_metric(request_type=dict) + + +def test_get_custom_metric_empty_call(): + # 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=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_metric), + '__call__') as call: + client.get_custom_metric() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetCustomMetricRequest() + + +@pytest.mark.asyncio +async def test_get_custom_metric_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetCustomMetricRequest): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric( + name='name_value', + parameter_name='parameter_name_value', + display_name='display_name_value', + description='description_value', + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + )) + response = await client.get_custom_metric(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.GetCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == 'name_value' + assert response.parameter_name == 'parameter_name_value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +@pytest.mark.asyncio +async def test_get_custom_metric_async_from_dict(): + await test_get_custom_metric_async(request_type=dict) + + +def test_get_custom_metric_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetCustomMetricRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_metric), + '__call__') as call: + call.return_value = resources.CustomMetric() + client.get_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_custom_metric_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.GetCustomMetricRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_metric), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) + await client.get_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_custom_metric_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_custom_metric( + 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_custom_metric_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_custom_metric( + analytics_admin.GetCustomMetricRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_custom_metric_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_metric), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_custom_metric( + 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_custom_metric_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_custom_metric( + analytics_admin.GetCustomMetricRequest(), + name='name_value', + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.AnalyticsAdminServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.AnalyticsAdminServiceGrpcTransport( + credentials=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( + credentials=ga_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(google.auth, 'default') as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = AnalyticsAdminServiceClient( + credentials=ga_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(core_exceptions.DuplicateCredentialArgs): + transport = transports.AnalyticsAdminServiceTransport( + credentials=ga_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=ga_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', + 'list_ios_app_data_streams', + 'get_android_app_data_stream', + 'delete_android_app_data_stream', + 'update_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', + 'get_measurement_protocol_secret', + 'list_measurement_protocol_secrets', + 'create_measurement_protocol_secret', + 'delete_measurement_protocol_secret', + 'update_measurement_protocol_secret', + 'search_change_history_events', + 'get_google_signals_settings', + 'update_google_signals_settings', + 'create_conversion_event', + 'get_conversion_event', + 'delete_conversion_event', + 'list_conversion_events', + 'create_custom_dimension', + 'update_custom_dimension', + 'list_custom_dimensions', + 'archive_custom_dimension', + 'get_custom_dimension', + 'create_custom_metric', + 'update_custom_metric', + 'list_custom_metrics', + 'archive_custom_metric', + 'get_custom_metric', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + +@requires_google_auth_gte_1_25_0 +def test_analytics_admin_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.AnalyticsAdminServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/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", + ) + + +@requires_google_auth_lt_1_25_0 +def test_analytics_admin_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_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(google.auth, 'default', autospec=True) 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 = (ga_credentials.AnonymousCredentials(), None) + transport = transports.AnalyticsAdminServiceTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_analytics_admin_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + AnalyticsAdminServiceClient() + adc.assert_called_once_with( + scopes=None, + default_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, + ) + + +@requires_google_auth_lt_1_25_0 +def test_analytics_admin_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + 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, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.AnalyticsAdminServiceGrpcTransport, + transports.AnalyticsAdminServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_analytics_admin_service_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/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, + ], +) +@requires_google_auth_lt_1_25_0 +def test_analytics_admin_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/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,grpc_helpers", + [ + (transports.AnalyticsAdminServiceGrpcTransport, grpc_helpers), + (transports.AnalyticsAdminServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_analytics_admin_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "analyticsadmin.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_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', +), + scopes=["1", "2"], + default_host="analyticsadmin.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.AnalyticsAdminServiceGrpcTransport, transports.AnalyticsAdminServiceGrpcAsyncIOTransport]) +def test_analytics_admin_service_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + + +def test_analytics_admin_service_host_no_port(): + client = AnalyticsAdminServiceClient( + credentials=ga_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=ga_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 = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.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=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_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_conversion_event_path(): + property = "winkle" + conversion_event = "nautilus" + expected = "properties/{property}/conversionEvents/{conversion_event}".format(property=property, conversion_event=conversion_event, ) + actual = AnalyticsAdminServiceClient.conversion_event_path(property, conversion_event) + assert expected == actual + + +def test_parse_conversion_event_path(): + expected = { + "property": "scallop", + "conversion_event": "abalone", + } + path = AnalyticsAdminServiceClient.conversion_event_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_conversion_event_path(path) + assert expected == actual + +def test_custom_dimension_path(): + property = "squid" + expected = "properties/{property}/customDimensions".format(property=property, ) + actual = AnalyticsAdminServiceClient.custom_dimension_path(property) + assert expected == actual + + +def test_parse_custom_dimension_path(): + expected = { + "property": "clam", + } + path = AnalyticsAdminServiceClient.custom_dimension_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_custom_dimension_path(path) + assert expected == actual + +def test_custom_metric_path(): + property = "whelk" + expected = "properties/{property}/customMetrics".format(property=property, ) + actual = AnalyticsAdminServiceClient.custom_metric_path(property) + assert expected == actual + + +def test_parse_custom_metric_path(): + expected = { + "property": "octopus", + } + path = AnalyticsAdminServiceClient.custom_metric_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_custom_metric_path(path) + assert expected == actual + +def test_data_sharing_settings_path(): + account = "oyster" + 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": "nudibranch", + } + 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 = "cuttlefish" + web_data_stream = "mussel" + 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": "winkle", + "web_data_stream": "nautilus", + } + 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 = "scallop" + firebase_link = "abalone" + 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": "squid", + "firebase_link": "clam", + } + 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 = "whelk" + 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": "octopus", + } + 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 = "oyster" + google_ads_link = "nudibranch" + 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": "cuttlefish", + "google_ads_link": "mussel", + } + 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_google_signals_settings_path(): + property = "winkle" + expected = "properties/{property}/googleSignalsSettings".format(property=property, ) + actual = AnalyticsAdminServiceClient.google_signals_settings_path(property) + assert expected == actual + + +def test_parse_google_signals_settings_path(): + expected = { + "property": "nautilus", + } + path = AnalyticsAdminServiceClient.google_signals_settings_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_google_signals_settings_path(path) + assert expected == actual + +def test_ios_app_data_stream_path(): + property = "scallop" + ios_app_data_stream = "abalone" + 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": "squid", + "ios_app_data_stream": "clam", + } + 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_measurement_protocol_secret_path(): + property = "whelk" + web_data_stream = "octopus" + measurement_protocol_secret = "oyster" + expected = "properties/{property}/webDataStreams/{web_data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}".format(property=property, web_data_stream=web_data_stream, measurement_protocol_secret=measurement_protocol_secret, ) + actual = AnalyticsAdminServiceClient.measurement_protocol_secret_path(property, web_data_stream, measurement_protocol_secret) + assert expected == actual + + +def test_parse_measurement_protocol_secret_path(): + expected = { + "property": "nudibranch", + "web_data_stream": "cuttlefish", + "measurement_protocol_secret": "mussel", + } + path = AnalyticsAdminServiceClient.measurement_protocol_secret_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_measurement_protocol_secret_path(path) + assert expected == actual + +def test_property_path(): + property = "winkle" + expected = "properties/{property}".format(property=property, ) + actual = AnalyticsAdminServiceClient.property_path(property) + assert expected == actual + + +def test_parse_property_path(): + expected = { + "property": "nautilus", + } + 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 = "scallop" + user_link = "abalone" + 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": "squid", + "user_link": "clam", + } + 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 = "whelk" + web_data_stream = "octopus" + 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": "oyster", + "web_data_stream": "nudibranch", + } + 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 = "cuttlefish" + 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": "mussel", + } + 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 = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = AnalyticsAdminServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + 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 = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = AnalyticsAdminServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + 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 = "squid" + expected = "projects/{project}".format(project=project, ) + actual = AnalyticsAdminServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + 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 = "whelk" + location = "octopus" + 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": "oyster", + "location": "nudibranch", + } + 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=ga_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=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) From a49f851bca1a1f9360e5eb0a5c5af9cfcfa8ad17 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 23 Jul 2021 21:32:21 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md --- .../analytics_admin_service/client.py | 4 + owl-bot-staging/v1alpha/.coveragerc | 17 - owl-bot-staging/v1alpha/MANIFEST.in | 2 - owl-bot-staging/v1alpha/README.rst | 49 - .../admin_v1alpha/analytics_admin_service.rst | 10 - .../v1alpha/docs/admin_v1alpha/services.rst | 6 - .../v1alpha/docs/admin_v1alpha/types.rst | 7 - owl-bot-staging/v1alpha/docs/conf.py | 376 - owl-bot-staging/v1alpha/docs/index.rst | 7 - .../google/analytics/admin/__init__.py | 253 - .../v1alpha/google/analytics/admin/py.typed | 2 - .../analytics/admin_v1alpha/__init__.py | 254 - .../admin_v1alpha/gapic_metadata.json | 703 - .../google/analytics/admin_v1alpha/py.typed | 2 - .../admin_v1alpha/services/__init__.py | 15 - .../analytics_admin_service/__init__.py | 22 - .../analytics_admin_service/async_client.py | 5495 ----- .../analytics_admin_service/client.py | 5840 ----- .../analytics_admin_service/pagers.py | 1849 -- .../transports/__init__.py | 33 - .../transports/base.py | 1111 - .../transports/grpc.py | 2083 -- .../transports/grpc_asyncio.py | 2087 -- .../analytics/admin_v1alpha/types/__init__.py | 252 - .../admin_v1alpha/types/analytics_admin.py | 2195 -- .../admin_v1alpha/types/resources.py | 1408 -- owl-bot-staging/v1alpha/mypy.ini | 3 - owl-bot-staging/v1alpha/noxfile.py | 132 - .../scripts/fixup_admin_v1alpha_keywords.py | 243 - owl-bot-staging/v1alpha/setup.py | 54 - owl-bot-staging/v1alpha/tests/__init__.py | 16 - .../v1alpha/tests/unit/__init__.py | 16 - .../v1alpha/tests/unit/gapic/__init__.py | 16 - .../unit/gapic/admin_v1alpha/__init__.py | 16 - .../test_analytics_admin_service.py | 19266 ---------------- .../test_analytics_admin_service.py | 31 +- 36 files changed, 22 insertions(+), 43853 deletions(-) delete mode 100644 owl-bot-staging/v1alpha/.coveragerc 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/gapic_metadata.json 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/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1alpha/tests/unit/gapic/__init__.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/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py index 5e965b75..38b1d7c1 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py @@ -570,6 +570,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def get_account( diff --git a/owl-bot-staging/v1alpha/.coveragerc b/owl-bot-staging/v1alpha/.coveragerc deleted file mode 100644 index e02b8f0e..00000000 --- a/owl-bot-staging/v1alpha/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/analytics/admin/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/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 d771e00c..00000000 --- a/owl-bot-staging/v1alpha/docs/admin_v1alpha/analytics_admin_service.rst +++ /dev/null @@ -1,10 +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 b7010958..00000000 --- a/owl-bot-staging/v1alpha/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# google-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 18c53507..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin/__init__.py +++ /dev/null @@ -1,253 +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.client import AnalyticsAdminServiceClient -from google.analytics.admin_v1alpha.services.analytics_admin_service.async_client import AnalyticsAdminServiceAsyncClient - -from google.analytics.admin_v1alpha.types.analytics_admin import ArchiveCustomDimensionRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ArchiveCustomMetricRequest -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 CreateConversionEventRequest -from google.analytics.admin_v1alpha.types.analytics_admin import CreateCustomDimensionRequest -from google.analytics.admin_v1alpha.types.analytics_admin import CreateCustomMetricRequest -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 CreateMeasurementProtocolSecretRequest -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 DeleteConversionEventRequest -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 DeleteMeasurementProtocolSecretRequest -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 GetConversionEventRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetCustomDimensionRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetCustomMetricRequest -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 GetGoogleSignalsSettingsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetIosAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import GetMeasurementProtocolSecretRequest -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 ListAccountsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsResponse -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 ListAndroidAppDataStreamsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListAndroidAppDataStreamsResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListConversionEventsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListConversionEventsResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListCustomDimensionsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListCustomDimensionsResponse -from google.analytics.admin_v1alpha.types.analytics_admin import ListCustomMetricsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListCustomMetricsResponse -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 ListMeasurementProtocolSecretsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListMeasurementProtocolSecretsResponse -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 SearchChangeHistoryEventsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import SearchChangeHistoryEventsResponse -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 UpdateCustomDimensionRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateCustomMetricRequest -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 UpdateGoogleSignalsSettingsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateIosAppDataStreamRequest -from google.analytics.admin_v1alpha.types.analytics_admin import UpdateMeasurementProtocolSecretRequest -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 ChangeHistoryChange -from google.analytics.admin_v1alpha.types.resources import ChangeHistoryEvent -from google.analytics.admin_v1alpha.types.resources import ConversionEvent -from google.analytics.admin_v1alpha.types.resources import CustomDimension -from google.analytics.admin_v1alpha.types.resources import CustomMetric -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 GoogleSignalsSettings -from google.analytics.admin_v1alpha.types.resources import IosAppDataStream -from google.analytics.admin_v1alpha.types.resources import MeasurementProtocolSecret -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 -from google.analytics.admin_v1alpha.types.resources import ActionType -from google.analytics.admin_v1alpha.types.resources import ActorType -from google.analytics.admin_v1alpha.types.resources import ChangeHistoryResourceType -from google.analytics.admin_v1alpha.types.resources import GoogleSignalsConsent -from google.analytics.admin_v1alpha.types.resources import GoogleSignalsState -from google.analytics.admin_v1alpha.types.resources import IndustryCategory -from google.analytics.admin_v1alpha.types.resources import MaximumUserAccess - -__all__ = ('AnalyticsAdminServiceClient', - 'AnalyticsAdminServiceAsyncClient', - 'ArchiveCustomDimensionRequest', - 'ArchiveCustomMetricRequest', - 'AuditUserLinksRequest', - 'AuditUserLinksResponse', - 'BatchCreateUserLinksRequest', - 'BatchCreateUserLinksResponse', - 'BatchDeleteUserLinksRequest', - 'BatchGetUserLinksRequest', - 'BatchGetUserLinksResponse', - 'BatchUpdateUserLinksRequest', - 'BatchUpdateUserLinksResponse', - 'CreateConversionEventRequest', - 'CreateCustomDimensionRequest', - 'CreateCustomMetricRequest', - 'CreateFirebaseLinkRequest', - 'CreateGoogleAdsLinkRequest', - 'CreateMeasurementProtocolSecretRequest', - 'CreatePropertyRequest', - 'CreateUserLinkRequest', - 'CreateWebDataStreamRequest', - 'DeleteAccountRequest', - 'DeleteAndroidAppDataStreamRequest', - 'DeleteConversionEventRequest', - 'DeleteFirebaseLinkRequest', - 'DeleteGoogleAdsLinkRequest', - 'DeleteIosAppDataStreamRequest', - 'DeleteMeasurementProtocolSecretRequest', - 'DeletePropertyRequest', - 'DeleteUserLinkRequest', - 'DeleteWebDataStreamRequest', - 'GetAccountRequest', - 'GetAndroidAppDataStreamRequest', - 'GetConversionEventRequest', - 'GetCustomDimensionRequest', - 'GetCustomMetricRequest', - 'GetDataSharingSettingsRequest', - 'GetEnhancedMeasurementSettingsRequest', - 'GetGlobalSiteTagRequest', - 'GetGoogleSignalsSettingsRequest', - 'GetIosAppDataStreamRequest', - 'GetMeasurementProtocolSecretRequest', - 'GetPropertyRequest', - 'GetUserLinkRequest', - 'GetWebDataStreamRequest', - 'ListAccountsRequest', - 'ListAccountsResponse', - 'ListAccountSummariesRequest', - 'ListAccountSummariesResponse', - 'ListAndroidAppDataStreamsRequest', - 'ListAndroidAppDataStreamsResponse', - 'ListConversionEventsRequest', - 'ListConversionEventsResponse', - 'ListCustomDimensionsRequest', - 'ListCustomDimensionsResponse', - 'ListCustomMetricsRequest', - 'ListCustomMetricsResponse', - 'ListFirebaseLinksRequest', - 'ListFirebaseLinksResponse', - 'ListGoogleAdsLinksRequest', - 'ListGoogleAdsLinksResponse', - 'ListIosAppDataStreamsRequest', - 'ListIosAppDataStreamsResponse', - 'ListMeasurementProtocolSecretsRequest', - 'ListMeasurementProtocolSecretsResponse', - 'ListPropertiesRequest', - 'ListPropertiesResponse', - 'ListUserLinksRequest', - 'ListUserLinksResponse', - 'ListWebDataStreamsRequest', - 'ListWebDataStreamsResponse', - 'ProvisionAccountTicketRequest', - 'ProvisionAccountTicketResponse', - 'SearchChangeHistoryEventsRequest', - 'SearchChangeHistoryEventsResponse', - 'UpdateAccountRequest', - 'UpdateAndroidAppDataStreamRequest', - 'UpdateCustomDimensionRequest', - 'UpdateCustomMetricRequest', - 'UpdateEnhancedMeasurementSettingsRequest', - 'UpdateFirebaseLinkRequest', - 'UpdateGoogleAdsLinkRequest', - 'UpdateGoogleSignalsSettingsRequest', - 'UpdateIosAppDataStreamRequest', - 'UpdateMeasurementProtocolSecretRequest', - 'UpdatePropertyRequest', - 'UpdateUserLinkRequest', - 'UpdateWebDataStreamRequest', - 'Account', - 'AccountSummary', - 'AndroidAppDataStream', - 'AuditUserLink', - 'ChangeHistoryChange', - 'ChangeHistoryEvent', - 'ConversionEvent', - 'CustomDimension', - 'CustomMetric', - 'DataSharingSettings', - 'EnhancedMeasurementSettings', - 'FirebaseLink', - 'GlobalSiteTag', - 'GoogleAdsLink', - 'GoogleSignalsSettings', - 'IosAppDataStream', - 'MeasurementProtocolSecret', - 'Property', - 'PropertySummary', - 'UserLink', - 'WebDataStream', - 'ActionType', - 'ActorType', - 'ChangeHistoryResourceType', - 'GoogleSignalsConsent', - 'GoogleSignalsState', - 'IndustryCategory', - 'MaximumUserAccess', -) 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 0b253fca..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/__init__.py +++ /dev/null @@ -1,254 +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 .services.analytics_admin_service import AnalyticsAdminServiceAsyncClient - -from .types.analytics_admin import ArchiveCustomDimensionRequest -from .types.analytics_admin import ArchiveCustomMetricRequest -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 CreateConversionEventRequest -from .types.analytics_admin import CreateCustomDimensionRequest -from .types.analytics_admin import CreateCustomMetricRequest -from .types.analytics_admin import CreateFirebaseLinkRequest -from .types.analytics_admin import CreateGoogleAdsLinkRequest -from .types.analytics_admin import CreateMeasurementProtocolSecretRequest -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 DeleteConversionEventRequest -from .types.analytics_admin import DeleteFirebaseLinkRequest -from .types.analytics_admin import DeleteGoogleAdsLinkRequest -from .types.analytics_admin import DeleteIosAppDataStreamRequest -from .types.analytics_admin import DeleteMeasurementProtocolSecretRequest -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 GetConversionEventRequest -from .types.analytics_admin import GetCustomDimensionRequest -from .types.analytics_admin import GetCustomMetricRequest -from .types.analytics_admin import GetDataSharingSettingsRequest -from .types.analytics_admin import GetEnhancedMeasurementSettingsRequest -from .types.analytics_admin import GetGlobalSiteTagRequest -from .types.analytics_admin import GetGoogleSignalsSettingsRequest -from .types.analytics_admin import GetIosAppDataStreamRequest -from .types.analytics_admin import GetMeasurementProtocolSecretRequest -from .types.analytics_admin import GetPropertyRequest -from .types.analytics_admin import GetUserLinkRequest -from .types.analytics_admin import GetWebDataStreamRequest -from .types.analytics_admin import ListAccountsRequest -from .types.analytics_admin import ListAccountsResponse -from .types.analytics_admin import ListAccountSummariesRequest -from .types.analytics_admin import ListAccountSummariesResponse -from .types.analytics_admin import ListAndroidAppDataStreamsRequest -from .types.analytics_admin import ListAndroidAppDataStreamsResponse -from .types.analytics_admin import ListConversionEventsRequest -from .types.analytics_admin import ListConversionEventsResponse -from .types.analytics_admin import ListCustomDimensionsRequest -from .types.analytics_admin import ListCustomDimensionsResponse -from .types.analytics_admin import ListCustomMetricsRequest -from .types.analytics_admin import ListCustomMetricsResponse -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 ListMeasurementProtocolSecretsRequest -from .types.analytics_admin import ListMeasurementProtocolSecretsResponse -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 SearchChangeHistoryEventsRequest -from .types.analytics_admin import SearchChangeHistoryEventsResponse -from .types.analytics_admin import UpdateAccountRequest -from .types.analytics_admin import UpdateAndroidAppDataStreamRequest -from .types.analytics_admin import UpdateCustomDimensionRequest -from .types.analytics_admin import UpdateCustomMetricRequest -from .types.analytics_admin import UpdateEnhancedMeasurementSettingsRequest -from .types.analytics_admin import UpdateFirebaseLinkRequest -from .types.analytics_admin import UpdateGoogleAdsLinkRequest -from .types.analytics_admin import UpdateGoogleSignalsSettingsRequest -from .types.analytics_admin import UpdateIosAppDataStreamRequest -from .types.analytics_admin import UpdateMeasurementProtocolSecretRequest -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 ChangeHistoryChange -from .types.resources import ChangeHistoryEvent -from .types.resources import ConversionEvent -from .types.resources import CustomDimension -from .types.resources import CustomMetric -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 GoogleSignalsSettings -from .types.resources import IosAppDataStream -from .types.resources import MeasurementProtocolSecret -from .types.resources import Property -from .types.resources import PropertySummary -from .types.resources import UserLink -from .types.resources import WebDataStream -from .types.resources import ActionType -from .types.resources import ActorType -from .types.resources import ChangeHistoryResourceType -from .types.resources import GoogleSignalsConsent -from .types.resources import GoogleSignalsState -from .types.resources import IndustryCategory -from .types.resources import MaximumUserAccess - -__all__ = ( - 'AnalyticsAdminServiceAsyncClient', -'Account', -'AccountSummary', -'ActionType', -'ActorType', -'AnalyticsAdminServiceClient', -'AndroidAppDataStream', -'ArchiveCustomDimensionRequest', -'ArchiveCustomMetricRequest', -'AuditUserLink', -'AuditUserLinksRequest', -'AuditUserLinksResponse', -'BatchCreateUserLinksRequest', -'BatchCreateUserLinksResponse', -'BatchDeleteUserLinksRequest', -'BatchGetUserLinksRequest', -'BatchGetUserLinksResponse', -'BatchUpdateUserLinksRequest', -'BatchUpdateUserLinksResponse', -'ChangeHistoryChange', -'ChangeHistoryEvent', -'ChangeHistoryResourceType', -'ConversionEvent', -'CreateConversionEventRequest', -'CreateCustomDimensionRequest', -'CreateCustomMetricRequest', -'CreateFirebaseLinkRequest', -'CreateGoogleAdsLinkRequest', -'CreateMeasurementProtocolSecretRequest', -'CreatePropertyRequest', -'CreateUserLinkRequest', -'CreateWebDataStreamRequest', -'CustomDimension', -'CustomMetric', -'DataSharingSettings', -'DeleteAccountRequest', -'DeleteAndroidAppDataStreamRequest', -'DeleteConversionEventRequest', -'DeleteFirebaseLinkRequest', -'DeleteGoogleAdsLinkRequest', -'DeleteIosAppDataStreamRequest', -'DeleteMeasurementProtocolSecretRequest', -'DeletePropertyRequest', -'DeleteUserLinkRequest', -'DeleteWebDataStreamRequest', -'EnhancedMeasurementSettings', -'FirebaseLink', -'GetAccountRequest', -'GetAndroidAppDataStreamRequest', -'GetConversionEventRequest', -'GetCustomDimensionRequest', -'GetCustomMetricRequest', -'GetDataSharingSettingsRequest', -'GetEnhancedMeasurementSettingsRequest', -'GetGlobalSiteTagRequest', -'GetGoogleSignalsSettingsRequest', -'GetIosAppDataStreamRequest', -'GetMeasurementProtocolSecretRequest', -'GetPropertyRequest', -'GetUserLinkRequest', -'GetWebDataStreamRequest', -'GlobalSiteTag', -'GoogleAdsLink', -'GoogleSignalsConsent', -'GoogleSignalsSettings', -'GoogleSignalsState', -'IndustryCategory', -'IosAppDataStream', -'ListAccountSummariesRequest', -'ListAccountSummariesResponse', -'ListAccountsRequest', -'ListAccountsResponse', -'ListAndroidAppDataStreamsRequest', -'ListAndroidAppDataStreamsResponse', -'ListConversionEventsRequest', -'ListConversionEventsResponse', -'ListCustomDimensionsRequest', -'ListCustomDimensionsResponse', -'ListCustomMetricsRequest', -'ListCustomMetricsResponse', -'ListFirebaseLinksRequest', -'ListFirebaseLinksResponse', -'ListGoogleAdsLinksRequest', -'ListGoogleAdsLinksResponse', -'ListIosAppDataStreamsRequest', -'ListIosAppDataStreamsResponse', -'ListMeasurementProtocolSecretsRequest', -'ListMeasurementProtocolSecretsResponse', -'ListPropertiesRequest', -'ListPropertiesResponse', -'ListUserLinksRequest', -'ListUserLinksResponse', -'ListWebDataStreamsRequest', -'ListWebDataStreamsResponse', -'MaximumUserAccess', -'MeasurementProtocolSecret', -'Property', -'PropertySummary', -'ProvisionAccountTicketRequest', -'ProvisionAccountTicketResponse', -'SearchChangeHistoryEventsRequest', -'SearchChangeHistoryEventsResponse', -'UpdateAccountRequest', -'UpdateAndroidAppDataStreamRequest', -'UpdateCustomDimensionRequest', -'UpdateCustomMetricRequest', -'UpdateEnhancedMeasurementSettingsRequest', -'UpdateFirebaseLinkRequest', -'UpdateGoogleAdsLinkRequest', -'UpdateGoogleSignalsSettingsRequest', -'UpdateIosAppDataStreamRequest', -'UpdateMeasurementProtocolSecretRequest', -'UpdatePropertyRequest', -'UpdateUserLinkRequest', -'UpdateWebDataStreamRequest', -'UserLink', -'WebDataStream', -) diff --git a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/gapic_metadata.json deleted file mode 100644 index fb4e612c..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/gapic_metadata.json +++ /dev/null @@ -1,703 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.analytics.admin_v1alpha", - "protoPackage": "google.analytics.admin.v1alpha", - "schema": "1.0", - "services": { - "AnalyticsAdminService": { - "clients": { - "grpc": { - "libraryClient": "AnalyticsAdminServiceClient", - "rpcs": { - "ArchiveCustomDimension": { - "methods": [ - "archive_custom_dimension" - ] - }, - "ArchiveCustomMetric": { - "methods": [ - "archive_custom_metric" - ] - }, - "AuditUserLinks": { - "methods": [ - "audit_user_links" - ] - }, - "BatchCreateUserLinks": { - "methods": [ - "batch_create_user_links" - ] - }, - "BatchDeleteUserLinks": { - "methods": [ - "batch_delete_user_links" - ] - }, - "BatchGetUserLinks": { - "methods": [ - "batch_get_user_links" - ] - }, - "BatchUpdateUserLinks": { - "methods": [ - "batch_update_user_links" - ] - }, - "CreateConversionEvent": { - "methods": [ - "create_conversion_event" - ] - }, - "CreateCustomDimension": { - "methods": [ - "create_custom_dimension" - ] - }, - "CreateCustomMetric": { - "methods": [ - "create_custom_metric" - ] - }, - "CreateFirebaseLink": { - "methods": [ - "create_firebase_link" - ] - }, - "CreateGoogleAdsLink": { - "methods": [ - "create_google_ads_link" - ] - }, - "CreateMeasurementProtocolSecret": { - "methods": [ - "create_measurement_protocol_secret" - ] - }, - "CreateProperty": { - "methods": [ - "create_property" - ] - }, - "CreateUserLink": { - "methods": [ - "create_user_link" - ] - }, - "CreateWebDataStream": { - "methods": [ - "create_web_data_stream" - ] - }, - "DeleteAccount": { - "methods": [ - "delete_account" - ] - }, - "DeleteAndroidAppDataStream": { - "methods": [ - "delete_android_app_data_stream" - ] - }, - "DeleteConversionEvent": { - "methods": [ - "delete_conversion_event" - ] - }, - "DeleteFirebaseLink": { - "methods": [ - "delete_firebase_link" - ] - }, - "DeleteGoogleAdsLink": { - "methods": [ - "delete_google_ads_link" - ] - }, - "DeleteIosAppDataStream": { - "methods": [ - "delete_ios_app_data_stream" - ] - }, - "DeleteMeasurementProtocolSecret": { - "methods": [ - "delete_measurement_protocol_secret" - ] - }, - "DeleteProperty": { - "methods": [ - "delete_property" - ] - }, - "DeleteUserLink": { - "methods": [ - "delete_user_link" - ] - }, - "DeleteWebDataStream": { - "methods": [ - "delete_web_data_stream" - ] - }, - "GetAccount": { - "methods": [ - "get_account" - ] - }, - "GetAndroidAppDataStream": { - "methods": [ - "get_android_app_data_stream" - ] - }, - "GetConversionEvent": { - "methods": [ - "get_conversion_event" - ] - }, - "GetCustomDimension": { - "methods": [ - "get_custom_dimension" - ] - }, - "GetCustomMetric": { - "methods": [ - "get_custom_metric" - ] - }, - "GetDataSharingSettings": { - "methods": [ - "get_data_sharing_settings" - ] - }, - "GetEnhancedMeasurementSettings": { - "methods": [ - "get_enhanced_measurement_settings" - ] - }, - "GetGlobalSiteTag": { - "methods": [ - "get_global_site_tag" - ] - }, - "GetGoogleSignalsSettings": { - "methods": [ - "get_google_signals_settings" - ] - }, - "GetIosAppDataStream": { - "methods": [ - "get_ios_app_data_stream" - ] - }, - "GetMeasurementProtocolSecret": { - "methods": [ - "get_measurement_protocol_secret" - ] - }, - "GetProperty": { - "methods": [ - "get_property" - ] - }, - "GetUserLink": { - "methods": [ - "get_user_link" - ] - }, - "GetWebDataStream": { - "methods": [ - "get_web_data_stream" - ] - }, - "ListAccountSummaries": { - "methods": [ - "list_account_summaries" - ] - }, - "ListAccounts": { - "methods": [ - "list_accounts" - ] - }, - "ListAndroidAppDataStreams": { - "methods": [ - "list_android_app_data_streams" - ] - }, - "ListConversionEvents": { - "methods": [ - "list_conversion_events" - ] - }, - "ListCustomDimensions": { - "methods": [ - "list_custom_dimensions" - ] - }, - "ListCustomMetrics": { - "methods": [ - "list_custom_metrics" - ] - }, - "ListFirebaseLinks": { - "methods": [ - "list_firebase_links" - ] - }, - "ListGoogleAdsLinks": { - "methods": [ - "list_google_ads_links" - ] - }, - "ListIosAppDataStreams": { - "methods": [ - "list_ios_app_data_streams" - ] - }, - "ListMeasurementProtocolSecrets": { - "methods": [ - "list_measurement_protocol_secrets" - ] - }, - "ListProperties": { - "methods": [ - "list_properties" - ] - }, - "ListUserLinks": { - "methods": [ - "list_user_links" - ] - }, - "ListWebDataStreams": { - "methods": [ - "list_web_data_streams" - ] - }, - "ProvisionAccountTicket": { - "methods": [ - "provision_account_ticket" - ] - }, - "SearchChangeHistoryEvents": { - "methods": [ - "search_change_history_events" - ] - }, - "UpdateAccount": { - "methods": [ - "update_account" - ] - }, - "UpdateAndroidAppDataStream": { - "methods": [ - "update_android_app_data_stream" - ] - }, - "UpdateCustomDimension": { - "methods": [ - "update_custom_dimension" - ] - }, - "UpdateCustomMetric": { - "methods": [ - "update_custom_metric" - ] - }, - "UpdateEnhancedMeasurementSettings": { - "methods": [ - "update_enhanced_measurement_settings" - ] - }, - "UpdateFirebaseLink": { - "methods": [ - "update_firebase_link" - ] - }, - "UpdateGoogleAdsLink": { - "methods": [ - "update_google_ads_link" - ] - }, - "UpdateGoogleSignalsSettings": { - "methods": [ - "update_google_signals_settings" - ] - }, - "UpdateIosAppDataStream": { - "methods": [ - "update_ios_app_data_stream" - ] - }, - "UpdateMeasurementProtocolSecret": { - "methods": [ - "update_measurement_protocol_secret" - ] - }, - "UpdateProperty": { - "methods": [ - "update_property" - ] - }, - "UpdateUserLink": { - "methods": [ - "update_user_link" - ] - }, - "UpdateWebDataStream": { - "methods": [ - "update_web_data_stream" - ] - } - } - }, - "grpc-async": { - "libraryClient": "AnalyticsAdminServiceAsyncClient", - "rpcs": { - "ArchiveCustomDimension": { - "methods": [ - "archive_custom_dimension" - ] - }, - "ArchiveCustomMetric": { - "methods": [ - "archive_custom_metric" - ] - }, - "AuditUserLinks": { - "methods": [ - "audit_user_links" - ] - }, - "BatchCreateUserLinks": { - "methods": [ - "batch_create_user_links" - ] - }, - "BatchDeleteUserLinks": { - "methods": [ - "batch_delete_user_links" - ] - }, - "BatchGetUserLinks": { - "methods": [ - "batch_get_user_links" - ] - }, - "BatchUpdateUserLinks": { - "methods": [ - "batch_update_user_links" - ] - }, - "CreateConversionEvent": { - "methods": [ - "create_conversion_event" - ] - }, - "CreateCustomDimension": { - "methods": [ - "create_custom_dimension" - ] - }, - "CreateCustomMetric": { - "methods": [ - "create_custom_metric" - ] - }, - "CreateFirebaseLink": { - "methods": [ - "create_firebase_link" - ] - }, - "CreateGoogleAdsLink": { - "methods": [ - "create_google_ads_link" - ] - }, - "CreateMeasurementProtocolSecret": { - "methods": [ - "create_measurement_protocol_secret" - ] - }, - "CreateProperty": { - "methods": [ - "create_property" - ] - }, - "CreateUserLink": { - "methods": [ - "create_user_link" - ] - }, - "CreateWebDataStream": { - "methods": [ - "create_web_data_stream" - ] - }, - "DeleteAccount": { - "methods": [ - "delete_account" - ] - }, - "DeleteAndroidAppDataStream": { - "methods": [ - "delete_android_app_data_stream" - ] - }, - "DeleteConversionEvent": { - "methods": [ - "delete_conversion_event" - ] - }, - "DeleteFirebaseLink": { - "methods": [ - "delete_firebase_link" - ] - }, - "DeleteGoogleAdsLink": { - "methods": [ - "delete_google_ads_link" - ] - }, - "DeleteIosAppDataStream": { - "methods": [ - "delete_ios_app_data_stream" - ] - }, - "DeleteMeasurementProtocolSecret": { - "methods": [ - "delete_measurement_protocol_secret" - ] - }, - "DeleteProperty": { - "methods": [ - "delete_property" - ] - }, - "DeleteUserLink": { - "methods": [ - "delete_user_link" - ] - }, - "DeleteWebDataStream": { - "methods": [ - "delete_web_data_stream" - ] - }, - "GetAccount": { - "methods": [ - "get_account" - ] - }, - "GetAndroidAppDataStream": { - "methods": [ - "get_android_app_data_stream" - ] - }, - "GetConversionEvent": { - "methods": [ - "get_conversion_event" - ] - }, - "GetCustomDimension": { - "methods": [ - "get_custom_dimension" - ] - }, - "GetCustomMetric": { - "methods": [ - "get_custom_metric" - ] - }, - "GetDataSharingSettings": { - "methods": [ - "get_data_sharing_settings" - ] - }, - "GetEnhancedMeasurementSettings": { - "methods": [ - "get_enhanced_measurement_settings" - ] - }, - "GetGlobalSiteTag": { - "methods": [ - "get_global_site_tag" - ] - }, - "GetGoogleSignalsSettings": { - "methods": [ - "get_google_signals_settings" - ] - }, - "GetIosAppDataStream": { - "methods": [ - "get_ios_app_data_stream" - ] - }, - "GetMeasurementProtocolSecret": { - "methods": [ - "get_measurement_protocol_secret" - ] - }, - "GetProperty": { - "methods": [ - "get_property" - ] - }, - "GetUserLink": { - "methods": [ - "get_user_link" - ] - }, - "GetWebDataStream": { - "methods": [ - "get_web_data_stream" - ] - }, - "ListAccountSummaries": { - "methods": [ - "list_account_summaries" - ] - }, - "ListAccounts": { - "methods": [ - "list_accounts" - ] - }, - "ListAndroidAppDataStreams": { - "methods": [ - "list_android_app_data_streams" - ] - }, - "ListConversionEvents": { - "methods": [ - "list_conversion_events" - ] - }, - "ListCustomDimensions": { - "methods": [ - "list_custom_dimensions" - ] - }, - "ListCustomMetrics": { - "methods": [ - "list_custom_metrics" - ] - }, - "ListFirebaseLinks": { - "methods": [ - "list_firebase_links" - ] - }, - "ListGoogleAdsLinks": { - "methods": [ - "list_google_ads_links" - ] - }, - "ListIosAppDataStreams": { - "methods": [ - "list_ios_app_data_streams" - ] - }, - "ListMeasurementProtocolSecrets": { - "methods": [ - "list_measurement_protocol_secrets" - ] - }, - "ListProperties": { - "methods": [ - "list_properties" - ] - }, - "ListUserLinks": { - "methods": [ - "list_user_links" - ] - }, - "ListWebDataStreams": { - "methods": [ - "list_web_data_streams" - ] - }, - "ProvisionAccountTicket": { - "methods": [ - "provision_account_ticket" - ] - }, - "SearchChangeHistoryEvents": { - "methods": [ - "search_change_history_events" - ] - }, - "UpdateAccount": { - "methods": [ - "update_account" - ] - }, - "UpdateAndroidAppDataStream": { - "methods": [ - "update_android_app_data_stream" - ] - }, - "UpdateCustomDimension": { - "methods": [ - "update_custom_dimension" - ] - }, - "UpdateCustomMetric": { - "methods": [ - "update_custom_metric" - ] - }, - "UpdateEnhancedMeasurementSettings": { - "methods": [ - "update_enhanced_measurement_settings" - ] - }, - "UpdateFirebaseLink": { - "methods": [ - "update_firebase_link" - ] - }, - "UpdateGoogleAdsLink": { - "methods": [ - "update_google_ads_link" - ] - }, - "UpdateGoogleSignalsSettings": { - "methods": [ - "update_google_signals_settings" - ] - }, - "UpdateIosAppDataStream": { - "methods": [ - "update_ios_app_data_stream" - ] - }, - "UpdateMeasurementProtocolSecret": { - "methods": [ - "update_measurement_protocol_secret" - ] - }, - "UpdateProperty": { - "methods": [ - "update_property" - ] - }, - "UpdateUserLink": { - "methods": [ - "update_user_link" - ] - }, - "UpdateWebDataStream": { - "methods": [ - "update_web_data_stream" - ] - } - } - } - } - } - } -} 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 4de65971..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/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 4d8bff41..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .client import 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 cc2c3af0..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py +++ /dev/null @@ -1,5495 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.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 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # 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) - conversion_event_path = staticmethod(AnalyticsAdminServiceClient.conversion_event_path) - parse_conversion_event_path = staticmethod(AnalyticsAdminServiceClient.parse_conversion_event_path) - custom_dimension_path = staticmethod(AnalyticsAdminServiceClient.custom_dimension_path) - parse_custom_dimension_path = staticmethod(AnalyticsAdminServiceClient.parse_custom_dimension_path) - custom_metric_path = staticmethod(AnalyticsAdminServiceClient.custom_metric_path) - parse_custom_metric_path = staticmethod(AnalyticsAdminServiceClient.parse_custom_metric_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) - google_signals_settings_path = staticmethod(AnalyticsAdminServiceClient.google_signals_settings_path) - parse_google_signals_settings_path = staticmethod(AnalyticsAdminServiceClient.parse_google_signals_settings_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) - measurement_protocol_secret_path = staticmethod(AnalyticsAdminServiceClient.measurement_protocol_secret_path) - parse_measurement_protocol_secret_path = staticmethod(AnalyticsAdminServiceClient.parse_measurement_protocol_secret_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: - """Returns 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: ga_credentials.Credentials = None, - transport: Union[str, AnalyticsAdminServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates 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_pb2.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]] = (), - ) -> resources.Property: - 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. - - 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.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. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_property(self, - request: analytics_admin.UpdatePropertyRequest = None, - *, - property: resources.Property = None, - update_mask: field_mask_pb2.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_pb2.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_pb2.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 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_pb2.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 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_pb2.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_pb2.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_pb2.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 - - async def get_measurement_protocol_secret(self, - request: analytics_admin.GetMeasurementProtocolSecretRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.MeasurementProtocolSecret: - r"""Lookup for a single "GA4" MeasurementProtocolSecret. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetMeasurementProtocolSecretRequest`): - The request object. Request message for - GetMeasurementProtocolSecret RPC. - name (:class:`str`): - Required. The name of the measurement - protocol secret to lookup. Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} - Note: Any type of stream (WebDataStream, - IosAppDataStream, AndroidAppDataStream) - may be a parent. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.MeasurementProtocolSecret: - A secret value used for sending hits - to Measurement Protocol. - - """ - # Create or coerce a protobuf request object. - # Sanity 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.GetMeasurementProtocolSecretRequest(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_measurement_protocol_secret, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_measurement_protocol_secrets(self, - request: analytics_admin.ListMeasurementProtocolSecretsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMeasurementProtocolSecretsAsyncPager: - r"""Returns child MeasurementProtocolSecrets under the - specified parent Property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest`): - The request object. Request message for - ListMeasurementProtocolSecret RPC - parent (:class:`str`): - Required. The resource name of the - parent stream. Any type of stream - (WebDataStream, IosAppDataStream, - AndroidAppDataStream) may be a parent. - Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets - - 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.ListMeasurementProtocolSecretsAsyncPager: - Response message for - ListMeasurementProtocolSecret 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.ListMeasurementProtocolSecretsRequest(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_measurement_protocol_secrets, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListMeasurementProtocolSecretsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_measurement_protocol_secret(self, - request: analytics_admin.CreateMeasurementProtocolSecretRequest = None, - *, - parent: str = None, - measurement_protocol_secret: resources.MeasurementProtocolSecret = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.MeasurementProtocolSecret: - r"""Creates a measurement protocol secret. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest`): - The request object. Request message for - CreateMeasurementProtocolSecret RPC - parent (:class:`str`): - Required. The parent resource where - this secret will be created. Any type of - stream (WebDataStream, IosAppDataStream, - AndroidAppDataStream) may be a parent. - Format: - properties/{property}/webDataStreams/{webDataStream} - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - measurement_protocol_secret (:class:`google.analytics.admin_v1alpha.types.MeasurementProtocolSecret`): - Required. The measurement protocol - secret to create. - - This corresponds to the ``measurement_protocol_secret`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.MeasurementProtocolSecret: - A secret value used for sending hits - to Measurement Protocol. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, measurement_protocol_secret]) - if request is 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.CreateMeasurementProtocolSecretRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if measurement_protocol_secret is not None: - request.measurement_protocol_secret = measurement_protocol_secret - - # 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_measurement_protocol_secret, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_measurement_protocol_secret(self, - request: analytics_admin.DeleteMeasurementProtocolSecretRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes target MeasurementProtocolSecret. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteMeasurementProtocolSecretRequest`): - The request object. Request message for - DeleteMeasurementProtocolSecret RPC - name (:class:`str`): - Required. The name of the - MeasurementProtocolSecret to delete. - Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} - Note: Any type of stream (WebDataStream, - IosAppDataStream, AndroidAppDataStream) - may be a parent. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be 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.DeleteMeasurementProtocolSecretRequest(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_measurement_protocol_secret, - 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_measurement_protocol_secret(self, - request: analytics_admin.UpdateMeasurementProtocolSecretRequest = None, - *, - measurement_protocol_secret: resources.MeasurementProtocolSecret = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.MeasurementProtocolSecret: - r"""Updates a measurement protocol secret. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateMeasurementProtocolSecretRequest`): - The request object. Request message for - UpdateMeasurementProtocolSecret RPC - measurement_protocol_secret (:class:`google.analytics.admin_v1alpha.types.MeasurementProtocolSecret`): - Required. The measurement protocol - secret to update. - - This corresponds to the ``measurement_protocol_secret`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: - A secret value used for sending hits - to Measurement Protocol. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([measurement_protocol_secret, 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.UpdateMeasurementProtocolSecretRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if measurement_protocol_secret is not None: - request.measurement_protocol_secret = measurement_protocol_secret - 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_measurement_protocol_secret, - 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(( - ("measurement_protocol_secret.name", request.measurement_protocol_secret.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def search_change_history_events(self, - request: analytics_admin.SearchChangeHistoryEventsRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.SearchChangeHistoryEventsAsyncPager: - r"""Searches through all changes to an account or its - children given the specified set of filters. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest`): - The request object. Request message for - SearchChangeHistoryEvents 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.SearchChangeHistoryEventsAsyncPager: - Response message for SearchAccounts - RPC. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = analytics_admin.SearchChangeHistoryEventsRequest(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.search_change_history_events, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("account", request.account), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.SearchChangeHistoryEventsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_google_signals_settings(self, - request: analytics_admin.GetGoogleSignalsSettingsRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GoogleSignalsSettings: - r"""Lookup for Google Signals settings for a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetGoogleSignalsSettingsRequest`): - The request object. Request message for - GetGoogleSignalsSettings RPC - name (:class:`str`): - Required. The name of the google - signals settings to retrieve. Format: - properties/{property}/googleSignalsSettings - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.GoogleSignalsSettings: - Settings values for Google Signals. - This is a singleton 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.GetGoogleSignalsSettingsRequest(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_google_signals_settings, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_google_signals_settings(self, - request: analytics_admin.UpdateGoogleSignalsSettingsRequest = None, - *, - google_signals_settings: resources.GoogleSignalsSettings = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GoogleSignalsSettings: - r"""Updates Google Signals settings for a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateGoogleSignalsSettingsRequest`): - The request object. Request message for - UpdateGoogleSignalsSettings RPC - google_signals_settings (:class:`google.analytics.admin_v1alpha.types.GoogleSignalsSettings`): - Required. The settings to update. The ``name`` field is - used to identify the settings to be updated. - - This corresponds to the ``google_signals_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.GoogleSignalsSettings: - Settings values for Google Signals. - This is a singleton 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([google_signals_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.UpdateGoogleSignalsSettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if google_signals_settings is not None: - request.google_signals_settings = google_signals_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_google_signals_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(( - ("google_signals_settings.name", request.google_signals_settings.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_conversion_event(self, - request: analytics_admin.CreateConversionEventRequest = None, - *, - parent: str = None, - conversion_event: resources.ConversionEvent = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.ConversionEvent: - r"""Creates a conversion event with the specified - attributes. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateConversionEventRequest`): - The request object. Request message for - CreateConversionEvent RPC - parent (:class:`str`): - Required. The resource name of the - parent property where this conversion - event 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. - conversion_event (:class:`google.analytics.admin_v1alpha.types.ConversionEvent`): - Required. The conversion event to - create. - - This corresponds to the ``conversion_event`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.ConversionEvent: - A conversion event in a Google - Analytics 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([parent, conversion_event]) - if request is 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.CreateConversionEventRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if conversion_event is not None: - request.conversion_event = conversion_event - - # 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_conversion_event, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_conversion_event(self, - request: analytics_admin.GetConversionEventRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.ConversionEvent: - r"""Retrieve a single conversion event. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetConversionEventRequest`): - The request object. Request message for - GetConversionEvent RPC - name (:class:`str`): - Required. The resource name of the conversion event to - retrieve. Format: - properties/{property}/conversionEvents/{conversion_event} - Example: "properties/123/conversionEvents/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.ConversionEvent: - A conversion event in a Google - Analytics 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.GetConversionEventRequest(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_conversion_event, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_conversion_event(self, - request: analytics_admin.DeleteConversionEventRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a conversion event in a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.DeleteConversionEventRequest`): - The request object. Request message for - DeleteConversionEvent RPC - name (:class:`str`): - Required. The resource name of the conversion event to - delete. Format: - properties/{property}/conversionEvents/{conversion_event} - Example: "properties/123/conversionEvents/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.DeleteConversionEventRequest(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_conversion_event, - 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 list_conversion_events(self, - request: analytics_admin.ListConversionEventsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListConversionEventsAsyncPager: - r"""Returns a list of conversion events in the specified - parent property. - Returns an empty list if no conversion events are found. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListConversionEventsRequest`): - The request object. Request message for - ListConversionEvents RPC - parent (:class:`str`): - Required. The resource name of the - parent property. Example: - '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.ListConversionEventsAsyncPager: - Response message for - ListConversionEvents 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.ListConversionEventsRequest(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_conversion_events, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListConversionEventsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_custom_dimension(self, - request: analytics_admin.CreateCustomDimensionRequest = None, - *, - parent: str = None, - custom_dimension: resources.CustomDimension = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomDimension: - r"""Creates a CustomDimension. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest`): - The request object. Request message for - CreateCustomDimension 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. - custom_dimension (:class:`google.analytics.admin_v1alpha.types.CustomDimension`): - Required. The CustomDimension to - create. - - This corresponds to the ``custom_dimension`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.CustomDimension: - A definition for a CustomDimension. - """ - # Create or coerce a protobuf request object. - # Sanity 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, custom_dimension]) - if request is 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.CreateCustomDimensionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if custom_dimension is not None: - request.custom_dimension = custom_dimension - - # 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_custom_dimension, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_custom_dimension(self, - request: analytics_admin.UpdateCustomDimensionRequest = None, - *, - custom_dimension: resources.CustomDimension = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomDimension: - r"""Updates a CustomDimension on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateCustomDimensionRequest`): - The request object. Request message for - UpdateCustomDimension RPC. - custom_dimension (:class:`google.analytics.admin_v1alpha.types.CustomDimension`): - The CustomDimension to update - This corresponds to the ``custom_dimension`` 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. 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.CustomDimension: - A definition for a CustomDimension. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([custom_dimension, 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.UpdateCustomDimensionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if custom_dimension is not None: - request.custom_dimension = custom_dimension - 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_custom_dimension, - 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(( - ("custom_dimension.name", request.custom_dimension.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_custom_dimensions(self, - request: analytics_admin.ListCustomDimensionsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCustomDimensionsAsyncPager: - r"""Lists CustomDimensions on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest`): - The request object. Request message for - ListCustomDimensions 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.ListCustomDimensionsAsyncPager: - Response message for - ListCustomDimensions 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.ListCustomDimensionsRequest(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_custom_dimensions, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCustomDimensionsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def archive_custom_dimension(self, - request: analytics_admin.ArchiveCustomDimensionRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Archives a CustomDimension on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ArchiveCustomDimensionRequest`): - The request object. Request message for - ArchiveCustomDimension RPC. - name (:class:`str`): - Required. The name of the - CustomDimension to archive. Example - format: - properties/1234/customDimensions/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.ArchiveCustomDimensionRequest(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.archive_custom_dimension, - 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 get_custom_dimension(self, - request: analytics_admin.GetCustomDimensionRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomDimension: - r"""Lookup for a single CustomDimension. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetCustomDimensionRequest`): - The request object. Request message for - GetCustomDimension RPC. - name (:class:`str`): - Required. The name of the - CustomDimension to get. Example format: - properties/1234/customDimensions/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.CustomDimension: - A definition for a CustomDimension. - """ - # Create or coerce a protobuf request object. - # Sanity 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.GetCustomDimensionRequest(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_custom_dimension, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_custom_metric(self, - request: analytics_admin.CreateCustomMetricRequest = None, - *, - parent: str = None, - custom_metric: resources.CustomMetric = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomMetric: - r"""Creates a CustomMetric. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateCustomMetricRequest`): - The request object. Request message for - CreateCustomMetric 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. - custom_metric (:class:`google.analytics.admin_v1alpha.types.CustomMetric`): - Required. The CustomMetric to create. - This corresponds to the ``custom_metric`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.CustomMetric: - A definition for a custom metric. - """ - # Create or coerce a protobuf request object. - # Sanity 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, custom_metric]) - if request is 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.CreateCustomMetricRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if custom_metric is not None: - request.custom_metric = custom_metric - - # 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_custom_metric, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_custom_metric(self, - request: analytics_admin.UpdateCustomMetricRequest = None, - *, - custom_metric: resources.CustomMetric = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomMetric: - r"""Updates a CustomMetric on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.UpdateCustomMetricRequest`): - The request object. Request message for - UpdateCustomMetric RPC. - custom_metric (:class:`google.analytics.admin_v1alpha.types.CustomMetric`): - The CustomMetric to update - This corresponds to the ``custom_metric`` 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. 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.CustomMetric: - A definition for a custom metric. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([custom_metric, 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.UpdateCustomMetricRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if custom_metric is not None: - request.custom_metric = custom_metric - 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_custom_metric, - 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(( - ("custom_metric.name", request.custom_metric.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_custom_metrics(self, - request: analytics_admin.ListCustomMetricsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCustomMetricsAsyncPager: - r"""Lists CustomMetrics on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ListCustomMetricsRequest`): - The request object. Request message for - ListCustomMetrics 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.ListCustomMetricsAsyncPager: - Response message for - ListCustomMetrics 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.ListCustomMetricsRequest(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_custom_metrics, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCustomMetricsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def archive_custom_metric(self, - request: analytics_admin.ArchiveCustomMetricRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Archives a CustomMetric on a property. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.ArchiveCustomMetricRequest`): - The request object. Request message for - ArchiveCustomMetric RPC. - name (:class:`str`): - Required. The name of the - CustomMetric to archive. Example format: - properties/1234/customMetrics/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.ArchiveCustomMetricRequest(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.archive_custom_metric, - 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 get_custom_metric(self, - request: analytics_admin.GetCustomMetricRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomMetric: - r"""Lookup for a single CustomMetric. - - Args: - request (:class:`google.analytics.admin_v1alpha.types.GetCustomMetricRequest`): - The request object. Request message for GetCustomMetric - RPC. - name (:class:`str`): - Required. The name of the - CustomMetric to get. Example format: - properties/1234/customMetrics/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.CustomMetric: - A definition for a custom metric. - """ - # Create or coerce a protobuf request object. - # Sanity 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.GetCustomMetricRequest(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_custom_metric, - 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 0e73ca1e..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +++ /dev/null @@ -1,5840 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from distutils import util -import os -import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.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 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # 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]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta): - """Service Interface for the Analytics Admin API (GA4).""" - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "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: - """Returns 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: - """Returns a fully-qualified account string.""" - return "accounts/{account}".format(account=account, ) - - @staticmethod - def parse_account_path(path: str) -> Dict[str,str]: - """Parses 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: - """Returns 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]: - """Parses 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: - """Returns 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]: - """Parses 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 conversion_event_path(property: str,conversion_event: str,) -> str: - """Returns a fully-qualified conversion_event string.""" - return "properties/{property}/conversionEvents/{conversion_event}".format(property=property, conversion_event=conversion_event, ) - - @staticmethod - def parse_conversion_event_path(path: str) -> Dict[str,str]: - """Parses a conversion_event path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/conversionEvents/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def custom_dimension_path(property: str,) -> str: - """Returns a fully-qualified custom_dimension string.""" - return "properties/{property}/customDimensions".format(property=property, ) - - @staticmethod - def parse_custom_dimension_path(path: str) -> Dict[str,str]: - """Parses a custom_dimension path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/customDimensions$", path) - return m.groupdict() if m else {} - - @staticmethod - def custom_metric_path(property: str,) -> str: - """Returns a fully-qualified custom_metric string.""" - return "properties/{property}/customMetrics".format(property=property, ) - - @staticmethod - def parse_custom_metric_path(path: str) -> Dict[str,str]: - """Parses a custom_metric path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/customMetrics$", path) - return m.groupdict() if m else {} - - @staticmethod - def data_sharing_settings_path(account: str,) -> str: - """Returns 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]: - """Parses 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: - """Returns 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]: - """Parses 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: - """Returns 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]: - """Parses 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: - """Returns 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]: - """Parses 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: - """Returns 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]: - """Parses 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 google_signals_settings_path(property: str,) -> str: - """Returns a fully-qualified google_signals_settings string.""" - return "properties/{property}/googleSignalsSettings".format(property=property, ) - - @staticmethod - def parse_google_signals_settings_path(path: str) -> Dict[str,str]: - """Parses a google_signals_settings path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/googleSignalsSettings$", path) - return m.groupdict() if m else {} - - @staticmethod - def ios_app_data_stream_path(property: str,ios_app_data_stream: str,) -> str: - """Returns 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]: - """Parses 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 measurement_protocol_secret_path(property: str,web_data_stream: str,measurement_protocol_secret: str,) -> str: - """Returns a fully-qualified measurement_protocol_secret string.""" - return "properties/{property}/webDataStreams/{web_data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}".format(property=property, web_data_stream=web_data_stream, measurement_protocol_secret=measurement_protocol_secret, ) - - @staticmethod - def parse_measurement_protocol_secret_path(path: str) -> Dict[str,str]: - """Parses a measurement_protocol_secret path into its component segments.""" - m = re.match(r"^properties/(?P.+?)/webDataStreams/(?P.+?)/measurementProtocolSecrets/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def property_path(property: str,) -> str: - """Returns a fully-qualified property string.""" - return "properties/{property}".format(property=property, ) - - @staticmethod - def parse_property_path(path: str) -> Dict[str,str]: - """Parses 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: - """Returns 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]: - """Parses 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: - """Returns 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]: - """Parses 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: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str, ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str, ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str, ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path(project: str, location: str, ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format(project=project, location=location, ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, AnalyticsAdminServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates 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() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, 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, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), - ) - - 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_pb2.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]] = (), - ) -> resources.Property: - 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. - - 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.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. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_property(self, - request: analytics_admin.UpdatePropertyRequest = None, - *, - property: resources.Property = None, - update_mask: field_mask_pb2.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_pb2.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_pb2.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 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_pb2.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 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_pb2.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_pb2.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_pb2.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 - - def get_measurement_protocol_secret(self, - request: analytics_admin.GetMeasurementProtocolSecretRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.MeasurementProtocolSecret: - r"""Lookup for a single "GA4" MeasurementProtocolSecret. - - Args: - request (google.analytics.admin_v1alpha.types.GetMeasurementProtocolSecretRequest): - The request object. Request message for - GetMeasurementProtocolSecret RPC. - name (str): - Required. The name of the measurement - protocol secret to lookup. Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} - Note: Any type of stream (WebDataStream, - IosAppDataStream, AndroidAppDataStream) - may be a parent. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.MeasurementProtocolSecret: - A secret value used for sending hits - to Measurement Protocol. - - """ - # Create or coerce a protobuf request object. - # Sanity 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.GetMeasurementProtocolSecretRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetMeasurementProtocolSecretRequest): - request = analytics_admin.GetMeasurementProtocolSecretRequest(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_measurement_protocol_secret] - - # Certain fields should be 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_measurement_protocol_secrets(self, - request: analytics_admin.ListMeasurementProtocolSecretsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListMeasurementProtocolSecretsPager: - r"""Returns child MeasurementProtocolSecrets under the - specified parent Property. - - Args: - request (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest): - The request object. Request message for - ListMeasurementProtocolSecret RPC - parent (str): - Required. The resource name of the - parent stream. Any type of stream - (WebDataStream, IosAppDataStream, - AndroidAppDataStream) may be a parent. - Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets - - 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.ListMeasurementProtocolSecretsPager: - Response message for - ListMeasurementProtocolSecret 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.ListMeasurementProtocolSecretsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListMeasurementProtocolSecretsRequest): - request = analytics_admin.ListMeasurementProtocolSecretsRequest(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_measurement_protocol_secrets] - - # 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.ListMeasurementProtocolSecretsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_measurement_protocol_secret(self, - request: analytics_admin.CreateMeasurementProtocolSecretRequest = None, - *, - parent: str = None, - measurement_protocol_secret: resources.MeasurementProtocolSecret = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.MeasurementProtocolSecret: - r"""Creates a measurement protocol secret. - - Args: - request (google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest): - The request object. Request message for - CreateMeasurementProtocolSecret RPC - parent (str): - Required. The parent resource where - this secret will be created. Any type of - stream (WebDataStream, IosAppDataStream, - AndroidAppDataStream) may be a parent. - Format: - properties/{property}/webDataStreams/{webDataStream} - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): - Required. The measurement protocol - secret to create. - - This corresponds to the ``measurement_protocol_secret`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.MeasurementProtocolSecret: - A secret value used for sending hits - to Measurement Protocol. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, measurement_protocol_secret]) - if request is 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.CreateMeasurementProtocolSecretRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateMeasurementProtocolSecretRequest): - request = analytics_admin.CreateMeasurementProtocolSecretRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if measurement_protocol_secret is not None: - request.measurement_protocol_secret = measurement_protocol_secret - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_measurement_protocol_secret] - - # 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_measurement_protocol_secret(self, - request: analytics_admin.DeleteMeasurementProtocolSecretRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes target MeasurementProtocolSecret. - - Args: - request (google.analytics.admin_v1alpha.types.DeleteMeasurementProtocolSecretRequest): - The request object. Request message for - DeleteMeasurementProtocolSecret RPC - name (str): - Required. The name of the - MeasurementProtocolSecret to delete. - Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} - Note: Any type of stream (WebDataStream, - IosAppDataStream, AndroidAppDataStream) - may be a parent. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be 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.DeleteMeasurementProtocolSecretRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteMeasurementProtocolSecretRequest): - request = analytics_admin.DeleteMeasurementProtocolSecretRequest(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_measurement_protocol_secret] - - # Certain fields should be 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_measurement_protocol_secret(self, - request: analytics_admin.UpdateMeasurementProtocolSecretRequest = None, - *, - measurement_protocol_secret: resources.MeasurementProtocolSecret = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.MeasurementProtocolSecret: - r"""Updates a measurement protocol secret. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateMeasurementProtocolSecretRequest): - The request object. Request message for - UpdateMeasurementProtocolSecret RPC - measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): - Required. The measurement protocol - secret to update. - - This corresponds to the ``measurement_protocol_secret`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - Omitted fields will not be updated. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: - A secret value used for sending hits - to Measurement Protocol. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([measurement_protocol_secret, 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.UpdateMeasurementProtocolSecretRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateMeasurementProtocolSecretRequest): - request = analytics_admin.UpdateMeasurementProtocolSecretRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if measurement_protocol_secret is not None: - request.measurement_protocol_secret = measurement_protocol_secret - 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_measurement_protocol_secret] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("measurement_protocol_secret.name", request.measurement_protocol_secret.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def search_change_history_events(self, - request: analytics_admin.SearchChangeHistoryEventsRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.SearchChangeHistoryEventsPager: - r"""Searches through all changes to an account or its - children given the specified set of filters. - - Args: - request (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest): - The request object. Request message for - SearchChangeHistoryEvents 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.SearchChangeHistoryEventsPager: - Response message for SearchAccounts - 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.SearchChangeHistoryEventsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.SearchChangeHistoryEventsRequest): - request = analytics_admin.SearchChangeHistoryEventsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.search_change_history_events] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("account", request.account), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.SearchChangeHistoryEventsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_google_signals_settings(self, - request: analytics_admin.GetGoogleSignalsSettingsRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GoogleSignalsSettings: - r"""Lookup for Google Signals settings for a property. - - Args: - request (google.analytics.admin_v1alpha.types.GetGoogleSignalsSettingsRequest): - The request object. Request message for - GetGoogleSignalsSettings RPC - name (str): - Required. The name of the google - signals settings to retrieve. Format: - properties/{property}/googleSignalsSettings - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.GoogleSignalsSettings: - Settings values for Google Signals. - This is a singleton 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.GetGoogleSignalsSettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetGoogleSignalsSettingsRequest): - request = analytics_admin.GetGoogleSignalsSettingsRequest(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_google_signals_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_google_signals_settings(self, - request: analytics_admin.UpdateGoogleSignalsSettingsRequest = None, - *, - google_signals_settings: resources.GoogleSignalsSettings = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.GoogleSignalsSettings: - r"""Updates Google Signals settings for a property. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateGoogleSignalsSettingsRequest): - The request object. Request message for - UpdateGoogleSignalsSettings RPC - google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): - Required. The settings to update. The ``name`` field is - used to identify the settings to be updated. - - This corresponds to the ``google_signals_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.GoogleSignalsSettings: - Settings values for Google Signals. - This is a singleton 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([google_signals_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.UpdateGoogleSignalsSettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateGoogleSignalsSettingsRequest): - request = analytics_admin.UpdateGoogleSignalsSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if google_signals_settings is not None: - request.google_signals_settings = google_signals_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_google_signals_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("google_signals_settings.name", request.google_signals_settings.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_conversion_event(self, - request: analytics_admin.CreateConversionEventRequest = None, - *, - parent: str = None, - conversion_event: resources.ConversionEvent = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.ConversionEvent: - r"""Creates a conversion event with the specified - attributes. - - Args: - request (google.analytics.admin_v1alpha.types.CreateConversionEventRequest): - The request object. Request message for - CreateConversionEvent RPC - parent (str): - Required. The resource name of the - parent property where this conversion - event 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. - conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): - Required. The conversion event to - create. - - This corresponds to the ``conversion_event`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.ConversionEvent: - A conversion event in a Google - Analytics 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([parent, conversion_event]) - if request is 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.CreateConversionEventRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateConversionEventRequest): - request = analytics_admin.CreateConversionEventRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if conversion_event is not None: - request.conversion_event = conversion_event - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_conversion_event] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_conversion_event(self, - request: analytics_admin.GetConversionEventRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.ConversionEvent: - r"""Retrieve a single conversion event. - - Args: - request (google.analytics.admin_v1alpha.types.GetConversionEventRequest): - The request object. Request message for - GetConversionEvent RPC - name (str): - Required. The resource name of the conversion event to - retrieve. Format: - properties/{property}/conversionEvents/{conversion_event} - Example: "properties/123/conversionEvents/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.ConversionEvent: - A conversion event in a Google - Analytics 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.GetConversionEventRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetConversionEventRequest): - request = analytics_admin.GetConversionEventRequest(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_conversion_event] - - # Certain fields should be 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_conversion_event(self, - request: analytics_admin.DeleteConversionEventRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a conversion event in a property. - - Args: - request (google.analytics.admin_v1alpha.types.DeleteConversionEventRequest): - The request object. Request message for - DeleteConversionEvent RPC - name (str): - Required. The resource name of the conversion event to - delete. Format: - properties/{property}/conversionEvents/{conversion_event} - Example: "properties/123/conversionEvents/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.DeleteConversionEventRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.DeleteConversionEventRequest): - request = analytics_admin.DeleteConversionEventRequest(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_conversion_event] - - # Certain fields should be 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_conversion_events(self, - request: analytics_admin.ListConversionEventsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListConversionEventsPager: - r"""Returns a list of conversion events in the specified - parent property. - Returns an empty list if no conversion events are found. - - Args: - request (google.analytics.admin_v1alpha.types.ListConversionEventsRequest): - The request object. Request message for - ListConversionEvents RPC - parent (str): - Required. The resource name of the - parent property. Example: - '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.ListConversionEventsPager: - Response message for - ListConversionEvents 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.ListConversionEventsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListConversionEventsRequest): - request = analytics_admin.ListConversionEventsRequest(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_conversion_events] - - # 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.ListConversionEventsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_custom_dimension(self, - request: analytics_admin.CreateCustomDimensionRequest = None, - *, - parent: str = None, - custom_dimension: resources.CustomDimension = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomDimension: - r"""Creates a CustomDimension. - - Args: - request (google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest): - The request object. Request message for - CreateCustomDimension 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. - custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): - Required. The CustomDimension to - create. - - This corresponds to the ``custom_dimension`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.CustomDimension: - A definition for a CustomDimension. - """ - # Create or coerce a protobuf request object. - # Sanity 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, custom_dimension]) - if request is 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.CreateCustomDimensionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateCustomDimensionRequest): - request = analytics_admin.CreateCustomDimensionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if custom_dimension is not None: - request.custom_dimension = custom_dimension - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_custom_dimension] - - # 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_custom_dimension(self, - request: analytics_admin.UpdateCustomDimensionRequest = None, - *, - custom_dimension: resources.CustomDimension = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomDimension: - r"""Updates a CustomDimension on a property. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateCustomDimensionRequest): - The request object. Request message for - UpdateCustomDimension RPC. - custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): - The CustomDimension to update - This corresponds to the ``custom_dimension`` 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. 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.CustomDimension: - A definition for a CustomDimension. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([custom_dimension, 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.UpdateCustomDimensionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateCustomDimensionRequest): - request = analytics_admin.UpdateCustomDimensionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if custom_dimension is not None: - request.custom_dimension = custom_dimension - 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_custom_dimension] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("custom_dimension.name", request.custom_dimension.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_custom_dimensions(self, - request: analytics_admin.ListCustomDimensionsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCustomDimensionsPager: - r"""Lists CustomDimensions on a property. - - Args: - request (google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest): - The request object. Request message for - ListCustomDimensions 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.ListCustomDimensionsPager: - Response message for - ListCustomDimensions 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.ListCustomDimensionsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListCustomDimensionsRequest): - request = analytics_admin.ListCustomDimensionsRequest(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_custom_dimensions] - - # 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.ListCustomDimensionsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def archive_custom_dimension(self, - request: analytics_admin.ArchiveCustomDimensionRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Archives a CustomDimension on a property. - - Args: - request (google.analytics.admin_v1alpha.types.ArchiveCustomDimensionRequest): - The request object. Request message for - ArchiveCustomDimension RPC. - name (str): - Required. The name of the - CustomDimension to archive. Example - format: - properties/1234/customDimensions/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.ArchiveCustomDimensionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ArchiveCustomDimensionRequest): - request = analytics_admin.ArchiveCustomDimensionRequest(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.archive_custom_dimension] - - # Certain fields should be 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 get_custom_dimension(self, - request: analytics_admin.GetCustomDimensionRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomDimension: - r"""Lookup for a single CustomDimension. - - Args: - request (google.analytics.admin_v1alpha.types.GetCustomDimensionRequest): - The request object. Request message for - GetCustomDimension RPC. - name (str): - Required. The name of the - CustomDimension to get. Example format: - properties/1234/customDimensions/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.CustomDimension: - A definition for a CustomDimension. - """ - # Create or coerce a protobuf request object. - # Sanity 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.GetCustomDimensionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetCustomDimensionRequest): - request = analytics_admin.GetCustomDimensionRequest(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_custom_dimension] - - # Certain fields should be 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_custom_metric(self, - request: analytics_admin.CreateCustomMetricRequest = None, - *, - parent: str = None, - custom_metric: resources.CustomMetric = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomMetric: - r"""Creates a CustomMetric. - - Args: - request (google.analytics.admin_v1alpha.types.CreateCustomMetricRequest): - The request object. Request message for - CreateCustomMetric 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. - custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): - Required. The CustomMetric to create. - This corresponds to the ``custom_metric`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.CustomMetric: - A definition for a custom metric. - """ - # Create or coerce a protobuf request object. - # Sanity 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, custom_metric]) - if request is 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.CreateCustomMetricRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateCustomMetricRequest): - request = analytics_admin.CreateCustomMetricRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if custom_metric is not None: - request.custom_metric = custom_metric - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_custom_metric] - - # 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_custom_metric(self, - request: analytics_admin.UpdateCustomMetricRequest = None, - *, - custom_metric: resources.CustomMetric = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomMetric: - r"""Updates a CustomMetric on a property. - - Args: - request (google.analytics.admin_v1alpha.types.UpdateCustomMetricRequest): - The request object. Request message for - UpdateCustomMetric RPC. - custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): - The CustomMetric to update - This corresponds to the ``custom_metric`` 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. 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.CustomMetric: - A definition for a custom metric. - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([custom_metric, 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.UpdateCustomMetricRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.UpdateCustomMetricRequest): - request = analytics_admin.UpdateCustomMetricRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if custom_metric is not None: - request.custom_metric = custom_metric - 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_custom_metric] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("custom_metric.name", request.custom_metric.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_custom_metrics(self, - request: analytics_admin.ListCustomMetricsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCustomMetricsPager: - r"""Lists CustomMetrics on a property. - - Args: - request (google.analytics.admin_v1alpha.types.ListCustomMetricsRequest): - The request object. Request message for - ListCustomMetrics 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.ListCustomMetricsPager: - Response message for - ListCustomMetrics 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.ListCustomMetricsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ListCustomMetricsRequest): - request = analytics_admin.ListCustomMetricsRequest(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_custom_metrics] - - # 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.ListCustomMetricsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def archive_custom_metric(self, - request: analytics_admin.ArchiveCustomMetricRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Archives a CustomMetric on a property. - - Args: - request (google.analytics.admin_v1alpha.types.ArchiveCustomMetricRequest): - The request object. Request message for - ArchiveCustomMetric RPC. - name (str): - Required. The name of the - CustomMetric to archive. Example format: - properties/1234/customMetrics/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.ArchiveCustomMetricRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.ArchiveCustomMetricRequest): - request = analytics_admin.ArchiveCustomMetricRequest(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.archive_custom_metric] - - # Certain fields should be 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 get_custom_metric(self, - request: analytics_admin.GetCustomMetricRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CustomMetric: - r"""Lookup for a single CustomMetric. - - Args: - request (google.analytics.admin_v1alpha.types.GetCustomMetricRequest): - The request object. Request message for GetCustomMetric - RPC. - name (str): - Required. The name of the - CustomMetric to get. Example format: - properties/1234/customMetrics/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.CustomMetric: - A definition for a custom metric. - """ - # Create or coerce a protobuf request object. - # Sanity 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.GetCustomMetricRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.GetCustomMetricRequest): - request = analytics_admin.GetCustomMetricRequest(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_custom_metric] - - # Certain fields should be 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 9dbd5071..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py +++ /dev/null @@ -1,1849 +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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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]] = ()): - """Instantiates 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) - - -class ListMeasurementProtocolSecretsPager: - """A pager for iterating through ``list_measurement_protocol_secrets`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``measurement_protocol_secrets`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListMeasurementProtocolSecrets`` requests and continue to iterate - through the ``measurement_protocol_secrets`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` - 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.ListMeasurementProtocolSecretsResponse], - request: analytics_admin.ListMeasurementProtocolSecretsRequest, - response: analytics_admin.ListMeasurementProtocolSecretsResponse, - *, - 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.ListMeasurementProtocolSecretsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse): - 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.ListMeasurementProtocolSecretsRequest(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.ListMeasurementProtocolSecretsResponse]: - 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.MeasurementProtocolSecret]: - for page in self.pages: - yield from page.measurement_protocol_secrets - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListMeasurementProtocolSecretsAsyncPager: - """A pager for iterating through ``list_measurement_protocol_secrets`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``measurement_protocol_secrets`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListMeasurementProtocolSecrets`` requests and continue to iterate - through the ``measurement_protocol_secrets`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` - 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.ListMeasurementProtocolSecretsResponse]], - request: analytics_admin.ListMeasurementProtocolSecretsRequest, - response: analytics_admin.ListMeasurementProtocolSecretsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse): - 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.ListMeasurementProtocolSecretsRequest(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.ListMeasurementProtocolSecretsResponse]: - 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.MeasurementProtocolSecret]: - async def async_generator(): - async for page in self.pages: - for response in page.measurement_protocol_secrets: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class SearchChangeHistoryEventsPager: - """A pager for iterating through ``search_change_history_events`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``change_history_events`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``SearchChangeHistoryEvents`` requests and continue to iterate - through the ``change_history_events`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` - 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.SearchChangeHistoryEventsResponse], - request: analytics_admin.SearchChangeHistoryEventsRequest, - response: analytics_admin.SearchChangeHistoryEventsResponse, - *, - 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.SearchChangeHistoryEventsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse): - 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.SearchChangeHistoryEventsRequest(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.SearchChangeHistoryEventsResponse]: - 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.ChangeHistoryEvent]: - for page in self.pages: - yield from page.change_history_events - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class SearchChangeHistoryEventsAsyncPager: - """A pager for iterating through ``search_change_history_events`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``change_history_events`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``SearchChangeHistoryEvents`` requests and continue to iterate - through the ``change_history_events`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` - 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.SearchChangeHistoryEventsResponse]], - request: analytics_admin.SearchChangeHistoryEventsRequest, - response: analytics_admin.SearchChangeHistoryEventsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse): - 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.SearchChangeHistoryEventsRequest(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.SearchChangeHistoryEventsResponse]: - 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.ChangeHistoryEvent]: - async def async_generator(): - async for page in self.pages: - for response in page.change_history_events: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListConversionEventsPager: - """A pager for iterating through ``list_conversion_events`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``conversion_events`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListConversionEvents`` requests and continue to iterate - through the ``conversion_events`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` - 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.ListConversionEventsResponse], - request: analytics_admin.ListConversionEventsRequest, - response: analytics_admin.ListConversionEventsResponse, - *, - 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.ListConversionEventsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListConversionEventsResponse): - 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.ListConversionEventsRequest(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.ListConversionEventsResponse]: - 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.ConversionEvent]: - for page in self.pages: - yield from page.conversion_events - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListConversionEventsAsyncPager: - """A pager for iterating through ``list_conversion_events`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``conversion_events`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListConversionEvents`` requests and continue to iterate - through the ``conversion_events`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` - 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.ListConversionEventsResponse]], - request: analytics_admin.ListConversionEventsRequest, - response: analytics_admin.ListConversionEventsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListConversionEventsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListConversionEventsResponse): - 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.ListConversionEventsRequest(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.ListConversionEventsResponse]: - 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.ConversionEvent]: - async def async_generator(): - async for page in self.pages: - for response in page.conversion_events: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCustomDimensionsPager: - """A pager for iterating through ``list_custom_dimensions`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``custom_dimensions`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCustomDimensions`` requests and continue to iterate - through the ``custom_dimensions`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` - 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.ListCustomDimensionsResponse], - request: analytics_admin.ListCustomDimensionsRequest, - response: analytics_admin.ListCustomDimensionsResponse, - *, - 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.ListCustomDimensionsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse): - 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.ListCustomDimensionsRequest(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.ListCustomDimensionsResponse]: - 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.CustomDimension]: - for page in self.pages: - yield from page.custom_dimensions - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCustomDimensionsAsyncPager: - """A pager for iterating through ``list_custom_dimensions`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``custom_dimensions`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCustomDimensions`` requests and continue to iterate - through the ``custom_dimensions`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` - 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.ListCustomDimensionsResponse]], - request: analytics_admin.ListCustomDimensionsRequest, - response: analytics_admin.ListCustomDimensionsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse): - 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.ListCustomDimensionsRequest(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.ListCustomDimensionsResponse]: - 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.CustomDimension]: - async def async_generator(): - async for page in self.pages: - for response in page.custom_dimensions: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCustomMetricsPager: - """A pager for iterating through ``list_custom_metrics`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``custom_metrics`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCustomMetrics`` requests and continue to iterate - through the ``custom_metrics`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` - 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.ListCustomMetricsResponse], - request: analytics_admin.ListCustomMetricsRequest, - response: analytics_admin.ListCustomMetricsResponse, - *, - 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.ListCustomMetricsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListCustomMetricsResponse): - 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.ListCustomMetricsRequest(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.ListCustomMetricsResponse]: - 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.CustomMetric]: - for page in self.pages: - yield from page.custom_metrics - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCustomMetricsAsyncPager: - """A pager for iterating through ``list_custom_metrics`` requests. - - This class thinly wraps an initial - :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``custom_metrics`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCustomMetrics`` requests and continue to iterate - through the ``custom_metrics`` field on the - corresponding responses. - - All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` - 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.ListCustomMetricsResponse]], - request: analytics_admin.ListCustomMetricsRequest, - response: analytics_admin.ListCustomMetricsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.admin_v1alpha.types.ListCustomMetricsRequest): - The initial request object. - response (google.analytics.admin_v1alpha.types.ListCustomMetricsResponse): - 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.ListCustomMetricsRequest(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.ListCustomMetricsResponse]: - 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.CustomMetric]: - async def async_generator(): - async for page in self.pages: - for response in page.custom_metrics: - 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 0ed7784f..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import 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 9a92228f..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py +++ /dev/null @@ -1,1111 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # 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 # 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() - -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - - -class 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', - ) - - DEFAULT_HOST: str = 'analyticsadmin.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) - - elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) - - # If the credentials is service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.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.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.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, - ), - self.get_measurement_protocol_secret: gapic_v1.method.wrap_method( - self.get_measurement_protocol_secret, - default_timeout=None, - client_info=client_info, - ), - self.list_measurement_protocol_secrets: gapic_v1.method.wrap_method( - self.list_measurement_protocol_secrets, - default_timeout=None, - client_info=client_info, - ), - self.create_measurement_protocol_secret: gapic_v1.method.wrap_method( - self.create_measurement_protocol_secret, - default_timeout=None, - client_info=client_info, - ), - self.delete_measurement_protocol_secret: gapic_v1.method.wrap_method( - self.delete_measurement_protocol_secret, - default_timeout=None, - client_info=client_info, - ), - self.update_measurement_protocol_secret: gapic_v1.method.wrap_method( - self.update_measurement_protocol_secret, - default_timeout=None, - client_info=client_info, - ), - self.search_change_history_events: gapic_v1.method.wrap_method( - self.search_change_history_events, - default_timeout=None, - client_info=client_info, - ), - self.get_google_signals_settings: gapic_v1.method.wrap_method( - self.get_google_signals_settings, - default_timeout=None, - client_info=client_info, - ), - self.update_google_signals_settings: gapic_v1.method.wrap_method( - self.update_google_signals_settings, - default_timeout=None, - client_info=client_info, - ), - self.create_conversion_event: gapic_v1.method.wrap_method( - self.create_conversion_event, - default_timeout=None, - client_info=client_info, - ), - self.get_conversion_event: gapic_v1.method.wrap_method( - self.get_conversion_event, - default_timeout=None, - client_info=client_info, - ), - self.delete_conversion_event: gapic_v1.method.wrap_method( - self.delete_conversion_event, - default_timeout=None, - client_info=client_info, - ), - self.list_conversion_events: gapic_v1.method.wrap_method( - self.list_conversion_events, - default_timeout=None, - client_info=client_info, - ), - self.create_custom_dimension: gapic_v1.method.wrap_method( - self.create_custom_dimension, - default_timeout=None, - client_info=client_info, - ), - self.update_custom_dimension: gapic_v1.method.wrap_method( - self.update_custom_dimension, - default_timeout=None, - client_info=client_info, - ), - self.list_custom_dimensions: gapic_v1.method.wrap_method( - self.list_custom_dimensions, - default_timeout=None, - client_info=client_info, - ), - self.archive_custom_dimension: gapic_v1.method.wrap_method( - self.archive_custom_dimension, - default_timeout=None, - client_info=client_info, - ), - self.get_custom_dimension: gapic_v1.method.wrap_method( - self.get_custom_dimension, - default_timeout=None, - client_info=client_info, - ), - self.create_custom_metric: gapic_v1.method.wrap_method( - self.create_custom_metric, - default_timeout=None, - client_info=client_info, - ), - self.update_custom_metric: gapic_v1.method.wrap_method( - self.update_custom_metric, - default_timeout=None, - client_info=client_info, - ), - self.list_custom_metrics: gapic_v1.method.wrap_method( - self.list_custom_metrics, - default_timeout=None, - client_info=client_info, - ), - self.archive_custom_metric: gapic_v1.method.wrap_method( - self.archive_custom_metric, - default_timeout=None, - client_info=client_info, - ), - self.get_custom_metric: gapic_v1.method.wrap_method( - self.get_custom_metric, - default_timeout=None, - client_info=client_info, - ), - } - - @property - def get_account(self) -> Callable[ - [analytics_admin.GetAccountRequest], - Union[ - resources.Account, - Awaitable[resources.Account] - ]]: - raise NotImplementedError() - - @property - def list_accounts(self) -> Callable[ - [analytics_admin.ListAccountsRequest], - Union[ - analytics_admin.ListAccountsResponse, - Awaitable[analytics_admin.ListAccountsResponse] - ]]: - raise NotImplementedError() - - @property - def delete_account(self) -> Callable[ - [analytics_admin.DeleteAccountRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def update_account(self) -> Callable[ - [analytics_admin.UpdateAccountRequest], - Union[ - resources.Account, - Awaitable[resources.Account] - ]]: - raise NotImplementedError() - - @property - def provision_account_ticket(self) -> Callable[ - [analytics_admin.ProvisionAccountTicketRequest], - Union[ - analytics_admin.ProvisionAccountTicketResponse, - Awaitable[analytics_admin.ProvisionAccountTicketResponse] - ]]: - raise NotImplementedError() - - @property - def list_account_summaries(self) -> Callable[ - [analytics_admin.ListAccountSummariesRequest], - Union[ - analytics_admin.ListAccountSummariesResponse, - Awaitable[analytics_admin.ListAccountSummariesResponse] - ]]: - raise NotImplementedError() - - @property - def get_property(self) -> Callable[ - [analytics_admin.GetPropertyRequest], - Union[ - resources.Property, - Awaitable[resources.Property] - ]]: - raise NotImplementedError() - - @property - def list_properties(self) -> Callable[ - [analytics_admin.ListPropertiesRequest], - Union[ - analytics_admin.ListPropertiesResponse, - Awaitable[analytics_admin.ListPropertiesResponse] - ]]: - raise NotImplementedError() - - @property - def create_property(self) -> Callable[ - [analytics_admin.CreatePropertyRequest], - Union[ - resources.Property, - Awaitable[resources.Property] - ]]: - raise NotImplementedError() - - @property - def delete_property(self) -> Callable[ - [analytics_admin.DeletePropertyRequest], - Union[ - resources.Property, - Awaitable[resources.Property] - ]]: - raise NotImplementedError() - - @property - def update_property(self) -> Callable[ - [analytics_admin.UpdatePropertyRequest], - Union[ - resources.Property, - Awaitable[resources.Property] - ]]: - raise NotImplementedError() - - @property - def get_user_link(self) -> Callable[ - [analytics_admin.GetUserLinkRequest], - Union[ - resources.UserLink, - Awaitable[resources.UserLink] - ]]: - raise NotImplementedError() - - @property - def batch_get_user_links(self) -> Callable[ - [analytics_admin.BatchGetUserLinksRequest], - Union[ - analytics_admin.BatchGetUserLinksResponse, - Awaitable[analytics_admin.BatchGetUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def list_user_links(self) -> Callable[ - [analytics_admin.ListUserLinksRequest], - Union[ - analytics_admin.ListUserLinksResponse, - Awaitable[analytics_admin.ListUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def audit_user_links(self) -> Callable[ - [analytics_admin.AuditUserLinksRequest], - Union[ - analytics_admin.AuditUserLinksResponse, - Awaitable[analytics_admin.AuditUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def create_user_link(self) -> Callable[ - [analytics_admin.CreateUserLinkRequest], - Union[ - resources.UserLink, - Awaitable[resources.UserLink] - ]]: - raise NotImplementedError() - - @property - def batch_create_user_links(self) -> Callable[ - [analytics_admin.BatchCreateUserLinksRequest], - Union[ - analytics_admin.BatchCreateUserLinksResponse, - Awaitable[analytics_admin.BatchCreateUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def update_user_link(self) -> Callable[ - [analytics_admin.UpdateUserLinkRequest], - Union[ - resources.UserLink, - Awaitable[resources.UserLink] - ]]: - raise NotImplementedError() - - @property - def batch_update_user_links(self) -> Callable[ - [analytics_admin.BatchUpdateUserLinksRequest], - Union[ - analytics_admin.BatchUpdateUserLinksResponse, - Awaitable[analytics_admin.BatchUpdateUserLinksResponse] - ]]: - raise NotImplementedError() - - @property - def delete_user_link(self) -> Callable[ - [analytics_admin.DeleteUserLinkRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def batch_delete_user_links(self) -> Callable[ - [analytics_admin.BatchDeleteUserLinksRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def get_web_data_stream(self) -> Callable[ - [analytics_admin.GetWebDataStreamRequest], - Union[ - resources.WebDataStream, - Awaitable[resources.WebDataStream] - ]]: - raise NotImplementedError() - - @property - def delete_web_data_stream(self) -> Callable[ - [analytics_admin.DeleteWebDataStreamRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def update_web_data_stream(self) -> Callable[ - [analytics_admin.UpdateWebDataStreamRequest], - Union[ - resources.WebDataStream, - Awaitable[resources.WebDataStream] - ]]: - raise NotImplementedError() - - @property - def create_web_data_stream(self) -> Callable[ - [analytics_admin.CreateWebDataStreamRequest], - Union[ - resources.WebDataStream, - Awaitable[resources.WebDataStream] - ]]: - raise NotImplementedError() - - @property - def list_web_data_streams(self) -> Callable[ - [analytics_admin.ListWebDataStreamsRequest], - Union[ - analytics_admin.ListWebDataStreamsResponse, - Awaitable[analytics_admin.ListWebDataStreamsResponse] - ]]: - raise NotImplementedError() - - @property - def get_ios_app_data_stream(self) -> Callable[ - [analytics_admin.GetIosAppDataStreamRequest], - Union[ - resources.IosAppDataStream, - Awaitable[resources.IosAppDataStream] - ]]: - raise NotImplementedError() - - @property - def delete_ios_app_data_stream(self) -> Callable[ - [analytics_admin.DeleteIosAppDataStreamRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def update_ios_app_data_stream(self) -> Callable[ - [analytics_admin.UpdateIosAppDataStreamRequest], - Union[ - resources.IosAppDataStream, - Awaitable[resources.IosAppDataStream] - ]]: - raise NotImplementedError() - - @property - def list_ios_app_data_streams(self) -> Callable[ - [analytics_admin.ListIosAppDataStreamsRequest], - Union[ - analytics_admin.ListIosAppDataStreamsResponse, - Awaitable[analytics_admin.ListIosAppDataStreamsResponse] - ]]: - raise NotImplementedError() - - @property - def get_android_app_data_stream(self) -> Callable[ - [analytics_admin.GetAndroidAppDataStreamRequest], - Union[ - resources.AndroidAppDataStream, - Awaitable[resources.AndroidAppDataStream] - ]]: - raise NotImplementedError() - - @property - def delete_android_app_data_stream(self) -> Callable[ - [analytics_admin.DeleteAndroidAppDataStreamRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def update_android_app_data_stream(self) -> Callable[ - [analytics_admin.UpdateAndroidAppDataStreamRequest], - Union[ - resources.AndroidAppDataStream, - Awaitable[resources.AndroidAppDataStream] - ]]: - raise NotImplementedError() - - @property - def list_android_app_data_streams(self) -> Callable[ - [analytics_admin.ListAndroidAppDataStreamsRequest], - Union[ - analytics_admin.ListAndroidAppDataStreamsResponse, - Awaitable[analytics_admin.ListAndroidAppDataStreamsResponse] - ]]: - raise NotImplementedError() - - @property - def get_enhanced_measurement_settings(self) -> Callable[ - [analytics_admin.GetEnhancedMeasurementSettingsRequest], - Union[ - resources.EnhancedMeasurementSettings, - Awaitable[resources.EnhancedMeasurementSettings] - ]]: - raise NotImplementedError() - - @property - def update_enhanced_measurement_settings(self) -> Callable[ - [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], - Union[ - resources.EnhancedMeasurementSettings, - Awaitable[resources.EnhancedMeasurementSettings] - ]]: - raise NotImplementedError() - - @property - def create_firebase_link(self) -> Callable[ - [analytics_admin.CreateFirebaseLinkRequest], - Union[ - resources.FirebaseLink, - Awaitable[resources.FirebaseLink] - ]]: - raise NotImplementedError() - - @property - def update_firebase_link(self) -> Callable[ - [analytics_admin.UpdateFirebaseLinkRequest], - Union[ - resources.FirebaseLink, - Awaitable[resources.FirebaseLink] - ]]: - raise NotImplementedError() - - @property - def delete_firebase_link(self) -> Callable[ - [analytics_admin.DeleteFirebaseLinkRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_firebase_links(self) -> Callable[ - [analytics_admin.ListFirebaseLinksRequest], - Union[ - analytics_admin.ListFirebaseLinksResponse, - Awaitable[analytics_admin.ListFirebaseLinksResponse] - ]]: - raise NotImplementedError() - - @property - def get_global_site_tag(self) -> Callable[ - [analytics_admin.GetGlobalSiteTagRequest], - Union[ - resources.GlobalSiteTag, - Awaitable[resources.GlobalSiteTag] - ]]: - raise NotImplementedError() - - @property - def create_google_ads_link(self) -> Callable[ - [analytics_admin.CreateGoogleAdsLinkRequest], - Union[ - resources.GoogleAdsLink, - Awaitable[resources.GoogleAdsLink] - ]]: - raise NotImplementedError() - - @property - def update_google_ads_link(self) -> Callable[ - [analytics_admin.UpdateGoogleAdsLinkRequest], - Union[ - resources.GoogleAdsLink, - Awaitable[resources.GoogleAdsLink] - ]]: - raise NotImplementedError() - - @property - def delete_google_ads_link(self) -> Callable[ - [analytics_admin.DeleteGoogleAdsLinkRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_google_ads_links(self) -> Callable[ - [analytics_admin.ListGoogleAdsLinksRequest], - Union[ - analytics_admin.ListGoogleAdsLinksResponse, - Awaitable[analytics_admin.ListGoogleAdsLinksResponse] - ]]: - raise NotImplementedError() - - @property - def get_data_sharing_settings(self) -> Callable[ - [analytics_admin.GetDataSharingSettingsRequest], - Union[ - resources.DataSharingSettings, - Awaitable[resources.DataSharingSettings] - ]]: - raise NotImplementedError() - - @property - def get_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.GetMeasurementProtocolSecretRequest], - Union[ - resources.MeasurementProtocolSecret, - Awaitable[resources.MeasurementProtocolSecret] - ]]: - raise NotImplementedError() - - @property - def list_measurement_protocol_secrets(self) -> Callable[ - [analytics_admin.ListMeasurementProtocolSecretsRequest], - Union[ - analytics_admin.ListMeasurementProtocolSecretsResponse, - Awaitable[analytics_admin.ListMeasurementProtocolSecretsResponse] - ]]: - raise NotImplementedError() - - @property - def create_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.CreateMeasurementProtocolSecretRequest], - Union[ - resources.MeasurementProtocolSecret, - Awaitable[resources.MeasurementProtocolSecret] - ]]: - raise NotImplementedError() - - @property - def delete_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.DeleteMeasurementProtocolSecretRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def update_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.UpdateMeasurementProtocolSecretRequest], - Union[ - resources.MeasurementProtocolSecret, - Awaitable[resources.MeasurementProtocolSecret] - ]]: - raise NotImplementedError() - - @property - def search_change_history_events(self) -> Callable[ - [analytics_admin.SearchChangeHistoryEventsRequest], - Union[ - analytics_admin.SearchChangeHistoryEventsResponse, - Awaitable[analytics_admin.SearchChangeHistoryEventsResponse] - ]]: - raise NotImplementedError() - - @property - def get_google_signals_settings(self) -> Callable[ - [analytics_admin.GetGoogleSignalsSettingsRequest], - Union[ - resources.GoogleSignalsSettings, - Awaitable[resources.GoogleSignalsSettings] - ]]: - raise NotImplementedError() - - @property - def update_google_signals_settings(self) -> Callable[ - [analytics_admin.UpdateGoogleSignalsSettingsRequest], - Union[ - resources.GoogleSignalsSettings, - Awaitable[resources.GoogleSignalsSettings] - ]]: - raise NotImplementedError() - - @property - def create_conversion_event(self) -> Callable[ - [analytics_admin.CreateConversionEventRequest], - Union[ - resources.ConversionEvent, - Awaitable[resources.ConversionEvent] - ]]: - raise NotImplementedError() - - @property - def get_conversion_event(self) -> Callable[ - [analytics_admin.GetConversionEventRequest], - Union[ - resources.ConversionEvent, - Awaitable[resources.ConversionEvent] - ]]: - raise NotImplementedError() - - @property - def delete_conversion_event(self) -> Callable[ - [analytics_admin.DeleteConversionEventRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_conversion_events(self) -> Callable[ - [analytics_admin.ListConversionEventsRequest], - Union[ - analytics_admin.ListConversionEventsResponse, - Awaitable[analytics_admin.ListConversionEventsResponse] - ]]: - raise NotImplementedError() - - @property - def create_custom_dimension(self) -> Callable[ - [analytics_admin.CreateCustomDimensionRequest], - Union[ - resources.CustomDimension, - Awaitable[resources.CustomDimension] - ]]: - raise NotImplementedError() - - @property - def update_custom_dimension(self) -> Callable[ - [analytics_admin.UpdateCustomDimensionRequest], - Union[ - resources.CustomDimension, - Awaitable[resources.CustomDimension] - ]]: - raise NotImplementedError() - - @property - def list_custom_dimensions(self) -> Callable[ - [analytics_admin.ListCustomDimensionsRequest], - Union[ - analytics_admin.ListCustomDimensionsResponse, - Awaitable[analytics_admin.ListCustomDimensionsResponse] - ]]: - raise NotImplementedError() - - @property - def archive_custom_dimension(self) -> Callable[ - [analytics_admin.ArchiveCustomDimensionRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def get_custom_dimension(self) -> Callable[ - [analytics_admin.GetCustomDimensionRequest], - Union[ - resources.CustomDimension, - Awaitable[resources.CustomDimension] - ]]: - raise NotImplementedError() - - @property - def create_custom_metric(self) -> Callable[ - [analytics_admin.CreateCustomMetricRequest], - Union[ - resources.CustomMetric, - Awaitable[resources.CustomMetric] - ]]: - raise NotImplementedError() - - @property - def update_custom_metric(self) -> Callable[ - [analytics_admin.UpdateCustomMetricRequest], - Union[ - resources.CustomMetric, - Awaitable[resources.CustomMetric] - ]]: - raise NotImplementedError() - - @property - def list_custom_metrics(self) -> Callable[ - [analytics_admin.ListCustomMetricsRequest], - Union[ - analytics_admin.ListCustomMetricsResponse, - Awaitable[analytics_admin.ListCustomMetricsResponse] - ]]: - raise NotImplementedError() - - @property - def archive_custom_metric(self) -> Callable[ - [analytics_admin.ArchiveCustomMetricRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def get_custom_metric(self) -> Callable[ - [analytics_admin.GetCustomMetricRequest], - Union[ - resources.CustomMetric, - Awaitable[resources.CustomMetric] - ]]: - 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 0a250678..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py +++ /dev/null @@ -1,2083 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources -from google.protobuf import empty_pb2 # 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: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or 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. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'analyticsadmin.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def 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_pb2.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_pb2.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], - resources.Property]: - 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], - ~.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 '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=resources.Property.deserialize, - ) - 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_pb2.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_pb2.Empty.FromString, - ) - return self._stubs['delete_user_link'] - - @property - def batch_delete_user_links(self) -> Callable[ - [analytics_admin.BatchDeleteUserLinksRequest], - empty_pb2.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_pb2.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_pb2.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_pb2.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_pb2.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_pb2.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 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_pb2.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_pb2.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 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_pb2.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_pb2.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_pb2.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_pb2.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'] - - @property - def get_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.GetMeasurementProtocolSecretRequest], - resources.MeasurementProtocolSecret]: - r"""Return a callable for the get measurement protocol - secret method over gRPC. - - Lookup for a single "GA4" MeasurementProtocolSecret. - - Returns: - Callable[[~.GetMeasurementProtocolSecretRequest], - ~.MeasurementProtocolSecret]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: - self._stubs['get_measurement_protocol_secret'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetMeasurementProtocolSecret', - request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, - response_deserializer=resources.MeasurementProtocolSecret.deserialize, - ) - return self._stubs['get_measurement_protocol_secret'] - - @property - def list_measurement_protocol_secrets(self) -> Callable[ - [analytics_admin.ListMeasurementProtocolSecretsRequest], - analytics_admin.ListMeasurementProtocolSecretsResponse]: - r"""Return a callable for the list measurement protocol - secrets method over gRPC. - - Returns child MeasurementProtocolSecrets under the - specified parent Property. - - Returns: - Callable[[~.ListMeasurementProtocolSecretsRequest], - ~.ListMeasurementProtocolSecretsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_measurement_protocol_secrets' not in self._stubs: - self._stubs['list_measurement_protocol_secrets'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListMeasurementProtocolSecrets', - request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, - response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, - ) - return self._stubs['list_measurement_protocol_secrets'] - - @property - def create_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.CreateMeasurementProtocolSecretRequest], - resources.MeasurementProtocolSecret]: - r"""Return a callable for the create measurement protocol - secret method over gRPC. - - Creates a measurement protocol secret. - - Returns: - Callable[[~.CreateMeasurementProtocolSecretRequest], - ~.MeasurementProtocolSecret]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: - self._stubs['create_measurement_protocol_secret'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateMeasurementProtocolSecret', - request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, - response_deserializer=resources.MeasurementProtocolSecret.deserialize, - ) - return self._stubs['create_measurement_protocol_secret'] - - @property - def delete_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.DeleteMeasurementProtocolSecretRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete measurement protocol - secret method over gRPC. - - Deletes target MeasurementProtocolSecret. - - Returns: - Callable[[~.DeleteMeasurementProtocolSecretRequest], - ~.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_measurement_protocol_secret' not in self._stubs: - self._stubs['delete_measurement_protocol_secret'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteMeasurementProtocolSecret', - request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_measurement_protocol_secret'] - - @property - def update_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.UpdateMeasurementProtocolSecretRequest], - resources.MeasurementProtocolSecret]: - r"""Return a callable for the update measurement protocol - secret method over gRPC. - - Updates a measurement protocol secret. - - Returns: - Callable[[~.UpdateMeasurementProtocolSecretRequest], - ~.MeasurementProtocolSecret]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: - self._stubs['update_measurement_protocol_secret'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateMeasurementProtocolSecret', - request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, - response_deserializer=resources.MeasurementProtocolSecret.deserialize, - ) - return self._stubs['update_measurement_protocol_secret'] - - @property - def search_change_history_events(self) -> Callable[ - [analytics_admin.SearchChangeHistoryEventsRequest], - analytics_admin.SearchChangeHistoryEventsResponse]: - r"""Return a callable for the search change history events method over gRPC. - - Searches through all changes to an account or its - children given the specified set of filters. - - Returns: - Callable[[~.SearchChangeHistoryEventsRequest], - ~.SearchChangeHistoryEventsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'search_change_history_events' not in self._stubs: - self._stubs['search_change_history_events'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/SearchChangeHistoryEvents', - request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, - response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, - ) - return self._stubs['search_change_history_events'] - - @property - def get_google_signals_settings(self) -> Callable[ - [analytics_admin.GetGoogleSignalsSettingsRequest], - resources.GoogleSignalsSettings]: - r"""Return a callable for the get google signals settings method over gRPC. - - Lookup for Google Signals settings for a property. - - Returns: - Callable[[~.GetGoogleSignalsSettingsRequest], - ~.GoogleSignalsSettings]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_google_signals_settings' not in self._stubs: - self._stubs['get_google_signals_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGoogleSignalsSettings', - request_serializer=analytics_admin.GetGoogleSignalsSettingsRequest.serialize, - response_deserializer=resources.GoogleSignalsSettings.deserialize, - ) - return self._stubs['get_google_signals_settings'] - - @property - def update_google_signals_settings(self) -> Callable[ - [analytics_admin.UpdateGoogleSignalsSettingsRequest], - resources.GoogleSignalsSettings]: - r"""Return a callable for the update google signals settings method over gRPC. - - Updates Google Signals settings for a property. - - Returns: - Callable[[~.UpdateGoogleSignalsSettingsRequest], - ~.GoogleSignalsSettings]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_signals_settings' not in self._stubs: - self._stubs['update_google_signals_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleSignalsSettings', - request_serializer=analytics_admin.UpdateGoogleSignalsSettingsRequest.serialize, - response_deserializer=resources.GoogleSignalsSettings.deserialize, - ) - return self._stubs['update_google_signals_settings'] - - @property - def create_conversion_event(self) -> Callable[ - [analytics_admin.CreateConversionEventRequest], - resources.ConversionEvent]: - r"""Return a callable for the create conversion event method over gRPC. - - Creates a conversion event with the specified - attributes. - - Returns: - Callable[[~.CreateConversionEventRequest], - ~.ConversionEvent]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_conversion_event' not in self._stubs: - self._stubs['create_conversion_event'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConversionEvent', - request_serializer=analytics_admin.CreateConversionEventRequest.serialize, - response_deserializer=resources.ConversionEvent.deserialize, - ) - return self._stubs['create_conversion_event'] - - @property - def get_conversion_event(self) -> Callable[ - [analytics_admin.GetConversionEventRequest], - resources.ConversionEvent]: - r"""Return a callable for the get conversion event method over gRPC. - - Retrieve a single conversion event. - - Returns: - Callable[[~.GetConversionEventRequest], - ~.ConversionEvent]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_conversion_event' not in self._stubs: - self._stubs['get_conversion_event'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetConversionEvent', - request_serializer=analytics_admin.GetConversionEventRequest.serialize, - response_deserializer=resources.ConversionEvent.deserialize, - ) - return self._stubs['get_conversion_event'] - - @property - def delete_conversion_event(self) -> Callable[ - [analytics_admin.DeleteConversionEventRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete conversion event method over gRPC. - - Deletes a conversion event in a property. - - Returns: - Callable[[~.DeleteConversionEventRequest], - ~.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_conversion_event' not in self._stubs: - self._stubs['delete_conversion_event'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConversionEvent', - request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_conversion_event'] - - @property - def list_conversion_events(self) -> Callable[ - [analytics_admin.ListConversionEventsRequest], - analytics_admin.ListConversionEventsResponse]: - r"""Return a callable for the list conversion events method over gRPC. - - Returns a list of conversion events in the specified - parent property. - Returns an empty list if no conversion events are found. - - Returns: - Callable[[~.ListConversionEventsRequest], - ~.ListConversionEventsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_conversion_events' not in self._stubs: - self._stubs['list_conversion_events'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConversionEvents', - request_serializer=analytics_admin.ListConversionEventsRequest.serialize, - response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, - ) - return self._stubs['list_conversion_events'] - - @property - def create_custom_dimension(self) -> Callable[ - [analytics_admin.CreateCustomDimensionRequest], - resources.CustomDimension]: - r"""Return a callable for the create custom dimension method over gRPC. - - Creates a CustomDimension. - - Returns: - Callable[[~.CreateCustomDimensionRequest], - ~.CustomDimension]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: - self._stubs['create_custom_dimension'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomDimension', - request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, - response_deserializer=resources.CustomDimension.deserialize, - ) - return self._stubs['create_custom_dimension'] - - @property - def update_custom_dimension(self) -> Callable[ - [analytics_admin.UpdateCustomDimensionRequest], - resources.CustomDimension]: - r"""Return a callable for the update custom dimension method over gRPC. - - Updates a CustomDimension on a property. - - Returns: - Callable[[~.UpdateCustomDimensionRequest], - ~.CustomDimension]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: - self._stubs['update_custom_dimension'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomDimension', - request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, - response_deserializer=resources.CustomDimension.deserialize, - ) - return self._stubs['update_custom_dimension'] - - @property - def list_custom_dimensions(self) -> Callable[ - [analytics_admin.ListCustomDimensionsRequest], - analytics_admin.ListCustomDimensionsResponse]: - r"""Return a callable for the list custom dimensions method over gRPC. - - Lists CustomDimensions on a property. - - Returns: - Callable[[~.ListCustomDimensionsRequest], - ~.ListCustomDimensionsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_dimensions' not in self._stubs: - self._stubs['list_custom_dimensions'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomDimensions', - request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, - response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, - ) - return self._stubs['list_custom_dimensions'] - - @property - def archive_custom_dimension(self) -> Callable[ - [analytics_admin.ArchiveCustomDimensionRequest], - empty_pb2.Empty]: - r"""Return a callable for the archive custom dimension method over gRPC. - - Archives a CustomDimension on a property. - - Returns: - Callable[[~.ArchiveCustomDimensionRequest], - ~.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 'archive_custom_dimension' not in self._stubs: - self._stubs['archive_custom_dimension'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomDimension', - request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['archive_custom_dimension'] - - @property - def get_custom_dimension(self) -> Callable[ - [analytics_admin.GetCustomDimensionRequest], - resources.CustomDimension]: - r"""Return a callable for the get custom dimension method over gRPC. - - Lookup for a single CustomDimension. - - Returns: - Callable[[~.GetCustomDimensionRequest], - ~.CustomDimension]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: - self._stubs['get_custom_dimension'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomDimension', - request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, - response_deserializer=resources.CustomDimension.deserialize, - ) - return self._stubs['get_custom_dimension'] - - @property - def create_custom_metric(self) -> Callable[ - [analytics_admin.CreateCustomMetricRequest], - resources.CustomMetric]: - r"""Return a callable for the create custom metric method over gRPC. - - Creates a CustomMetric. - - Returns: - Callable[[~.CreateCustomMetricRequest], - ~.CustomMetric]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: - self._stubs['create_custom_metric'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomMetric', - request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, - response_deserializer=resources.CustomMetric.deserialize, - ) - return self._stubs['create_custom_metric'] - - @property - def update_custom_metric(self) -> Callable[ - [analytics_admin.UpdateCustomMetricRequest], - resources.CustomMetric]: - r"""Return a callable for the update custom metric method over gRPC. - - Updates a CustomMetric on a property. - - Returns: - Callable[[~.UpdateCustomMetricRequest], - ~.CustomMetric]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: - self._stubs['update_custom_metric'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomMetric', - request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, - response_deserializer=resources.CustomMetric.deserialize, - ) - return self._stubs['update_custom_metric'] - - @property - def list_custom_metrics(self) -> Callable[ - [analytics_admin.ListCustomMetricsRequest], - analytics_admin.ListCustomMetricsResponse]: - r"""Return a callable for the list custom metrics method over gRPC. - - Lists CustomMetrics on a property. - - Returns: - Callable[[~.ListCustomMetricsRequest], - ~.ListCustomMetricsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_metrics' not in self._stubs: - self._stubs['list_custom_metrics'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomMetrics', - request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, - response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, - ) - return self._stubs['list_custom_metrics'] - - @property - def archive_custom_metric(self) -> Callable[ - [analytics_admin.ArchiveCustomMetricRequest], - empty_pb2.Empty]: - r"""Return a callable for the archive custom metric method over gRPC. - - Archives a CustomMetric on a property. - - Returns: - Callable[[~.ArchiveCustomMetricRequest], - ~.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 'archive_custom_metric' not in self._stubs: - self._stubs['archive_custom_metric'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomMetric', - request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['archive_custom_metric'] - - @property - def get_custom_metric(self) -> Callable[ - [analytics_admin.GetCustomMetricRequest], - resources.CustomMetric]: - r"""Return a callable for the get custom metric method over gRPC. - - Lookup for a single CustomMetric. - - Returns: - Callable[[~.GetCustomMetricRequest], - ~.CustomMetric]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: - self._stubs['get_custom_metric'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomMetric', - request_serializer=analytics_admin.GetCustomMetricRequest.serialize, - response_deserializer=resources.CustomMetric.deserialize, - ) - return self._stubs['get_custom_metric'] - - -__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 54c05583..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,2087 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.analytics.admin_v1alpha.types import analytics_admin -from google.analytics.admin_v1alpha.types import resources -from google.protobuf import empty_pb2 # 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: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - def __init__(self, *, - host: str = 'analyticsadmin.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or 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. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def 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_pb2.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_pb2.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[resources.Property]]: - 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[~.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 '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=resources.Property.deserialize, - ) - 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_pb2.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_pb2.Empty.FromString, - ) - return self._stubs['delete_user_link'] - - @property - def batch_delete_user_links(self) -> Callable[ - [analytics_admin.BatchDeleteUserLinksRequest], - Awaitable[empty_pb2.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_pb2.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_pb2.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_pb2.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_pb2.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_pb2.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 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_pb2.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_pb2.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 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_pb2.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_pb2.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_pb2.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_pb2.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'] - - @property - def get_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.GetMeasurementProtocolSecretRequest], - Awaitable[resources.MeasurementProtocolSecret]]: - r"""Return a callable for the get measurement protocol - secret method over gRPC. - - Lookup for a single "GA4" MeasurementProtocolSecret. - - Returns: - Callable[[~.GetMeasurementProtocolSecretRequest], - Awaitable[~.MeasurementProtocolSecret]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: - self._stubs['get_measurement_protocol_secret'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetMeasurementProtocolSecret', - request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, - response_deserializer=resources.MeasurementProtocolSecret.deserialize, - ) - return self._stubs['get_measurement_protocol_secret'] - - @property - def list_measurement_protocol_secrets(self) -> Callable[ - [analytics_admin.ListMeasurementProtocolSecretsRequest], - Awaitable[analytics_admin.ListMeasurementProtocolSecretsResponse]]: - r"""Return a callable for the list measurement protocol - secrets method over gRPC. - - Returns child MeasurementProtocolSecrets under the - specified parent Property. - - Returns: - Callable[[~.ListMeasurementProtocolSecretsRequest], - Awaitable[~.ListMeasurementProtocolSecretsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_measurement_protocol_secrets' not in self._stubs: - self._stubs['list_measurement_protocol_secrets'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListMeasurementProtocolSecrets', - request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, - response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, - ) - return self._stubs['list_measurement_protocol_secrets'] - - @property - def create_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.CreateMeasurementProtocolSecretRequest], - Awaitable[resources.MeasurementProtocolSecret]]: - r"""Return a callable for the create measurement protocol - secret method over gRPC. - - Creates a measurement protocol secret. - - Returns: - Callable[[~.CreateMeasurementProtocolSecretRequest], - Awaitable[~.MeasurementProtocolSecret]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: - self._stubs['create_measurement_protocol_secret'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateMeasurementProtocolSecret', - request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, - response_deserializer=resources.MeasurementProtocolSecret.deserialize, - ) - return self._stubs['create_measurement_protocol_secret'] - - @property - def delete_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.DeleteMeasurementProtocolSecretRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete measurement protocol - secret method over gRPC. - - Deletes target MeasurementProtocolSecret. - - Returns: - Callable[[~.DeleteMeasurementProtocolSecretRequest], - 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_measurement_protocol_secret' not in self._stubs: - self._stubs['delete_measurement_protocol_secret'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteMeasurementProtocolSecret', - request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_measurement_protocol_secret'] - - @property - def update_measurement_protocol_secret(self) -> Callable[ - [analytics_admin.UpdateMeasurementProtocolSecretRequest], - Awaitable[resources.MeasurementProtocolSecret]]: - r"""Return a callable for the update measurement protocol - secret method over gRPC. - - Updates a measurement protocol secret. - - Returns: - Callable[[~.UpdateMeasurementProtocolSecretRequest], - Awaitable[~.MeasurementProtocolSecret]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_measurement_protocol_secret' not in self._stubs: - self._stubs['update_measurement_protocol_secret'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateMeasurementProtocolSecret', - request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, - response_deserializer=resources.MeasurementProtocolSecret.deserialize, - ) - return self._stubs['update_measurement_protocol_secret'] - - @property - def search_change_history_events(self) -> Callable[ - [analytics_admin.SearchChangeHistoryEventsRequest], - Awaitable[analytics_admin.SearchChangeHistoryEventsResponse]]: - r"""Return a callable for the search change history events method over gRPC. - - Searches through all changes to an account or its - children given the specified set of filters. - - Returns: - Callable[[~.SearchChangeHistoryEventsRequest], - Awaitable[~.SearchChangeHistoryEventsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'search_change_history_events' not in self._stubs: - self._stubs['search_change_history_events'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/SearchChangeHistoryEvents', - request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, - response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, - ) - return self._stubs['search_change_history_events'] - - @property - def get_google_signals_settings(self) -> Callable[ - [analytics_admin.GetGoogleSignalsSettingsRequest], - Awaitable[resources.GoogleSignalsSettings]]: - r"""Return a callable for the get google signals settings method over gRPC. - - Lookup for Google Signals settings for a property. - - Returns: - Callable[[~.GetGoogleSignalsSettingsRequest], - Awaitable[~.GoogleSignalsSettings]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_google_signals_settings' not in self._stubs: - self._stubs['get_google_signals_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGoogleSignalsSettings', - request_serializer=analytics_admin.GetGoogleSignalsSettingsRequest.serialize, - response_deserializer=resources.GoogleSignalsSettings.deserialize, - ) - return self._stubs['get_google_signals_settings'] - - @property - def update_google_signals_settings(self) -> Callable[ - [analytics_admin.UpdateGoogleSignalsSettingsRequest], - Awaitable[resources.GoogleSignalsSettings]]: - r"""Return a callable for the update google signals settings method over gRPC. - - Updates Google Signals settings for a property. - - Returns: - Callable[[~.UpdateGoogleSignalsSettingsRequest], - Awaitable[~.GoogleSignalsSettings]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_signals_settings' not in self._stubs: - self._stubs['update_google_signals_settings'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleSignalsSettings', - request_serializer=analytics_admin.UpdateGoogleSignalsSettingsRequest.serialize, - response_deserializer=resources.GoogleSignalsSettings.deserialize, - ) - return self._stubs['update_google_signals_settings'] - - @property - def create_conversion_event(self) -> Callable[ - [analytics_admin.CreateConversionEventRequest], - Awaitable[resources.ConversionEvent]]: - r"""Return a callable for the create conversion event method over gRPC. - - Creates a conversion event with the specified - attributes. - - Returns: - Callable[[~.CreateConversionEventRequest], - Awaitable[~.ConversionEvent]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_conversion_event' not in self._stubs: - self._stubs['create_conversion_event'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConversionEvent', - request_serializer=analytics_admin.CreateConversionEventRequest.serialize, - response_deserializer=resources.ConversionEvent.deserialize, - ) - return self._stubs['create_conversion_event'] - - @property - def get_conversion_event(self) -> Callable[ - [analytics_admin.GetConversionEventRequest], - Awaitable[resources.ConversionEvent]]: - r"""Return a callable for the get conversion event method over gRPC. - - Retrieve a single conversion event. - - Returns: - Callable[[~.GetConversionEventRequest], - Awaitable[~.ConversionEvent]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_conversion_event' not in self._stubs: - self._stubs['get_conversion_event'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetConversionEvent', - request_serializer=analytics_admin.GetConversionEventRequest.serialize, - response_deserializer=resources.ConversionEvent.deserialize, - ) - return self._stubs['get_conversion_event'] - - @property - def delete_conversion_event(self) -> Callable[ - [analytics_admin.DeleteConversionEventRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete conversion event method over gRPC. - - Deletes a conversion event in a property. - - Returns: - Callable[[~.DeleteConversionEventRequest], - 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_conversion_event' not in self._stubs: - self._stubs['delete_conversion_event'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConversionEvent', - request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_conversion_event'] - - @property - def list_conversion_events(self) -> Callable[ - [analytics_admin.ListConversionEventsRequest], - Awaitable[analytics_admin.ListConversionEventsResponse]]: - r"""Return a callable for the list conversion events method over gRPC. - - Returns a list of conversion events in the specified - parent property. - Returns an empty list if no conversion events are found. - - Returns: - Callable[[~.ListConversionEventsRequest], - Awaitable[~.ListConversionEventsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_conversion_events' not in self._stubs: - self._stubs['list_conversion_events'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConversionEvents', - request_serializer=analytics_admin.ListConversionEventsRequest.serialize, - response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, - ) - return self._stubs['list_conversion_events'] - - @property - def create_custom_dimension(self) -> Callable[ - [analytics_admin.CreateCustomDimensionRequest], - Awaitable[resources.CustomDimension]]: - r"""Return a callable for the create custom dimension method over gRPC. - - Creates a CustomDimension. - - Returns: - Callable[[~.CreateCustomDimensionRequest], - Awaitable[~.CustomDimension]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: - self._stubs['create_custom_dimension'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomDimension', - request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, - response_deserializer=resources.CustomDimension.deserialize, - ) - return self._stubs['create_custom_dimension'] - - @property - def update_custom_dimension(self) -> Callable[ - [analytics_admin.UpdateCustomDimensionRequest], - Awaitable[resources.CustomDimension]]: - r"""Return a callable for the update custom dimension method over gRPC. - - Updates a CustomDimension on a property. - - Returns: - Callable[[~.UpdateCustomDimensionRequest], - Awaitable[~.CustomDimension]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: - self._stubs['update_custom_dimension'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomDimension', - request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, - response_deserializer=resources.CustomDimension.deserialize, - ) - return self._stubs['update_custom_dimension'] - - @property - def list_custom_dimensions(self) -> Callable[ - [analytics_admin.ListCustomDimensionsRequest], - Awaitable[analytics_admin.ListCustomDimensionsResponse]]: - r"""Return a callable for the list custom dimensions method over gRPC. - - Lists CustomDimensions on a property. - - Returns: - Callable[[~.ListCustomDimensionsRequest], - Awaitable[~.ListCustomDimensionsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_dimensions' not in self._stubs: - self._stubs['list_custom_dimensions'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomDimensions', - request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, - response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, - ) - return self._stubs['list_custom_dimensions'] - - @property - def archive_custom_dimension(self) -> Callable[ - [analytics_admin.ArchiveCustomDimensionRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the archive custom dimension method over gRPC. - - Archives a CustomDimension on a property. - - Returns: - Callable[[~.ArchiveCustomDimensionRequest], - 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 'archive_custom_dimension' not in self._stubs: - self._stubs['archive_custom_dimension'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomDimension', - request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['archive_custom_dimension'] - - @property - def get_custom_dimension(self) -> Callable[ - [analytics_admin.GetCustomDimensionRequest], - Awaitable[resources.CustomDimension]]: - r"""Return a callable for the get custom dimension method over gRPC. - - Lookup for a single CustomDimension. - - Returns: - Callable[[~.GetCustomDimensionRequest], - Awaitable[~.CustomDimension]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_dimension' not in self._stubs: - self._stubs['get_custom_dimension'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomDimension', - request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, - response_deserializer=resources.CustomDimension.deserialize, - ) - return self._stubs['get_custom_dimension'] - - @property - def create_custom_metric(self) -> Callable[ - [analytics_admin.CreateCustomMetricRequest], - Awaitable[resources.CustomMetric]]: - r"""Return a callable for the create custom metric method over gRPC. - - Creates a CustomMetric. - - Returns: - Callable[[~.CreateCustomMetricRequest], - Awaitable[~.CustomMetric]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: - self._stubs['create_custom_metric'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomMetric', - request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, - response_deserializer=resources.CustomMetric.deserialize, - ) - return self._stubs['create_custom_metric'] - - @property - def update_custom_metric(self) -> Callable[ - [analytics_admin.UpdateCustomMetricRequest], - Awaitable[resources.CustomMetric]]: - r"""Return a callable for the update custom metric method over gRPC. - - Updates a CustomMetric on a property. - - Returns: - Callable[[~.UpdateCustomMetricRequest], - Awaitable[~.CustomMetric]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: - self._stubs['update_custom_metric'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomMetric', - request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, - response_deserializer=resources.CustomMetric.deserialize, - ) - return self._stubs['update_custom_metric'] - - @property - def list_custom_metrics(self) -> Callable[ - [analytics_admin.ListCustomMetricsRequest], - Awaitable[analytics_admin.ListCustomMetricsResponse]]: - r"""Return a callable for the list custom metrics method over gRPC. - - Lists CustomMetrics on a property. - - Returns: - Callable[[~.ListCustomMetricsRequest], - Awaitable[~.ListCustomMetricsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_metrics' not in self._stubs: - self._stubs['list_custom_metrics'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomMetrics', - request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, - response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, - ) - return self._stubs['list_custom_metrics'] - - @property - def archive_custom_metric(self) -> Callable[ - [analytics_admin.ArchiveCustomMetricRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the archive custom metric method over gRPC. - - Archives a CustomMetric on a property. - - Returns: - Callable[[~.ArchiveCustomMetricRequest], - 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 'archive_custom_metric' not in self._stubs: - self._stubs['archive_custom_metric'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomMetric', - request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['archive_custom_metric'] - - @property - def get_custom_metric(self) -> Callable[ - [analytics_admin.GetCustomMetricRequest], - Awaitable[resources.CustomMetric]]: - r"""Return a callable for the get custom metric method over gRPC. - - Lookup for a single CustomMetric. - - Returns: - Callable[[~.GetCustomMetricRequest], - Awaitable[~.CustomMetric]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_custom_metric' not in self._stubs: - self._stubs['get_custom_metric'] = self.grpc_channel.unary_unary( - '/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomMetric', - request_serializer=analytics_admin.GetCustomMetricRequest.serialize, - response_deserializer=resources.CustomMetric.deserialize, - ) - return self._stubs['get_custom_metric'] - - -__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 53dd3618..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/__init__.py +++ /dev/null @@ -1,252 +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 ( - ArchiveCustomDimensionRequest, - ArchiveCustomMetricRequest, - AuditUserLinksRequest, - AuditUserLinksResponse, - BatchCreateUserLinksRequest, - BatchCreateUserLinksResponse, - BatchDeleteUserLinksRequest, - BatchGetUserLinksRequest, - BatchGetUserLinksResponse, - BatchUpdateUserLinksRequest, - BatchUpdateUserLinksResponse, - CreateConversionEventRequest, - CreateCustomDimensionRequest, - CreateCustomMetricRequest, - CreateFirebaseLinkRequest, - CreateGoogleAdsLinkRequest, - CreateMeasurementProtocolSecretRequest, - CreatePropertyRequest, - CreateUserLinkRequest, - CreateWebDataStreamRequest, - DeleteAccountRequest, - DeleteAndroidAppDataStreamRequest, - DeleteConversionEventRequest, - DeleteFirebaseLinkRequest, - DeleteGoogleAdsLinkRequest, - DeleteIosAppDataStreamRequest, - DeleteMeasurementProtocolSecretRequest, - DeletePropertyRequest, - DeleteUserLinkRequest, - DeleteWebDataStreamRequest, - GetAccountRequest, - GetAndroidAppDataStreamRequest, - GetConversionEventRequest, - GetCustomDimensionRequest, - GetCustomMetricRequest, - GetDataSharingSettingsRequest, - GetEnhancedMeasurementSettingsRequest, - GetGlobalSiteTagRequest, - GetGoogleSignalsSettingsRequest, - GetIosAppDataStreamRequest, - GetMeasurementProtocolSecretRequest, - GetPropertyRequest, - GetUserLinkRequest, - GetWebDataStreamRequest, - ListAccountsRequest, - ListAccountsResponse, - ListAccountSummariesRequest, - ListAccountSummariesResponse, - ListAndroidAppDataStreamsRequest, - ListAndroidAppDataStreamsResponse, - ListConversionEventsRequest, - ListConversionEventsResponse, - ListCustomDimensionsRequest, - ListCustomDimensionsResponse, - ListCustomMetricsRequest, - ListCustomMetricsResponse, - ListFirebaseLinksRequest, - ListFirebaseLinksResponse, - ListGoogleAdsLinksRequest, - ListGoogleAdsLinksResponse, - ListIosAppDataStreamsRequest, - ListIosAppDataStreamsResponse, - ListMeasurementProtocolSecretsRequest, - ListMeasurementProtocolSecretsResponse, - ListPropertiesRequest, - ListPropertiesResponse, - ListUserLinksRequest, - ListUserLinksResponse, - ListWebDataStreamsRequest, - ListWebDataStreamsResponse, - ProvisionAccountTicketRequest, - ProvisionAccountTicketResponse, - SearchChangeHistoryEventsRequest, - SearchChangeHistoryEventsResponse, - UpdateAccountRequest, - UpdateAndroidAppDataStreamRequest, - UpdateCustomDimensionRequest, - UpdateCustomMetricRequest, - UpdateEnhancedMeasurementSettingsRequest, - UpdateFirebaseLinkRequest, - UpdateGoogleAdsLinkRequest, - UpdateGoogleSignalsSettingsRequest, - UpdateIosAppDataStreamRequest, - UpdateMeasurementProtocolSecretRequest, - UpdatePropertyRequest, - UpdateUserLinkRequest, - UpdateWebDataStreamRequest, -) -from .resources import ( - Account, - AccountSummary, - AndroidAppDataStream, - AuditUserLink, - ChangeHistoryChange, - ChangeHistoryEvent, - ConversionEvent, - CustomDimension, - CustomMetric, - DataSharingSettings, - EnhancedMeasurementSettings, - FirebaseLink, - GlobalSiteTag, - GoogleAdsLink, - GoogleSignalsSettings, - IosAppDataStream, - MeasurementProtocolSecret, - Property, - PropertySummary, - UserLink, - WebDataStream, - ActionType, - ActorType, - ChangeHistoryResourceType, - GoogleSignalsConsent, - GoogleSignalsState, - IndustryCategory, - MaximumUserAccess, -) - -__all__ = ( - 'ArchiveCustomDimensionRequest', - 'ArchiveCustomMetricRequest', - 'AuditUserLinksRequest', - 'AuditUserLinksResponse', - 'BatchCreateUserLinksRequest', - 'BatchCreateUserLinksResponse', - 'BatchDeleteUserLinksRequest', - 'BatchGetUserLinksRequest', - 'BatchGetUserLinksResponse', - 'BatchUpdateUserLinksRequest', - 'BatchUpdateUserLinksResponse', - 'CreateConversionEventRequest', - 'CreateCustomDimensionRequest', - 'CreateCustomMetricRequest', - 'CreateFirebaseLinkRequest', - 'CreateGoogleAdsLinkRequest', - 'CreateMeasurementProtocolSecretRequest', - 'CreatePropertyRequest', - 'CreateUserLinkRequest', - 'CreateWebDataStreamRequest', - 'DeleteAccountRequest', - 'DeleteAndroidAppDataStreamRequest', - 'DeleteConversionEventRequest', - 'DeleteFirebaseLinkRequest', - 'DeleteGoogleAdsLinkRequest', - 'DeleteIosAppDataStreamRequest', - 'DeleteMeasurementProtocolSecretRequest', - 'DeletePropertyRequest', - 'DeleteUserLinkRequest', - 'DeleteWebDataStreamRequest', - 'GetAccountRequest', - 'GetAndroidAppDataStreamRequest', - 'GetConversionEventRequest', - 'GetCustomDimensionRequest', - 'GetCustomMetricRequest', - 'GetDataSharingSettingsRequest', - 'GetEnhancedMeasurementSettingsRequest', - 'GetGlobalSiteTagRequest', - 'GetGoogleSignalsSettingsRequest', - 'GetIosAppDataStreamRequest', - 'GetMeasurementProtocolSecretRequest', - 'GetPropertyRequest', - 'GetUserLinkRequest', - 'GetWebDataStreamRequest', - 'ListAccountsRequest', - 'ListAccountsResponse', - 'ListAccountSummariesRequest', - 'ListAccountSummariesResponse', - 'ListAndroidAppDataStreamsRequest', - 'ListAndroidAppDataStreamsResponse', - 'ListConversionEventsRequest', - 'ListConversionEventsResponse', - 'ListCustomDimensionsRequest', - 'ListCustomDimensionsResponse', - 'ListCustomMetricsRequest', - 'ListCustomMetricsResponse', - 'ListFirebaseLinksRequest', - 'ListFirebaseLinksResponse', - 'ListGoogleAdsLinksRequest', - 'ListGoogleAdsLinksResponse', - 'ListIosAppDataStreamsRequest', - 'ListIosAppDataStreamsResponse', - 'ListMeasurementProtocolSecretsRequest', - 'ListMeasurementProtocolSecretsResponse', - 'ListPropertiesRequest', - 'ListPropertiesResponse', - 'ListUserLinksRequest', - 'ListUserLinksResponse', - 'ListWebDataStreamsRequest', - 'ListWebDataStreamsResponse', - 'ProvisionAccountTicketRequest', - 'ProvisionAccountTicketResponse', - 'SearchChangeHistoryEventsRequest', - 'SearchChangeHistoryEventsResponse', - 'UpdateAccountRequest', - 'UpdateAndroidAppDataStreamRequest', - 'UpdateCustomDimensionRequest', - 'UpdateCustomMetricRequest', - 'UpdateEnhancedMeasurementSettingsRequest', - 'UpdateFirebaseLinkRequest', - 'UpdateGoogleAdsLinkRequest', - 'UpdateGoogleSignalsSettingsRequest', - 'UpdateIosAppDataStreamRequest', - 'UpdateMeasurementProtocolSecretRequest', - 'UpdatePropertyRequest', - 'UpdateUserLinkRequest', - 'UpdateWebDataStreamRequest', - 'Account', - 'AccountSummary', - 'AndroidAppDataStream', - 'AuditUserLink', - 'ChangeHistoryChange', - 'ChangeHistoryEvent', - 'ConversionEvent', - 'CustomDimension', - 'CustomMetric', - 'DataSharingSettings', - 'EnhancedMeasurementSettings', - 'FirebaseLink', - 'GlobalSiteTag', - 'GoogleAdsLink', - 'GoogleSignalsSettings', - 'IosAppDataStream', - 'MeasurementProtocolSecret', - 'Property', - 'PropertySummary', - 'UserLink', - 'WebDataStream', - 'ActionType', - 'ActorType', - 'ChangeHistoryResourceType', - 'GoogleSignalsConsent', - 'GoogleSignalsState', - '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 6ae00c0e..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/analytics_admin.py +++ /dev/null @@ -1,2195 +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 # type: ignore -from google.protobuf import timestamp_pb2 # 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', - 'ListIosAppDataStreamsRequest', - 'ListIosAppDataStreamsResponse', - 'GetAndroidAppDataStreamRequest', - 'DeleteAndroidAppDataStreamRequest', - 'UpdateAndroidAppDataStreamRequest', - 'ListAndroidAppDataStreamsRequest', - 'ListAndroidAppDataStreamsResponse', - 'GetEnhancedMeasurementSettingsRequest', - 'UpdateEnhancedMeasurementSettingsRequest', - 'CreateFirebaseLinkRequest', - 'UpdateFirebaseLinkRequest', - 'DeleteFirebaseLinkRequest', - 'ListFirebaseLinksRequest', - 'ListFirebaseLinksResponse', - 'GetGlobalSiteTagRequest', - 'CreateGoogleAdsLinkRequest', - 'UpdateGoogleAdsLinkRequest', - 'DeleteGoogleAdsLinkRequest', - 'ListGoogleAdsLinksRequest', - 'ListGoogleAdsLinksResponse', - 'GetDataSharingSettingsRequest', - 'ListAccountSummariesRequest', - 'ListAccountSummariesResponse', - 'SearchChangeHistoryEventsRequest', - 'SearchChangeHistoryEventsResponse', - 'GetMeasurementProtocolSecretRequest', - 'CreateMeasurementProtocolSecretRequest', - 'DeleteMeasurementProtocolSecretRequest', - 'UpdateMeasurementProtocolSecretRequest', - 'ListMeasurementProtocolSecretsRequest', - 'ListMeasurementProtocolSecretsResponse', - 'GetGoogleSignalsSettingsRequest', - 'UpdateGoogleSignalsSettingsRequest', - 'CreateConversionEventRequest', - 'GetConversionEventRequest', - 'DeleteConversionEventRequest', - 'ListConversionEventsRequest', - 'ListConversionEventsResponse', - 'CreateCustomDimensionRequest', - 'UpdateCustomDimensionRequest', - 'ListCustomDimensionsRequest', - 'ListCustomDimensionsResponse', - 'ArchiveCustomDimensionRequest', - 'GetCustomDimensionRequest', - 'CreateCustomMetricRequest', - 'UpdateCustomMetricRequest', - 'ListCustomMetricsRequest', - 'ListCustomMetricsResponse', - 'ArchiveCustomMetricRequest', - 'GetCustomMetricRequest', - }, -) - - -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_pb2.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_pb2.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_pb2.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_pb2.FieldMask, - ) - - -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_pb2.FieldMask, - ) - - -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_pb2.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_pb2.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_pb2.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, - ) - - -class SearchChangeHistoryEventsRequest(proto.Message): - r"""Request message for SearchChangeHistoryEvents RPC. - Attributes: - account (str): - Required. The account resource for which to - return change history resources. - property (str): - Optional. Resource name for a child property. - If set, only return changes made to this - property or its child resources. - resource_type (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryResourceType]): - Optional. If set, only return changes if they - are for a resource that matches at least one of - these types. - action (Sequence[google.analytics.admin_v1alpha.types.ActionType]): - Optional. If set, only return changes that - match one or more of these types of actions. - actor_email (Sequence[str]): - Optional. If set, only return changes if they - are made by a user in this list. - earliest_change_time (google.protobuf.timestamp_pb2.Timestamp): - Optional. If set, only return changes made - after this time (inclusive). - latest_change_time (google.protobuf.timestamp_pb2.Timestamp): - Optional. If set, only return changes made - before this time (inclusive). - page_size (int): - Optional. The maximum number of - ChangeHistoryEvent items to return. The service - may return fewer than this value, even if there - are additional pages. If unspecified, at most 50 - items will be returned. The maximum value is 200 - (higher values will be coerced to the maximum). - page_token (str): - Optional. A page token, received from a previous - ``SearchChangeHistoryEvents`` call. Provide this to retrieve - the subsequent page. When paginating, all other parameters - provided to ``SearchChangeHistoryEvents`` must match the - call that provided the page token. - """ - - account = proto.Field( - proto.STRING, - number=1, - ) - property = proto.Field( - proto.STRING, - number=2, - ) - resource_type = proto.RepeatedField( - proto.ENUM, - number=3, - enum=resources.ChangeHistoryResourceType, - ) - action = proto.RepeatedField( - proto.ENUM, - number=4, - enum=resources.ActionType, - ) - actor_email = proto.RepeatedField( - proto.STRING, - number=5, - ) - earliest_change_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - latest_change_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - page_size = proto.Field( - proto.INT32, - number=8, - ) - page_token = proto.Field( - proto.STRING, - number=9, - ) - - -class SearchChangeHistoryEventsResponse(proto.Message): - r"""Response message for SearchAccounts RPC. - Attributes: - change_history_events (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryEvent]): - 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 - - change_history_events = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.ChangeHistoryEvent, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class GetMeasurementProtocolSecretRequest(proto.Message): - r"""Request message for GetMeasurementProtocolSecret RPC. - Attributes: - name (str): - Required. The name of the measurement - protocol secret to lookup. Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} - Note: Any type of stream (WebDataStream, - IosAppDataStream, AndroidAppDataStream) may be a - parent. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateMeasurementProtocolSecretRequest(proto.Message): - r"""Request message for CreateMeasurementProtocolSecret RPC - Attributes: - parent (str): - Required. The parent resource where this - secret will be created. Any type of stream - (WebDataStream, IosAppDataStream, - AndroidAppDataStream) may be a parent. - Format: - properties/{property}/webDataStreams/{webDataStream} - measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): - Required. The measurement protocol secret to - create. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - measurement_protocol_secret = proto.Field( - proto.MESSAGE, - number=2, - message=resources.MeasurementProtocolSecret, - ) - - -class DeleteMeasurementProtocolSecretRequest(proto.Message): - r"""Request message for DeleteMeasurementProtocolSecret RPC - Attributes: - name (str): - Required. The name of the - MeasurementProtocolSecret to delete. Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} - Note: Any type of stream (WebDataStream, - IosAppDataStream, AndroidAppDataStream) may be a - parent. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateMeasurementProtocolSecretRequest(proto.Message): - r"""Request message for UpdateMeasurementProtocolSecret RPC - Attributes: - measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): - Required. The measurement protocol secret to - update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. - """ - - measurement_protocol_secret = proto.Field( - proto.MESSAGE, - number=1, - message=resources.MeasurementProtocolSecret, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class ListMeasurementProtocolSecretsRequest(proto.Message): - r"""Request message for ListMeasurementProtocolSecret RPC - Attributes: - parent (str): - Required. The resource name of the parent - stream. Any type of stream (WebDataStream, - IosAppDataStream, AndroidAppDataStream) may be a - parent. - Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets - page_size (int): - The maximum number of resources to return. - If unspecified, at most 10 resources will be - returned. The maximum value is 10. Higher values - will be coerced to the maximum. - page_token (str): - A page token, received from a previous - ``ListMeasurementProtocolSecrets`` call. Provide this to - retrieve the subsequent page. When paginating, all other - parameters provided to ``ListMeasurementProtocolSecrets`` - 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 ListMeasurementProtocolSecretsResponse(proto.Message): - r"""Response message for ListMeasurementProtocolSecret RPC - Attributes: - measurement_protocol_secrets (Sequence[google.analytics.admin_v1alpha.types.MeasurementProtocolSecret]): - A list of secrets for the parent stream - specified in the request. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - measurement_protocol_secrets = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.MeasurementProtocolSecret, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class GetGoogleSignalsSettingsRequest(proto.Message): - r"""Request message for GetGoogleSignalsSettings RPC - Attributes: - name (str): - Required. The name of the google signals - settings to retrieve. Format: - properties/{property}/googleSignalsSettings - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateGoogleSignalsSettingsRequest(proto.Message): - r"""Request message for UpdateGoogleSignalsSettings RPC - Attributes: - google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): - 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. - """ - - google_signals_settings = proto.Field( - proto.MESSAGE, - number=1, - message=resources.GoogleSignalsSettings, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class CreateConversionEventRequest(proto.Message): - r"""Request message for CreateConversionEvent RPC - Attributes: - conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): - Required. The conversion event to create. - parent (str): - Required. The resource name of the parent - property where this conversion event will be - created. Format: properties/123 - """ - - conversion_event = proto.Field( - proto.MESSAGE, - number=1, - message=resources.ConversionEvent, - ) - parent = proto.Field( - proto.STRING, - number=2, - ) - - -class GetConversionEventRequest(proto.Message): - r"""Request message for GetConversionEvent RPC - Attributes: - name (str): - Required. The resource name of the conversion event to - retrieve. Format: - properties/{property}/conversionEvents/{conversion_event} - Example: "properties/123/conversionEvents/456". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class DeleteConversionEventRequest(proto.Message): - r"""Request message for DeleteConversionEvent RPC - Attributes: - name (str): - Required. The resource name of the conversion event to - delete. Format: - properties/{property}/conversionEvents/{conversion_event} - Example: "properties/123/conversionEvents/456". - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListConversionEventsRequest(proto.Message): - r"""Request message for ListConversionEvents RPC - Attributes: - parent (str): - Required. The resource name of the parent - property. Example: '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 - ``ListConversionEvents`` call. Provide this to retrieve the - subsequent page. When paginating, all other parameters - provided to ``ListConversionEvents`` 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 ListConversionEventsResponse(proto.Message): - r"""Response message for ListConversionEvents RPC. - Attributes: - conversion_events (Sequence[google.analytics.admin_v1alpha.types.ConversionEvent]): - The requested conversion events - 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 - - conversion_events = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.ConversionEvent, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class CreateCustomDimensionRequest(proto.Message): - r"""Request message for CreateCustomDimension RPC. - Attributes: - parent (str): - Required. Example format: properties/1234 - custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): - Required. The CustomDimension to create. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - custom_dimension = proto.Field( - proto.MESSAGE, - number=2, - message=resources.CustomDimension, - ) - - -class UpdateCustomDimensionRequest(proto.Message): - r"""Request message for UpdateCustomDimension RPC. - Attributes: - custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): - The CustomDimension to update - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - custom_dimension = proto.Field( - proto.MESSAGE, - number=1, - message=resources.CustomDimension, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class ListCustomDimensionsRequest(proto.Message): - r"""Request message for ListCustomDimensions 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 - ``ListCustomDimensions`` call. Provide this to retrieve the - subsequent page. - - When paginating, all other parameters provided to - ``ListCustomDimensions`` 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 ListCustomDimensionsResponse(proto.Message): - r"""Response message for ListCustomDimensions RPC. - Attributes: - custom_dimensions (Sequence[google.analytics.admin_v1alpha.types.CustomDimension]): - List of CustomDimensions. - 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 - - custom_dimensions = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.CustomDimension, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class ArchiveCustomDimensionRequest(proto.Message): - r"""Request message for ArchiveCustomDimension RPC. - Attributes: - name (str): - Required. The name of the CustomDimension to - archive. Example format: - properties/1234/customDimensions/5678 - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class GetCustomDimensionRequest(proto.Message): - r"""Request message for GetCustomDimension RPC. - Attributes: - name (str): - Required. The name of the CustomDimension to - get. Example format: - properties/1234/customDimensions/5678 - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateCustomMetricRequest(proto.Message): - r"""Request message for CreateCustomMetric RPC. - Attributes: - parent (str): - Required. Example format: properties/1234 - custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): - Required. The CustomMetric to create. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - custom_metric = proto.Field( - proto.MESSAGE, - number=2, - message=resources.CustomMetric, - ) - - -class UpdateCustomMetricRequest(proto.Message): - r"""Request message for UpdateCustomMetric RPC. - Attributes: - custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): - The CustomMetric to update - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. - """ - - custom_metric = proto.Field( - proto.MESSAGE, - number=1, - message=resources.CustomMetric, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class ListCustomMetricsRequest(proto.Message): - r"""Request message for ListCustomMetrics 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 ``ListCustomMetrics`` - call. Provide this to retrieve the subsequent page. - - When paginating, all other parameters provided to - ``ListCustomMetrics`` 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 ListCustomMetricsResponse(proto.Message): - r"""Response message for ListCustomMetrics RPC. - Attributes: - custom_metrics (Sequence[google.analytics.admin_v1alpha.types.CustomMetric]): - List of CustomMetrics. - 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 - - custom_metrics = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.CustomMetric, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class ArchiveCustomMetricRequest(proto.Message): - r"""Request message for ArchiveCustomMetric RPC. - Attributes: - name (str): - Required. The name of the CustomMetric to - archive. Example format: - properties/1234/customMetrics/5678 - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class GetCustomMetricRequest(proto.Message): - r"""Request message for GetCustomMetric RPC. - Attributes: - name (str): - Required. The name of the CustomMetric to - get. Example format: - properties/1234/customMetrics/5678 - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -__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 62dc4410..00000000 --- a/owl-bot-staging/v1alpha/google/analytics/admin_v1alpha/types/resources.py +++ /dev/null @@ -1,1408 +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 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.analytics.admin.v1alpha', - manifest={ - 'MaximumUserAccess', - 'IndustryCategory', - 'ActorType', - 'ActionType', - 'ChangeHistoryResourceType', - 'GoogleSignalsState', - 'GoogleSignalsConsent', - 'Account', - 'Property', - 'AndroidAppDataStream', - 'IosAppDataStream', - 'WebDataStream', - 'UserLink', - 'AuditUserLink', - 'EnhancedMeasurementSettings', - 'FirebaseLink', - 'GlobalSiteTag', - 'GoogleAdsLink', - 'DataSharingSettings', - 'AccountSummary', - 'PropertySummary', - 'MeasurementProtocolSecret', - 'ChangeHistoryEvent', - 'ChangeHistoryChange', - 'ConversionEvent', - 'GoogleSignalsSettings', - 'CustomDimension', - 'CustomMetric', - }, -) - - -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 ActorType(proto.Enum): - r"""Different kinds of actors that can make changes to Google - Analytics resources. - """ - ACTOR_TYPE_UNSPECIFIED = 0 - USER = 1 - SYSTEM = 2 - SUPPORT = 3 - - -class ActionType(proto.Enum): - r"""Types of actions that may change a resource.""" - ACTION_TYPE_UNSPECIFIED = 0 - CREATED = 1 - UPDATED = 2 - DELETED = 3 - - -class ChangeHistoryResourceType(proto.Enum): - r"""Types of resources whose changes may be returned from change - history. - """ - CHANGE_HISTORY_RESOURCE_TYPE_UNSPECIFIED = 0 - ACCOUNT = 1 - PROPERTY = 2 - WEB_DATA_STREAM = 3 - ANDROID_APP_DATA_STREAM = 4 - IOS_APP_DATA_STREAM = 5 - FIREBASE_LINK = 6 - GOOGLE_ADS_LINK = 7 - GOOGLE_SIGNALS_SETTINGS = 8 - CONVERSION_EVENT = 9 - MEASUREMENT_PROTOCOL_SECRET = 10 - CUSTOM_DIMENSION = 11 - CUSTOM_METRIC = 12 - - -class GoogleSignalsState(proto.Enum): - r"""Status of the Google Signals settings (i.e., whether this - feature has been enabled for the property). - """ - GOOGLE_SIGNALS_STATE_UNSPECIFIED = 0 - GOOGLE_SIGNALS_ENABLED = 1 - GOOGLE_SIGNALS_DISABLED = 2 - - -class GoogleSignalsConsent(proto.Enum): - r"""Consent field of the Google Signals settings (i.e., whether - the user has consented to the Google Signals terms of service.) - """ - GOOGLE_SIGNALS_CONSENT_UNSPECIFIED = 0 - GOOGLE_SIGNALS_CONSENT_CONSENTED = 2 - GOOGLE_SIGNALS_CONSENT_NOT_CONSENTED = 1 - - -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_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.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): - Required. 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". - delete_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. If set, the time at which this - property was trashed. If not set, then this - property is not currently in the trash can. - expire_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. If set, the time at which this - trashed property will be permanently deleted. If - not set, then this property is not currently in - the trash can and is not slated to be deleted. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - create_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.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, - ) - delete_time = proto.Field( - proto.MESSAGE, - number=11, - message=timestamp_pb2.Timestamp, - ) - expire_time = proto.Field( - proto.MESSAGE, - number=12, - message=timestamp_pb2.Timestamp, - ) - - -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_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.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_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.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_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.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): - Output only. Example format: - properties/1234/userLinks/5678 - email_address (str): - Immutable. 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_pb2.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_pb2.BoolValue, - ) - email_address = proto.Field( - proto.STRING, - number=6, - ) - create_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - - -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, - ) - - -class MeasurementProtocolSecret(proto.Message): - r"""A secret value used for sending hits to Measurement Protocol. - Attributes: - name (str): - Output only. Resource name of this secret. - This secret may be a child of any type of - stream. Format: - properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} - display_name (str): - Required. Human-readable display name for - this secret. - secret_value (str): - Output only. The measurement protocol secret value. Pass - this value to the api_secret field of the Measurement - Protocol API when sending hits to this secret's parent - property. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - display_name = proto.Field( - proto.STRING, - number=2, - ) - secret_value = proto.Field( - proto.STRING, - number=3, - ) - - -class ChangeHistoryEvent(proto.Message): - r"""A set of changes within a Google Analytics account or its - child properties that resulted from the same cause. Common - causes would be updates made in the Google Analytics UI, changes - from customer support, or automatic Google Analytics system - changes. - - Attributes: - id (str): - ID of this change history event. This ID is - unique across Google Analytics. - change_time (google.protobuf.timestamp_pb2.Timestamp): - Time when change was made. - actor_type (google.analytics.admin_v1alpha.types.ActorType): - The type of actor that made this change. - user_actor_email (str): - Email address of the Google account that made - the change. This will be a valid email address - if the actor field is set to USER, and empty - otherwise. Google accounts that have been - deleted will cause an error. - changes_filtered (bool): - If true, then the list of changes returned - was filtered, and does not represent all changes - that occurred in this event. - changes (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryChange]): - A list of changes made in this change history - event that fit the filters specified in - SearchChangeHistoryEventsRequest. - """ - - id = proto.Field( - proto.STRING, - number=1, - ) - change_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - actor_type = proto.Field( - proto.ENUM, - number=3, - enum='ActorType', - ) - user_actor_email = proto.Field( - proto.STRING, - number=4, - ) - changes_filtered = proto.Field( - proto.BOOL, - number=5, - ) - changes = proto.RepeatedField( - proto.MESSAGE, - number=6, - message='ChangeHistoryChange', - ) - - -class ChangeHistoryChange(proto.Message): - r"""A description of a change to a single Google Analytics - resource. - - Attributes: - resource (str): - Resource name of the resource whose changes - are described by this entry. - action (google.analytics.admin_v1alpha.types.ActionType): - The type of action that changed this - resource. - resource_before_change (google.analytics.admin_v1alpha.types.ChangeHistoryChange.ChangeHistoryResource): - Resource contents from before the change was - made. If this resource was created in this - change, this field will be missing. - resource_after_change (google.analytics.admin_v1alpha.types.ChangeHistoryChange.ChangeHistoryResource): - Resource contents from after the change was - made. If this resource was deleted in this - change, this field will be missing. - """ - - class ChangeHistoryResource(proto.Message): - r"""A snapshot of a resource as before or after the result of a - change in change history. - - Attributes: - account (google.analytics.admin_v1alpha.types.Account): - A snapshot of an Account resource in change - history. - property (google.analytics.admin_v1alpha.types.Property): - A snapshot of a Property resource in change - history. - web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): - A snapshot of a WebDataStream resource in - change history. - android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): - A snapshot of an AndroidAppDataStream - resource in change history. - ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): - A snapshot of an IosAppDataStream resource in - change history. - firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): - A snapshot of a FirebaseLink resource in - change history. - google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): - A snapshot of a GoogleAdsLink resource in - change history. - google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): - A snapshot of a GoogleSignalsSettings - resource in change history. - conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): - A snapshot of a ConversionEvent resource in - change history. - measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): - A snapshot of a MeasurementProtocolSecret - resource in change history. - custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): - A snapshot of a CustomDimension resource in - change history. - custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): - A snapshot of a CustomMetric resource in - change history. - """ - - account = proto.Field( - proto.MESSAGE, - number=1, - oneof='resource', - message='Account', - ) - property = proto.Field( - proto.MESSAGE, - number=2, - oneof='resource', - message='Property', - ) - web_data_stream = proto.Field( - proto.MESSAGE, - number=3, - oneof='resource', - message='WebDataStream', - ) - android_app_data_stream = proto.Field( - proto.MESSAGE, - number=4, - oneof='resource', - message='AndroidAppDataStream', - ) - ios_app_data_stream = proto.Field( - proto.MESSAGE, - number=5, - oneof='resource', - message='IosAppDataStream', - ) - firebase_link = proto.Field( - proto.MESSAGE, - number=6, - oneof='resource', - message='FirebaseLink', - ) - google_ads_link = proto.Field( - proto.MESSAGE, - number=7, - oneof='resource', - message='GoogleAdsLink', - ) - google_signals_settings = proto.Field( - proto.MESSAGE, - number=8, - oneof='resource', - message='GoogleSignalsSettings', - ) - conversion_event = proto.Field( - proto.MESSAGE, - number=11, - oneof='resource', - message='ConversionEvent', - ) - measurement_protocol_secret = proto.Field( - proto.MESSAGE, - number=12, - oneof='resource', - message='MeasurementProtocolSecret', - ) - custom_dimension = proto.Field( - proto.MESSAGE, - number=13, - oneof='resource', - message='CustomDimension', - ) - custom_metric = proto.Field( - proto.MESSAGE, - number=14, - oneof='resource', - message='CustomMetric', - ) - - resource = proto.Field( - proto.STRING, - number=1, - ) - action = proto.Field( - proto.ENUM, - number=2, - enum='ActionType', - ) - resource_before_change = proto.Field( - proto.MESSAGE, - number=3, - message=ChangeHistoryResource, - ) - resource_after_change = proto.Field( - proto.MESSAGE, - number=4, - message=ChangeHistoryResource, - ) - - -class ConversionEvent(proto.Message): - r"""A conversion event in a Google Analytics property. - Attributes: - name (str): - Output only. Resource name of this conversion event. Format: - properties/{property}/conversionEvents/{conversion_event} - event_name (str): - Immutable. The event name for this conversion - event. Examples: 'click', 'purchase' - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when this conversion event - was created in the property. - is_deletable (bool): - Output only. If set, this event can currently - be deleted via DeleteConversionEvent. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - event_name = proto.Field( - proto.STRING, - number=2, - ) - create_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - is_deletable = proto.Field( - proto.BOOL, - number=4, - ) - - -class GoogleSignalsSettings(proto.Message): - r"""Settings values for Google Signals. This is a singleton - resource. - - Attributes: - name (str): - Output only. Resource name of this setting. Format: - properties/{property_id}/googleSignalsSettings Example: - "properties/1000/googleSignalsSettings". - state (google.analytics.admin_v1alpha.types.GoogleSignalsState): - Status of this setting. - consent (google.analytics.admin_v1alpha.types.GoogleSignalsConsent): - Output only. Terms of Service acceptance. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - state = proto.Field( - proto.ENUM, - number=3, - enum='GoogleSignalsState', - ) - consent = proto.Field( - proto.ENUM, - number=4, - enum='GoogleSignalsConsent', - ) - - -class CustomDimension(proto.Message): - r"""A definition for a CustomDimension. - Attributes: - name (str): - Output only. Resource name for this - CustomDimension resource. Format: - properties/{property}/customDimensions/{customDimension} - parameter_name (str): - Required. Immutable. Tagging parameter name - for this custom dimension. - If this is a user-scoped dimension, then this is - the user property name. If this is an event- - scoped dimension, then this is the event - parameter name. - - May only contain alphanumeric and underscore - characters, starting with a letter. Max length - of 24 characters for user-scoped dimensions, 40 - characters for event-scoped dimensions. - display_name (str): - Required. Display name for this custom - dimension as shown in the Analytics UI. Max - length of 82 characters, alphanumeric plus space - and underscore starting with a letter. Legacy - system-generated display names may contain - square brackets, but updates to this field will - never permit square brackets. - description (str): - Optional. Description for this custom - dimension. Max length of 150 characters. - scope (google.analytics.admin_v1alpha.types.CustomDimension.DimensionScope): - Required. Immutable. The scope of this - dimension. - disallow_ads_personalization (bool): - Optional. If set to true, sets this dimension - as NPA and excludes it from ads personalization. - This is currently only supported by user-scoped - custom dimensions. - """ - class DimensionScope(proto.Enum): - r"""Valid values for the scope of this dimension.""" - DIMENSION_SCOPE_UNSPECIFIED = 0 - EVENT = 1 - USER = 2 - - name = proto.Field( - proto.STRING, - number=1, - ) - parameter_name = proto.Field( - proto.STRING, - number=2, - ) - display_name = proto.Field( - proto.STRING, - number=3, - ) - description = proto.Field( - proto.STRING, - number=4, - ) - scope = proto.Field( - proto.ENUM, - number=5, - enum=DimensionScope, - ) - disallow_ads_personalization = proto.Field( - proto.BOOL, - number=6, - ) - - -class CustomMetric(proto.Message): - r"""A definition for a custom metric. - Attributes: - name (str): - Output only. Resource name for this - CustomMetric resource. Format: - properties/{property}/customMetrics/{customMetric} - parameter_name (str): - Required. Immutable. Tagging name for this - custom metric. - If this is an event-scoped metric, then this is - the event parameter name. - - May only contain alphanumeric and underscore - charactes, starting with a letter. Max length of - 40 characters for event-scoped metrics. - display_name (str): - Required. Display name for this custom metric - as shown in the Analytics UI. Max length of 82 - characters, alphanumeric plus space and - underscore starting with a letter. Legacy - system-generated display names may contain - square brackets, but updates to this field will - never permit square brackets. - description (str): - Optional. Description for this custom - dimension. Max length of 150 characters. - measurement_unit (google.analytics.admin_v1alpha.types.CustomMetric.MeasurementUnit): - Required. Immutable. The type for the custom - metric's value. - scope (google.analytics.admin_v1alpha.types.CustomMetric.MetricScope): - Required. Immutable. The scope of this custom - metric. - """ - class MeasurementUnit(proto.Enum): - r"""Possible types of representing the custom metric's value. - Currency representation may change in the future, requiring a - breaking API change. - """ - MEASUREMENT_UNIT_UNSPECIFIED = 0 - STANDARD = 1 - CURRENCY = 2 - FEET = 3 - METERS = 4 - KILOMETERS = 5 - MILES = 6 - MILLISECONDS = 7 - SECONDS = 8 - MINUTES = 9 - HOURS = 10 - - class MetricScope(proto.Enum): - r"""The scope of this metric.""" - METRIC_SCOPE_UNSPECIFIED = 0 - EVENT = 1 - - name = proto.Field( - proto.STRING, - number=1, - ) - parameter_name = proto.Field( - proto.STRING, - number=2, - ) - display_name = proto.Field( - proto.STRING, - number=3, - ) - description = proto.Field( - proto.STRING, - number=4, - ) - measurement_unit = proto.Field( - proto.ENUM, - number=5, - enum=MeasurementUnit, - ) - scope = proto.Field( - proto.ENUM, - number=6, - enum=MetricScope, - ) - - -__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 af3f21b7..00000000 --- a/owl-bot-staging/v1alpha/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/analytics/admin_v1alpha/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py b/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py deleted file mode 100644 index 24c3b61f..00000000 --- a/owl-bot-staging/v1alpha/scripts/fixup_admin_v1alpha_keywords.py +++ /dev/null @@ -1,243 +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]] = { - 'archive_custom_dimension': ('name', ), - 'archive_custom_metric': ('name', ), - '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_conversion_event': ('conversion_event', 'parent', ), - 'create_custom_dimension': ('parent', 'custom_dimension', ), - 'create_custom_metric': ('parent', 'custom_metric', ), - 'create_firebase_link': ('parent', 'firebase_link', ), - 'create_google_ads_link': ('parent', 'google_ads_link', ), - 'create_measurement_protocol_secret': ('parent', 'measurement_protocol_secret', ), - '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_conversion_event': ('name', ), - 'delete_firebase_link': ('name', ), - 'delete_google_ads_link': ('name', ), - 'delete_ios_app_data_stream': ('name', ), - 'delete_measurement_protocol_secret': ('name', ), - 'delete_property': ('name', ), - 'delete_user_link': ('name', ), - 'delete_web_data_stream': ('name', ), - 'get_account': ('name', ), - 'get_android_app_data_stream': ('name', ), - 'get_conversion_event': ('name', ), - 'get_custom_dimension': ('name', ), - 'get_custom_metric': ('name', ), - 'get_data_sharing_settings': ('name', ), - 'get_enhanced_measurement_settings': ('name', ), - 'get_global_site_tag': ('name', ), - 'get_google_signals_settings': ('name', ), - 'get_ios_app_data_stream': ('name', ), - 'get_measurement_protocol_secret': ('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_conversion_events': ('parent', 'page_size', 'page_token', ), - 'list_custom_dimensions': ('parent', 'page_size', 'page_token', ), - 'list_custom_metrics': ('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_measurement_protocol_secrets': ('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', ), - 'search_change_history_events': ('account', 'property', 'resource_type', 'action', 'actor_email', 'earliest_change_time', 'latest_change_time', 'page_size', 'page_token', ), - 'update_account': ('account', 'update_mask', ), - 'update_android_app_data_stream': ('android_app_data_stream', 'update_mask', ), - 'update_custom_dimension': ('update_mask', 'custom_dimension', ), - 'update_custom_metric': ('update_mask', 'custom_metric', ), - '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_google_signals_settings': ('google_signals_settings', 'update_mask', ), - 'update_ios_app_data_stream': ('ios_app_data_stream', 'update_mask', ), - 'update_measurement_protocol_secret': ('measurement_protocol_secret', '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 a9698642..00000000 --- a/owl-bot-staging/v1alpha/setup.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-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.27.0, < 3.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - 'packaging >= 14.3', ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1alpha/tests/__init__.py b/owl-bot-staging/v1alpha/tests/__init__.py deleted file mode 100644 index b54a5fcc..00000000 --- a/owl-bot-staging/v1alpha/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/__init__.py b/owl-bot-staging/v1alpha/tests/unit/__init__.py deleted file mode 100644 index b54a5fcc..00000000 --- a/owl-bot-staging/v1alpha/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py b/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py deleted file mode 100644 index b54a5fcc..00000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/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 b54a5fcc..00000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/__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/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 8eda4f6e..00000000 --- a/owl-bot-staging/v1alpha/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +++ /dev/null @@ -1,19266 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import mock -import packaging.version - -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.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.services.analytics_admin_service.transports.base import _GOOGLE_AUTH_VERSION -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 as core_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 as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -import google.auth - - -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert 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 = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == 'analyticsadmin.googleapis.com:443' - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.AnalyticsAdminServiceGrpcTransport, "grpc"), - (transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_analytics_admin_service_client_service_account_always_use_jwt(transport_class, transport_name): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize("client_class", [ - AnalyticsAdminServiceClient, - AnalyticsAdminServiceAsyncClient, -]) -def test_analytics_admin_service_client_from_service_account_file(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == '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=ga_credentials.AnonymousCredentials() - ) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(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, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (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, - always_use_jwt_access=True, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (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, - always_use_jwt_access=True, - ) - -@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, - always_use_jwt_access=True, - ) - - -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, - always_use_jwt_access=True, - ) - - -def test_get_account(transport: str = 'grpc', request_type=analytics_admin.GetAccountRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_account( - analytics_admin.GetAccountRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_account_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_account( - analytics_admin.GetAccountRequest(), - name='name_value', - ) - - -def test_list_accounts(transport: str = 'grpc', request_type=analytics_admin.ListAccountsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_account( - analytics_admin.DeleteAccountRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_account_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_account( - analytics_admin.DeleteAccountRequest(), - name='name_value', - ) - - -def test_update_account(transport: str = 'grpc', request_type=analytics_admin.UpdateAccountRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].account == resources.Account(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_account_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_account( - analytics_admin.UpdateAccountRequest(), - account=resources.Account(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_account_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].account == resources.Account(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_account_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_account( - analytics_admin.UpdateAccountRequest(), - account=resources.Account(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_provision_account_ticket(transport: str = 'grpc', request_type=analytics_admin.ProvisionAccountTicketRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.provision_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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', - ) - 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' - - -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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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', - )) - 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' - - -@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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_property( - analytics_admin.GetPropertyRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_property_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_property( - analytics_admin.GetPropertyRequest(), - name='name_value', - ) - - -def test_list_properties(transport: str = 'grpc', request_type=analytics_admin.ListPropertiesRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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', - ) - 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' - - -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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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', - )) - 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' - - -@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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_property( - analytics_admin.CreatePropertyRequest(), - property=resources.Property(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_property_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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 = 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', - ) - 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 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' - - -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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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(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', - )) - 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 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' - - -@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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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 = resources.Property() - 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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(resources.Property()) - 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=ga_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 = resources.Property() - # 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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_property( - analytics_admin.DeletePropertyRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_property_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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 = 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.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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_property( - analytics_admin.DeletePropertyRequest(), - name='name_value', - ) - - -def test_update_property(transport: str = 'grpc', request_type=analytics_admin.UpdatePropertyRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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', - ) - 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' - - -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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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', - )) - 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' - - -@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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].property == resources.Property(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_property_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_property( - analytics_admin.UpdatePropertyRequest(), - property=resources.Property(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_property_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].property == resources.Property(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_property_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_property( - analytics_admin.UpdatePropertyRequest(), - property=resources.Property(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_get_user_link(transport: str = 'grpc', request_type=analytics_admin.GetUserLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_user_link( - analytics_admin.GetUserLinkRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_user_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_user_links( - analytics_admin.ListUserLinksRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_user_links_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_user_links( - analytics_admin.ListUserLinksRequest(), - parent='parent_value', - ) - - -def test_list_user_links_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_user_link( - analytics_admin.DeleteUserLinkRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_user_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_web_data_stream( - analytics_admin.GetWebDataStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_web_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_web_data_stream( - analytics_admin.DeleteWebDataStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_web_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].web_data_stream == resources.WebDataStream(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_web_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_web_data_stream( - analytics_admin.UpdateWebDataStreamRequest(), - web_data_stream=resources.WebDataStream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_web_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].web_data_stream == resources.WebDataStream(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_web_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_web_data_stream( - analytics_admin.UpdateWebDataStreamRequest(), - web_data_stream=resources.WebDataStream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_web_data_stream(transport: str = 'grpc', request_type=analytics_admin.CreateWebDataStreamRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_web_data_streams( - analytics_admin.ListWebDataStreamsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_web_data_streams_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_web_data_streams( - analytics_admin.ListWebDataStreamsRequest(), - parent='parent_value', - ) - - -def test_list_web_data_streams_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].ios_app_data_stream == resources.IosAppDataStream(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_ios_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_ios_app_data_stream( - analytics_admin.UpdateIosAppDataStreamRequest(), - ios_app_data_stream=resources.IosAppDataStream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_ios_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].ios_app_data_stream == resources.IosAppDataStream(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_ios_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_ios_app_data_stream( - analytics_admin.UpdateIosAppDataStreamRequest(), - ios_app_data_stream=resources.IosAppDataStream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_list_ios_app_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListIosAppDataStreamsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_ios_app_data_streams( - analytics_admin.ListIosAppDataStreamsRequest(), - parent='parent_value', - ) - - -def test_list_ios_app_data_streams_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_android_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_android_app_data_stream( - analytics_admin.UpdateAndroidAppDataStreamRequest(), - android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_android_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].android_app_data_stream == resources.AndroidAppDataStream(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_android_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_android_app_data_stream( - analytics_admin.UpdateAndroidAppDataStreamRequest(), - android_app_data_stream=resources.AndroidAppDataStream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_list_android_app_data_streams(transport: str = 'grpc', request_type=analytics_admin.ListAndroidAppDataStreamsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_android_app_data_streams( - analytics_admin.ListAndroidAppDataStreamsRequest(), - parent='parent_value', - ) - - -def test_list_android_app_data_streams_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_enhanced_measurement_settings( - analytics_admin.GetEnhancedMeasurementSettingsRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_enhanced_measurement_settings_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].enhanced_measurement_settings == resources.EnhancedMeasurementSettings(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_enhanced_measurement_settings_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_enhanced_measurement_settings( - analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), - enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_enhanced_measurement_settings_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].enhanced_measurement_settings == resources.EnhancedMeasurementSettings(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_enhanced_measurement_settings_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_enhanced_measurement_settings( - analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), - enhanced_measurement_settings=resources.EnhancedMeasurementSettings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_firebase_link(transport: str = 'grpc', request_type=analytics_admin.CreateFirebaseLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].firebase_link == resources.FirebaseLink(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_firebase_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_firebase_link( - analytics_admin.UpdateFirebaseLinkRequest(), - firebase_link=resources.FirebaseLink(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_firebase_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].firebase_link == resources.FirebaseLink(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_firebase_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_firebase_link( - analytics_admin.UpdateFirebaseLinkRequest(), - firebase_link=resources.FirebaseLink(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_firebase_link(transport: str = 'grpc', request_type=analytics_admin.DeleteFirebaseLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_firebase_link( - analytics_admin.DeleteFirebaseLinkRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_firebase_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_firebase_link( - analytics_admin.DeleteFirebaseLinkRequest(), - name='name_value', - ) - - -def test_list_firebase_links(transport: str = 'grpc', request_type=analytics_admin.ListFirebaseLinksRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_firebase_links( - analytics_admin.ListFirebaseLinksRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_firebase_links_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_firebase_links( - analytics_admin.ListFirebaseLinksRequest(), - parent='parent_value', - ) - - -def test_list_firebase_links_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_global_site_tag( - analytics_admin.GetGlobalSiteTagRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_global_site_tag_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].google_ads_link == resources.GoogleAdsLink(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_google_ads_link_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_google_ads_link( - analytics_admin.UpdateGoogleAdsLinkRequest(), - google_ads_link=resources.GoogleAdsLink(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_google_ads_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].google_ads_link == resources.GoogleAdsLink(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_google_ads_link_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_google_ads_link( - analytics_admin.UpdateGoogleAdsLinkRequest(), - google_ads_link=resources.GoogleAdsLink(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_google_ads_link(transport: str = 'grpc', request_type=analytics_admin.DeleteGoogleAdsLinkRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_google_ads_link( - analytics_admin.DeleteGoogleAdsLinkRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_google_ads_link_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_google_ads_links( - analytics_admin.ListGoogleAdsLinksRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_google_ads_links_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_google_ads_links( - analytics_admin.ListGoogleAdsLinksRequest(), - parent='parent_value', - ) - - -def test_list_google_ads_links_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_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=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_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=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_data_sharing_settings( - analytics_admin.GetDataSharingSettingsRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_data_sharing_settings_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_data_sharing_settings( - analytics_admin.GetDataSharingSettingsRequest(), - name='name_value', - ) - - -def test_get_measurement_protocol_secret(transport: str = 'grpc', request_type=analytics_admin.GetMeasurementProtocolSecretRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret( - name='name_value', - display_name='display_name_value', - secret_value='secret_value_value', - ) - response = client.get_measurement_protocol_secret(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.GetMeasurementProtocolSecretRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.secret_value == 'secret_value_value' - - -def test_get_measurement_protocol_secret_from_dict(): - test_get_measurement_protocol_secret(request_type=dict) - - -def test_get_measurement_protocol_secret_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_measurement_protocol_secret), - '__call__') as call: - client.get_measurement_protocol_secret() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetMeasurementProtocolSecretRequest() - - -@pytest.mark.asyncio -async def test_get_measurement_protocol_secret_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetMeasurementProtocolSecretRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret( - name='name_value', - display_name='display_name_value', - secret_value='secret_value_value', - )) - response = await client.get_measurement_protocol_secret(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.GetMeasurementProtocolSecretRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.secret_value == 'secret_value_value' - - -@pytest.mark.asyncio -async def test_get_measurement_protocol_secret_async_from_dict(): - await test_get_measurement_protocol_secret_async(request_type=dict) - - -def test_get_measurement_protocol_secret_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetMeasurementProtocolSecretRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_measurement_protocol_secret), - '__call__') as call: - call.return_value = resources.MeasurementProtocolSecret() - client.get_measurement_protocol_secret(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_measurement_protocol_secret_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetMeasurementProtocolSecretRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_measurement_protocol_secret), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) - await client.get_measurement_protocol_secret(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_measurement_protocol_secret_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_measurement_protocol_secret( - 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_measurement_protocol_secret_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_measurement_protocol_secret( - analytics_admin.GetMeasurementProtocolSecretRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_measurement_protocol_secret_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_measurement_protocol_secret( - 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_measurement_protocol_secret_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_measurement_protocol_secret( - analytics_admin.GetMeasurementProtocolSecretRequest(), - name='name_value', - ) - - -def test_list_measurement_protocol_secrets(transport: str = 'grpc', request_type=analytics_admin.ListMeasurementProtocolSecretsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secrets), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_measurement_protocol_secrets(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.ListMeasurementProtocolSecretsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMeasurementProtocolSecretsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_measurement_protocol_secrets_from_dict(): - test_list_measurement_protocol_secrets(request_type=dict) - - -def test_list_measurement_protocol_secrets_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__') as call: - client.list_measurement_protocol_secrets() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListMeasurementProtocolSecretsRequest() - - -@pytest.mark.asyncio -async def test_list_measurement_protocol_secrets_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListMeasurementProtocolSecretsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secrets), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListMeasurementProtocolSecretsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_measurement_protocol_secrets(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.ListMeasurementProtocolSecretsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMeasurementProtocolSecretsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_measurement_protocol_secrets_async_from_dict(): - await test_list_measurement_protocol_secrets_async(request_type=dict) - - -def test_list_measurement_protocol_secrets_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ListMeasurementProtocolSecretsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__') as call: - call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() - client.list_measurement_protocol_secrets(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_measurement_protocol_secrets_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ListMeasurementProtocolSecretsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListMeasurementProtocolSecretsResponse()) - await client.list_measurement_protocol_secrets(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_measurement_protocol_secrets_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_measurement_protocol_secrets( - 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_measurement_protocol_secrets_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_measurement_protocol_secrets( - analytics_admin.ListMeasurementProtocolSecretsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_measurement_protocol_secrets_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListMeasurementProtocolSecretsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_measurement_protocol_secrets( - 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_measurement_protocol_secrets_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_measurement_protocol_secrets( - analytics_admin.ListMeasurementProtocolSecretsRequest(), - parent='parent_value', - ) - - -def test_list_measurement_protocol_secrets_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - ], - next_page_token='abc', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[], - next_page_token='def', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - ], - next_page_token='ghi', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_measurement_protocol_secrets(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.MeasurementProtocolSecret) - for i in results) - -def test_list_measurement_protocol_secrets_pages(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - ], - next_page_token='abc', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[], - next_page_token='def', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - ], - next_page_token='ghi', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - ], - ), - RuntimeError, - ) - pages = list(client.list_measurement_protocol_secrets(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_measurement_protocol_secrets_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - ], - next_page_token='abc', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[], - next_page_token='def', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - ], - next_page_token='ghi', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_measurement_protocol_secrets(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.MeasurementProtocolSecret) - for i in responses) - -@pytest.mark.asyncio -async def test_list_measurement_protocol_secrets_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_measurement_protocol_secrets), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - ], - next_page_token='abc', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[], - next_page_token='def', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - ], - next_page_token='ghi', - ), - analytics_admin.ListMeasurementProtocolSecretsResponse( - measurement_protocol_secrets=[ - resources.MeasurementProtocolSecret(), - resources.MeasurementProtocolSecret(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_measurement_protocol_secrets(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_measurement_protocol_secret(transport: str = 'grpc', request_type=analytics_admin.CreateMeasurementProtocolSecretRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret( - name='name_value', - display_name='display_name_value', - secret_value='secret_value_value', - ) - response = client.create_measurement_protocol_secret(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.CreateMeasurementProtocolSecretRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.secret_value == 'secret_value_value' - - -def test_create_measurement_protocol_secret_from_dict(): - test_create_measurement_protocol_secret(request_type=dict) - - -def test_create_measurement_protocol_secret_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_measurement_protocol_secret), - '__call__') as call: - client.create_measurement_protocol_secret() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateMeasurementProtocolSecretRequest() - - -@pytest.mark.asyncio -async def test_create_measurement_protocol_secret_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateMeasurementProtocolSecretRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret( - name='name_value', - display_name='display_name_value', - secret_value='secret_value_value', - )) - response = await client.create_measurement_protocol_secret(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.CreateMeasurementProtocolSecretRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.secret_value == 'secret_value_value' - - -@pytest.mark.asyncio -async def test_create_measurement_protocol_secret_async_from_dict(): - await test_create_measurement_protocol_secret_async(request_type=dict) - - -def test_create_measurement_protocol_secret_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.CreateMeasurementProtocolSecretRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_measurement_protocol_secret), - '__call__') as call: - call.return_value = resources.MeasurementProtocolSecret() - client.create_measurement_protocol_secret(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_measurement_protocol_secret_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.CreateMeasurementProtocolSecretRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_measurement_protocol_secret), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) - await client.create_measurement_protocol_secret(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_measurement_protocol_secret_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_measurement_protocol_secret( - parent='parent_value', - measurement_protocol_secret=resources.MeasurementProtocolSecret(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].measurement_protocol_secret == resources.MeasurementProtocolSecret(name='name_value') - - -def test_create_measurement_protocol_secret_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_measurement_protocol_secret( - analytics_admin.CreateMeasurementProtocolSecretRequest(), - parent='parent_value', - measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_measurement_protocol_secret_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_measurement_protocol_secret( - parent='parent_value', - measurement_protocol_secret=resources.MeasurementProtocolSecret(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].measurement_protocol_secret == resources.MeasurementProtocolSecret(name='name_value') - - -@pytest.mark.asyncio -async def test_create_measurement_protocol_secret_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_measurement_protocol_secret( - analytics_admin.CreateMeasurementProtocolSecretRequest(), - parent='parent_value', - measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), - ) - - -def test_delete_measurement_protocol_secret(transport: str = 'grpc', request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_measurement_protocol_secret(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.DeleteMeasurementProtocolSecretRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_measurement_protocol_secret_from_dict(): - test_delete_measurement_protocol_secret(request_type=dict) - - -def test_delete_measurement_protocol_secret_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_measurement_protocol_secret), - '__call__') as call: - client.delete_measurement_protocol_secret() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteMeasurementProtocolSecretRequest() - - -@pytest.mark.asyncio -async def test_delete_measurement_protocol_secret_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_measurement_protocol_secret(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.DeleteMeasurementProtocolSecretRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_measurement_protocol_secret_async_from_dict(): - await test_delete_measurement_protocol_secret_async(request_type=dict) - - -def test_delete_measurement_protocol_secret_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.DeleteMeasurementProtocolSecretRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_measurement_protocol_secret), - '__call__') as call: - call.return_value = None - client.delete_measurement_protocol_secret(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_measurement_protocol_secret_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.DeleteMeasurementProtocolSecretRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_measurement_protocol_secret), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_measurement_protocol_secret(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_measurement_protocol_secret_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_measurement_protocol_secret), - '__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_measurement_protocol_secret( - 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_measurement_protocol_secret_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_measurement_protocol_secret( - analytics_admin.DeleteMeasurementProtocolSecretRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_measurement_protocol_secret_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_measurement_protocol_secret), - '__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_measurement_protocol_secret( - 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_measurement_protocol_secret_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_measurement_protocol_secret( - analytics_admin.DeleteMeasurementProtocolSecretRequest(), - name='name_value', - ) - - -def test_update_measurement_protocol_secret(transport: str = 'grpc', request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret( - name='name_value', - display_name='display_name_value', - secret_value='secret_value_value', - ) - response = client.update_measurement_protocol_secret(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.UpdateMeasurementProtocolSecretRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.secret_value == 'secret_value_value' - - -def test_update_measurement_protocol_secret_from_dict(): - test_update_measurement_protocol_secret(request_type=dict) - - -def test_update_measurement_protocol_secret_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_measurement_protocol_secret), - '__call__') as call: - client.update_measurement_protocol_secret() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateMeasurementProtocolSecretRequest() - - -@pytest.mark.asyncio -async def test_update_measurement_protocol_secret_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret( - name='name_value', - display_name='display_name_value', - secret_value='secret_value_value', - )) - response = await client.update_measurement_protocol_secret(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.UpdateMeasurementProtocolSecretRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.secret_value == 'secret_value_value' - - -@pytest.mark.asyncio -async def test_update_measurement_protocol_secret_async_from_dict(): - await test_update_measurement_protocol_secret_async(request_type=dict) - - -def test_update_measurement_protocol_secret_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.UpdateMeasurementProtocolSecretRequest() - - request.measurement_protocol_secret.name = 'measurement_protocol_secret.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_measurement_protocol_secret), - '__call__') as call: - call.return_value = resources.MeasurementProtocolSecret() - client.update_measurement_protocol_secret(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'measurement_protocol_secret.name=measurement_protocol_secret.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_measurement_protocol_secret_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.UpdateMeasurementProtocolSecretRequest() - - request.measurement_protocol_secret.name = 'measurement_protocol_secret.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_measurement_protocol_secret), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) - await client.update_measurement_protocol_secret(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'measurement_protocol_secret.name=measurement_protocol_secret.name/value', - ) in kw['metadata'] - - -def test_update_measurement_protocol_secret_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_measurement_protocol_secret( - measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].measurement_protocol_secret == resources.MeasurementProtocolSecret(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_measurement_protocol_secret_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_measurement_protocol_secret( - analytics_admin.UpdateMeasurementProtocolSecretRequest(), - measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_measurement_protocol_secret_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_measurement_protocol_secret), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.MeasurementProtocolSecret() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.MeasurementProtocolSecret()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_measurement_protocol_secret( - measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].measurement_protocol_secret == resources.MeasurementProtocolSecret(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_measurement_protocol_secret_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_measurement_protocol_secret( - analytics_admin.UpdateMeasurementProtocolSecretRequest(), - measurement_protocol_secret=resources.MeasurementProtocolSecret(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_search_change_history_events(transport: str = 'grpc', request_type=analytics_admin.SearchChangeHistoryEventsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.SearchChangeHistoryEventsResponse( - next_page_token='next_page_token_value', - ) - response = client.search_change_history_events(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.SearchChangeHistoryEventsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchChangeHistoryEventsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_search_change_history_events_from_dict(): - test_search_change_history_events(request_type=dict) - - -def test_search_change_history_events_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__') as call: - client.search_change_history_events() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.SearchChangeHistoryEventsRequest() - - -@pytest.mark.asyncio -async def test_search_change_history_events_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.SearchChangeHistoryEventsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.SearchChangeHistoryEventsResponse( - next_page_token='next_page_token_value', - )) - response = await client.search_change_history_events(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.SearchChangeHistoryEventsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchChangeHistoryEventsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_search_change_history_events_async_from_dict(): - await test_search_change_history_events_async(request_type=dict) - - -def test_search_change_history_events_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.SearchChangeHistoryEventsRequest() - - request.account = 'account/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__') as call: - call.return_value = analytics_admin.SearchChangeHistoryEventsResponse() - client.search_change_history_events(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'account=account/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_search_change_history_events_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.SearchChangeHistoryEventsRequest() - - request.account = 'account/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.SearchChangeHistoryEventsResponse()) - await client.search_change_history_events(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'account=account/value', - ) in kw['metadata'] - - -def test_search_change_history_events_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - ], - next_page_token='abc', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[], - next_page_token='def', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - ], - next_page_token='ghi', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('account', ''), - )), - ) - pager = client.search_change_history_events(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.ChangeHistoryEvent) - for i in results) - -def test_search_change_history_events_pages(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - ], - next_page_token='abc', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[], - next_page_token='def', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - ], - next_page_token='ghi', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - ], - ), - RuntimeError, - ) - pages = list(client.search_change_history_events(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_search_change_history_events_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - ], - next_page_token='abc', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[], - next_page_token='def', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - ], - next_page_token='ghi', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - ], - ), - RuntimeError, - ) - async_pager = await client.search_change_history_events(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.ChangeHistoryEvent) - for i in responses) - -@pytest.mark.asyncio -async def test_search_change_history_events_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.search_change_history_events), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - ], - next_page_token='abc', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[], - next_page_token='def', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - ], - next_page_token='ghi', - ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.search_change_history_events(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_google_signals_settings(transport: str = 'grpc', request_type=analytics_admin.GetGoogleSignalsSettingsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_signals_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleSignalsSettings( - name='name_value', - state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, - consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, - ) - response = client.get_google_signals_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.GetGoogleSignalsSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleSignalsSettings) - assert response.name == 'name_value' - assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED - assert response.consent == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED - - -def test_get_google_signals_settings_from_dict(): - test_get_google_signals_settings(request_type=dict) - - -def test_get_google_signals_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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_google_signals_settings), - '__call__') as call: - client.get_google_signals_settings() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetGoogleSignalsSettingsRequest() - - -@pytest.mark.asyncio -async def test_get_google_signals_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetGoogleSignalsSettingsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_google_signals_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings( - name='name_value', - state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, - consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, - )) - response = await client.get_google_signals_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.GetGoogleSignalsSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleSignalsSettings) - assert response.name == 'name_value' - assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED - assert response.consent == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED - - -@pytest.mark.asyncio -async def test_get_google_signals_settings_async_from_dict(): - await test_get_google_signals_settings_async(request_type=dict) - - -def test_get_google_signals_settings_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetGoogleSignalsSettingsRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_google_signals_settings), - '__call__') as call: - call.return_value = resources.GoogleSignalsSettings() - client.get_google_signals_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_google_signals_settings_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetGoogleSignalsSettingsRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_google_signals_settings), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings()) - await client.get_google_signals_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_google_signals_settings_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_google_signals_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleSignalsSettings() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_google_signals_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_google_signals_settings_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_google_signals_settings( - analytics_admin.GetGoogleSignalsSettingsRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_google_signals_settings_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_google_signals_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleSignalsSettings() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_google_signals_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_google_signals_settings_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_google_signals_settings( - analytics_admin.GetGoogleSignalsSettingsRequest(), - name='name_value', - ) - - -def test_update_google_signals_settings(transport: str = 'grpc', request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_signals_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleSignalsSettings( - name='name_value', - state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, - consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, - ) - response = client.update_google_signals_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.UpdateGoogleSignalsSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleSignalsSettings) - assert response.name == 'name_value' - assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED - assert response.consent == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED - - -def test_update_google_signals_settings_from_dict(): - test_update_google_signals_settings(request_type=dict) - - -def test_update_google_signals_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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_signals_settings), - '__call__') as call: - client.update_google_signals_settings() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateGoogleSignalsSettingsRequest() - - -@pytest.mark.asyncio -async def test_update_google_signals_settings_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_signals_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings( - name='name_value', - state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, - consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, - )) - response = await client.update_google_signals_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.UpdateGoogleSignalsSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleSignalsSettings) - assert response.name == 'name_value' - assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED - assert response.consent == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED - - -@pytest.mark.asyncio -async def test_update_google_signals_settings_async_from_dict(): - await test_update_google_signals_settings_async(request_type=dict) - - -def test_update_google_signals_settings_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.UpdateGoogleSignalsSettingsRequest() - - request.google_signals_settings.name = 'google_signals_settings.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_signals_settings), - '__call__') as call: - call.return_value = resources.GoogleSignalsSettings() - client.update_google_signals_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', - 'google_signals_settings.name=google_signals_settings.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_google_signals_settings_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.UpdateGoogleSignalsSettingsRequest() - - request.google_signals_settings.name = 'google_signals_settings.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_signals_settings), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings()) - await client.update_google_signals_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', - 'google_signals_settings.name=google_signals_settings.name/value', - ) in kw['metadata'] - - -def test_update_google_signals_settings_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_signals_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleSignalsSettings() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_google_signals_settings( - google_signals_settings=resources.GoogleSignalsSettings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].google_signals_settings == resources.GoogleSignalsSettings(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_google_signals_settings_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_google_signals_settings( - analytics_admin.UpdateGoogleSignalsSettingsRequest(), - google_signals_settings=resources.GoogleSignalsSettings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_google_signals_settings_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_google_signals_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GoogleSignalsSettings() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.GoogleSignalsSettings()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_google_signals_settings( - google_signals_settings=resources.GoogleSignalsSettings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].google_signals_settings == resources.GoogleSignalsSettings(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_google_signals_settings_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_google_signals_settings( - analytics_admin.UpdateGoogleSignalsSettingsRequest(), - google_signals_settings=resources.GoogleSignalsSettings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_conversion_event(transport: str = 'grpc', request_type=analytics_admin.CreateConversionEventRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ConversionEvent( - name='name_value', - event_name='event_name_value', - is_deletable=True, - ) - response = client.create_conversion_event(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.CreateConversionEventRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.ConversionEvent) - assert response.name == 'name_value' - assert response.event_name == 'event_name_value' - assert response.is_deletable is True - - -def test_create_conversion_event_from_dict(): - test_create_conversion_event(request_type=dict) - - -def test_create_conversion_event_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversion_event), - '__call__') as call: - client.create_conversion_event() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateConversionEventRequest() - - -@pytest.mark.asyncio -async def test_create_conversion_event_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateConversionEventRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent( - name='name_value', - event_name='event_name_value', - is_deletable=True, - )) - response = await client.create_conversion_event(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.CreateConversionEventRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.ConversionEvent) - assert response.name == 'name_value' - assert response.event_name == 'event_name_value' - assert response.is_deletable is True - - -@pytest.mark.asyncio -async def test_create_conversion_event_async_from_dict(): - await test_create_conversion_event_async(request_type=dict) - - -def test_create_conversion_event_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.CreateConversionEventRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversion_event), - '__call__') as call: - call.return_value = resources.ConversionEvent() - client.create_conversion_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_conversion_event_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.CreateConversionEventRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversion_event), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent()) - await client.create_conversion_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_conversion_event_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ConversionEvent() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_conversion_event( - parent='parent_value', - conversion_event=resources.ConversionEvent(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].conversion_event == resources.ConversionEvent(name='name_value') - - -def test_create_conversion_event_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_conversion_event( - analytics_admin.CreateConversionEventRequest(), - parent='parent_value', - conversion_event=resources.ConversionEvent(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_conversion_event_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ConversionEvent() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_conversion_event( - parent='parent_value', - conversion_event=resources.ConversionEvent(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].conversion_event == resources.ConversionEvent(name='name_value') - - -@pytest.mark.asyncio -async def test_create_conversion_event_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_conversion_event( - analytics_admin.CreateConversionEventRequest(), - parent='parent_value', - conversion_event=resources.ConversionEvent(name='name_value'), - ) - - -def test_get_conversion_event(transport: str = 'grpc', request_type=analytics_admin.GetConversionEventRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ConversionEvent( - name='name_value', - event_name='event_name_value', - is_deletable=True, - ) - response = client.get_conversion_event(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.GetConversionEventRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.ConversionEvent) - assert response.name == 'name_value' - assert response.event_name == 'event_name_value' - assert response.is_deletable is True - - -def test_get_conversion_event_from_dict(): - test_get_conversion_event(request_type=dict) - - -def test_get_conversion_event_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversion_event), - '__call__') as call: - client.get_conversion_event() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetConversionEventRequest() - - -@pytest.mark.asyncio -async def test_get_conversion_event_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetConversionEventRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent( - name='name_value', - event_name='event_name_value', - is_deletable=True, - )) - response = await client.get_conversion_event(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.GetConversionEventRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.ConversionEvent) - assert response.name == 'name_value' - assert response.event_name == 'event_name_value' - assert response.is_deletable is True - - -@pytest.mark.asyncio -async def test_get_conversion_event_async_from_dict(): - await test_get_conversion_event_async(request_type=dict) - - -def test_get_conversion_event_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetConversionEventRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversion_event), - '__call__') as call: - call.return_value = resources.ConversionEvent() - client.get_conversion_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_conversion_event_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetConversionEventRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversion_event), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent()) - await client.get_conversion_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_conversion_event_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ConversionEvent() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_conversion_event( - 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_conversion_event_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_conversion_event( - analytics_admin.GetConversionEventRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_conversion_event_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ConversionEvent() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ConversionEvent()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_conversion_event( - 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_conversion_event_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_conversion_event( - analytics_admin.GetConversionEventRequest(), - name='name_value', - ) - - -def test_delete_conversion_event(transport: str = 'grpc', request_type=analytics_admin.DeleteConversionEventRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_conversion_event(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.DeleteConversionEventRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_conversion_event_from_dict(): - test_delete_conversion_event(request_type=dict) - - -def test_delete_conversion_event_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversion_event), - '__call__') as call: - client.delete_conversion_event() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteConversionEventRequest() - - -@pytest.mark.asyncio -async def test_delete_conversion_event_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.DeleteConversionEventRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_conversion_event), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_conversion_event(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.DeleteConversionEventRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_conversion_event_async_from_dict(): - await test_delete_conversion_event_async(request_type=dict) - - -def test_delete_conversion_event_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.DeleteConversionEventRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversion_event), - '__call__') as call: - call.return_value = None - client.delete_conversion_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_conversion_event_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.DeleteConversionEventRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversion_event), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_conversion_event(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_conversion_event_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversion_event), - '__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_conversion_event( - 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_conversion_event_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_conversion_event( - analytics_admin.DeleteConversionEventRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_conversion_event_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversion_event), - '__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_conversion_event( - 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_conversion_event_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_conversion_event( - analytics_admin.DeleteConversionEventRequest(), - name='name_value', - ) - - -def test_list_conversion_events(transport: str = 'grpc', request_type=analytics_admin.ListConversionEventsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_conversion_events), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListConversionEventsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_conversion_events(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.ListConversionEventsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConversionEventsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_conversion_events_from_dict(): - test_list_conversion_events(request_type=dict) - - -def test_list_conversion_events_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__') as call: - client.list_conversion_events() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListConversionEventsRequest() - - -@pytest.mark.asyncio -async def test_list_conversion_events_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListConversionEventsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_conversion_events), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListConversionEventsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_conversion_events(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.ListConversionEventsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConversionEventsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_conversion_events_async_from_dict(): - await test_list_conversion_events_async(request_type=dict) - - -def test_list_conversion_events_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ListConversionEventsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__') as call: - call.return_value = analytics_admin.ListConversionEventsResponse() - client.list_conversion_events(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_conversion_events_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ListConversionEventsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListConversionEventsResponse()) - await client.list_conversion_events(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_conversion_events_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListConversionEventsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_conversion_events( - 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_conversion_events_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_conversion_events( - analytics_admin.ListConversionEventsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_conversion_events_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListConversionEventsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListConversionEventsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_conversion_events( - 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_conversion_events_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_conversion_events( - analytics_admin.ListConversionEventsRequest(), - parent='parent_value', - ) - - -def test_list_conversion_events_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - next_page_token='abc', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[], - next_page_token='def', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - ], - next_page_token='ghi', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_conversion_events(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.ConversionEvent) - for i in results) - -def test_list_conversion_events_pages(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - next_page_token='abc', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[], - next_page_token='def', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - ], - next_page_token='ghi', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - ), - RuntimeError, - ) - pages = list(client.list_conversion_events(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_conversion_events_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - next_page_token='abc', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[], - next_page_token='def', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - ], - next_page_token='ghi', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_conversion_events(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.ConversionEvent) - for i in responses) - -@pytest.mark.asyncio -async def test_list_conversion_events_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversion_events), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - next_page_token='abc', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[], - next_page_token='def', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - ], - next_page_token='ghi', - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_conversion_events(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_custom_dimension(transport: str = 'grpc', request_type=analytics_admin.CreateCustomDimensionRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - scope=resources.CustomDimension.DimensionScope.EVENT, - disallow_ads_personalization=True, - ) - response = client.create_custom_dimension(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.CreateCustomDimensionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomDimension) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.scope == resources.CustomDimension.DimensionScope.EVENT - assert response.disallow_ads_personalization is True - - -def test_create_custom_dimension_from_dict(): - test_create_custom_dimension(request_type=dict) - - -def test_create_custom_dimension_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_dimension), - '__call__') as call: - client.create_custom_dimension() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateCustomDimensionRequest() - - -@pytest.mark.asyncio -async def test_create_custom_dimension_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateCustomDimensionRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - scope=resources.CustomDimension.DimensionScope.EVENT, - disallow_ads_personalization=True, - )) - response = await client.create_custom_dimension(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.CreateCustomDimensionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomDimension) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.scope == resources.CustomDimension.DimensionScope.EVENT - assert response.disallow_ads_personalization is True - - -@pytest.mark.asyncio -async def test_create_custom_dimension_async_from_dict(): - await test_create_custom_dimension_async(request_type=dict) - - -def test_create_custom_dimension_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.CreateCustomDimensionRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_dimension), - '__call__') as call: - call.return_value = resources.CustomDimension() - client.create_custom_dimension(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_custom_dimension_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.CreateCustomDimensionRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_dimension), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) - await client.create_custom_dimension(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_custom_dimension_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_custom_dimension( - parent='parent_value', - custom_dimension=resources.CustomDimension(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].custom_dimension == resources.CustomDimension(name='name_value') - - -def test_create_custom_dimension_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_custom_dimension( - analytics_admin.CreateCustomDimensionRequest(), - parent='parent_value', - custom_dimension=resources.CustomDimension(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_custom_dimension_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_custom_dimension( - parent='parent_value', - custom_dimension=resources.CustomDimension(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].custom_dimension == resources.CustomDimension(name='name_value') - - -@pytest.mark.asyncio -async def test_create_custom_dimension_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_custom_dimension( - analytics_admin.CreateCustomDimensionRequest(), - parent='parent_value', - custom_dimension=resources.CustomDimension(name='name_value'), - ) - - -def test_update_custom_dimension(transport: str = 'grpc', request_type=analytics_admin.UpdateCustomDimensionRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - scope=resources.CustomDimension.DimensionScope.EVENT, - disallow_ads_personalization=True, - ) - response = client.update_custom_dimension(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.UpdateCustomDimensionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomDimension) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.scope == resources.CustomDimension.DimensionScope.EVENT - assert response.disallow_ads_personalization is True - - -def test_update_custom_dimension_from_dict(): - test_update_custom_dimension(request_type=dict) - - -def test_update_custom_dimension_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_dimension), - '__call__') as call: - client.update_custom_dimension() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateCustomDimensionRequest() - - -@pytest.mark.asyncio -async def test_update_custom_dimension_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateCustomDimensionRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - scope=resources.CustomDimension.DimensionScope.EVENT, - disallow_ads_personalization=True, - )) - response = await client.update_custom_dimension(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.UpdateCustomDimensionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomDimension) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.scope == resources.CustomDimension.DimensionScope.EVENT - assert response.disallow_ads_personalization is True - - -@pytest.mark.asyncio -async def test_update_custom_dimension_async_from_dict(): - await test_update_custom_dimension_async(request_type=dict) - - -def test_update_custom_dimension_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.UpdateCustomDimensionRequest() - - request.custom_dimension.name = 'custom_dimension.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_dimension), - '__call__') as call: - call.return_value = resources.CustomDimension() - client.update_custom_dimension(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'custom_dimension.name=custom_dimension.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_custom_dimension_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.UpdateCustomDimensionRequest() - - request.custom_dimension.name = 'custom_dimension.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_dimension), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) - await client.update_custom_dimension(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'custom_dimension.name=custom_dimension.name/value', - ) in kw['metadata'] - - -def test_update_custom_dimension_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_custom_dimension( - custom_dimension=resources.CustomDimension(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].custom_dimension == resources.CustomDimension(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_custom_dimension_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_custom_dimension( - analytics_admin.UpdateCustomDimensionRequest(), - custom_dimension=resources.CustomDimension(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_custom_dimension_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_custom_dimension( - custom_dimension=resources.CustomDimension(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].custom_dimension == resources.CustomDimension(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_custom_dimension_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_custom_dimension( - analytics_admin.UpdateCustomDimensionRequest(), - custom_dimension=resources.CustomDimension(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_list_custom_dimensions(transport: str = 'grpc', request_type=analytics_admin.ListCustomDimensionsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_dimensions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListCustomDimensionsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_custom_dimensions(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.ListCustomDimensionsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomDimensionsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_custom_dimensions_from_dict(): - test_list_custom_dimensions(request_type=dict) - - -def test_list_custom_dimensions_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__') as call: - client.list_custom_dimensions() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListCustomDimensionsRequest() - - -@pytest.mark.asyncio -async def test_list_custom_dimensions_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListCustomDimensionsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_dimensions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomDimensionsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_custom_dimensions(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.ListCustomDimensionsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomDimensionsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_custom_dimensions_async_from_dict(): - await test_list_custom_dimensions_async(request_type=dict) - - -def test_list_custom_dimensions_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ListCustomDimensionsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__') as call: - call.return_value = analytics_admin.ListCustomDimensionsResponse() - client.list_custom_dimensions(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_custom_dimensions_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ListCustomDimensionsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomDimensionsResponse()) - await client.list_custom_dimensions(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_custom_dimensions_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListCustomDimensionsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_custom_dimensions( - 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_custom_dimensions_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_custom_dimensions( - analytics_admin.ListCustomDimensionsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_custom_dimensions_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListCustomDimensionsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomDimensionsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_custom_dimensions( - 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_custom_dimensions_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_custom_dimensions( - analytics_admin.ListCustomDimensionsRequest(), - parent='parent_value', - ) - - -def test_list_custom_dimensions_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - resources.CustomDimension(), - resources.CustomDimension(), - ], - next_page_token='abc', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[], - next_page_token='def', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - ], - next_page_token='ghi', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - resources.CustomDimension(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_custom_dimensions(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.CustomDimension) - for i in results) - -def test_list_custom_dimensions_pages(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - resources.CustomDimension(), - resources.CustomDimension(), - ], - next_page_token='abc', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[], - next_page_token='def', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - ], - next_page_token='ghi', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - resources.CustomDimension(), - ], - ), - RuntimeError, - ) - pages = list(client.list_custom_dimensions(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_custom_dimensions_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - resources.CustomDimension(), - resources.CustomDimension(), - ], - next_page_token='abc', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[], - next_page_token='def', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - ], - next_page_token='ghi', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - resources.CustomDimension(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_custom_dimensions(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.CustomDimension) - for i in responses) - -@pytest.mark.asyncio -async def test_list_custom_dimensions_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_dimensions), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - resources.CustomDimension(), - resources.CustomDimension(), - ], - next_page_token='abc', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[], - next_page_token='def', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - ], - next_page_token='ghi', - ), - analytics_admin.ListCustomDimensionsResponse( - custom_dimensions=[ - resources.CustomDimension(), - resources.CustomDimension(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_custom_dimensions(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_archive_custom_dimension(transport: str = 'grpc', request_type=analytics_admin.ArchiveCustomDimensionRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.archive_custom_dimension(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.ArchiveCustomDimensionRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_archive_custom_dimension_from_dict(): - test_archive_custom_dimension(request_type=dict) - - -def test_archive_custom_dimension_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_dimension), - '__call__') as call: - client.archive_custom_dimension() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ArchiveCustomDimensionRequest() - - -@pytest.mark.asyncio -async def test_archive_custom_dimension_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ArchiveCustomDimensionRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.archive_custom_dimension(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.ArchiveCustomDimensionRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_archive_custom_dimension_async_from_dict(): - await test_archive_custom_dimension_async(request_type=dict) - - -def test_archive_custom_dimension_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ArchiveCustomDimensionRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_dimension), - '__call__') as call: - call.return_value = None - client.archive_custom_dimension(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_archive_custom_dimension_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ArchiveCustomDimensionRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_dimension), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.archive_custom_dimension(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_archive_custom_dimension_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_dimension), - '__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.archive_custom_dimension( - 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_archive_custom_dimension_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.archive_custom_dimension( - analytics_admin.ArchiveCustomDimensionRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_archive_custom_dimension_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_dimension), - '__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.archive_custom_dimension( - 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_archive_custom_dimension_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.archive_custom_dimension( - analytics_admin.ArchiveCustomDimensionRequest(), - name='name_value', - ) - - -def test_get_custom_dimension(transport: str = 'grpc', request_type=analytics_admin.GetCustomDimensionRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - scope=resources.CustomDimension.DimensionScope.EVENT, - disallow_ads_personalization=True, - ) - response = client.get_custom_dimension(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.GetCustomDimensionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomDimension) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.scope == resources.CustomDimension.DimensionScope.EVENT - assert response.disallow_ads_personalization is True - - -def test_get_custom_dimension_from_dict(): - test_get_custom_dimension(request_type=dict) - - -def test_get_custom_dimension_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_dimension), - '__call__') as call: - client.get_custom_dimension() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetCustomDimensionRequest() - - -@pytest.mark.asyncio -async def test_get_custom_dimension_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetCustomDimensionRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - scope=resources.CustomDimension.DimensionScope.EVENT, - disallow_ads_personalization=True, - )) - response = await client.get_custom_dimension(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.GetCustomDimensionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomDimension) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.scope == resources.CustomDimension.DimensionScope.EVENT - assert response.disallow_ads_personalization is True - - -@pytest.mark.asyncio -async def test_get_custom_dimension_async_from_dict(): - await test_get_custom_dimension_async(request_type=dict) - - -def test_get_custom_dimension_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetCustomDimensionRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_dimension), - '__call__') as call: - call.return_value = resources.CustomDimension() - client.get_custom_dimension(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_custom_dimension_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetCustomDimensionRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_dimension), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) - await client.get_custom_dimension(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_custom_dimension_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_custom_dimension( - 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_custom_dimension_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_custom_dimension( - analytics_admin.GetCustomDimensionRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_custom_dimension_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_dimension), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomDimension() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomDimension()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_custom_dimension( - 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_custom_dimension_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_custom_dimension( - analytics_admin.GetCustomDimensionRequest(), - name='name_value', - ) - - -def test_create_custom_metric(transport: str = 'grpc', request_type=analytics_admin.CreateCustomMetricRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, - scope=resources.CustomMetric.MetricScope.EVENT, - ) - response = client.create_custom_metric(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.CreateCustomMetricRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD - assert response.scope == resources.CustomMetric.MetricScope.EVENT - - -def test_create_custom_metric_from_dict(): - test_create_custom_metric(request_type=dict) - - -def test_create_custom_metric_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_metric), - '__call__') as call: - client.create_custom_metric() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateCustomMetricRequest() - - -@pytest.mark.asyncio -async def test_create_custom_metric_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.CreateCustomMetricRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, - scope=resources.CustomMetric.MetricScope.EVENT, - )) - response = await client.create_custom_metric(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.CreateCustomMetricRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD - assert response.scope == resources.CustomMetric.MetricScope.EVENT - - -@pytest.mark.asyncio -async def test_create_custom_metric_async_from_dict(): - await test_create_custom_metric_async(request_type=dict) - - -def test_create_custom_metric_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.CreateCustomMetricRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_metric), - '__call__') as call: - call.return_value = resources.CustomMetric() - client.create_custom_metric(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_custom_metric_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.CreateCustomMetricRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_metric), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) - await client.create_custom_metric(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_custom_metric_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_custom_metric( - parent='parent_value', - custom_metric=resources.CustomMetric(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].custom_metric == resources.CustomMetric(name='name_value') - - -def test_create_custom_metric_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_custom_metric( - analytics_admin.CreateCustomMetricRequest(), - parent='parent_value', - custom_metric=resources.CustomMetric(name='name_value'), - ) - - -@pytest.mark.asyncio -async def test_create_custom_metric_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_custom_metric( - parent='parent_value', - custom_metric=resources.CustomMetric(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].custom_metric == resources.CustomMetric(name='name_value') - - -@pytest.mark.asyncio -async def test_create_custom_metric_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_custom_metric( - analytics_admin.CreateCustomMetricRequest(), - parent='parent_value', - custom_metric=resources.CustomMetric(name='name_value'), - ) - - -def test_update_custom_metric(transport: str = 'grpc', request_type=analytics_admin.UpdateCustomMetricRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, - scope=resources.CustomMetric.MetricScope.EVENT, - ) - response = client.update_custom_metric(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.UpdateCustomMetricRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD - assert response.scope == resources.CustomMetric.MetricScope.EVENT - - -def test_update_custom_metric_from_dict(): - test_update_custom_metric(request_type=dict) - - -def test_update_custom_metric_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_metric), - '__call__') as call: - client.update_custom_metric() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateCustomMetricRequest() - - -@pytest.mark.asyncio -async def test_update_custom_metric_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.UpdateCustomMetricRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, - scope=resources.CustomMetric.MetricScope.EVENT, - )) - response = await client.update_custom_metric(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.UpdateCustomMetricRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD - assert response.scope == resources.CustomMetric.MetricScope.EVENT - - -@pytest.mark.asyncio -async def test_update_custom_metric_async_from_dict(): - await test_update_custom_metric_async(request_type=dict) - - -def test_update_custom_metric_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.UpdateCustomMetricRequest() - - request.custom_metric.name = 'custom_metric.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_metric), - '__call__') as call: - call.return_value = resources.CustomMetric() - client.update_custom_metric(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'custom_metric.name=custom_metric.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_custom_metric_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.UpdateCustomMetricRequest() - - request.custom_metric.name = 'custom_metric.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_metric), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) - await client.update_custom_metric(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'custom_metric.name=custom_metric.name/value', - ) in kw['metadata'] - - -def test_update_custom_metric_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_custom_metric( - custom_metric=resources.CustomMetric(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].custom_metric == resources.CustomMetric(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_custom_metric_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_custom_metric( - analytics_admin.UpdateCustomMetricRequest(), - custom_metric=resources.CustomMetric(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_custom_metric_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_custom_metric( - custom_metric=resources.CustomMetric(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].custom_metric == resources.CustomMetric(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_custom_metric_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_custom_metric( - analytics_admin.UpdateCustomMetricRequest(), - custom_metric=resources.CustomMetric(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_list_custom_metrics(transport: str = 'grpc', request_type=analytics_admin.ListCustomMetricsRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_metrics), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListCustomMetricsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_custom_metrics(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.ListCustomMetricsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomMetricsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_custom_metrics_from_dict(): - test_list_custom_metrics(request_type=dict) - - -def test_list_custom_metrics_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__') as call: - client.list_custom_metrics() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListCustomMetricsRequest() - - -@pytest.mark.asyncio -async def test_list_custom_metrics_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ListCustomMetricsRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_metrics), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomMetricsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_custom_metrics(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.ListCustomMetricsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomMetricsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_custom_metrics_async_from_dict(): - await test_list_custom_metrics_async(request_type=dict) - - -def test_list_custom_metrics_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ListCustomMetricsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__') as call: - call.return_value = analytics_admin.ListCustomMetricsResponse() - client.list_custom_metrics(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_custom_metrics_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ListCustomMetricsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomMetricsResponse()) - await client.list_custom_metrics(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_custom_metrics_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListCustomMetricsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_custom_metrics( - 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_custom_metrics_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_custom_metrics( - analytics_admin.ListCustomMetricsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_custom_metrics_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListCustomMetricsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(analytics_admin.ListCustomMetricsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_custom_metrics( - 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_custom_metrics_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_custom_metrics( - analytics_admin.ListCustomMetricsRequest(), - parent='parent_value', - ) - - -def test_list_custom_metrics_pager(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - resources.CustomMetric(), - ], - next_page_token='abc', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[], - next_page_token='def', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - ], - next_page_token='ghi', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_custom_metrics(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.CustomMetric) - for i in results) - -def test_list_custom_metrics_pages(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - resources.CustomMetric(), - ], - next_page_token='abc', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[], - next_page_token='def', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - ], - next_page_token='ghi', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - ], - ), - RuntimeError, - ) - pages = list(client.list_custom_metrics(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_custom_metrics_async_pager(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - resources.CustomMetric(), - ], - next_page_token='abc', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[], - next_page_token='def', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - ], - next_page_token='ghi', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_custom_metrics(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.CustomMetric) - for i in responses) - -@pytest.mark.asyncio -async def test_list_custom_metrics_async_pages(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_custom_metrics), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - resources.CustomMetric(), - ], - next_page_token='abc', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[], - next_page_token='def', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - ], - next_page_token='ghi', - ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_custom_metrics(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_archive_custom_metric(transport: str = 'grpc', request_type=analytics_admin.ArchiveCustomMetricRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.archive_custom_metric(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.ArchiveCustomMetricRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_archive_custom_metric_from_dict(): - test_archive_custom_metric(request_type=dict) - - -def test_archive_custom_metric_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_metric), - '__call__') as call: - client.archive_custom_metric() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ArchiveCustomMetricRequest() - - -@pytest.mark.asyncio -async def test_archive_custom_metric_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.ArchiveCustomMetricRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.archive_custom_metric(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.ArchiveCustomMetricRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_archive_custom_metric_async_from_dict(): - await test_archive_custom_metric_async(request_type=dict) - - -def test_archive_custom_metric_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ArchiveCustomMetricRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_metric), - '__call__') as call: - call.return_value = None - client.archive_custom_metric(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_archive_custom_metric_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.ArchiveCustomMetricRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_metric), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.archive_custom_metric(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_archive_custom_metric_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_metric), - '__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.archive_custom_metric( - 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_archive_custom_metric_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.archive_custom_metric( - analytics_admin.ArchiveCustomMetricRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_archive_custom_metric_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.archive_custom_metric), - '__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.archive_custom_metric( - 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_archive_custom_metric_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.archive_custom_metric( - analytics_admin.ArchiveCustomMetricRequest(), - name='name_value', - ) - - -def test_get_custom_metric(transport: str = 'grpc', request_type=analytics_admin.GetCustomMetricRequest): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, - scope=resources.CustomMetric.MetricScope.EVENT, - ) - response = client.get_custom_metric(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.GetCustomMetricRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD - assert response.scope == resources.CustomMetric.MetricScope.EVENT - - -def test_get_custom_metric_from_dict(): - test_get_custom_metric(request_type=dict) - - -def test_get_custom_metric_empty_call(): - # 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=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_metric), - '__call__') as call: - client.get_custom_metric() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetCustomMetricRequest() - - -@pytest.mark.asyncio -async def test_get_custom_metric_async(transport: str = 'grpc_asyncio', request_type=analytics_admin.GetCustomMetricRequest): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric( - name='name_value', - parameter_name='parameter_name_value', - display_name='display_name_value', - description='description_value', - measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, - scope=resources.CustomMetric.MetricScope.EVENT, - )) - response = await client.get_custom_metric(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.GetCustomMetricRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) - assert response.name == 'name_value' - assert response.parameter_name == 'parameter_name_value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD - assert response.scope == resources.CustomMetric.MetricScope.EVENT - - -@pytest.mark.asyncio -async def test_get_custom_metric_async_from_dict(): - await test_get_custom_metric_async(request_type=dict) - - -def test_get_custom_metric_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetCustomMetricRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_metric), - '__call__') as call: - call.return_value = resources.CustomMetric() - client.get_custom_metric(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_custom_metric_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value 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.GetCustomMetricRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_metric), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) - await client.get_custom_metric(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_custom_metric_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_custom_metric( - 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_custom_metric_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_custom_metric( - analytics_admin.GetCustomMetricRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_custom_metric_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_custom_metric), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CustomMetric() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CustomMetric()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_custom_metric( - 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_custom_metric_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_custom_metric( - analytics_admin.GetCustomMetricRequest(), - name='name_value', - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=ga_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=ga_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=ga_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=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( - credentials=ga_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(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = AnalyticsAdminServiceClient( - credentials=ga_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(core_exceptions.DuplicateCredentialArgs): - transport = transports.AnalyticsAdminServiceTransport( - credentials=ga_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=ga_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', - 'list_ios_app_data_streams', - 'get_android_app_data_stream', - 'delete_android_app_data_stream', - 'update_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', - 'get_measurement_protocol_secret', - 'list_measurement_protocol_secrets', - 'create_measurement_protocol_secret', - 'delete_measurement_protocol_secret', - 'update_measurement_protocol_secret', - 'search_change_history_events', - 'get_google_signals_settings', - 'update_google_signals_settings', - 'create_conversion_event', - 'get_conversion_event', - 'delete_conversion_event', - 'list_conversion_events', - 'create_custom_dimension', - 'update_custom_dimension', - 'list_custom_dimensions', - 'archive_custom_dimension', - 'get_custom_dimension', - 'create_custom_metric', - 'update_custom_metric', - 'list_custom_metrics', - 'archive_custom_metric', - 'get_custom_metric', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - -@requires_google_auth_gte_1_25_0 -def test_analytics_admin_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.AnalyticsAdminServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/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", - ) - - -@requires_google_auth_lt_1_25_0 -def test_analytics_admin_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_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(google.auth, 'default', autospec=True) 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 = (ga_credentials.AnonymousCredentials(), None) - transport = transports.AnalyticsAdminServiceTransport() - adc.assert_called_once() - - -@requires_google_auth_gte_1_25_0 -def test_analytics_admin_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - AnalyticsAdminServiceClient() - adc.assert_called_once_with( - scopes=None, - default_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, - ) - - -@requires_google_auth_lt_1_25_0 -def test_analytics_admin_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - 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, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.AnalyticsAdminServiceGrpcTransport, - transports.AnalyticsAdminServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_gte_1_25_0 -def test_analytics_admin_service_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/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, - ], -) -@requires_google_auth_lt_1_25_0 -def test_analytics_admin_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/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,grpc_helpers", - [ - (transports.AnalyticsAdminServiceGrpcTransport, grpc_helpers), - (transports.AnalyticsAdminServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_analytics_admin_service_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "analyticsadmin.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_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', -), - scopes=["1", "2"], - default_host="analyticsadmin.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.AnalyticsAdminServiceGrpcTransport, transports.AnalyticsAdminServiceGrpcAsyncIOTransport]) -def test_analytics_admin_service_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key - ) - - -def test_analytics_admin_service_host_no_port(): - client = AnalyticsAdminServiceClient( - credentials=ga_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=ga_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 = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.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=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_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_conversion_event_path(): - property = "winkle" - conversion_event = "nautilus" - expected = "properties/{property}/conversionEvents/{conversion_event}".format(property=property, conversion_event=conversion_event, ) - actual = AnalyticsAdminServiceClient.conversion_event_path(property, conversion_event) - assert expected == actual - - -def test_parse_conversion_event_path(): - expected = { - "property": "scallop", - "conversion_event": "abalone", - } - path = AnalyticsAdminServiceClient.conversion_event_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_conversion_event_path(path) - assert expected == actual - -def test_custom_dimension_path(): - property = "squid" - expected = "properties/{property}/customDimensions".format(property=property, ) - actual = AnalyticsAdminServiceClient.custom_dimension_path(property) - assert expected == actual - - -def test_parse_custom_dimension_path(): - expected = { - "property": "clam", - } - path = AnalyticsAdminServiceClient.custom_dimension_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_custom_dimension_path(path) - assert expected == actual - -def test_custom_metric_path(): - property = "whelk" - expected = "properties/{property}/customMetrics".format(property=property, ) - actual = AnalyticsAdminServiceClient.custom_metric_path(property) - assert expected == actual - - -def test_parse_custom_metric_path(): - expected = { - "property": "octopus", - } - path = AnalyticsAdminServiceClient.custom_metric_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_custom_metric_path(path) - assert expected == actual - -def test_data_sharing_settings_path(): - account = "oyster" - 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": "nudibranch", - } - 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 = "cuttlefish" - web_data_stream = "mussel" - 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": "winkle", - "web_data_stream": "nautilus", - } - 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 = "scallop" - firebase_link = "abalone" - 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": "squid", - "firebase_link": "clam", - } - 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 = "whelk" - 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": "octopus", - } - 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 = "oyster" - google_ads_link = "nudibranch" - 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": "cuttlefish", - "google_ads_link": "mussel", - } - 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_google_signals_settings_path(): - property = "winkle" - expected = "properties/{property}/googleSignalsSettings".format(property=property, ) - actual = AnalyticsAdminServiceClient.google_signals_settings_path(property) - assert expected == actual - - -def test_parse_google_signals_settings_path(): - expected = { - "property": "nautilus", - } - path = AnalyticsAdminServiceClient.google_signals_settings_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_google_signals_settings_path(path) - assert expected == actual - -def test_ios_app_data_stream_path(): - property = "scallop" - ios_app_data_stream = "abalone" - 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": "squid", - "ios_app_data_stream": "clam", - } - 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_measurement_protocol_secret_path(): - property = "whelk" - web_data_stream = "octopus" - measurement_protocol_secret = "oyster" - expected = "properties/{property}/webDataStreams/{web_data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}".format(property=property, web_data_stream=web_data_stream, measurement_protocol_secret=measurement_protocol_secret, ) - actual = AnalyticsAdminServiceClient.measurement_protocol_secret_path(property, web_data_stream, measurement_protocol_secret) - assert expected == actual - - -def test_parse_measurement_protocol_secret_path(): - expected = { - "property": "nudibranch", - "web_data_stream": "cuttlefish", - "measurement_protocol_secret": "mussel", - } - path = AnalyticsAdminServiceClient.measurement_protocol_secret_path(**expected) - - # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_measurement_protocol_secret_path(path) - assert expected == actual - -def test_property_path(): - property = "winkle" - expected = "properties/{property}".format(property=property, ) - actual = AnalyticsAdminServiceClient.property_path(property) - assert expected == actual - - -def test_parse_property_path(): - expected = { - "property": "nautilus", - } - 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 = "scallop" - user_link = "abalone" - 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": "squid", - "user_link": "clam", - } - 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 = "whelk" - web_data_stream = "octopus" - 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": "oyster", - "web_data_stream": "nudibranch", - } - 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 = "cuttlefish" - 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": "mussel", - } - 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 = "winkle" - expected = "folders/{folder}".format(folder=folder, ) - actual = AnalyticsAdminServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - 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 = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) - actual = AnalyticsAdminServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - 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 = "squid" - expected = "projects/{project}".format(project=project, ) - actual = AnalyticsAdminServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - 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 = "whelk" - location = "octopus" - 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": "oyster", - "location": "nudibranch", - } - 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=ga_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=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py b/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py index ceb4446b..a93b7437 100644 --- a/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +++ b/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py @@ -127,18 +127,6 @@ def test_analytics_admin_service_client_from_service_account_info(client_class): assert client.transport._host == "analyticsadmin.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", [AnalyticsAdminServiceClient, AnalyticsAdminServiceAsyncClient,] -) -def test_analytics_admin_service_client_service_account_always_use_jwt(client_class): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -146,7 +134,7 @@ def test_analytics_admin_service_client_service_account_always_use_jwt(client_cl (transports.AnalyticsAdminServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_analytics_admin_service_client_service_account_always_use_jwt_true( +def test_analytics_admin_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -156,6 +144,13 @@ def test_analytics_admin_service_client_service_account_always_use_jwt_true( transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", [AnalyticsAdminServiceClient, AnalyticsAdminServiceAsyncClient,] @@ -240,6 +235,7 @@ def test_analytics_admin_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -256,6 +252,7 @@ def test_analytics_admin_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -272,6 +269,7 @@ def test_analytics_admin_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -300,6 +298,7 @@ def test_analytics_admin_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -376,6 +375,7 @@ def test_analytics_admin_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -409,6 +409,7 @@ def test_analytics_admin_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -430,6 +431,7 @@ def test_analytics_admin_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -464,6 +466,7 @@ def test_analytics_admin_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -498,6 +501,7 @@ def test_analytics_admin_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -517,6 +521,7 @@ def test_analytics_admin_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, )