diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..9c6959c2 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,18 @@ +[run] +branch = True + +[report] +fail_under = 100 +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/.flake8 b/.flake8 index ed931638..29227d4c 100644 --- a/.flake8 +++ b/.flake8 @@ -26,6 +26,7 @@ exclude = *_pb2.py # Standard linting exemptions. + **/.nox/** __pycache__, .git, *.pyc, diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..30c3973a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,11 @@ +# Code owners file. +# This file controls who is tagged for review for any given pull request. +# +# For syntax help see: +# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax + +# The @googleapis/yoshi-python is the default owner for changes in this repo +* @googleapis/yoshi-python + +# The python-samples-reviewers team is the default owner for samples changes +/samples/ @googleapis/python-samples-owners \ No newline at end of file diff --git a/.github/snippet-bot.yml b/.github/snippet-bot.yml new file mode 100644 index 00000000..e69de29b diff --git a/.gitignore b/.gitignore index b87e1ed5..b9daa52f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ pip-log.txt # Built documentation docs/_build bigquery/docs/generated +docs.metadata # Virtual environment env/ @@ -57,4 +58,4 @@ system_tests/local_test_setup # Make sure a generated file isn't accidentally committed. pylintrc -pylintrc.test \ No newline at end of file +pylintrc.test diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 59437799..c65a3d35 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -15,7 +15,11 @@ set -eo pipefail -cd github/python-analytics-admin +if [[ -z "${PROJECT_ROOT:-}" ]]; then + PROJECT_ROOT="github/python-analytics-admin" +fi + +cd "${PROJECT_ROOT}" # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 @@ -30,10 +34,16 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json") # Remove old nox -python3.6 -m pip uninstall --yes --quiet nox-automation +python3 -m pip uninstall --yes --quiet nox-automation # Install nox -python3.6 -m pip install --upgrade --quiet nox -python3.6 -m nox --version - -python3.6 -m nox +python3 -m pip install --upgrade --quiet nox +python3 -m nox --version + +# If NOX_SESSION is set, it only runs the specified session, +# otherwise run all the sessions. +if [[ -n "${NOX_SESSION:-}" ]]; then + python3 -m nox -s ${NOX_SESSION:-} +else + python3 -m nox +fi diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile new file mode 100644 index 00000000..412b0b56 --- /dev/null +++ b/.kokoro/docker/docs/Dockerfile @@ -0,0 +1,98 @@ +# 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 ubuntu:20.04 + +ENV DEBIAN_FRONTEND noninteractive + +# Ensure local Python is preferred over distribution Python. +ENV PATH /usr/local/bin:$PATH + +# Install dependencies. +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-transport-https \ + build-essential \ + ca-certificates \ + curl \ + dirmngr \ + git \ + gpg-agent \ + graphviz \ + libbz2-dev \ + libdb5.3-dev \ + libexpat1-dev \ + libffi-dev \ + liblzma-dev \ + libreadline-dev \ + libsnappy-dev \ + libssl-dev \ + libsqlite3-dev \ + portaudio19-dev \ + redis-server \ + software-properties-common \ + ssh \ + sudo \ + tcl \ + tcl-dev \ + tk \ + tk-dev \ + uuid-dev \ + wget \ + zlib1g-dev \ + && add-apt-repository universe \ + && apt-get update \ + && apt-get -y install jq \ + && apt-get clean autoclean \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* \ + && rm -f /var/cache/apt/archives/*.deb + + +COPY fetch_gpg_keys.sh /tmp +# Install the desired versions of Python. +RUN set -ex \ + && export GNUPGHOME="$(mktemp -d)" \ + && echo "disable-ipv6" >> "${GNUPGHOME}/dirmngr.conf" \ + && /tmp/fetch_gpg_keys.sh \ + && for PYTHON_VERSION in 3.7.8 3.8.5; do \ + wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ + && wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ + && gpg --batch --verify python-${PYTHON_VERSION}.tar.xz.asc python-${PYTHON_VERSION}.tar.xz \ + && rm -r python-${PYTHON_VERSION}.tar.xz.asc \ + && mkdir -p /usr/src/python-${PYTHON_VERSION} \ + && tar -xJC /usr/src/python-${PYTHON_VERSION} --strip-components=1 -f python-${PYTHON_VERSION}.tar.xz \ + && rm python-${PYTHON_VERSION}.tar.xz \ + && cd /usr/src/python-${PYTHON_VERSION} \ + && ./configure \ + --enable-shared \ + # This works only on Python 2.7 and throws a warning on every other + # version, but seems otherwise harmless. + --enable-unicode=ucs4 \ + --with-system-ffi \ + --without-ensurepip \ + && make -j$(nproc) \ + && make install \ + && ldconfig \ + ; done \ + && rm -rf "${GNUPGHOME}" \ + && rm -rf /usr/src/python* \ + && rm -rf ~/.cache/ + +RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ + && python3.7 /tmp/get-pip.py \ + && python3.8 /tmp/get-pip.py \ + && rm /tmp/get-pip.py + +CMD ["python3.7"] diff --git a/.kokoro/docker/docs/fetch_gpg_keys.sh b/.kokoro/docker/docs/fetch_gpg_keys.sh new file mode 100755 index 00000000..d653dd86 --- /dev/null +++ b/.kokoro/docker/docs/fetch_gpg_keys.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# 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. + +# A script to fetch gpg keys with retry. +# Avoid jinja parsing the file. +# + +function retry { + if [[ "${#}" -le 1 ]]; then + echo "Usage: ${0} retry_count commands.." + exit 1 + fi + local retries=${1} + local command="${@:2}" + until [[ "${retries}" -le 0 ]]; do + $command && return 0 + if [[ $? -ne 0 ]]; then + echo "command failed, retrying" + ((retries--)) + fi + done + return 1 +} + +# 3.6.9, 3.7.5 (Ned Deily) +retry 3 gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \ + 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D + +# 3.8.0 (Łukasz Langa) +retry 3 gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \ + E3FF2839C048B25C084DEBE9B26995E310250568 + +# diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg index fa288711..ce443c13 100644 --- a/.kokoro/docs/common.cfg +++ b/.kokoro/docs/common.cfg @@ -11,12 +11,12 @@ action { gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" # Use the trampoline script to run in docker. -build_file: "python-analytics-admin/.kokoro/trampoline.sh" +build_file: "python-analytics-admin/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/python-multi" + value: "gcr.io/cloud-devrel-kokoro-resources/python-lib-docs" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" @@ -28,6 +28,23 @@ env_vars: { value: "docs-staging" } +env_vars: { + key: "V2_STAGING_BUCKET" + value: "docs-staging-v2" +} + +# It will upload the docker image after successful builds. +env_vars: { + key: "TRAMPOLINE_IMAGE_UPLOAD" + value: "true" +} + +# It will always build the docker image. +env_vars: { + key: "TRAMPOLINE_DOCKERFILE" + value: ".kokoro/docker/docs/Dockerfile" +} + # Fetch the token needed for reporting release status to GitHub before_action { fetch_keystore { diff --git a/.kokoro/docs/docs-presubmit.cfg b/.kokoro/docs/docs-presubmit.cfg new file mode 100644 index 00000000..4ee2c46a --- /dev/null +++ b/.kokoro/docs/docs-presubmit.cfg @@ -0,0 +1,28 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "STAGING_BUCKET" + value: "gcloud-python-test" +} + +env_vars: { + key: "V2_STAGING_BUCKET" + value: "gcloud-python-test" +} + +# We only upload the image in the main `docs` build. +env_vars: { + key: "TRAMPOLINE_IMAGE_UPLOAD" + value: "false" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-analytics-admin/.kokoro/build.sh" +} + +# Only run this nox session. +env_vars: { + key: "NOX_SESSION" + value: "docs docfx" +} diff --git a/.kokoro/populate-secrets.sh b/.kokoro/populate-secrets.sh new file mode 100755 index 00000000..f5251425 --- /dev/null +++ b/.kokoro/populate-secrets.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# 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. + +set -eo pipefail + +function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;} +function msg { println "$*" >&2 ;} +function println { printf '%s\n' "$(now) $*" ;} + + +# Populates requested secrets set in SECRET_MANAGER_KEYS from service account: +# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com +SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" +msg "Creating folder on disk for secrets: ${SECRET_LOCATION}" +mkdir -p ${SECRET_LOCATION} +for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") +do + msg "Retrieving secret ${key}" + docker run --entrypoint=gcloud \ + --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ + gcr.io/google.com/cloudsdktool/cloud-sdk \ + secrets versions access latest \ + --project cloud-devrel-kokoro-resources \ + --secret ${key} > \ + "${SECRET_LOCATION}/${key}" + if [[ $? == 0 ]]; then + msg "Secret written to ${SECRET_LOCATION}/${key}" + else + msg "Error retrieving secret ${key}" + fi +done diff --git a/.kokoro/publish-docs.sh b/.kokoro/publish-docs.sh index f5a4968a..8acb14e8 100755 --- a/.kokoro/publish-docs.sh +++ b/.kokoro/publish-docs.sh @@ -18,26 +18,16 @@ set -eo pipefail # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 -cd github/python-analytics-admin - -# Remove old nox -python3.6 -m pip uninstall --yes --quiet nox-automation +export PATH="${HOME}/.local/bin:${PATH}" # Install nox -python3.6 -m pip install --upgrade --quiet nox -python3.6 -m nox --version +python3 -m pip install --user --upgrade --quiet nox +python3 -m nox --version # build docs nox -s docs -python3 -m pip install gcp-docuploader - -# install a json parser -sudo apt-get update -sudo apt-get -y install software-properties-common -sudo add-apt-repository universe -sudo apt-get update -sudo apt-get -y install jq +python3 -m pip install --user gcp-docuploader # create metadata python3 -m docuploader create-metadata \ @@ -52,4 +42,23 @@ python3 -m docuploader create-metadata \ cat docs.metadata # upload docs -python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket docs-staging +python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket "${STAGING_BUCKET}" + + +# docfx yaml files +nox -s docfx + +# create metadata. +python3 -m docuploader create-metadata \ + --name=$(jq --raw-output '.name // empty' .repo-metadata.json) \ + --version=$(python3 setup.py --version) \ + --language=$(jq --raw-output '.language // empty' .repo-metadata.json) \ + --distribution-name=$(python3 setup.py --name) \ + --product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \ + --github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \ + --issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json) + +cat docs.metadata + +# upload docs +python3 -m docuploader upload docs/_build/html/docfx_yaml --metadata-file docs.metadata --destination-prefix docfx --staging-bucket "${V2_STAGING_BUCKET}" diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index bed189e2..0ed8b652 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,42 +23,18 @@ env_vars: { value: "github/python-analytics-admin/.kokoro/release.sh" } -# Fetch the token needed for reporting release status to GitHub -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "yoshi-automation-github-key" - } - } -} - -# Fetch PyPI password -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "google_cloud_pypi_password" - } - } -} - -# Fetch magictoken to use with Magic Github Proxy -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "releasetool-magictoken" - } - } +# Fetch PyPI password +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "google_cloud_pypi_password" + } + } } -# Fetch api key to use with Magic Github Proxy -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "magic-github-proxy-api-key" - } - } -} +# Tokens needed to report release status back to GitHub +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.6/common.cfg b/.kokoro/samples/python3.6/common.cfg index b79e165b..b7fccdac 100644 --- a/.kokoro/samples/python3.6/common.cfg +++ b/.kokoro/samples/python3.6/common.cfg @@ -13,6 +13,12 @@ env_vars: { value: "py-3.6" } +# Declare build specific Cloud project. +env_vars: { + key: "BUILD_SPECIFIC_GCLOUD_PROJECT" + value: "python-docs-samples-tests-py36" +} + env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/python-analytics-admin/.kokoro/test-samples.sh" diff --git a/.kokoro/samples/python3.7/common.cfg b/.kokoro/samples/python3.7/common.cfg index 46f8d81d..d91f9c36 100644 --- a/.kokoro/samples/python3.7/common.cfg +++ b/.kokoro/samples/python3.7/common.cfg @@ -13,6 +13,12 @@ env_vars: { value: "py-3.7" } +# Declare build specific Cloud project. +env_vars: { + key: "BUILD_SPECIFIC_GCLOUD_PROJECT" + value: "python-docs-samples-tests-py37" +} + env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/python-analytics-admin/.kokoro/test-samples.sh" diff --git a/.kokoro/samples/python3.8/common.cfg b/.kokoro/samples/python3.8/common.cfg index 0668aa73..9cb150e5 100644 --- a/.kokoro/samples/python3.8/common.cfg +++ b/.kokoro/samples/python3.8/common.cfg @@ -13,6 +13,12 @@ env_vars: { value: "py-3.8" } +# Declare build specific Cloud project. +env_vars: { + key: "BUILD_SPECIFIC_GCLOUD_PROJECT" + value: "python-docs-samples-tests-py38" +} + env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/python-analytics-admin/.kokoro/test-samples.sh" diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh index 68553d6c..897f35a7 100755 --- a/.kokoro/test-samples.sh +++ b/.kokoro/test-samples.sh @@ -28,6 +28,12 @@ if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then git checkout $LATEST_RELEASE fi +# Exit early if samples directory doesn't exist +if [ ! -d "./samples" ]; then + echo "No tests run. `./samples` not found" + exit 0 +fi + # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 @@ -101,4 +107,4 @@ cd "$ROOT" # Workaround for Kokoro permissions issue: delete secrets rm testing/{test-env.sh,client-secrets.json,service-account.json} -exit "$RTN" \ No newline at end of file +exit "$RTN" diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh index e8c4251f..f39236e9 100755 --- a/.kokoro/trampoline.sh +++ b/.kokoro/trampoline.sh @@ -15,9 +15,14 @@ set -eo pipefail -python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" || ret_code=$? +# Always run the cleanup script, regardless of the success of bouncing into +# the container. +function cleanup() { + chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + echo "cleanup"; +} +trap cleanup EXIT -chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh -${KOKORO_GFILE_DIR}/trampoline_cleanup.sh || true - -exit ${ret_code} +$(dirname $0)/populate-secrets.sh # Secret Manager secrets. +python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" \ No newline at end of file diff --git a/.kokoro/trampoline_v2.sh b/.kokoro/trampoline_v2.sh new file mode 100755 index 00000000..719bcd5b --- /dev/null +++ b/.kokoro/trampoline_v2.sh @@ -0,0 +1,487 @@ +#!/usr/bin/env bash +# 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. + +# trampoline_v2.sh +# +# This script does 3 things. +# +# 1. Prepare the Docker image for the test +# 2. Run the Docker with appropriate flags to run the test +# 3. Upload the newly built Docker image +# +# in a way that is somewhat compatible with trampoline_v1. +# +# To run this script, first download few files from gcs to /dev/shm. +# (/dev/shm is passed into the container as KOKORO_GFILE_DIR). +# +# gsutil cp gs://cloud-devrel-kokoro-resources/python-docs-samples/secrets_viewer_service_account.json /dev/shm +# gsutil cp gs://cloud-devrel-kokoro-resources/python-docs-samples/automl_secrets.txt /dev/shm +# +# Then run the script. +# .kokoro/trampoline_v2.sh +# +# These environment variables are required: +# TRAMPOLINE_IMAGE: The docker image to use. +# TRAMPOLINE_DOCKERFILE: The location of the Dockerfile. +# +# You can optionally change these environment variables: +# TRAMPOLINE_IMAGE_UPLOAD: +# (true|false): Whether to upload the Docker image after the +# successful builds. +# TRAMPOLINE_BUILD_FILE: The script to run in the docker container. +# TRAMPOLINE_WORKSPACE: The workspace path in the docker container. +# Defaults to /workspace. +# Potentially there are some repo specific envvars in .trampolinerc in +# the project root. + + +set -euo pipefail + +TRAMPOLINE_VERSION="2.0.5" + +if command -v tput >/dev/null && [[ -n "${TERM:-}" ]]; then + readonly IO_COLOR_RED="$(tput setaf 1)" + readonly IO_COLOR_GREEN="$(tput setaf 2)" + readonly IO_COLOR_YELLOW="$(tput setaf 3)" + readonly IO_COLOR_RESET="$(tput sgr0)" +else + readonly IO_COLOR_RED="" + readonly IO_COLOR_GREEN="" + readonly IO_COLOR_YELLOW="" + readonly IO_COLOR_RESET="" +fi + +function function_exists { + [ $(LC_ALL=C type -t $1)"" == "function" ] +} + +# Logs a message using the given color. The first argument must be one +# of the IO_COLOR_* variables defined above, such as +# "${IO_COLOR_YELLOW}". The remaining arguments will be logged in the +# given color. The log message will also have an RFC-3339 timestamp +# prepended (in UTC). You can disable the color output by setting +# TERM=vt100. +function log_impl() { + local color="$1" + shift + local timestamp="$(date -u "+%Y-%m-%dT%H:%M:%SZ")" + echo "================================================================" + echo "${color}${timestamp}:" "$@" "${IO_COLOR_RESET}" + echo "================================================================" +} + +# Logs the given message with normal coloring and a timestamp. +function log() { + log_impl "${IO_COLOR_RESET}" "$@" +} + +# Logs the given message in green with a timestamp. +function log_green() { + log_impl "${IO_COLOR_GREEN}" "$@" +} + +# Logs the given message in yellow with a timestamp. +function log_yellow() { + log_impl "${IO_COLOR_YELLOW}" "$@" +} + +# Logs the given message in red with a timestamp. +function log_red() { + log_impl "${IO_COLOR_RED}" "$@" +} + +readonly tmpdir=$(mktemp -d -t ci-XXXXXXXX) +readonly tmphome="${tmpdir}/h" +mkdir -p "${tmphome}" + +function cleanup() { + rm -rf "${tmpdir}" +} +trap cleanup EXIT + +RUNNING_IN_CI="${RUNNING_IN_CI:-false}" + +# The workspace in the container, defaults to /workspace. +TRAMPOLINE_WORKSPACE="${TRAMPOLINE_WORKSPACE:-/workspace}" + +pass_down_envvars=( + # TRAMPOLINE_V2 variables. + # Tells scripts whether they are running as part of CI or not. + "RUNNING_IN_CI" + # Indicates which CI system we're in. + "TRAMPOLINE_CI" + # Indicates the version of the script. + "TRAMPOLINE_VERSION" +) + +log_yellow "Building with Trampoline ${TRAMPOLINE_VERSION}" + +# Detect which CI systems we're in. If we're in any of the CI systems +# we support, `RUNNING_IN_CI` will be true and `TRAMPOLINE_CI` will be +# the name of the CI system. Both envvars will be passing down to the +# container for telling which CI system we're in. +if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then + # descriptive env var for indicating it's on CI. + RUNNING_IN_CI="true" + TRAMPOLINE_CI="kokoro" + if [[ "${TRAMPOLINE_USE_LEGACY_SERVICE_ACCOUNT:-}" == "true" ]]; then + if [[ ! -f "${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json" ]]; then + log_red "${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json does not exist. Did you forget to mount cloud-devrel-kokoro-resources/trampoline? Aborting." + exit 1 + fi + # This service account will be activated later. + TRAMPOLINE_SERVICE_ACCOUNT="${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json" + else + if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then + gcloud auth list + fi + log_yellow "Configuring Container Registry access" + gcloud auth configure-docker --quiet + fi + pass_down_envvars+=( + # KOKORO dynamic variables. + "KOKORO_BUILD_NUMBER" + "KOKORO_BUILD_ID" + "KOKORO_JOB_NAME" + "KOKORO_GIT_COMMIT" + "KOKORO_GITHUB_COMMIT" + "KOKORO_GITHUB_PULL_REQUEST_NUMBER" + "KOKORO_GITHUB_PULL_REQUEST_COMMIT" + # For Build Cop Bot + "KOKORO_GITHUB_COMMIT_URL" + "KOKORO_GITHUB_PULL_REQUEST_URL" + ) +elif [[ "${TRAVIS:-}" == "true" ]]; then + RUNNING_IN_CI="true" + TRAMPOLINE_CI="travis" + pass_down_envvars+=( + "TRAVIS_BRANCH" + "TRAVIS_BUILD_ID" + "TRAVIS_BUILD_NUMBER" + "TRAVIS_BUILD_WEB_URL" + "TRAVIS_COMMIT" + "TRAVIS_COMMIT_MESSAGE" + "TRAVIS_COMMIT_RANGE" + "TRAVIS_JOB_NAME" + "TRAVIS_JOB_NUMBER" + "TRAVIS_JOB_WEB_URL" + "TRAVIS_PULL_REQUEST" + "TRAVIS_PULL_REQUEST_BRANCH" + "TRAVIS_PULL_REQUEST_SHA" + "TRAVIS_PULL_REQUEST_SLUG" + "TRAVIS_REPO_SLUG" + "TRAVIS_SECURE_ENV_VARS" + "TRAVIS_TAG" + ) +elif [[ -n "${GITHUB_RUN_ID:-}" ]]; then + RUNNING_IN_CI="true" + TRAMPOLINE_CI="github-workflow" + pass_down_envvars+=( + "GITHUB_WORKFLOW" + "GITHUB_RUN_ID" + "GITHUB_RUN_NUMBER" + "GITHUB_ACTION" + "GITHUB_ACTIONS" + "GITHUB_ACTOR" + "GITHUB_REPOSITORY" + "GITHUB_EVENT_NAME" + "GITHUB_EVENT_PATH" + "GITHUB_SHA" + "GITHUB_REF" + "GITHUB_HEAD_REF" + "GITHUB_BASE_REF" + ) +elif [[ "${CIRCLECI:-}" == "true" ]]; then + RUNNING_IN_CI="true" + TRAMPOLINE_CI="circleci" + pass_down_envvars+=( + "CIRCLE_BRANCH" + "CIRCLE_BUILD_NUM" + "CIRCLE_BUILD_URL" + "CIRCLE_COMPARE_URL" + "CIRCLE_JOB" + "CIRCLE_NODE_INDEX" + "CIRCLE_NODE_TOTAL" + "CIRCLE_PREVIOUS_BUILD_NUM" + "CIRCLE_PROJECT_REPONAME" + "CIRCLE_PROJECT_USERNAME" + "CIRCLE_REPOSITORY_URL" + "CIRCLE_SHA1" + "CIRCLE_STAGE" + "CIRCLE_USERNAME" + "CIRCLE_WORKFLOW_ID" + "CIRCLE_WORKFLOW_JOB_ID" + "CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS" + "CIRCLE_WORKFLOW_WORKSPACE_ID" + ) +fi + +# Configure the service account for pulling the docker image. +function repo_root() { + local dir="$1" + while [[ ! -d "${dir}/.git" ]]; do + dir="$(dirname "$dir")" + done + echo "${dir}" +} + +# Detect the project root. In CI builds, we assume the script is in +# the git tree and traverse from there, otherwise, traverse from `pwd` +# to find `.git` directory. +if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then + PROGRAM_PATH="$(realpath "$0")" + PROGRAM_DIR="$(dirname "${PROGRAM_PATH}")" + PROJECT_ROOT="$(repo_root "${PROGRAM_DIR}")" +else + PROJECT_ROOT="$(repo_root $(pwd))" +fi + +log_yellow "Changing to the project root: ${PROJECT_ROOT}." +cd "${PROJECT_ROOT}" + +# To support relative path for `TRAMPOLINE_SERVICE_ACCOUNT`, we need +# to use this environment variable in `PROJECT_ROOT`. +if [[ -n "${TRAMPOLINE_SERVICE_ACCOUNT:-}" ]]; then + + mkdir -p "${tmpdir}/gcloud" + gcloud_config_dir="${tmpdir}/gcloud" + + log_yellow "Using isolated gcloud config: ${gcloud_config_dir}." + export CLOUDSDK_CONFIG="${gcloud_config_dir}" + + log_yellow "Using ${TRAMPOLINE_SERVICE_ACCOUNT} for authentication." + gcloud auth activate-service-account \ + --key-file "${TRAMPOLINE_SERVICE_ACCOUNT}" + log_yellow "Configuring Container Registry access" + gcloud auth configure-docker --quiet +fi + +required_envvars=( + # The basic trampoline configurations. + "TRAMPOLINE_IMAGE" + "TRAMPOLINE_BUILD_FILE" +) + +if [[ -f "${PROJECT_ROOT}/.trampolinerc" ]]; then + source "${PROJECT_ROOT}/.trampolinerc" +fi + +log_yellow "Checking environment variables." +for e in "${required_envvars[@]}" +do + if [[ -z "${!e:-}" ]]; then + log "Missing ${e} env var. Aborting." + exit 1 + fi +done + +# We want to support legacy style TRAMPOLINE_BUILD_FILE used with V1 +# script: e.g. "github/repo-name/.kokoro/run_tests.sh" +TRAMPOLINE_BUILD_FILE="${TRAMPOLINE_BUILD_FILE#github/*/}" +log_yellow "Using TRAMPOLINE_BUILD_FILE: ${TRAMPOLINE_BUILD_FILE}" + +# ignore error on docker operations and test execution +set +e + +log_yellow "Preparing Docker image." +# We only download the docker image in CI builds. +if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then + # Download the docker image specified by `TRAMPOLINE_IMAGE` + + # We may want to add --max-concurrent-downloads flag. + + log_yellow "Start pulling the Docker image: ${TRAMPOLINE_IMAGE}." + if docker pull "${TRAMPOLINE_IMAGE}"; then + log_green "Finished pulling the Docker image: ${TRAMPOLINE_IMAGE}." + has_image="true" + else + log_red "Failed pulling the Docker image: ${TRAMPOLINE_IMAGE}." + has_image="false" + fi +else + # For local run, check if we have the image. + if docker images "${TRAMPOLINE_IMAGE}:latest" | grep "${TRAMPOLINE_IMAGE}"; then + has_image="true" + else + has_image="false" + fi +fi + + +# The default user for a Docker container has uid 0 (root). To avoid +# creating root-owned files in the build directory we tell docker to +# use the current user ID. +user_uid="$(id -u)" +user_gid="$(id -g)" +user_name="$(id -un)" + +# To allow docker in docker, we add the user to the docker group in +# the host os. +docker_gid=$(cut -d: -f3 < <(getent group docker)) + +update_cache="false" +if [[ "${TRAMPOLINE_DOCKERFILE:-none}" != "none" ]]; then + # Build the Docker image from the source. + context_dir=$(dirname "${TRAMPOLINE_DOCKERFILE}") + docker_build_flags=( + "-f" "${TRAMPOLINE_DOCKERFILE}" + "-t" "${TRAMPOLINE_IMAGE}" + "--build-arg" "UID=${user_uid}" + "--build-arg" "USERNAME=${user_name}" + ) + if [[ "${has_image}" == "true" ]]; then + docker_build_flags+=("--cache-from" "${TRAMPOLINE_IMAGE}") + fi + + log_yellow "Start building the docker image." + if [[ "${TRAMPOLINE_VERBOSE:-false}" == "true" ]]; then + echo "docker build" "${docker_build_flags[@]}" "${context_dir}" + fi + + # ON CI systems, we want to suppress docker build logs, only + # output the logs when it fails. + if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then + if docker build "${docker_build_flags[@]}" "${context_dir}" \ + > "${tmpdir}/docker_build.log" 2>&1; then + if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then + cat "${tmpdir}/docker_build.log" + fi + + log_green "Finished building the docker image." + update_cache="true" + else + log_red "Failed to build the Docker image, aborting." + log_yellow "Dumping the build logs:" + cat "${tmpdir}/docker_build.log" + exit 1 + fi + else + if docker build "${docker_build_flags[@]}" "${context_dir}"; then + log_green "Finished building the docker image." + update_cache="true" + else + log_red "Failed to build the Docker image, aborting." + exit 1 + fi + fi +else + if [[ "${has_image}" != "true" ]]; then + log_red "We do not have ${TRAMPOLINE_IMAGE} locally, aborting." + exit 1 + fi +fi + +# We use an array for the flags so they are easier to document. +docker_flags=( + # Remove the container after it exists. + "--rm" + + # Use the host network. + "--network=host" + + # Run in priviledged mode. We are not using docker for sandboxing or + # isolation, just for packaging our dev tools. + "--privileged" + + # Run the docker script with the user id. Because the docker image gets to + # write in ${PWD} you typically want this to be your user id. + # To allow docker in docker, we need to use docker gid on the host. + "--user" "${user_uid}:${docker_gid}" + + # Pass down the USER. + "--env" "USER=${user_name}" + + # Mount the project directory inside the Docker container. + "--volume" "${PROJECT_ROOT}:${TRAMPOLINE_WORKSPACE}" + "--workdir" "${TRAMPOLINE_WORKSPACE}" + "--env" "PROJECT_ROOT=${TRAMPOLINE_WORKSPACE}" + + # Mount the temporary home directory. + "--volume" "${tmphome}:/h" + "--env" "HOME=/h" + + # Allow docker in docker. + "--volume" "/var/run/docker.sock:/var/run/docker.sock" + + # Mount the /tmp so that docker in docker can mount the files + # there correctly. + "--volume" "/tmp:/tmp" + # Pass down the KOKORO_GFILE_DIR and KOKORO_KEYSTORE_DIR + # TODO(tmatsuo): This part is not portable. + "--env" "TRAMPOLINE_SECRET_DIR=/secrets" + "--volume" "${KOKORO_GFILE_DIR:-/dev/shm}:/secrets/gfile" + "--env" "KOKORO_GFILE_DIR=/secrets/gfile" + "--volume" "${KOKORO_KEYSTORE_DIR:-/dev/shm}:/secrets/keystore" + "--env" "KOKORO_KEYSTORE_DIR=/secrets/keystore" +) + +# Add an option for nicer output if the build gets a tty. +if [[ -t 0 ]]; then + docker_flags+=("-it") +fi + +# Passing down env vars +for e in "${pass_down_envvars[@]}" +do + if [[ -n "${!e:-}" ]]; then + docker_flags+=("--env" "${e}=${!e}") + fi +done + +# If arguments are given, all arguments will become the commands run +# in the container, otherwise run TRAMPOLINE_BUILD_FILE. +if [[ $# -ge 1 ]]; then + log_yellow "Running the given commands '" "${@:1}" "' in the container." + readonly commands=("${@:1}") + if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then + echo docker run "${docker_flags[@]}" "${TRAMPOLINE_IMAGE}" "${commands[@]}" + fi + docker run "${docker_flags[@]}" "${TRAMPOLINE_IMAGE}" "${commands[@]}" +else + log_yellow "Running the tests in a Docker container." + docker_flags+=("--entrypoint=${TRAMPOLINE_BUILD_FILE}") + if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then + echo docker run "${docker_flags[@]}" "${TRAMPOLINE_IMAGE}" + fi + docker run "${docker_flags[@]}" "${TRAMPOLINE_IMAGE}" +fi + + +test_retval=$? + +if [[ ${test_retval} -eq 0 ]]; then + log_green "Build finished with ${test_retval}" +else + log_red "Build finished with ${test_retval}" +fi + +# Only upload it when the test passes. +if [[ "${update_cache}" == "true" ]] && \ + [[ $test_retval == 0 ]] && \ + [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]]; then + log_yellow "Uploading the Docker image." + if docker push "${TRAMPOLINE_IMAGE}"; then + log_green "Finished uploading the Docker image." + else + log_red "Failed uploading the Docker image." + fi + # Call trampoline_after_upload_hook if it's defined. + if function_exists trampoline_after_upload_hook; then + trampoline_after_upload_hook + fi + +fi + +exit "${test_retval}" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..a9024b15 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml +- repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 diff --git a/.trampolinerc b/.trampolinerc new file mode 100644 index 00000000..383b6ec8 --- /dev/null +++ b/.trampolinerc @@ -0,0 +1,52 @@ +# 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. + +# Template for .trampolinerc + +# Add required env vars here. +required_envvars+=( + "STAGING_BUCKET" + "V2_STAGING_BUCKET" +) + +# Add env vars which are passed down into the container here. +pass_down_envvars+=( + "STAGING_BUCKET" + "V2_STAGING_BUCKET" + "NOX_SESSION" +) + +# Prevent unintentional override on the default image. +if [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]] && \ + [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then + echo "Please set TRAMPOLINE_IMAGE if you want to upload the Docker image." + exit 1 +fi + +# Define the default value if it makes sense. +if [[ -z "${TRAMPOLINE_IMAGE_UPLOAD:-}" ]]; then + TRAMPOLINE_IMAGE_UPLOAD="" +fi + +if [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then + TRAMPOLINE_IMAGE="" +fi + +if [[ -z "${TRAMPOLINE_DOCKERFILE:-}" ]]; then + TRAMPOLINE_DOCKERFILE="" +fi + +if [[ -z "${TRAMPOLINE_BUILD_FILE:-}" ]]; then + TRAMPOLINE_BUILD_FILE="" +fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 2469293c..6c91bbe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,35 @@ # Changelog +## [0.2.0](https://www.github.com/googleapis/python-analytics-admin/compare/v0.1.0...v0.2.0) (2021-01-20) + + +### ⚠ BREAKING CHANGES + +* `update_mask` field is required for all Update operations +* rename `country_code` field to `region_code` in `Account` +* rename `url_query_parameter` field to `uri_query_parameter` in `EnhancedMeasurementSettings` +* remove `parent` field from `GoogleAdsLink` +* remove unused fields from `EnhancedMeasurementSettings` (#29) + +### Features + +* add ListAccountSummaries ([#20](https://www.github.com/googleapis/python-analytics-admin/issues/20)) ([04d05d7](https://www.github.com/googleapis/python-analytics-admin/commit/04d05d7436a752dba18cb04d0e6882b1670114d7)) +* add pagination support for `ListFirebaseLinks` operation ([bc756a9](https://www.github.com/googleapis/python-analytics-admin/commit/bc756a9566497ab6ff997d26d7fa35c9a6355ecf)) + + +### Bug Fixes + +* `update_mask` field is required for all Update operations ([bc756a9](https://www.github.com/googleapis/python-analytics-admin/commit/bc756a9566497ab6ff997d26d7fa35c9a6355ecf)) +* remove `parent` field from `GoogleAdsLink` ([bc756a9](https://www.github.com/googleapis/python-analytics-admin/commit/bc756a9566497ab6ff997d26d7fa35c9a6355ecf)) +* remove unused fields from `EnhancedMeasurementSettings` ([#29](https://www.github.com/googleapis/python-analytics-admin/issues/29)) ([bc756a9](https://www.github.com/googleapis/python-analytics-admin/commit/bc756a9566497ab6ff997d26d7fa35c9a6355ecf)) +* rename `country_code` field to `region_code` in `Account` ([bc756a9](https://www.github.com/googleapis/python-analytics-admin/commit/bc756a9566497ab6ff997d26d7fa35c9a6355ecf)) +* rename `url_query_parameter` field to `uri_query_parameter` in `EnhancedMeasurementSettings` ([bc756a9](https://www.github.com/googleapis/python-analytics-admin/commit/bc756a9566497ab6ff997d26d7fa35c9a6355ecf)) + + +### Documentation + +* added a sample ([#9](https://www.github.com/googleapis/python-analytics-admin/issues/9)) ([60918d8](https://www.github.com/googleapis/python-analytics-admin/commit/60918d8896d37f32a19c3d5724611df5cc4d4619)) + ## 0.1.0 (2020-07-23) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index b3d1f602..039f4368 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,44 +1,95 @@ -# Contributor Code of Conduct +# Code of Conduct -As contributors and maintainers of this project, -and in the interest of fostering an open and welcoming community, -we pledge to respect all people who contribute through reporting issues, -posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project -a harassment-free experience for everyone, -regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, religion, or nationality. +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments -* Public or private harassment -* Publishing other's private information, -such as physical or electronic -addresses, without explicit permission -* Other unethical or unprofessional conduct. +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct. -By adopting this Code of Conduct, -project maintainers commit themselves to fairly and consistently -applying these principles to every aspect of managing this project. -Project maintainers who do not follow or enforce the Code of Conduct -may be permanently removed from the project team. - -This code of conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior -may be reported by opening an issue -or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, -available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + + +Reports should be directed to *googleapis-stewards@google.com*, the +Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 27b38725..62af0707 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -21,8 +21,8 @@ In order to add a feature: - The feature must be documented in both the API and narrative documentation. -- The feature must work fully on the following CPython versions: 2.7, - 3.5, 3.6, 3.7 and 3.8 on both UNIX and Windows. +- The feature must work fully on the following CPython versions: + 3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows. - The feature must not add unnecessary dependencies (where "unnecessary" is of course subjective, but new dependencies should @@ -80,25 +80,6 @@ We use `nox `__ to instrument our tests. .. nox: https://pypi.org/project/nox/ -Note on Editable Installs / Develop Mode -======================================== - -- As mentioned previously, using ``setuptools`` in `develop mode`_ - or a ``pip`` `editable install`_ is not possible with this - library. This is because this library uses `namespace packages`_. - For context see `Issue #2316`_ and the relevant `PyPA issue`_. - - Since ``editable`` / ``develop`` mode can't be used, packages - need to be installed directly. Hence your changes to the source - tree don't get incorporated into the **already installed** - package. - -.. _namespace packages: https://www.python.org/dev/peps/pep-0420/ -.. _Issue #2316: https://github.com/GoogleCloudPlatform/google-cloud-python/issues/2316 -.. _PyPA issue: https://github.com/pypa/packaging-problems/issues/12 -.. _develop mode: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode -.. _editable install: https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs - ***************************************** I'm getting weird errors... Can you help? ***************************************** @@ -130,6 +111,16 @@ Coding Style should point to the official ``googleapis`` checkout and the the branch should be the main branch on that remote (``master``). +- This repository contains configuration for the + `pre-commit `__ tool, which automates checking + our linters during a commit. If you have it installed on your ``$PATH``, + you can enable enforcing those checks via: + +.. code-block:: bash + + $ pre-commit install + pre-commit installed at .git/hooks/pre-commit + Exceptions to PEP8: - Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for @@ -211,25 +202,24 @@ Supported Python Versions We support: -- `Python 3.5`_ - `Python 3.6`_ - `Python 3.7`_ - `Python 3.8`_ +- `Python 3.9`_ -.. _Python 3.5: https://docs.python.org/3.5/ .. _Python 3.6: https://docs.python.org/3.6/ .. _Python 3.7: https://docs.python.org/3.7/ .. _Python 3.8: https://docs.python.org/3.8/ +.. _Python 3.9: https://docs.python.org/3.9/ Supported versions can be found in our ``noxfile.py`` `config`_. .. _config: https://github.com/googleapis/python-analytics-admin/blob/master/noxfile.py -Python 2.7 support is deprecated. All code changes should maintain Python 2.7 compatibility until January 1, 2020. We also explicitly decided to support Python 3 beginning with version -3.5. Reasons for this include: +3.6. Reasons for this include: - Encouraging use of newest versions of Python 3 - Taking the lead of `prominent`_ open-source `projects`_ diff --git a/LICENSE b/LICENSE index a8ee855d..d6456956 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ - Apache License + + Apache License Version 2.0, January 2004 - https://www.apache.org/licenses/ + http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -192,7 +193,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 + 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, diff --git a/docs/_static/custom.css b/docs/_static/custom.css index 0abaf229..bcd37bbd 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -1,4 +1,9 @@ div#python2-eol { border-color: red; border-width: medium; -} \ No newline at end of file +} + +/* Ensure minimum width for 'Parameters' / 'Returns' column */ +dl.field-list > dt { + min-width: 100px +} diff --git a/docs/admin_v1alpha/analytics_admin_service.rst b/docs/admin_v1alpha/analytics_admin_service.rst new file mode 100644 index 00000000..25d3cf20 --- /dev/null +++ b/docs/admin_v1alpha/analytics_admin_service.rst @@ -0,0 +1,11 @@ +AnalyticsAdminService +--------------------------------------- + +.. automodule:: google.analytics.admin_v1alpha.services.analytics_admin_service + :members: + :inherited-members: + + +.. automodule:: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers + :members: + :inherited-members: diff --git a/docs/admin_v1alpha/services.rst b/docs/admin_v1alpha/services.rst index e1c39eb2..8d20fd9c 100644 --- a/docs/admin_v1alpha/services.rst +++ b/docs/admin_v1alpha/services.rst @@ -1,6 +1,6 @@ Services for Google Analytics Admin v1alpha API =============================================== +.. toctree:: + :maxdepth: 2 -.. automodule:: google.analytics.admin_v1alpha.services.analytics_admin_service - :members: - :inherited-members: + analytics_admin_service diff --git a/docs/admin_v1alpha/types.rst b/docs/admin_v1alpha/types.rst index b6a700a9..30d49a78 100644 --- a/docs/admin_v1alpha/types.rst +++ b/docs/admin_v1alpha/types.rst @@ -3,3 +3,5 @@ Types for Google Analytics Admin v1alpha API .. automodule:: google.analytics.admin_v1alpha.types :members: + :undoc-members: + :show-inheritance: diff --git a/docs/conf.py b/docs/conf.py index c977cf8e..9054574e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,12 +20,16 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath("..")) +# For plugins that can not read conf.py. +# See also: https://github.com/docascode/sphinx-docfx-yaml/issues/85 +sys.path.insert(0, os.path.abspath(".")) + __version__ = "" # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "1.6.3" +needs_sphinx = "1.5.5" # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -35,6 +39,7 @@ "sphinx.ext.autosummary", "sphinx.ext.intersphinx", "sphinx.ext.coverage", + "sphinx.ext.doctest", "sphinx.ext.napoleon", "sphinx.ext.todo", "sphinx.ext.viewcode", @@ -90,7 +95,12 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ["_build"] +exclude_patterns = [ + "_build", + "samples/AUTHORING_GUIDE.md", + "samples/CONTRIBUTING.md", + "samples/snippets/README.rst", +] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -335,10 +345,11 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "python": ("https://python.readthedocs.org/en/latest/", None), + "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), - "grpc": ("https://grpc.io/grpc/python/", None), + "grpc": ("https://grpc.github.io/grpc/python/", None), + "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), } diff --git a/google/analytics/admin/__init__.py b/google/analytics/admin/__init__.py index ac7fa0cd..2a25656a 100644 --- a/google/analytics/admin/__init__.py +++ b/google/analytics/admin/__init__.py @@ -96,6 +96,12 @@ from google.analytics.admin_v1alpha.types.analytics_admin import GetPropertyRequest from google.analytics.admin_v1alpha.types.analytics_admin import GetUserLinkRequest from google.analytics.admin_v1alpha.types.analytics_admin import GetWebDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListAccountSummariesRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListAccountSummariesResponse, +) from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsRequest from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsResponse from google.analytics.admin_v1alpha.types.analytics_admin import ( @@ -160,6 +166,7 @@ UpdateWebDataStreamRequest, ) from google.analytics.admin_v1alpha.types.resources import Account +from google.analytics.admin_v1alpha.types.resources import AccountSummary from google.analytics.admin_v1alpha.types.resources import AndroidAppDataStream from google.analytics.admin_v1alpha.types.resources import AuditUserLink from google.analytics.admin_v1alpha.types.resources import DataSharingSettings @@ -171,11 +178,13 @@ from google.analytics.admin_v1alpha.types.resources import IosAppDataStream from google.analytics.admin_v1alpha.types.resources import MaximumUserAccess from google.analytics.admin_v1alpha.types.resources import Property +from google.analytics.admin_v1alpha.types.resources import PropertySummary from google.analytics.admin_v1alpha.types.resources import UserLink from google.analytics.admin_v1alpha.types.resources import WebDataStream __all__ = ( "Account", + "AccountSummary", "AnalyticsAdminServiceAsyncClient", "AnalyticsAdminServiceClient", "AndroidAppDataStream", @@ -220,6 +229,8 @@ "GoogleAdsLink", "IndustryCategory", "IosAppDataStream", + "ListAccountSummariesRequest", + "ListAccountSummariesResponse", "ListAccountsRequest", "ListAccountsResponse", "ListAndroidAppDataStreamsRequest", @@ -238,6 +249,7 @@ "ListWebDataStreamsResponse", "MaximumUserAccess", "Property", + "PropertySummary", "ProvisionAccountTicketRequest", "ProvisionAccountTicketResponse", "UpdateAccountRequest", diff --git a/google/analytics/admin_v1alpha/__init__.py b/google/analytics/admin_v1alpha/__init__.py index 50e22774..9132398e 100644 --- a/google/analytics/admin_v1alpha/__init__.py +++ b/google/analytics/admin_v1alpha/__init__.py @@ -49,6 +49,8 @@ from .types.analytics_admin import GetPropertyRequest from .types.analytics_admin import GetUserLinkRequest from .types.analytics_admin import GetWebDataStreamRequest +from .types.analytics_admin import ListAccountSummariesRequest +from .types.analytics_admin import ListAccountSummariesResponse from .types.analytics_admin import ListAccountsRequest from .types.analytics_admin import ListAccountsResponse from .types.analytics_admin import ListAndroidAppDataStreamsRequest @@ -77,6 +79,7 @@ from .types.analytics_admin import UpdateUserLinkRequest from .types.analytics_admin import UpdateWebDataStreamRequest from .types.resources import Account +from .types.resources import AccountSummary from .types.resources import AndroidAppDataStream from .types.resources import AuditUserLink from .types.resources import DataSharingSettings @@ -88,12 +91,14 @@ from .types.resources import IosAppDataStream from .types.resources import MaximumUserAccess from .types.resources import Property +from .types.resources import PropertySummary from .types.resources import UserLink from .types.resources import WebDataStream __all__ = ( "Account", + "AccountSummary", "AndroidAppDataStream", "AuditUserLink", "AuditUserLinksRequest", @@ -136,6 +141,8 @@ "GoogleAdsLink", "IndustryCategory", "IosAppDataStream", + "ListAccountSummariesRequest", + "ListAccountSummariesResponse", "ListAccountsRequest", "ListAccountsResponse", "ListAndroidAppDataStreamsRequest", @@ -154,6 +161,7 @@ "ListWebDataStreamsResponse", "MaximumUserAccess", "Property", + "PropertySummary", "ProvisionAccountTicketRequest", "ProvisionAccountTicketResponse", "UpdateAccountRequest", diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py index 5f5d624d..27bd1270 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py @@ -35,50 +35,124 @@ from google.protobuf import timestamp_pb2 as timestamp # type: ignore from google.protobuf import wrappers_pb2 as wrappers # type: ignore -from .transports.base import AnalyticsAdminServiceTransport +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 (App+Web).""" + """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 ) - - property_path = staticmethod(AnalyticsAdminServiceClient.property_path) - - user_link_path = staticmethod(AnalyticsAdminServiceClient.user_link_path) - + parse_android_app_data_stream_path = staticmethod( + AnalyticsAdminServiceClient.parse_android_app_data_stream_path + ) + data_sharing_settings_path = staticmethod( + AnalyticsAdminServiceClient.data_sharing_settings_path + ) + parse_data_sharing_settings_path = staticmethod( + AnalyticsAdminServiceClient.parse_data_sharing_settings_path + ) enhanced_measurement_settings_path = staticmethod( AnalyticsAdminServiceClient.enhanced_measurement_settings_path ) - + parse_enhanced_measurement_settings_path = staticmethod( + AnalyticsAdminServiceClient.parse_enhanced_measurement_settings_path + ) + firebase_link_path = staticmethod(AnalyticsAdminServiceClient.firebase_link_path) + parse_firebase_link_path = staticmethod( + AnalyticsAdminServiceClient.parse_firebase_link_path + ) + global_site_tag_path = staticmethod( + AnalyticsAdminServiceClient.global_site_tag_path + ) + parse_global_site_tag_path = staticmethod( + AnalyticsAdminServiceClient.parse_global_site_tag_path + ) google_ads_link_path = staticmethod( AnalyticsAdminServiceClient.google_ads_link_path ) - - firebase_link_path = staticmethod(AnalyticsAdminServiceClient.firebase_link_path) - + parse_google_ads_link_path = staticmethod( + AnalyticsAdminServiceClient.parse_google_ads_link_path + ) + ios_app_data_stream_path = staticmethod( + AnalyticsAdminServiceClient.ios_app_data_stream_path + ) + parse_ios_app_data_stream_path = staticmethod( + AnalyticsAdminServiceClient.parse_ios_app_data_stream_path + ) + property_path = staticmethod(AnalyticsAdminServiceClient.property_path) + parse_property_path = staticmethod(AnalyticsAdminServiceClient.parse_property_path) + user_link_path = staticmethod(AnalyticsAdminServiceClient.user_link_path) + parse_user_link_path = staticmethod( + AnalyticsAdminServiceClient.parse_user_link_path + ) web_data_stream_path = staticmethod( AnalyticsAdminServiceClient.web_data_stream_path ) + parse_web_data_stream_path = staticmethod( + AnalyticsAdminServiceClient.parse_web_data_stream_path + ) - ios_app_data_stream_path = staticmethod( - AnalyticsAdminServiceClient.ios_app_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 ) - account_path = staticmethod(AnalyticsAdminServiceClient.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 + ) + + from_service_account_info = AnalyticsAdminServiceClient.from_service_account_info from_service_account_file = AnalyticsAdminServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> AnalyticsAdminServiceTransport: + """Return the transport used by the client instance. + + Returns: + AnalyticsAdminServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(AnalyticsAdminServiceClient).get_transport_class, type(AnalyticsAdminServiceClient), @@ -90,6 +164,7 @@ def __init__( credentials: credentials.Credentials = None, transport: Union[str, AnalyticsAdminServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the analytics admin service client. @@ -105,16 +180,19 @@ def __init__( 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 + 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, this is the default value for - the environment variable) and "auto" (auto switch to the default - mTLS endpoint if client SSL credentials is present). However, - the ``api_endpoint`` property takes precedence if provided. - (2) The ``client_cert_source`` property is used to provide client - SSL credentials for mutual TLS transport. If not provided, the - default SSL credentials will be used if present. + 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 @@ -122,7 +200,10 @@ def __init__( """ self._client = AnalyticsAdminServiceClient( - credentials=credentials, transport=transport, client_options=client_options, + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, ) async def get_account( @@ -135,16 +216,15 @@ async def get_account( metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Account: r"""Lookup for a single Account. - Throws "Target not found" if no such account found, or - if caller does not have permissions to access it. Args: - request (:class:`~.analytics_admin.GetAccountRequest`): + 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". + Example: "accounts/100" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -156,7 +236,7 @@ async def get_account( sent along with the request as metadata. Returns: - ~.resources.Account: + google.analytics.admin_v1alpha.types.Account: A resource message representing a Google Analytics account. @@ -164,7 +244,8 @@ async def get_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. - if request is not None and any([name]): + 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." @@ -183,7 +264,7 @@ async def get_account( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_account, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -207,13 +288,13 @@ async def list_accounts( metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAccountsAsyncPager: r"""Returns all accounts accessible by the caller. - Note that these accounts might not currently have - App+Web properties. Soft-deleted (ie: "trashed") - accounts are excluded by default. Returns an empty list - if no relevant accounts are found. + 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:`~.analytics_admin.ListAccountsRequest`): + request (:class:`google.analytics.admin_v1alpha.types.ListAccountsRequest`): The request object. Request message for ListAccounts RPC. @@ -224,7 +305,7 @@ async def list_accounts( sent along with the request as metadata. Returns: - ~.pagers.ListAccountsAsyncPager: + 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 @@ -240,7 +321,7 @@ async def list_accounts( rpc = gapic_v1.method_async.wrap_method( self._client._transport.list_accounts, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Send the request. @@ -277,13 +358,14 @@ async def delete_account( Returns an error if the target is not found. Args: - request (:class:`~.analytics_admin.DeleteAccountRequest`): + 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". + Example: "accounts/100" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -297,7 +379,8 @@ async def delete_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. - if request is not None and any([name]): + 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." @@ -316,7 +399,7 @@ async def delete_account( rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_account, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -343,18 +426,22 @@ async def update_account( r"""Updates an account. Args: - request (:class:`~.analytics_admin.UpdateAccountRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdateAccountRequest`): The request object. Request message for UpdateAccount RPC. - account (:class:`~.resources.Account`): + 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:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -366,7 +453,7 @@ async def update_account( sent along with the request as metadata. Returns: - ~.resources.Account: + google.analytics.admin_v1alpha.types.Account: A resource message representing a Google Analytics account. @@ -374,7 +461,8 @@ async def update_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. - if request is not None and any([account, update_mask]): + 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." @@ -395,7 +483,7 @@ async def update_account( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_account, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -423,7 +511,7 @@ async def provision_account_ticket( r"""Requests a ticket for creating an account. Args: - request (:class:`~.analytics_admin.ProvisionAccountTicketRequest`): + request (:class:`google.analytics.admin_v1alpha.types.ProvisionAccountTicketRequest`): The request object. Request message for ProvisionAccountTicket RPC. @@ -434,7 +522,7 @@ async def provision_account_ticket( sent along with the request as metadata. Returns: - ~.analytics_admin.ProvisionAccountTicketResponse: + google.analytics.admin_v1alpha.types.ProvisionAccountTicketResponse: Response message for ProvisionAccountTicket RPC. @@ -448,7 +536,7 @@ async def provision_account_ticket( rpc = gapic_v1.method_async.wrap_method( self._client._transport.provision_account_ticket, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Send the request. @@ -457,6 +545,61 @@ async def provision_account_ticket( # 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, @@ -466,17 +609,15 @@ async def get_property( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Property: - r"""Lookup for a single "App+Web" Property. - Throws "Target not found" if no such property found, if - property is not of the type "App+Web", or if caller does - not have permissions to access it. + r"""Lookup for a single "GA4" Property. Args: - request (:class:`~.analytics_admin.GetPropertyRequest`): + 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". + 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. @@ -488,15 +629,16 @@ async def get_property( sent along with the request as metadata. Returns: - ~.resources.Property: + google.analytics.admin_v1alpha.types.Property: A resource message representing a - Google Analytics App+Web property. + 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. - if request is not None and any([name]): + 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." @@ -515,7 +657,7 @@ async def get_property( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_property, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -540,14 +682,14 @@ async def list_properties( ) -> pagers.ListPropertiesAsyncPager: r"""Returns child Properties under the specified parent Account. - Only "App+Web" properties will be returned. + 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:`~.analytics_admin.ListPropertiesRequest`): + request (:class:`google.analytics.admin_v1alpha.types.ListPropertiesRequest`): The request object. Request message for ListProperties RPC. @@ -558,7 +700,7 @@ async def list_properties( sent along with the request as metadata. Returns: - ~.pagers.ListPropertiesAsyncPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListPropertiesAsyncPager: Response message for ListProperties RPC. Iterating over this object will yield @@ -575,7 +717,7 @@ async def list_properties( rpc = gapic_v1.method_async.wrap_method( self._client._transport.list_properties, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Send the request. @@ -599,17 +741,18 @@ async def create_property( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Property: - r"""Creates an "App+Web" property with the specified - location and attributes. + r"""Creates an "GA4" property with the specified location + and attributes. Args: - request (:class:`~.analytics_admin.CreatePropertyRequest`): + request (:class:`google.analytics.admin_v1alpha.types.CreatePropertyRequest`): The request object. Request message for CreateProperty RPC. - property (:class:`~.resources.Property`): + 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. @@ -621,15 +764,16 @@ async def create_property( sent along with the request as metadata. Returns: - ~.resources.Property: + google.analytics.admin_v1alpha.types.Property: A resource message representing a - Google Analytics App+Web property. + 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. - if request is not None and any([property]): + 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." @@ -648,7 +792,7 @@ async def create_property( rpc = gapic_v1.method_async.wrap_method( self._client._transport.create_property, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Send the request. @@ -677,16 +821,17 @@ async def delete_property( purged. https://support.google.com/analytics/answer/6154772 Returns an error if the target is not found, or is not - an App+Web Property. + an GA4 Property. Args: - request (:class:`~.analytics_admin.DeletePropertyRequest`): + 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". + "properties/1000" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -700,7 +845,8 @@ async def delete_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. - if request is not None and any([name]): + 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." @@ -719,7 +865,7 @@ async def delete_property( rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_property, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -746,19 +892,23 @@ async def update_property( r"""Updates a property. Args: - request (:class:`~.analytics_admin.UpdatePropertyRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdatePropertyRequest`): The request object. Request message for UpdateProperty RPC. - property (:class:`~.resources.Property`): + 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:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -770,15 +920,16 @@ async def update_property( sent along with the request as metadata. Returns: - ~.resources.Property: + google.analytics.admin_v1alpha.types.Property: A resource message representing a - Google Analytics App+Web property. + 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. - if request is not None and any([property, update_mask]): + 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." @@ -799,7 +950,7 @@ async def update_property( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_property, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -829,11 +980,12 @@ async def get_user_link( property. Args: - request (:class:`~.analytics_admin.GetUserLinkRequest`): + 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. @@ -845,7 +997,7 @@ async def get_user_link( sent along with the request as metadata. Returns: - ~.resources.UserLink: + google.analytics.admin_v1alpha.types.UserLink: A resource message representing a user's permissions on an Account or Property resource. @@ -854,7 +1006,8 @@ async def get_user_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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." @@ -873,7 +1026,7 @@ async def get_user_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_user_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -900,7 +1053,7 @@ async def batch_get_user_links( account or property. Args: - request (:class:`~.analytics_admin.BatchGetUserLinksRequest`): + request (:class:`google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest`): The request object. Request message for BatchGetUserLinks RPC. @@ -911,7 +1064,7 @@ async def batch_get_user_links( sent along with the request as metadata. Returns: - ~.analytics_admin.BatchGetUserLinksResponse: + google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse: Response message for BatchGetUserLinks RPC. @@ -925,7 +1078,7 @@ async def batch_get_user_links( rpc = gapic_v1.method_async.wrap_method( self._client._transport.batch_get_user_links, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -952,12 +1105,13 @@ async def list_user_links( r"""Lists all user links on an account or property. Args: - request (:class:`~.analytics_admin.ListUserLinksRequest`): + 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. @@ -969,7 +1123,7 @@ async def list_user_links( sent along with the request as metadata. Returns: - ~.pagers.ListUserLinksAsyncPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListUserLinksAsyncPager: Response message for ListUserLinks RPC. Iterating over this object will yield @@ -980,7 +1134,8 @@ async def list_user_links( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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." @@ -999,7 +1154,7 @@ async def list_user_links( rpc = gapic_v1.method_async.wrap_method( self._client._transport.list_user_links, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1041,7 +1196,7 @@ async def audit_user_links( in the GA or GMP UIs. Args: - request (:class:`~.analytics_admin.AuditUserLinksRequest`): + request (:class:`google.analytics.admin_v1alpha.types.AuditUserLinksRequest`): The request object. Request message for AuditUserLinks RPC. @@ -1052,7 +1207,7 @@ async def audit_user_links( sent along with the request as metadata. Returns: - ~.pagers.AuditUserLinksAsyncPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.AuditUserLinksAsyncPager: Response message for AuditUserLinks RPC. Iterating over this object will yield @@ -1069,7 +1224,7 @@ async def audit_user_links( rpc = gapic_v1.method_async.wrap_method( self._client._transport.audit_user_links, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1107,7 +1262,7 @@ async def create_user_link( permissions specified in the new UserLink. Args: - request (:class:`~.analytics_admin.CreateUserLinkRequest`): + request (:class:`google.analytics.admin_v1alpha.types.CreateUserLinkRequest`): The request object. Request message for CreateUserLink RPC. Users can have multiple email addresses associated with @@ -1121,10 +1276,11 @@ async def create_user_link( 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:`~.resources.UserLink`): + 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 @@ -1137,7 +1293,7 @@ async def create_user_link( sent along with the request as metadata. Returns: - ~.resources.UserLink: + google.analytics.admin_v1alpha.types.UserLink: A resource message representing a user's permissions on an Account or Property resource. @@ -1146,7 +1302,8 @@ async def create_user_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, user_link]): + 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." @@ -1167,7 +1324,7 @@ async def create_user_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.create_user_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1196,7 +1353,7 @@ async def batch_create_user_links( created, none of the UserLinks will be created. Args: - request (:class:`~.analytics_admin.BatchCreateUserLinksRequest`): + request (:class:`google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest`): The request object. Request message for BatchCreateUserLinks RPC. @@ -1207,7 +1364,7 @@ async def batch_create_user_links( sent along with the request as metadata. Returns: - ~.analytics_admin.BatchCreateUserLinksResponse: + google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse: Response message for BatchCreateUserLinks RPC. @@ -1221,7 +1378,7 @@ async def batch_create_user_links( rpc = gapic_v1.method_async.wrap_method( self._client._transport.batch_create_user_links, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1248,10 +1405,10 @@ async def update_user_link( r"""Updates a user link on an account or property. Args: - request (:class:`~.analytics_admin.UpdateUserLinkRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdateUserLinkRequest`): The request object. Request message for UpdateUserLink RPC. - user_link (:class:`~.resources.UserLink`): + 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 @@ -1264,7 +1421,7 @@ async def update_user_link( sent along with the request as metadata. Returns: - ~.resources.UserLink: + google.analytics.admin_v1alpha.types.UserLink: A resource message representing a user's permissions on an Account or Property resource. @@ -1273,7 +1430,8 @@ async def update_user_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([user_link]): + 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." @@ -1292,7 +1450,7 @@ async def update_user_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_user_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1321,7 +1479,7 @@ async def batch_update_user_links( account or property. Args: - request (:class:`~.analytics_admin.BatchUpdateUserLinksRequest`): + request (:class:`google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest`): The request object. Request message for BatchUpdateUserLinks RPC. @@ -1332,7 +1490,7 @@ async def batch_update_user_links( sent along with the request as metadata. Returns: - ~.analytics_admin.BatchUpdateUserLinksResponse: + google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse: Response message for BatchUpdateUserLinks RPC. @@ -1346,7 +1504,7 @@ async def batch_update_user_links( rpc = gapic_v1.method_async.wrap_method( self._client._transport.batch_update_user_links, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1373,12 +1531,13 @@ async def delete_user_link( r"""Deletes a user link on an account or property. Args: - request (:class:`~.analytics_admin.DeleteUserLinkRequest`): + 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. @@ -1392,7 +1551,8 @@ async def delete_user_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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." @@ -1411,7 +1571,7 @@ async def delete_user_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_user_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1437,7 +1597,7 @@ async def batch_delete_user_links( account or property. Args: - request (:class:`~.analytics_admin.BatchDeleteUserLinksRequest`): + request (:class:`google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest`): The request object. Request message for BatchDeleteUserLinks RPC. @@ -1456,7 +1616,7 @@ async def batch_delete_user_links( rpc = gapic_v1.method_async.wrap_method( self._client._transport.batch_delete_user_links, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1480,19 +1640,17 @@ async def get_web_data_stream( metadata: Sequence[Tuple[str, str]] = (), ) -> resources.WebDataStream: r"""Lookup for a single WebDataStream - Throws "Target not found" if no such web data stream - found, or if the caller does not have permissions to - access it. Args: - request (:class:`~.analytics_admin.GetWebDataStreamRequest`): + 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". + Example: "properties/123/webDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -1504,7 +1662,7 @@ async def get_web_data_stream( sent along with the request as metadata. Returns: - ~.resources.WebDataStream: + google.analytics.admin_v1alpha.types.WebDataStream: A resource message representing a Google Analytics web stream. @@ -1512,7 +1670,8 @@ async def get_web_data_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. - if request is not None and any([name]): + 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." @@ -1531,7 +1690,7 @@ async def get_web_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_web_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1558,14 +1717,15 @@ async def delete_web_data_stream( r"""Deletes a web stream on a property. Args: - request (:class:`~.analytics_admin.DeleteWebDataStreamRequest`): + 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". + Example: "properties/123/webDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -1579,7 +1739,8 @@ async def delete_web_data_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. - if request is not None and any([name]): + 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." @@ -1598,7 +1759,7 @@ async def delete_web_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_web_data_stream, default_timeout=None, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1625,18 +1786,22 @@ async def update_web_data_stream( r"""Updates a web stream on a property. Args: - request (:class:`~.analytics_admin.UpdateWebDataStreamRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdateWebDataStreamRequest`): The request object. Request message for UpdateWebDataStream RPC. - web_data_stream (:class:`~.resources.WebDataStream`): + 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:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -1648,7 +1813,7 @@ async def update_web_data_stream( sent along with the request as metadata. Returns: - ~.resources.WebDataStream: + google.analytics.admin_v1alpha.types.WebDataStream: A resource message representing a Google Analytics web stream. @@ -1656,7 +1821,8 @@ async def update_web_data_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. - if request is not None and any([web_data_stream, update_mask]): + 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." @@ -1677,7 +1843,7 @@ async def update_web_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_web_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1708,17 +1874,18 @@ async def create_web_data_stream( attributes. Args: - request (:class:`~.analytics_admin.CreateWebDataStreamRequest`): + 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:`~.resources.WebDataStream`): + 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 @@ -1731,7 +1898,7 @@ async def create_web_data_stream( sent along with the request as metadata. Returns: - ~.resources.WebDataStream: + google.analytics.admin_v1alpha.types.WebDataStream: A resource message representing a Google Analytics web stream. @@ -1739,7 +1906,8 @@ async def create_web_data_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. - if request is not None and any([parent, web_data_stream]): + 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." @@ -1760,7 +1928,7 @@ async def create_web_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.create_web_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1791,14 +1959,15 @@ async def list_web_data_streams( data streams are found. Args: - request (:class:`~.analytics_admin.ListWebDataStreamsRequest`): + 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". + Id 123: "properties/123" + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -1810,7 +1979,7 @@ async def list_web_data_streams( sent along with the request as metadata. Returns: - ~.pagers.ListWebDataStreamsAsyncPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListWebDataStreamsAsyncPager: Request message for ListWebDataStreams RPC. Iterating over this object will yield @@ -1821,7 +1990,8 @@ async def list_web_data_streams( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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." @@ -1840,7 +2010,7 @@ async def list_web_data_streams( rpc = gapic_v1.method_async.wrap_method( self._client._transport.list_web_data_streams, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1871,19 +2041,17 @@ async def get_ios_app_data_stream( metadata: Sequence[Tuple[str, str]] = (), ) -> resources.IosAppDataStream: r"""Lookup for a single IosAppDataStream - Throws "Target not found" if no such iOS app data stream - found, or if the caller does not have permissions to - access it. Args: - request (:class:`~.analytics_admin.GetIosAppDataStreamRequest`): + 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". + Example: "properties/123/iosAppDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -1895,7 +2063,7 @@ async def get_ios_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.IosAppDataStream: + google.analytics.admin_v1alpha.types.IosAppDataStream: A resource message representing a Google Analytics IOS app stream. @@ -1903,7 +2071,8 @@ async def get_ios_app_data_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. - if request is not None and any([name]): + 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." @@ -1922,7 +2091,7 @@ async def get_ios_app_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_ios_app_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -1949,14 +2118,15 @@ async def delete_ios_app_data_stream( r"""Deletes an iOS app stream on a property. Args: - request (:class:`~.analytics_admin.DeleteIosAppDataStreamRequest`): + 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". + Example: "properties/123/iosAppDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -1970,7 +2140,8 @@ async def delete_ios_app_data_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. - if request is not None and any([name]): + 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." @@ -1989,7 +2160,7 @@ async def delete_ios_app_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_ios_app_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2016,19 +2187,23 @@ async def update_ios_app_data_stream( r"""Updates an iOS app stream on a property. Args: - request (:class:`~.analytics_admin.UpdateIosAppDataStreamRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdateIosAppDataStreamRequest`): The request object. Request message for UpdateIosAppDataStream RPC. - ios_app_data_stream (:class:`~.resources.IosAppDataStream`): + 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:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -2040,7 +2215,7 @@ async def update_ios_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.IosAppDataStream: + google.analytics.admin_v1alpha.types.IosAppDataStream: A resource message representing a Google Analytics IOS app stream. @@ -2048,7 +2223,8 @@ async def update_ios_app_data_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. - if request is not None and any([ios_app_data_stream, update_mask]): + 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." @@ -2069,7 +2245,7 @@ async def update_ios_app_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_ios_app_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2100,19 +2276,21 @@ async def create_ios_app_data_stream( location and attributes. Args: - request (:class:`~.analytics_admin.CreateIosAppDataStreamRequest`): + request (:class:`google.analytics.admin_v1alpha.types.CreateIosAppDataStreamRequest`): The request object. Request message for CreateIosAppDataStream RPC. parent (:class:`str`): Required. The parent resource where this ios app data stream will be created. Format: properties/123 + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - ios_app_data_stream (:class:`~.resources.IosAppDataStream`): + ios_app_data_stream (:class:`google.analytics.admin_v1alpha.types.IosAppDataStream`): Required. The iOS app data stream to create. + This corresponds to the ``ios_app_data_stream`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2124,7 +2302,7 @@ async def create_ios_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.IosAppDataStream: + google.analytics.admin_v1alpha.types.IosAppDataStream: A resource message representing a Google Analytics IOS app stream. @@ -2132,7 +2310,8 @@ async def create_ios_app_data_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. - if request is not None and any([parent, ios_app_data_stream]): + has_flattened_params = any([parent, ios_app_data_stream]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -2153,7 +2332,7 @@ async def create_ios_app_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.create_ios_app_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2184,14 +2363,15 @@ async def list_ios_app_data_streams( iOS app data streams are found. Args: - request (:class:`~.analytics_admin.ListIosAppDataStreamsRequest`): + 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". + Id 123: "properties/123" + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2203,7 +2383,7 @@ async def list_ios_app_data_streams( sent along with the request as metadata. Returns: - ~.pagers.ListIosAppDataStreamsAsyncPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListIosAppDataStreamsAsyncPager: Request message for ListIosAppDataStreams RPC. Iterating over this object will yield @@ -2214,7 +2394,8 @@ async def list_ios_app_data_streams( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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." @@ -2233,7 +2414,7 @@ async def list_ios_app_data_streams( rpc = gapic_v1.method_async.wrap_method( self._client._transport.list_ios_app_data_streams, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2264,19 +2445,17 @@ async def get_android_app_data_stream( metadata: Sequence[Tuple[str, str]] = (), ) -> resources.AndroidAppDataStream: r"""Lookup for a single AndroidAppDataStream - Throws "Target not found" if no such android app data - stream found, or if the caller does not have permissions - to access it. Args: - request (:class:`~.analytics_admin.GetAndroidAppDataStreamRequest`): + 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". + Example: "properties/123/androidAppDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2288,7 +2467,7 @@ async def get_android_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.AndroidAppDataStream: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: A resource message representing a Google Analytics Android app stream. @@ -2296,7 +2475,8 @@ async def get_android_app_data_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. - if request is not None and any([name]): + 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." @@ -2315,7 +2495,7 @@ async def get_android_app_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_android_app_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2342,14 +2522,15 @@ async def delete_android_app_data_stream( r"""Deletes an android app stream on a property. Args: - request (:class:`~.analytics_admin.DeleteAndroidAppDataStreamRequest`): + 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". + Example: "properties/123/androidAppDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2363,7 +2544,8 @@ async def delete_android_app_data_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. - if request is not None and any([name]): + 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." @@ -2382,7 +2564,7 @@ async def delete_android_app_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_android_app_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2409,19 +2591,23 @@ async def update_android_app_data_stream( r"""Updates an android app stream on a property. Args: - request (:class:`~.analytics_admin.UpdateAndroidAppDataStreamRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdateAndroidAppDataStreamRequest`): The request object. Request message for UpdateAndroidAppDataStream RPC. - android_app_data_stream (:class:`~.resources.AndroidAppDataStream`): + 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:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -2433,7 +2619,7 @@ async def update_android_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.AndroidAppDataStream: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: A resource message representing a Google Analytics Android app stream. @@ -2441,7 +2627,8 @@ async def update_android_app_data_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. - if request is not None and any([android_app_data_stream, update_mask]): + 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." @@ -2462,7 +2649,7 @@ async def update_android_app_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_android_app_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2498,19 +2685,21 @@ async def create_android_app_data_stream( location and attributes. Args: - request (:class:`~.analytics_admin.CreateAndroidAppDataStreamRequest`): + request (:class:`google.analytics.admin_v1alpha.types.CreateAndroidAppDataStreamRequest`): The request object. Request message for CreateAndroidAppDataStream RPC. parent (:class:`str`): Required. The parent resource where this android app data stream will be created. Format: properties/123 + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - android_app_data_stream (:class:`~.resources.AndroidAppDataStream`): + android_app_data_stream (:class:`google.analytics.admin_v1alpha.types.AndroidAppDataStream`): Required. The android app stream to create. + This corresponds to the ``android_app_data_stream`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2522,7 +2711,7 @@ async def create_android_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.AndroidAppDataStream: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: A resource message representing a Google Analytics Android app stream. @@ -2530,7 +2719,8 @@ async def create_android_app_data_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. - if request is not None and any([parent, android_app_data_stream]): + has_flattened_params = any([parent, android_app_data_stream]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -2551,7 +2741,7 @@ async def create_android_app_data_stream( rpc = gapic_v1.method_async.wrap_method( self._client._transport.create_android_app_data_stream, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2582,14 +2772,15 @@ async def list_android_app_data_streams( android app streams are found. Args: - request (:class:`~.analytics_admin.ListAndroidAppDataStreamsRequest`): + 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". + Id 123: "properties/123" + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2601,7 +2792,7 @@ async def list_android_app_data_streams( sent along with the request as metadata. Returns: - ~.pagers.ListAndroidAppDataStreamsAsyncPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAndroidAppDataStreamsAsyncPager: Request message for ListAndroidDataStreams RPC. Iterating over this object will yield @@ -2612,7 +2803,8 @@ async def list_android_app_data_streams( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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." @@ -2631,7 +2823,7 @@ async def list_android_app_data_streams( rpc = gapic_v1.method_async.wrap_method( self._client._transport.list_android_app_data_streams, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2666,14 +2858,15 @@ async def get_enhanced_measurement_settings( enhanced measurement for these settings to take effect. Args: - request (:class:`~.analytics_admin.GetEnhancedMeasurementSettingsRequest`): + 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". + "properties/1000/webDataStreams/2000/enhancedMeasurementSettings" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2685,7 +2878,7 @@ async def get_enhanced_measurement_settings( sent along with the request as metadata. Returns: - ~.resources.EnhancedMeasurementSettings: + google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: Singleton resource under a WebDataStream, configuring measurement of additional site interactions and @@ -2695,7 +2888,8 @@ async def get_enhanced_measurement_settings( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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." @@ -2714,7 +2908,7 @@ async def get_enhanced_measurement_settings( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_enhanced_measurement_settings, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2744,18 +2938,22 @@ async def update_enhanced_measurement_settings( enhanced measurement for these settings to take effect. Args: - request (:class:`~.analytics_admin.UpdateEnhancedMeasurementSettingsRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdateEnhancedMeasurementSettingsRequest`): The request object. Request message for UpdateEnhancedMeasurementSettings RPC. - enhanced_measurement_settings (:class:`~.resources.EnhancedMeasurementSettings`): + 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:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -2767,7 +2965,7 @@ async def update_enhanced_measurement_settings( sent along with the request as metadata. Returns: - ~.resources.EnhancedMeasurementSettings: + google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: Singleton resource under a WebDataStream, configuring measurement of additional site interactions and @@ -2777,7 +2975,8 @@ async def update_enhanced_measurement_settings( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([enhanced_measurement_settings, update_mask]): + 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." @@ -2798,7 +2997,7 @@ async def update_enhanced_measurement_settings( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_enhanced_measurement_settings, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2834,18 +3033,20 @@ async def create_firebase_link( Properties can have at most one FirebaseLink. Args: - request (:class:`~.analytics_admin.CreateFirebaseLinkRequest`): + 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:`~.resources.FirebaseLink`): + 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. @@ -2857,15 +3058,16 @@ async def create_firebase_link( sent along with the request as metadata. Returns: - ~.resources.FirebaseLink: - A link between an App+Web property - and a Firebase project. + 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. - if request is not None and any([parent, firebase_link]): + 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." @@ -2886,7 +3088,7 @@ async def create_firebase_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.create_firebase_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2914,18 +3116,22 @@ async def update_firebase_link( r"""Updates a FirebaseLink on a property Args: - request (:class:`~.analytics_admin.UpdateFirebaseLinkRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdateFirebaseLinkRequest`): The request object. Request message for UpdateFirebaseLink RPC - firebase_link (:class:`~.resources.FirebaseLink`): + 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:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -2937,15 +3143,16 @@ async def update_firebase_link( sent along with the request as metadata. Returns: - ~.resources.FirebaseLink: - A link between an App+Web property - and a Firebase project. + 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. - if request is not None and any([firebase_link, update_mask]): + 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." @@ -2966,7 +3173,7 @@ async def update_firebase_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_firebase_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -2995,13 +3202,14 @@ async def delete_firebase_link( r"""Deletes a FirebaseLink on a property Args: - request (:class:`~.analytics_admin.DeleteFirebaseLinkRequest`): + 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. @@ -3015,7 +3223,8 @@ async def delete_firebase_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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." @@ -3034,7 +3243,7 @@ async def delete_firebase_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_firebase_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -3056,17 +3265,18 @@ async def list_firebase_links( retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.ListFirebaseLinksResponse: + ) -> pagers.ListFirebaseLinksAsyncPager: r"""Lists FirebaseLinks on a property. Properties can have at most one FirebaseLink. Args: - request (:class:`~.analytics_admin.ListFirebaseLinksRequest`): + 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. @@ -3078,15 +3288,19 @@ async def list_firebase_links( sent along with the request as metadata. Returns: - ~.analytics_admin.ListFirebaseLinksResponse: + 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. - if request is not None and any([parent]): + 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." @@ -3105,7 +3319,7 @@ async def list_firebase_links( rpc = gapic_v1.method_async.wrap_method( self._client._transport.list_firebase_links, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -3117,6 +3331,12 @@ async def list_firebase_links( # 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 @@ -3133,7 +3353,7 @@ async def get_global_site_tag( Site Tags are immutable singletons. Args: - request (:class:`~.analytics_admin.GetGlobalSiteTagRequest`): + request (:class:`google.analytics.admin_v1alpha.types.GetGlobalSiteTagRequest`): The request object. Request message for GetGlobalSiteTag RPC. name (:class:`str`): @@ -3142,7 +3362,8 @@ async def get_global_site_tag( Format: properties/{property_id}/webDataStreams/{stream_id}/globalSiteTag Example: - "properties/123/webDataStreams/456/globalSiteTag". + "properties/123/webDataStreams/456/globalSiteTag" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -3154,7 +3375,7 @@ async def get_global_site_tag( sent along with the request as metadata. Returns: - ~.resources.GlobalSiteTag: + google.analytics.admin_v1alpha.types.GlobalSiteTag: Read-only resource with the tag for sending data from a website to a WebDataStream. @@ -3163,7 +3384,8 @@ async def get_global_site_tag( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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." @@ -3182,7 +3404,7 @@ async def get_global_site_tag( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_global_site_tag, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -3210,18 +3432,20 @@ async def create_google_ads_link( r"""Creates a GoogleAdsLink. Args: - request (:class:`~.analytics_admin.CreateGoogleAdsLinkRequest`): + 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:`~.resources.GoogleAdsLink`): + 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. @@ -3233,15 +3457,16 @@ async def create_google_ads_link( sent along with the request as metadata. Returns: - ~.resources.GoogleAdsLink: - A link between an App+Web property - and a Google Ads account. + 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. - if request is not None and any([parent, google_ads_link]): + 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." @@ -3262,7 +3487,7 @@ async def create_google_ads_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.create_google_ads_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -3290,17 +3515,20 @@ async def update_google_ads_link( r"""Updates a GoogleAdsLink on a property Args: - request (:class:`~.analytics_admin.UpdateGoogleAdsLinkRequest`): + request (:class:`google.analytics.admin_v1alpha.types.UpdateGoogleAdsLinkRequest`): The request object. Request message for UpdateGoogleAdsLink RPC - google_ads_link (:class:`~.resources.GoogleAdsLink`): + 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:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -3312,15 +3540,16 @@ async def update_google_ads_link( sent along with the request as metadata. Returns: - ~.resources.GoogleAdsLink: - A link between an App+Web property - and a Google Ads account. + 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. - if request is not None and any([google_ads_link, update_mask]): + 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." @@ -3341,7 +3570,7 @@ async def update_google_ads_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.update_google_ads_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -3370,12 +3599,13 @@ async def delete_google_ads_link( r"""Deletes a GoogleAdsLink on a property Args: - request (:class:`~.analytics_admin.DeleteGoogleAdsLinkRequest`): + 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. @@ -3389,7 +3619,8 @@ async def delete_google_ads_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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." @@ -3408,7 +3639,7 @@ async def delete_google_ads_link( rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_google_ads_link, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -3434,12 +3665,13 @@ async def list_google_ads_links( r"""Lists GoogleAdsLinks on a property. Args: - request (:class:`~.analytics_admin.ListGoogleAdsLinksRequest`): + 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. @@ -3451,7 +3683,7 @@ async def list_google_ads_links( sent along with the request as metadata. Returns: - ~.pagers.ListGoogleAdsLinksAsyncPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListGoogleAdsLinksAsyncPager: Response message for ListGoogleAdsLinks RPC. Iterating over this object will yield @@ -3462,7 +3694,8 @@ async def list_google_ads_links( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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." @@ -3481,7 +3714,7 @@ async def list_google_ads_links( rpc = gapic_v1.method_async.wrap_method( self._client._transport.list_google_ads_links, default_timeout=60.0, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -3515,7 +3748,7 @@ async def get_data_sharing_settings( Data sharing settings are singletons. Args: - request (:class:`~.analytics_admin.GetDataSharingSettingsRequest`): + request (:class:`google.analytics.admin_v1alpha.types.GetDataSharingSettingsRequest`): The request object. Request message for GetDataSharingSettings RPC. name (:class:`str`): @@ -3523,7 +3756,8 @@ async def get_data_sharing_settings( lookup. Format: accounts/{account}/dataSharingSettings Example: - "accounts/1000/dataSharingSettings". + "accounts/1000/dataSharingSettings" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -3535,7 +3769,7 @@ async def get_data_sharing_settings( sent along with the request as metadata. Returns: - ~.resources.DataSharingSettings: + google.analytics.admin_v1alpha.types.DataSharingSettings: A resource message representing data sharing settings of a Google Analytics account. @@ -3544,7 +3778,8 @@ async def get_data_sharing_settings( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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." @@ -3563,7 +3798,7 @@ async def get_data_sharing_settings( rpc = gapic_v1.method_async.wrap_method( self._client._transport.get_data_sharing_settings, default_timeout=None, - client_info=_client_info, + client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; @@ -3580,11 +3815,11 @@ async def get_data_sharing_settings( try: - _client_info = gapic_v1.client_info.ClientInfo( + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=pkg_resources.get_distribution("google-analytics-admin",).version, ) except pkg_resources.DistributionNotFound: - _client_info = gapic_v1.client_info.ClientInfo() + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() __all__ = ("AnalyticsAdminServiceAsyncClient",) 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 26e9fedf..b3131d8a 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py @@ -16,17 +16,19 @@ # from collections import OrderedDict +from distutils import util import os import re -from typing import Callable, Dict, Sequence, Tuple, Type, Union +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import client_options as client_options_lib # type: ignore from google.api_core import exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials # type: ignore from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore @@ -37,7 +39,7 @@ from google.protobuf import timestamp_pb2 as timestamp # type: ignore from google.protobuf import wrappers_pb2 as wrappers # type: ignore -from .transports.base import AnalyticsAdminServiceTransport +from .transports.base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import AnalyticsAdminServiceGrpcTransport from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport @@ -78,7 +80,7 @@ def get_transport_class( class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta): - """Service Interface for the Analytics Admin API (App+Web).""" + """Service Interface for the Analytics Admin API (GA4).""" @staticmethod def _get_default_mtls_endpoint(api_endpoint): @@ -114,6 +116,22 @@ def _get_default_mtls_endpoint(api_endpoint): 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 @@ -126,7 +144,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + AnalyticsAdminServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -134,6 +152,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> AnalyticsAdminServiceTransport: + """Return the transport used by the client instance. + + Returns: + AnalyticsAdminServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def account_path(account: str,) -> str: """Return a fully-qualified account string.""" @@ -145,6 +172,19 @@ def parse_account_path(path: str) -> Dict[str, str]: m = re.match(r"^accounts/(?P.+?)$", path) return m.groupdict() if m else {} + @staticmethod + def account_summary_path(account_summary: str,) -> str: + """Return a fully-qualified account_summary string.""" + return "accountSummaries/{account_summary}".format( + account_summary=account_summary, + ) + + @staticmethod + def parse_account_summary_path(path: str) -> Dict[str, str]: + """Parse a account_summary path into its component segments.""" + m = re.match(r"^accountSummaries/(?P.+?)$", path) + return m.groupdict() if m else {} + @staticmethod def android_app_data_stream_path( property: str, android_app_data_stream: str, @@ -163,6 +203,17 @@ def parse_android_app_data_stream_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def data_sharing_settings_path(account: str,) -> str: + """Return a fully-qualified data_sharing_settings string.""" + return "accounts/{account}/dataSharingSettings".format(account=account,) + + @staticmethod + def parse_data_sharing_settings_path(path: str) -> Dict[str, str]: + """Parse a data_sharing_settings path into its component segments.""" + m = re.match(r"^accounts/(?P.+?)/dataSharingSettings$", path) + return m.groupdict() if m else {} + @staticmethod def enhanced_measurement_settings_path(property: str, web_data_stream: str,) -> str: """Return a fully-qualified enhanced_measurement_settings string.""" @@ -194,6 +245,17 @@ def parse_firebase_link_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def global_site_tag_path(property: str,) -> str: + """Return a fully-qualified global_site_tag string.""" + return "properties/{property}/globalSiteTag".format(property=property,) + + @staticmethod + def parse_global_site_tag_path(path: str) -> Dict[str, str]: + """Parse a global_site_tag path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/globalSiteTag$", path) + return m.groupdict() if m else {} + @staticmethod def google_ads_link_path(property: str, google_ads_link: str,) -> str: """Return a fully-qualified google_ads_link string.""" @@ -266,12 +328,72 @@ def parse_web_data_stream_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def common_billing_account_path(billing_account: str,) -> str: + """Return a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str, str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str,) -> str: + """Return a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder,) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str, str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str,) -> str: + """Return a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization,) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str, str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str,) -> str: + """Return a fully-qualified project string.""" + return "projects/{project}".format(project=project,) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str, str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str,) -> str: + """Return a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str, str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + def __init__( self, *, - credentials: credentials.Credentials = None, - transport: Union[str, AnalyticsAdminServiceTransport] = None, - client_options: ClientOptions = None, + credentials: Optional[credentials.Credentials] = None, + transport: Union[str, AnalyticsAdminServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the analytics admin service client. @@ -281,51 +403,77 @@ def __init__( 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 (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. + 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 + 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, this is the default value for - the environment variable) and "auto" (auto switch to the default - mTLS endpoint if client SSL credentials is present). However, - the ``api_endpoint`` property takes precedence if provided. - (2) The ``client_cert_source`` property is used to provide client - SSL credentials for mutual TLS transport. If not provided, the - default SSL credentials will be used if present. + 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 = ClientOptions.from_dict(client_options) + client_options = client_options_lib.from_dict(client_options) if client_options is None: - client_options = ClientOptions.ClientOptions() + 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")) + ) - if client_options.api_endpoint is None: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "never") + ssl_credentials = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + import grpc # type: ignore + + cert, key = client_options.client_cert_source() + ssl_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + is_mtls = True + else: + creds = SslCredentials() + is_mtls = creds.is_mtls + ssl_credentials = creds.ssl_credentials if is_mtls else None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") if use_mtls_env == "never": - client_options.api_endpoint = self.DEFAULT_ENDPOINT + api_endpoint = self.DEFAULT_ENDPOINT elif use_mtls_env == "always": - client_options.api_endpoint = self.DEFAULT_MTLS_ENDPOINT + api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - has_client_cert_source = ( - client_options.client_cert_source is not None - or mtls.has_default_client_cert_source() - ) - client_options.api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT - if has_client_cert_source - else self.DEFAULT_ENDPOINT + api_endpoint = ( + self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT ) else: raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS value. Accepted values: never, auto, always" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" ) # Save or instantiate the transport. @@ -349,11 +497,11 @@ def __init__( self._transport = Transport( credentials=credentials, credentials_file=client_options.credentials_file, - host=client_options.api_endpoint, + host=api_endpoint, scopes=client_options.scopes, - api_mtls_endpoint=client_options.api_endpoint, - client_cert_source=client_options.client_cert_source, + ssl_channel_credentials=ssl_credentials, quota_project_id=client_options.quota_project_id, + client_info=client_info, ) def get_account( @@ -366,16 +514,15 @@ def get_account( metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Account: r"""Lookup for a single Account. - Throws "Target not found" if no such account found, or - if caller does not have permissions to access it. Args: - request (:class:`~.analytics_admin.GetAccountRequest`): + request (google.analytics.admin_v1alpha.types.GetAccountRequest): The request object. Request message for GetAccount RPC. - name (:class:`str`): + name (str): Required. The name of the account to lookup. Format: accounts/{account} - Example: "accounts/100". + Example: "accounts/100" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -387,7 +534,7 @@ def get_account( sent along with the request as metadata. Returns: - ~.resources.Account: + google.analytics.admin_v1alpha.types.Account: A resource message representing a Google Analytics account. @@ -395,25 +542,29 @@ def get_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_account, default_timeout=60.0, client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.get_account] # Certain fields should be provided within the metadata header; # add these here. @@ -436,13 +587,13 @@ def list_accounts( metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAccountsPager: r"""Returns all accounts accessible by the caller. - Note that these accounts might not currently have - App+Web properties. Soft-deleted (ie: "trashed") - accounts are excluded by default. Returns an empty list - if no relevant accounts are found. + 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:`~.analytics_admin.ListAccountsRequest`): + request (google.analytics.admin_v1alpha.types.ListAccountsRequest): The request object. Request message for ListAccounts RPC. @@ -453,7 +604,7 @@ def list_accounts( sent along with the request as metadata. Returns: - ~.pagers.ListAccountsPager: + 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 @@ -462,15 +613,16 @@ def list_accounts( """ # Create or coerce a protobuf request object. - request = analytics_admin.ListAccountsRequest(request) + # 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 = gapic_v1.method.wrap_method( - self._transport.list_accounts, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.list_accounts] # Send the request. response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) @@ -506,13 +658,14 @@ def delete_account( Returns an error if the target is not found. Args: - request (:class:`~.analytics_admin.DeleteAccountRequest`): + request (google.analytics.admin_v1alpha.types.DeleteAccountRequest): The request object. Request message for DeleteAccount RPC. - name (:class:`str`): + name (str): Required. The name of the Account to soft-delete. Format: accounts/{account} - Example: "accounts/100". + Example: "accounts/100" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -526,27 +679,29 @@ def delete_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.delete_account, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.delete_account] # Certain fields should be provided within the metadata header; # add these here. @@ -572,18 +727,22 @@ def update_account( r"""Updates an account. Args: - request (:class:`~.analytics_admin.UpdateAccountRequest`): + request (google.analytics.admin_v1alpha.types.UpdateAccountRequest): The request object. Request message for UpdateAccount RPC. - account (:class:`~.resources.Account`): + 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 (:class:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -595,7 +754,7 @@ def update_account( sent along with the request as metadata. Returns: - ~.resources.Account: + google.analytics.admin_v1alpha.types.Account: A resource message representing a Google Analytics account. @@ -603,29 +762,31 @@ def update_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. - if request is not None and any([account, update_mask]): + 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) + # 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 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 + 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.wrap_method( - self._transport.update_account, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.update_account] # Certain fields should be provided within the metadata header; # add these here. @@ -652,7 +813,7 @@ def provision_account_ticket( r"""Requests a ticket for creating an account. Args: - request (:class:`~.analytics_admin.ProvisionAccountTicketRequest`): + request (google.analytics.admin_v1alpha.types.ProvisionAccountTicketRequest): The request object. Request message for ProvisionAccountTicket RPC. @@ -663,22 +824,23 @@ def provision_account_ticket( sent along with the request as metadata. Returns: - ~.analytics_admin.ProvisionAccountTicketResponse: + google.analytics.admin_v1alpha.types.ProvisionAccountTicketResponse: Response message for ProvisionAccountTicket RPC. """ # Create or coerce a protobuf request object. - request = analytics_admin.ProvisionAccountTicketRequest(request) + # 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 = gapic_v1.method.wrap_method( - self._transport.provision_account_ticket, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.provision_account_ticket] # Send the request. response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) @@ -686,6 +848,62 @@ def provision_account_ticket( # 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, @@ -695,17 +913,15 @@ def get_property( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Property: - r"""Lookup for a single "App+Web" Property. - Throws "Target not found" if no such property found, if - property is not of the type "App+Web", or if caller does - not have permissions to access it. + r"""Lookup for a single "GA4" Property. Args: - request (:class:`~.analytics_admin.GetPropertyRequest`): + request (google.analytics.admin_v1alpha.types.GetPropertyRequest): The request object. Request message for GetProperty RPC. - name (:class:`str`): + name (str): Required. The name of the property to lookup. Format: - properties/{property_id} Example: "properties/1000". + 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. @@ -717,35 +933,37 @@ def get_property( sent along with the request as metadata. Returns: - ~.resources.Property: + google.analytics.admin_v1alpha.types.Property: A resource message representing a - Google Analytics App+Web property. + 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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_property, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.get_property] # Certain fields should be provided within the metadata header; # add these here. @@ -769,14 +987,14 @@ def list_properties( ) -> pagers.ListPropertiesPager: r"""Returns child Properties under the specified parent Account. - Only "App+Web" properties will be returned. + 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:`~.analytics_admin.ListPropertiesRequest`): + request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): The request object. Request message for ListProperties RPC. @@ -787,7 +1005,7 @@ def list_properties( sent along with the request as metadata. Returns: - ~.pagers.ListPropertiesPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListPropertiesPager: Response message for ListProperties RPC. Iterating over this object will yield @@ -797,15 +1015,16 @@ def list_properties( """ # Create or coerce a protobuf request object. - request = analytics_admin.ListPropertiesRequest(request) + # 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 = gapic_v1.method.wrap_method( - self._transport.list_properties, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.list_properties] # Send the request. response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) @@ -828,17 +1047,18 @@ def create_property( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Property: - r"""Creates an "App+Web" property with the specified - location and attributes. + r"""Creates an "GA4" property with the specified location + and attributes. Args: - request (:class:`~.analytics_admin.CreatePropertyRequest`): + request (google.analytics.admin_v1alpha.types.CreatePropertyRequest): The request object. Request message for CreateProperty RPC. - property (:class:`~.resources.Property`): + 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. @@ -850,35 +1070,37 @@ def create_property( sent along with the request as metadata. Returns: - ~.resources.Property: + google.analytics.admin_v1alpha.types.Property: A resource message representing a - Google Analytics App+Web property. + 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. - if request is not None and any([property]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if property is not None: - request.property = property + 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.wrap_method( - self._transport.create_property, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.create_property] # Send the request. response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) @@ -906,16 +1128,17 @@ def delete_property( purged. https://support.google.com/analytics/answer/6154772 Returns an error if the target is not found, or is not - an App+Web Property. + an GA4 Property. Args: - request (:class:`~.analytics_admin.DeletePropertyRequest`): + request (google.analytics.admin_v1alpha.types.DeletePropertyRequest): The request object. Request message for DeleteProperty RPC. - name (:class:`str`): + name (str): Required. The name of the Property to soft-delete. Format: properties/{property_id} Example: - "properties/1000". + "properties/1000" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -929,27 +1152,29 @@ def delete_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.delete_property, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.delete_property] # Certain fields should be provided within the metadata header; # add these here. @@ -975,19 +1200,23 @@ def update_property( r"""Updates a property. Args: - request (:class:`~.analytics_admin.UpdatePropertyRequest`): + request (google.analytics.admin_v1alpha.types.UpdatePropertyRequest): The request object. Request message for UpdateProperty RPC. - property (:class:`~.resources.Property`): + 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 (:class:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -999,37 +1228,39 @@ def update_property( sent along with the request as metadata. Returns: - ~.resources.Property: + google.analytics.admin_v1alpha.types.Property: A resource message representing a - Google Analytics App+Web property. + 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. - if request is not None and any([property, update_mask]): + 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) + # 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 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 + 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.wrap_method( - self._transport.update_property, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.update_property] # Certain fields should be provided within the metadata header; # add these here. @@ -1058,11 +1289,12 @@ def get_user_link( property. Args: - request (:class:`~.analytics_admin.GetUserLinkRequest`): + request (google.analytics.admin_v1alpha.types.GetUserLinkRequest): The request object. Request message for GetUserLink RPC. - name (:class:`str`): + 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. @@ -1074,7 +1306,7 @@ def get_user_link( sent along with the request as metadata. Returns: - ~.resources.UserLink: + google.analytics.admin_v1alpha.types.UserLink: A resource message representing a user's permissions on an Account or Property resource. @@ -1083,27 +1315,29 @@ def get_user_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_user_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.get_user_link] # Certain fields should be provided within the metadata header; # add these here. @@ -1129,7 +1363,7 @@ def batch_get_user_links( account or property. Args: - request (:class:`~.analytics_admin.BatchGetUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest): The request object. Request message for BatchGetUserLinks RPC. @@ -1140,22 +1374,23 @@ def batch_get_user_links( sent along with the request as metadata. Returns: - ~.analytics_admin.BatchGetUserLinksResponse: + google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse: Response message for BatchGetUserLinks RPC. """ # Create or coerce a protobuf request object. - request = analytics_admin.BatchGetUserLinksRequest(request) + # 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 = gapic_v1.method.wrap_method( - self._transport.batch_get_user_links, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.batch_get_user_links] # Certain fields should be provided within the metadata header; # add these here. @@ -1181,12 +1416,13 @@ def list_user_links( r"""Lists all user links on an account or property. Args: - request (:class:`~.analytics_admin.ListUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): The request object. Request message for ListUserLinks RPC. - parent (:class:`str`): + 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. @@ -1198,7 +1434,7 @@ def list_user_links( sent along with the request as metadata. Returns: - ~.pagers.ListUserLinksPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListUserLinksPager: Response message for ListUserLinks RPC. Iterating over this object will yield @@ -1209,27 +1445,29 @@ def list_user_links( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if parent is not None: - request.parent = parent + 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.wrap_method( - self._transport.list_user_links, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.list_user_links] # Certain fields should be provided within the metadata header; # add these here. @@ -1270,7 +1508,7 @@ def audit_user_links( in the GA or GMP UIs. Args: - request (:class:`~.analytics_admin.AuditUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): The request object. Request message for AuditUserLinks RPC. @@ -1281,7 +1519,7 @@ def audit_user_links( sent along with the request as metadata. Returns: - ~.pagers.AuditUserLinksPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.AuditUserLinksPager: Response message for AuditUserLinks RPC. Iterating over this object will yield @@ -1291,15 +1529,16 @@ def audit_user_links( """ # Create or coerce a protobuf request object. - request = analytics_admin.AuditUserLinksRequest(request) + # 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 = gapic_v1.method.wrap_method( - self._transport.audit_user_links, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.audit_user_links] # Certain fields should be provided within the metadata header; # add these here. @@ -1336,7 +1575,7 @@ def create_user_link( permissions specified in the new UserLink. Args: - request (:class:`~.analytics_admin.CreateUserLinkRequest`): + request (google.analytics.admin_v1alpha.types.CreateUserLinkRequest): The request object. Request message for CreateUserLink RPC. Users can have multiple email addresses associated with @@ -1347,13 +1586,14 @@ def create_user_link( always contain the "primary" email address. As a result, the input and output email address for this request may differ. - parent (:class:`str`): + 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 (:class:`~.resources.UserLink`): + 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 @@ -1366,7 +1606,7 @@ def create_user_link( sent along with the request as metadata. Returns: - ~.resources.UserLink: + google.analytics.admin_v1alpha.types.UserLink: A resource message representing a user's permissions on an Account or Property resource. @@ -1375,29 +1615,31 @@ def create_user_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, user_link]): + 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) + # 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 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 + 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.wrap_method( - self._transport.create_user_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.create_user_link] # Certain fields should be provided within the metadata header; # add these here. @@ -1425,7 +1667,7 @@ def batch_create_user_links( created, none of the UserLinks will be created. Args: - request (:class:`~.analytics_admin.BatchCreateUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest): The request object. Request message for BatchCreateUserLinks RPC. @@ -1436,22 +1678,23 @@ def batch_create_user_links( sent along with the request as metadata. Returns: - ~.analytics_admin.BatchCreateUserLinksResponse: + google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse: Response message for BatchCreateUserLinks RPC. """ # Create or coerce a protobuf request object. - request = analytics_admin.BatchCreateUserLinksRequest(request) + # 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 = gapic_v1.method.wrap_method( - self._transport.batch_create_user_links, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.batch_create_user_links] # Certain fields should be provided within the metadata header; # add these here. @@ -1477,10 +1720,10 @@ def update_user_link( r"""Updates a user link on an account or property. Args: - request (:class:`~.analytics_admin.UpdateUserLinkRequest`): + request (google.analytics.admin_v1alpha.types.UpdateUserLinkRequest): The request object. Request message for UpdateUserLink RPC. - user_link (:class:`~.resources.UserLink`): + 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 @@ -1493,7 +1736,7 @@ def update_user_link( sent along with the request as metadata. Returns: - ~.resources.UserLink: + google.analytics.admin_v1alpha.types.UserLink: A resource message representing a user's permissions on an Account or Property resource. @@ -1502,27 +1745,29 @@ def update_user_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([user_link]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if user_link is not None: - request.user_link = user_link + 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.wrap_method( - self._transport.update_user_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.update_user_link] # Certain fields should be provided within the metadata header; # add these here. @@ -1550,7 +1795,7 @@ def batch_update_user_links( account or property. Args: - request (:class:`~.analytics_admin.BatchUpdateUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest): The request object. Request message for BatchUpdateUserLinks RPC. @@ -1561,22 +1806,23 @@ def batch_update_user_links( sent along with the request as metadata. Returns: - ~.analytics_admin.BatchUpdateUserLinksResponse: + google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse: Response message for BatchUpdateUserLinks RPC. """ # Create or coerce a protobuf request object. - request = analytics_admin.BatchUpdateUserLinksRequest(request) + # 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 = gapic_v1.method.wrap_method( - self._transport.batch_update_user_links, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.batch_update_user_links] # Certain fields should be provided within the metadata header; # add these here. @@ -1602,12 +1848,13 @@ def delete_user_link( r"""Deletes a user link on an account or property. Args: - request (:class:`~.analytics_admin.DeleteUserLinkRequest`): + request (google.analytics.admin_v1alpha.types.DeleteUserLinkRequest): The request object. Request message for DeleteUserLink RPC. - name (:class:`str`): + 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. @@ -1621,27 +1868,29 @@ def delete_user_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.delete_user_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.delete_user_link] # Certain fields should be provided within the metadata header; # add these here. @@ -1666,7 +1915,7 @@ def batch_delete_user_links( account or property. Args: - request (:class:`~.analytics_admin.BatchDeleteUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest): The request object. Request message for BatchDeleteUserLinks RPC. @@ -1678,15 +1927,16 @@ def batch_delete_user_links( """ # Create or coerce a protobuf request object. - request = analytics_admin.BatchDeleteUserLinksRequest(request) + # 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 = gapic_v1.method.wrap_method( - self._transport.batch_delete_user_links, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.batch_delete_user_links] # Certain fields should be provided within the metadata header; # add these here. @@ -1709,19 +1959,17 @@ def get_web_data_stream( metadata: Sequence[Tuple[str, str]] = (), ) -> resources.WebDataStream: r"""Lookup for a single WebDataStream - Throws "Target not found" if no such web data stream - found, or if the caller does not have permissions to - access it. Args: - request (:class:`~.analytics_admin.GetWebDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.GetWebDataStreamRequest): The request object. Request message for GetWebDataStream RPC. - name (:class:`str`): + name (str): Required. The name of the web data stream to lookup. Format: properties/{property_id}/webDataStreams/{stream_id} - Example: "properties/123/webDataStreams/456". + Example: "properties/123/webDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -1733,7 +1981,7 @@ def get_web_data_stream( sent along with the request as metadata. Returns: - ~.resources.WebDataStream: + google.analytics.admin_v1alpha.types.WebDataStream: A resource message representing a Google Analytics web stream. @@ -1741,27 +1989,29 @@ def get_web_data_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_web_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.get_web_data_stream] # Certain fields should be provided within the metadata header; # add these here. @@ -1787,14 +2037,15 @@ def delete_web_data_stream( r"""Deletes a web stream on a property. Args: - request (:class:`~.analytics_admin.DeleteWebDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.DeleteWebDataStreamRequest): The request object. Request message for DeleteWebDataStream RPC. - name (:class:`str`): + name (str): Required. The name of the web data stream to delete. Format: properties/{property_id}/webDataStreams/{stream_id} - Example: "properties/123/webDataStreams/456". + Example: "properties/123/webDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -1808,27 +2059,29 @@ def delete_web_data_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.delete_web_data_stream, - default_timeout=None, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.delete_web_data_stream] # Certain fields should be provided within the metadata header; # add these here. @@ -1854,18 +2107,22 @@ def update_web_data_stream( r"""Updates a web stream on a property. Args: - request (:class:`~.analytics_admin.UpdateWebDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.UpdateWebDataStreamRequest): The request object. Request message for UpdateWebDataStream RPC. - web_data_stream (:class:`~.resources.WebDataStream`): + 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 (:class:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -1877,7 +2134,7 @@ def update_web_data_stream( sent along with the request as metadata. Returns: - ~.resources.WebDataStream: + google.analytics.admin_v1alpha.types.WebDataStream: A resource message representing a Google Analytics web stream. @@ -1885,29 +2142,31 @@ def update_web_data_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. - if request is not None and any([web_data_stream, update_mask]): + 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) + # 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 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 + 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.wrap_method( - self._transport.update_web_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.update_web_data_stream] # Certain fields should be provided within the metadata header; # add these here. @@ -1937,17 +2196,18 @@ def create_web_data_stream( attributes. Args: - request (:class:`~.analytics_admin.CreateWebDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.CreateWebDataStreamRequest): The request object. Request message for CreateWebDataStream RPC. - parent (:class:`str`): + 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 (:class:`~.resources.WebDataStream`): + 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 @@ -1960,7 +2220,7 @@ def create_web_data_stream( sent along with the request as metadata. Returns: - ~.resources.WebDataStream: + google.analytics.admin_v1alpha.types.WebDataStream: A resource message representing a Google Analytics web stream. @@ -1968,29 +2228,31 @@ def create_web_data_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. - if request is not None and any([parent, web_data_stream]): + 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) + # 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 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 + 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.wrap_method( - self._transport.create_web_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.create_web_data_stream] # Certain fields should be provided within the metadata header; # add these here. @@ -2020,14 +2282,15 @@ def list_web_data_streams( data streams are found. Args: - request (:class:`~.analytics_admin.ListWebDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): The request object. Request message for ListWebDataStreams RPC. - parent (:class:`str`): + 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". + Id 123: "properties/123" + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2039,7 +2302,7 @@ def list_web_data_streams( sent along with the request as metadata. Returns: - ~.pagers.ListWebDataStreamsPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListWebDataStreamsPager: Request message for ListWebDataStreams RPC. Iterating over this object will yield @@ -2050,27 +2313,29 @@ def list_web_data_streams( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if parent is not None: - request.parent = parent + 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.wrap_method( - self._transport.list_web_data_streams, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.list_web_data_streams] # Certain fields should be provided within the metadata header; # add these here. @@ -2100,19 +2365,17 @@ def get_ios_app_data_stream( metadata: Sequence[Tuple[str, str]] = (), ) -> resources.IosAppDataStream: r"""Lookup for a single IosAppDataStream - Throws "Target not found" if no such iOS app data stream - found, or if the caller does not have permissions to - access it. Args: - request (:class:`~.analytics_admin.GetIosAppDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.GetIosAppDataStreamRequest): The request object. Request message for GetIosAppDataStream RPC. - name (:class:`str`): + 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". + Example: "properties/123/iosAppDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2124,7 +2387,7 @@ def get_ios_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.IosAppDataStream: + google.analytics.admin_v1alpha.types.IosAppDataStream: A resource message representing a Google Analytics IOS app stream. @@ -2132,27 +2395,29 @@ def get_ios_app_data_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_ios_app_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.get_ios_app_data_stream] # Certain fields should be provided within the metadata header; # add these here. @@ -2178,14 +2443,15 @@ def delete_ios_app_data_stream( r"""Deletes an iOS app stream on a property. Args: - request (:class:`~.analytics_admin.DeleteIosAppDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.DeleteIosAppDataStreamRequest): The request object. Request message for DeleteIosAppDataStream RPC. - name (:class:`str`): + 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". + Example: "properties/123/iosAppDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2199,27 +2465,31 @@ def delete_ios_app_data_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.delete_ios_app_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.delete_ios_app_data_stream + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2245,19 +2515,23 @@ def update_ios_app_data_stream( r"""Updates an iOS app stream on a property. Args: - request (:class:`~.analytics_admin.UpdateIosAppDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.UpdateIosAppDataStreamRequest): The request object. Request message for UpdateIosAppDataStream RPC. - ios_app_data_stream (:class:`~.resources.IosAppDataStream`): + 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 (:class:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -2269,7 +2543,7 @@ def update_ios_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.IosAppDataStream: + google.analytics.admin_v1alpha.types.IosAppDataStream: A resource message representing a Google Analytics IOS app stream. @@ -2277,29 +2551,33 @@ def update_ios_app_data_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. - if request is not None and any([ios_app_data_stream, update_mask]): + 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) + # 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 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 + 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.wrap_method( - self._transport.update_ios_app_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.update_ios_app_data_stream + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2329,19 +2607,21 @@ def create_ios_app_data_stream( location and attributes. Args: - request (:class:`~.analytics_admin.CreateIosAppDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.CreateIosAppDataStreamRequest): The request object. Request message for CreateIosAppDataStream RPC. - parent (:class:`str`): + parent (str): Required. The parent resource where this ios app data stream will be created. Format: properties/123 + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - ios_app_data_stream (:class:`~.resources.IosAppDataStream`): + ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): Required. The iOS app data stream to create. + This corresponds to the ``ios_app_data_stream`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2353,7 +2633,7 @@ def create_ios_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.IosAppDataStream: + google.analytics.admin_v1alpha.types.IosAppDataStream: A resource message representing a Google Analytics IOS app stream. @@ -2361,29 +2641,33 @@ def create_ios_app_data_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. - if request is not None and any([parent, ios_app_data_stream]): + has_flattened_params = any([parent, ios_app_data_stream]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." ) - request = analytics_admin.CreateIosAppDataStreamRequest(request) + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.CreateIosAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateIosAppDataStreamRequest): + request = analytics_admin.CreateIosAppDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + # If we have keyword arguments corresponding to fields on the + # request, apply these. - if parent is not None: - request.parent = parent - if ios_app_data_stream is not None: - request.ios_app_data_stream = ios_app_data_stream + if parent is not None: + request.parent = parent + if ios_app_data_stream is not None: + request.ios_app_data_stream = ios_app_data_stream # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.create_ios_app_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.create_ios_app_data_stream + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2413,14 +2697,15 @@ def list_ios_app_data_streams( iOS app data streams are found. Args: - request (:class:`~.analytics_admin.ListIosAppDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): The request object. Request message for ListIosAppDataStreams RPC. - parent (:class:`str`): + 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". + Id 123: "properties/123" + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2432,7 +2717,7 @@ def list_ios_app_data_streams( sent along with the request as metadata. Returns: - ~.pagers.ListIosAppDataStreamsPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListIosAppDataStreamsPager: Request message for ListIosAppDataStreams RPC. Iterating over this object will yield @@ -2443,27 +2728,31 @@ def list_ios_app_data_streams( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if parent is not None: - request.parent = parent + 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.wrap_method( - self._transport.list_ios_app_data_streams, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.list_ios_app_data_streams + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2493,19 +2782,17 @@ def get_android_app_data_stream( metadata: Sequence[Tuple[str, str]] = (), ) -> resources.AndroidAppDataStream: r"""Lookup for a single AndroidAppDataStream - Throws "Target not found" if no such android app data - stream found, or if the caller does not have permissions - to access it. Args: - request (:class:`~.analytics_admin.GetAndroidAppDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.GetAndroidAppDataStreamRequest): The request object. Request message for GetAndroidAppDataStream RPC. - name (:class:`str`): + 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". + Example: "properties/123/androidAppDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2517,7 +2804,7 @@ def get_android_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.AndroidAppDataStream: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: A resource message representing a Google Analytics Android app stream. @@ -2525,27 +2812,31 @@ def get_android_app_data_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_android_app_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.get_android_app_data_stream + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2571,14 +2862,15 @@ def delete_android_app_data_stream( r"""Deletes an android app stream on a property. Args: - request (:class:`~.analytics_admin.DeleteAndroidAppDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.DeleteAndroidAppDataStreamRequest): The request object. Request message for DeleteAndroidAppDataStream RPC. - name (:class:`str`): + 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". + Example: "properties/123/androidAppDataStreams/456" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2592,27 +2884,31 @@ def delete_android_app_data_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. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.delete_android_app_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.delete_android_app_data_stream + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2638,19 +2934,23 @@ def update_android_app_data_stream( r"""Updates an android app stream on a property. Args: - request (:class:`~.analytics_admin.UpdateAndroidAppDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.UpdateAndroidAppDataStreamRequest): The request object. Request message for UpdateAndroidAppDataStream RPC. - android_app_data_stream (:class:`~.resources.AndroidAppDataStream`): + 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 (:class:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -2662,7 +2962,7 @@ def update_android_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.AndroidAppDataStream: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: A resource message representing a Google Analytics Android app stream. @@ -2670,29 +2970,33 @@ def update_android_app_data_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. - if request is not None and any([android_app_data_stream, update_mask]): + 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) + # 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 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 + 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.wrap_method( - self._transport.update_android_app_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.update_android_app_data_stream + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2727,19 +3031,21 @@ def create_android_app_data_stream( location and attributes. Args: - request (:class:`~.analytics_admin.CreateAndroidAppDataStreamRequest`): + request (google.analytics.admin_v1alpha.types.CreateAndroidAppDataStreamRequest): The request object. Request message for CreateAndroidAppDataStream RPC. - parent (:class:`str`): + parent (str): Required. The parent resource where this android app data stream will be created. Format: properties/123 + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - android_app_data_stream (:class:`~.resources.AndroidAppDataStream`): + android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): Required. The android app stream to create. + This corresponds to the ``android_app_data_stream`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2751,7 +3057,7 @@ def create_android_app_data_stream( sent along with the request as metadata. Returns: - ~.resources.AndroidAppDataStream: + google.analytics.admin_v1alpha.types.AndroidAppDataStream: A resource message representing a Google Analytics Android app stream. @@ -2759,29 +3065,33 @@ def create_android_app_data_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. - if request is not None and any([parent, android_app_data_stream]): + has_flattened_params = any([parent, android_app_data_stream]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." ) - request = analytics_admin.CreateAndroidAppDataStreamRequest(request) + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.CreateAndroidAppDataStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateAndroidAppDataStreamRequest): + request = analytics_admin.CreateAndroidAppDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + # If we have keyword arguments corresponding to fields on the + # request, apply these. - if parent is not None: - request.parent = parent - if android_app_data_stream is not None: - request.android_app_data_stream = android_app_data_stream + if parent is not None: + request.parent = parent + if android_app_data_stream is not None: + request.android_app_data_stream = android_app_data_stream # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.create_android_app_data_stream, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.create_android_app_data_stream + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2811,14 +3121,15 @@ def list_android_app_data_streams( android app streams are found. Args: - request (:class:`~.analytics_admin.ListAndroidAppDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): The request object. Request message for ListAndroidAppDataStreams RPC. - parent (:class:`str`): + 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". + Id 123: "properties/123" + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2830,7 +3141,7 @@ def list_android_app_data_streams( sent along with the request as metadata. Returns: - ~.pagers.ListAndroidAppDataStreamsPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAndroidAppDataStreamsPager: Request message for ListAndroidDataStreams RPC. Iterating over this object will yield @@ -2841,27 +3152,31 @@ def list_android_app_data_streams( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if parent is not None: - request.parent = parent + 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.wrap_method( - self._transport.list_android_app_data_streams, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.list_android_app_data_streams + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2895,14 +3210,15 @@ def get_enhanced_measurement_settings( enhanced measurement for these settings to take effect. Args: - request (:class:`~.analytics_admin.GetEnhancedMeasurementSettingsRequest`): + request (google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest): The request object. Request message for GetEnhancedMeasurementSettings RPC. - name (:class:`str`): + name (str): Required. The name of the settings to lookup. Format: properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings Example: - "properties/1000/webDataStreams/2000/enhancedMeasurementSettings". + "properties/1000/webDataStreams/2000/enhancedMeasurementSettings" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -2914,7 +3230,7 @@ def get_enhanced_measurement_settings( sent along with the request as metadata. Returns: - ~.resources.EnhancedMeasurementSettings: + google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: Singleton resource under a WebDataStream, configuring measurement of additional site interactions and @@ -2924,27 +3240,33 @@ def get_enhanced_measurement_settings( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_enhanced_measurement_settings, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.get_enhanced_measurement_settings + ] # Certain fields should be provided within the metadata header; # add these here. @@ -2973,18 +3295,22 @@ def update_enhanced_measurement_settings( enhanced measurement for these settings to take effect. Args: - request (:class:`~.analytics_admin.UpdateEnhancedMeasurementSettingsRequest`): + request (google.analytics.admin_v1alpha.types.UpdateEnhancedMeasurementSettingsRequest): The request object. Request message for UpdateEnhancedMeasurementSettings RPC. - enhanced_measurement_settings (:class:`~.resources.EnhancedMeasurementSettings`): + 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 (:class:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -2996,7 +3322,7 @@ def update_enhanced_measurement_settings( sent along with the request as metadata. Returns: - ~.resources.EnhancedMeasurementSettings: + google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: Singleton resource under a WebDataStream, configuring measurement of additional site interactions and @@ -3006,29 +3332,35 @@ def update_enhanced_measurement_settings( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([enhanced_measurement_settings, update_mask]): + 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) + # 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 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 + 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.wrap_method( - self._transport.update_enhanced_measurement_settings, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.update_enhanced_measurement_settings + ] # Certain fields should be provided within the metadata header; # add these here. @@ -3063,18 +3395,20 @@ def create_firebase_link( Properties can have at most one FirebaseLink. Args: - request (:class:`~.analytics_admin.CreateFirebaseLinkRequest`): + request (google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest): The request object. Request message for CreateFirebaseLink RPC - parent (:class:`str`): + 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 (:class:`~.resources.FirebaseLink`): + 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. @@ -3086,37 +3420,39 @@ def create_firebase_link( sent along with the request as metadata. Returns: - ~.resources.FirebaseLink: - A link between an App+Web property - and a Firebase project. + 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. - if request is not None and any([parent, firebase_link]): + 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) + # 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 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 + 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.wrap_method( - self._transport.create_firebase_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.create_firebase_link] # Certain fields should be provided within the metadata header; # add these here. @@ -3143,18 +3479,22 @@ def update_firebase_link( r"""Updates a FirebaseLink on a property Args: - request (:class:`~.analytics_admin.UpdateFirebaseLinkRequest`): + request (google.analytics.admin_v1alpha.types.UpdateFirebaseLinkRequest): The request object. Request message for UpdateFirebaseLink RPC - firebase_link (:class:`~.resources.FirebaseLink`): + 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 (:class:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -3166,37 +3506,39 @@ def update_firebase_link( sent along with the request as metadata. Returns: - ~.resources.FirebaseLink: - A link between an App+Web property - and a Firebase project. + 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. - if request is not None and any([firebase_link, update_mask]): + 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) + # 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 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 + 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.wrap_method( - self._transport.update_firebase_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.update_firebase_link] # Certain fields should be provided within the metadata header; # add these here. @@ -3224,13 +3566,14 @@ def delete_firebase_link( r"""Deletes a FirebaseLink on a property Args: - request (:class:`~.analytics_admin.DeleteFirebaseLinkRequest`): + request (google.analytics.admin_v1alpha.types.DeleteFirebaseLinkRequest): The request object. Request message for DeleteFirebaseLink RPC - name (:class:`str`): + 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. @@ -3244,27 +3587,29 @@ def delete_firebase_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.delete_firebase_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.delete_firebase_link] # Certain fields should be provided within the metadata header; # add these here. @@ -3285,17 +3630,18 @@ def list_firebase_links( retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.ListFirebaseLinksResponse: + ) -> pagers.ListFirebaseLinksPager: r"""Lists FirebaseLinks on a property. Properties can have at most one FirebaseLink. Args: - request (:class:`~.analytics_admin.ListFirebaseLinksRequest`): + request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): The request object. Request message for ListFirebaseLinks RPC - parent (:class:`str`): + 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. @@ -3307,35 +3653,40 @@ def list_firebase_links( sent along with the request as metadata. Returns: - ~.analytics_admin.ListFirebaseLinksResponse: + 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. - if request is not None and any([parent]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if parent is not None: - request.parent = parent + 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.wrap_method( - self._transport.list_firebase_links, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.list_firebase_links] # Certain fields should be provided within the metadata header; # add these here. @@ -3346,6 +3697,12 @@ def list_firebase_links( # 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 @@ -3362,16 +3719,17 @@ def get_global_site_tag( Site Tags are immutable singletons. Args: - request (:class:`~.analytics_admin.GetGlobalSiteTagRequest`): + request (google.analytics.admin_v1alpha.types.GetGlobalSiteTagRequest): The request object. Request message for GetGlobalSiteTag RPC. - name (:class:`str`): + 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". + "properties/123/webDataStreams/456/globalSiteTag" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -3383,7 +3741,7 @@ def get_global_site_tag( sent along with the request as metadata. Returns: - ~.resources.GlobalSiteTag: + google.analytics.admin_v1alpha.types.GlobalSiteTag: Read-only resource with the tag for sending data from a website to a WebDataStream. @@ -3392,27 +3750,29 @@ def get_global_site_tag( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_global_site_tag, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.get_global_site_tag] # Certain fields should be provided within the metadata header; # add these here. @@ -3439,18 +3799,20 @@ def create_google_ads_link( r"""Creates a GoogleAdsLink. Args: - request (:class:`~.analytics_admin.CreateGoogleAdsLinkRequest`): + request (google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest): The request object. Request message for CreateGoogleAdsLink RPC - parent (:class:`str`): + 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 (:class:`~.resources.GoogleAdsLink`): + 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. @@ -3462,37 +3824,39 @@ def create_google_ads_link( sent along with the request as metadata. Returns: - ~.resources.GoogleAdsLink: - A link between an App+Web property - and a Google Ads account. + 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. - if request is not None and any([parent, google_ads_link]): + 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) + # 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 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 + 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.wrap_method( - self._transport.create_google_ads_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.create_google_ads_link] # Certain fields should be provided within the metadata header; # add these here. @@ -3519,17 +3883,20 @@ def update_google_ads_link( r"""Updates a GoogleAdsLink on a property Args: - request (:class:`~.analytics_admin.UpdateGoogleAdsLinkRequest`): + request (google.analytics.admin_v1alpha.types.UpdateGoogleAdsLinkRequest): The request object. Request message for UpdateGoogleAdsLink RPC - google_ads_link (:class:`~.resources.GoogleAdsLink`): + 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 (:class:`~.field_mask.FieldMask`): - The list of fields to be updated. - Omitted fields will not be updated. + 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. @@ -3541,37 +3908,39 @@ def update_google_ads_link( sent along with the request as metadata. Returns: - ~.resources.GoogleAdsLink: - A link between an App+Web property - and a Google Ads account. + 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. - if request is not None and any([google_ads_link, update_mask]): + 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) + # 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 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 + 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.wrap_method( - self._transport.update_google_ads_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.update_google_ads_link] # Certain fields should be provided within the metadata header; # add these here. @@ -3599,12 +3968,13 @@ def delete_google_ads_link( r"""Deletes a GoogleAdsLink on a property Args: - request (:class:`~.analytics_admin.DeleteGoogleAdsLinkRequest`): + request (google.analytics.admin_v1alpha.types.DeleteGoogleAdsLinkRequest): The request object. Request message for DeleteGoogleAdsLink RPC. - name (:class:`str`): + 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. @@ -3618,27 +3988,29 @@ def delete_google_ads_link( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.delete_google_ads_link, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.delete_google_ads_link] # Certain fields should be provided within the metadata header; # add these here. @@ -3663,12 +4035,13 @@ def list_google_ads_links( r"""Lists GoogleAdsLinks on a property. Args: - request (:class:`~.analytics_admin.ListGoogleAdsLinksRequest`): + request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): The request object. Request message for ListGoogleAdsLinks RPC. - parent (:class:`str`): + 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. @@ -3680,7 +4053,7 @@ def list_google_ads_links( sent along with the request as metadata. Returns: - ~.pagers.ListGoogleAdsLinksPager: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListGoogleAdsLinksPager: Response message for ListGoogleAdsLinks RPC. Iterating over this object will yield @@ -3691,27 +4064,29 @@ def list_google_ads_links( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if parent is not None: - request.parent = parent + 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.wrap_method( - self._transport.list_google_ads_links, - default_timeout=60.0, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[self._transport.list_google_ads_links] # Certain fields should be provided within the metadata header; # add these here. @@ -3744,15 +4119,16 @@ def get_data_sharing_settings( Data sharing settings are singletons. Args: - request (:class:`~.analytics_admin.GetDataSharingSettingsRequest`): + request (google.analytics.admin_v1alpha.types.GetDataSharingSettingsRequest): The request object. Request message for GetDataSharingSettings RPC. - name (:class:`str`): + name (str): Required. The name of the settings to lookup. Format: accounts/{account}/dataSharingSettings Example: - "accounts/1000/dataSharingSettings". + "accounts/1000/dataSharingSettings" + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -3764,7 +4140,7 @@ def get_data_sharing_settings( sent along with the request as metadata. Returns: - ~.resources.DataSharingSettings: + google.analytics.admin_v1alpha.types.DataSharingSettings: A resource message representing data sharing settings of a Google Analytics account. @@ -3773,27 +4149,31 @@ def get_data_sharing_settings( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + 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) + # 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 we have keyword arguments corresponding to fields on the + # request, apply these. - if name is not None: - request.name = name + 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.wrap_method( - self._transport.get_data_sharing_settings, - default_timeout=None, - client_info=_client_info, - ) + rpc = self._transport._wrapped_methods[ + self._transport.get_data_sharing_settings + ] # Certain fields should be provided within the metadata header; # add these here. @@ -3809,11 +4189,11 @@ def get_data_sharing_settings( try: - _client_info = gapic_v1.client_info.ClientInfo( + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=pkg_resources.get_distribution("google-analytics-admin",).version, ) except pkg_resources.DistributionNotFound: - _client_info = gapic_v1.client_info.ClientInfo() + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() __all__ = ("AnalyticsAdminServiceClient",) diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py index db0b9f91..2edd4ae9 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py @@ -25,7 +25,7 @@ class ListAccountsPager: """A pager for iterating through ``list_accounts`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListAccountsResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` object, and provides an ``__iter__`` method to iterate through its ``accounts`` field. @@ -34,7 +34,7 @@ class ListAccountsPager: through the ``accounts`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListAccountsResponse` + 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. """ @@ -52,9 +52,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListAccountsRequest`): + request (google.analytics.admin_v1alpha.types.ListAccountsRequest): The initial request object. - response (:class:`~.analytics_admin.ListAccountsResponse`): + 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. @@ -87,7 +87,7 @@ class ListAccountsAsyncPager: """A pager for iterating through ``list_accounts`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListAccountsResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListAccountsResponse` object, and provides an ``__aiter__`` method to iterate through its ``accounts`` field. @@ -96,7 +96,7 @@ class ListAccountsAsyncPager: through the ``accounts`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListAccountsResponse` + 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. """ @@ -114,9 +114,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListAccountsRequest`): + request (google.analytics.admin_v1alpha.types.ListAccountsRequest): The initial request object. - response (:class:`~.analytics_admin.ListAccountsResponse`): + 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. @@ -149,11 +149,141 @@ def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) +class ListAccountSummariesPager: + """A pager for iterating through ``list_account_summaries`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``account_summaries`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAccountSummaries`` requests and continue to iterate + through the ``account_summaries`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., analytics_admin.ListAccountSummariesResponse], + request: analytics_admin.ListAccountSummariesRequest, + response: analytics_admin.ListAccountSummariesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListAccountSummariesRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAccountSummariesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListAccountSummariesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListAccountSummariesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.AccountSummary]: + for page in self.pages: + yield from page.account_summaries + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAccountSummariesAsyncPager: + """A pager for iterating through ``list_account_summaries`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``account_summaries`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAccountSummaries`` requests and continue to iterate + through the ``account_summaries`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAccountSummariesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[analytics_admin.ListAccountSummariesResponse]], + request: analytics_admin.ListAccountSummariesRequest, + response: analytics_admin.ListAccountSummariesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListAccountSummariesRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAccountSummariesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListAccountSummariesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[analytics_admin.ListAccountSummariesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.AccountSummary]: + async def async_generator(): + async for page in self.pages: + for response in page.account_summaries: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListPropertiesPager: """A pager for iterating through ``list_properties`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListPropertiesResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` object, and provides an ``__iter__`` method to iterate through its ``properties`` field. @@ -162,7 +292,7 @@ class ListPropertiesPager: through the ``properties`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListPropertiesResponse` + 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. """ @@ -180,9 +310,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListPropertiesRequest`): + request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): The initial request object. - response (:class:`~.analytics_admin.ListPropertiesResponse`): + 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. @@ -215,7 +345,7 @@ class ListPropertiesAsyncPager: """A pager for iterating through ``list_properties`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListPropertiesResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListPropertiesResponse` object, and provides an ``__aiter__`` method to iterate through its ``properties`` field. @@ -224,7 +354,7 @@ class ListPropertiesAsyncPager: through the ``properties`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListPropertiesResponse` + 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. """ @@ -242,9 +372,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListPropertiesRequest`): + request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): The initial request object. - response (:class:`~.analytics_admin.ListPropertiesResponse`): + 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. @@ -281,7 +411,7 @@ class ListUserLinksPager: """A pager for iterating through ``list_user_links`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListUserLinksResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` object, and provides an ``__iter__`` method to iterate through its ``user_links`` field. @@ -290,7 +420,7 @@ class ListUserLinksPager: through the ``user_links`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListUserLinksResponse` + 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. """ @@ -308,9 +438,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): The initial request object. - response (:class:`~.analytics_admin.ListUserLinksResponse`): + 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. @@ -343,7 +473,7 @@ class ListUserLinksAsyncPager: """A pager for iterating through ``list_user_links`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListUserLinksResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListUserLinksResponse` object, and provides an ``__aiter__`` method to iterate through its ``user_links`` field. @@ -352,7 +482,7 @@ class ListUserLinksAsyncPager: through the ``user_links`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListUserLinksResponse` + 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. """ @@ -370,9 +500,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.ListUserLinksRequest): The initial request object. - response (:class:`~.analytics_admin.ListUserLinksResponse`): + 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. @@ -409,7 +539,7 @@ class AuditUserLinksPager: """A pager for iterating through ``audit_user_links`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.AuditUserLinksResponse` object, and + :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` object, and provides an ``__iter__`` method to iterate through its ``user_links`` field. @@ -418,7 +548,7 @@ class AuditUserLinksPager: through the ``user_links`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.AuditUserLinksResponse` + 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. """ @@ -436,9 +566,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.AuditUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): The initial request object. - response (:class:`~.analytics_admin.AuditUserLinksResponse`): + 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. @@ -471,7 +601,7 @@ class AuditUserLinksAsyncPager: """A pager for iterating through ``audit_user_links`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.AuditUserLinksResponse` object, and + :class:`google.analytics.admin_v1alpha.types.AuditUserLinksResponse` object, and provides an ``__aiter__`` method to iterate through its ``user_links`` field. @@ -480,7 +610,7 @@ class AuditUserLinksAsyncPager: through the ``user_links`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.AuditUserLinksResponse` + 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. """ @@ -498,9 +628,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.AuditUserLinksRequest`): + request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): The initial request object. - response (:class:`~.analytics_admin.AuditUserLinksResponse`): + 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. @@ -537,7 +667,7 @@ class ListWebDataStreamsPager: """A pager for iterating through ``list_web_data_streams`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListWebDataStreamsResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` object, and provides an ``__iter__`` method to iterate through its ``web_data_streams`` field. @@ -546,7 +676,7 @@ class ListWebDataStreamsPager: through the ``web_data_streams`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListWebDataStreamsResponse` + 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. """ @@ -564,9 +694,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListWebDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): The initial request object. - response (:class:`~.analytics_admin.ListWebDataStreamsResponse`): + 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. @@ -599,7 +729,7 @@ class ListWebDataStreamsAsyncPager: """A pager for iterating through ``list_web_data_streams`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListWebDataStreamsResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListWebDataStreamsResponse` object, and provides an ``__aiter__`` method to iterate through its ``web_data_streams`` field. @@ -608,7 +738,7 @@ class ListWebDataStreamsAsyncPager: through the ``web_data_streams`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListWebDataStreamsResponse` + 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. """ @@ -626,9 +756,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListWebDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListWebDataStreamsRequest): The initial request object. - response (:class:`~.analytics_admin.ListWebDataStreamsResponse`): + 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. @@ -665,7 +795,7 @@ class ListIosAppDataStreamsPager: """A pager for iterating through ``list_ios_app_data_streams`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListIosAppDataStreamsResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` object, and provides an ``__iter__`` method to iterate through its ``ios_app_data_streams`` field. @@ -674,7 +804,7 @@ class ListIosAppDataStreamsPager: through the ``ios_app_data_streams`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListIosAppDataStreamsResponse` + 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. """ @@ -692,9 +822,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListIosAppDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): The initial request object. - response (:class:`~.analytics_admin.ListIosAppDataStreamsResponse`): + 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. @@ -727,7 +857,7 @@ class ListIosAppDataStreamsAsyncPager: """A pager for iterating through ``list_ios_app_data_streams`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListIosAppDataStreamsResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListIosAppDataStreamsResponse` object, and provides an ``__aiter__`` method to iterate through its ``ios_app_data_streams`` field. @@ -736,7 +866,7 @@ class ListIosAppDataStreamsAsyncPager: through the ``ios_app_data_streams`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListIosAppDataStreamsResponse` + 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. """ @@ -754,9 +884,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListIosAppDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListIosAppDataStreamsRequest): The initial request object. - response (:class:`~.analytics_admin.ListIosAppDataStreamsResponse`): + 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. @@ -795,7 +925,7 @@ class ListAndroidAppDataStreamsPager: """A pager for iterating through ``list_android_app_data_streams`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListAndroidAppDataStreamsResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` object, and provides an ``__iter__`` method to iterate through its ``android_app_data_streams`` field. @@ -804,7 +934,7 @@ class ListAndroidAppDataStreamsPager: through the ``android_app_data_streams`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListAndroidAppDataStreamsResponse` + 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. """ @@ -822,9 +952,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListAndroidAppDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): The initial request object. - response (:class:`~.analytics_admin.ListAndroidAppDataStreamsResponse`): + 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. @@ -857,7 +987,7 @@ class ListAndroidAppDataStreamsAsyncPager: """A pager for iterating through ``list_android_app_data_streams`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListAndroidAppDataStreamsResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsResponse` object, and provides an ``__aiter__`` method to iterate through its ``android_app_data_streams`` field. @@ -866,7 +996,7 @@ class ListAndroidAppDataStreamsAsyncPager: through the ``android_app_data_streams`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListAndroidAppDataStreamsResponse` + 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. """ @@ -886,9 +1016,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListAndroidAppDataStreamsRequest`): + request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): The initial request object. - response (:class:`~.analytics_admin.ListAndroidAppDataStreamsResponse`): + 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. @@ -923,11 +1053,139 @@ def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) +class ListFirebaseLinksPager: + """A pager for iterating through ``list_firebase_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` object, and + provides an ``__iter__`` method to iterate through its + ``firebase_links`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFirebaseLinks`` requests and continue to iterate + through the ``firebase_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., analytics_admin.ListFirebaseLinksResponse], + request: analytics_admin.ListFirebaseLinksRequest, + response: analytics_admin.ListFirebaseLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListFirebaseLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListFirebaseLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.FirebaseLink]: + for page in self.pages: + yield from page.firebase_links + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListFirebaseLinksAsyncPager: + """A pager for iterating through ``list_firebase_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``firebase_links`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFirebaseLinks`` requests and continue to iterate + through the ``firebase_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[analytics_admin.ListFirebaseLinksResponse]], + request: analytics_admin.ListFirebaseLinksRequest, + response: analytics_admin.ListFirebaseLinksResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListFirebaseLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListFirebaseLinksResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListFirebaseLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListFirebaseLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.FirebaseLink]: + async def async_generator(): + async for page in self.pages: + for response in page.firebase_links: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListGoogleAdsLinksPager: """A pager for iterating through ``list_google_ads_links`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListGoogleAdsLinksResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` object, and provides an ``__iter__`` method to iterate through its ``google_ads_links`` field. @@ -936,7 +1194,7 @@ class ListGoogleAdsLinksPager: through the ``google_ads_links`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListGoogleAdsLinksResponse` + 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. """ @@ -954,9 +1212,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListGoogleAdsLinksRequest`): + request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): The initial request object. - response (:class:`~.analytics_admin.ListGoogleAdsLinksResponse`): + 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. @@ -989,7 +1247,7 @@ class ListGoogleAdsLinksAsyncPager: """A pager for iterating through ``list_google_ads_links`` requests. This class thinly wraps an initial - :class:`~.analytics_admin.ListGoogleAdsLinksResponse` object, and + :class:`google.analytics.admin_v1alpha.types.ListGoogleAdsLinksResponse` object, and provides an ``__aiter__`` method to iterate through its ``google_ads_links`` field. @@ -998,7 +1256,7 @@ class ListGoogleAdsLinksAsyncPager: through the ``google_ads_links`` field on the corresponding responses. - All the usual :class:`~.analytics_admin.ListGoogleAdsLinksResponse` + 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. """ @@ -1016,9 +1274,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.analytics_admin.ListGoogleAdsLinksRequest`): + request (google.analytics.admin_v1alpha.types.ListGoogleAdsLinksRequest): The initial request object. - response (:class:`~.analytics_admin.ListGoogleAdsLinksResponse`): + 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. diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py index b4840aac..e1e55440 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py @@ -30,7 +30,6 @@ _transport_registry["grpc"] = AnalyticsAdminServiceGrpcTransport _transport_registry["grpc_asyncio"] = AnalyticsAdminServiceGrpcAsyncIOTransport - __all__ = ( "AnalyticsAdminServiceTransport", "AnalyticsAdminServiceGrpcTransport", diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py index 4167ddd0..2521cf8b 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py @@ -17,9 +17,12 @@ import abc import typing +import pkg_resources -from google import auth +from google import auth # type: ignore from google.api_core import exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore from google.auth import credentials # type: ignore from google.analytics.admin_v1alpha.types import analytics_admin @@ -27,6 +30,14 @@ from google.protobuf import empty_pb2 as empty # type: ignore +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution("google-analytics-admin",).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + class AnalyticsAdminServiceTransport(abc.ABC): """Abstract transport class for AnalyticsAdminService.""" @@ -45,6 +56,7 @@ def __init__( credentials_file: typing.Optional[str] = None, scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, quota_project_id: typing.Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. @@ -62,6 +74,11 @@ def __init__( scope (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: @@ -88,6 +105,218 @@ def __init__( # Save the credentials. self._credentials = credentials + # Lifted into its own function so it can be stubbed out during tests. + self._prep_wrapped_messages(client_info) + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.get_account: gapic_v1.method.wrap_method( + self.get_account, default_timeout=60.0, client_info=client_info, + ), + self.list_accounts: gapic_v1.method.wrap_method( + self.list_accounts, default_timeout=60.0, client_info=client_info, + ), + self.delete_account: gapic_v1.method.wrap_method( + self.delete_account, default_timeout=60.0, client_info=client_info, + ), + self.update_account: gapic_v1.method.wrap_method( + self.update_account, default_timeout=60.0, client_info=client_info, + ), + self.provision_account_ticket: gapic_v1.method.wrap_method( + self.provision_account_ticket, + default_timeout=60.0, + client_info=client_info, + ), + self.list_account_summaries: gapic_v1.method.wrap_method( + self.list_account_summaries, + default_timeout=None, + client_info=client_info, + ), + self.get_property: gapic_v1.method.wrap_method( + self.get_property, default_timeout=60.0, client_info=client_info, + ), + self.list_properties: gapic_v1.method.wrap_method( + self.list_properties, default_timeout=60.0, client_info=client_info, + ), + self.create_property: gapic_v1.method.wrap_method( + self.create_property, default_timeout=60.0, client_info=client_info, + ), + self.delete_property: gapic_v1.method.wrap_method( + self.delete_property, default_timeout=60.0, client_info=client_info, + ), + self.update_property: gapic_v1.method.wrap_method( + self.update_property, default_timeout=60.0, client_info=client_info, + ), + self.get_user_link: gapic_v1.method.wrap_method( + self.get_user_link, default_timeout=60.0, client_info=client_info, + ), + self.batch_get_user_links: gapic_v1.method.wrap_method( + self.batch_get_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.list_user_links: gapic_v1.method.wrap_method( + self.list_user_links, default_timeout=60.0, client_info=client_info, + ), + self.audit_user_links: gapic_v1.method.wrap_method( + self.audit_user_links, default_timeout=60.0, client_info=client_info, + ), + self.create_user_link: gapic_v1.method.wrap_method( + self.create_user_link, default_timeout=60.0, client_info=client_info, + ), + self.batch_create_user_links: gapic_v1.method.wrap_method( + self.batch_create_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.update_user_link: gapic_v1.method.wrap_method( + self.update_user_link, default_timeout=60.0, client_info=client_info, + ), + self.batch_update_user_links: gapic_v1.method.wrap_method( + self.batch_update_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_user_link: gapic_v1.method.wrap_method( + self.delete_user_link, default_timeout=60.0, client_info=client_info, + ), + self.batch_delete_user_links: gapic_v1.method.wrap_method( + self.batch_delete_user_links, + default_timeout=60.0, + client_info=client_info, + ), + self.get_web_data_stream: gapic_v1.method.wrap_method( + self.get_web_data_stream, default_timeout=60.0, client_info=client_info, + ), + self.delete_web_data_stream: gapic_v1.method.wrap_method( + self.delete_web_data_stream, + default_timeout=None, + client_info=client_info, + ), + self.update_web_data_stream: gapic_v1.method.wrap_method( + self.update_web_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.create_web_data_stream: gapic_v1.method.wrap_method( + self.create_web_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.list_web_data_streams: gapic_v1.method.wrap_method( + self.list_web_data_streams, + default_timeout=60.0, + client_info=client_info, + ), + self.get_ios_app_data_stream: gapic_v1.method.wrap_method( + self.get_ios_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_ios_app_data_stream: gapic_v1.method.wrap_method( + self.delete_ios_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.update_ios_app_data_stream: gapic_v1.method.wrap_method( + self.update_ios_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.create_ios_app_data_stream: gapic_v1.method.wrap_method( + self.create_ios_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.list_ios_app_data_streams: gapic_v1.method.wrap_method( + self.list_ios_app_data_streams, + default_timeout=60.0, + client_info=client_info, + ), + self.get_android_app_data_stream: gapic_v1.method.wrap_method( + self.get_android_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_android_app_data_stream: gapic_v1.method.wrap_method( + self.delete_android_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.update_android_app_data_stream: gapic_v1.method.wrap_method( + self.update_android_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.create_android_app_data_stream: gapic_v1.method.wrap_method( + self.create_android_app_data_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.list_android_app_data_streams: gapic_v1.method.wrap_method( + self.list_android_app_data_streams, + default_timeout=60.0, + client_info=client_info, + ), + self.get_enhanced_measurement_settings: gapic_v1.method.wrap_method( + self.get_enhanced_measurement_settings, + default_timeout=60.0, + client_info=client_info, + ), + self.update_enhanced_measurement_settings: gapic_v1.method.wrap_method( + self.update_enhanced_measurement_settings, + default_timeout=60.0, + client_info=client_info, + ), + self.create_firebase_link: gapic_v1.method.wrap_method( + self.create_firebase_link, + default_timeout=60.0, + client_info=client_info, + ), + self.update_firebase_link: gapic_v1.method.wrap_method( + self.update_firebase_link, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_firebase_link: gapic_v1.method.wrap_method( + self.delete_firebase_link, + default_timeout=60.0, + client_info=client_info, + ), + self.list_firebase_links: gapic_v1.method.wrap_method( + self.list_firebase_links, default_timeout=60.0, client_info=client_info, + ), + self.get_global_site_tag: gapic_v1.method.wrap_method( + self.get_global_site_tag, default_timeout=60.0, client_info=client_info, + ), + self.create_google_ads_link: gapic_v1.method.wrap_method( + self.create_google_ads_link, + default_timeout=60.0, + client_info=client_info, + ), + self.update_google_ads_link: gapic_v1.method.wrap_method( + self.update_google_ads_link, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_google_ads_link: gapic_v1.method.wrap_method( + self.delete_google_ads_link, + default_timeout=60.0, + client_info=client_info, + ), + self.list_google_ads_links: gapic_v1.method.wrap_method( + self.list_google_ads_links, + default_timeout=60.0, + client_info=client_info, + ), + self.get_data_sharing_settings: gapic_v1.method.wrap_method( + self.get_data_sharing_settings, + default_timeout=None, + client_info=client_info, + ), + } + @property def get_account( self, @@ -139,6 +368,18 @@ def provision_account_ticket( ]: raise NotImplementedError() + @property + def list_account_summaries( + self, + ) -> typing.Callable[ + [analytics_admin.ListAccountSummariesRequest], + typing.Union[ + analytics_admin.ListAccountSummariesResponse, + typing.Awaitable[analytics_admin.ListAccountSummariesResponse], + ], + ]: + raise NotImplementedError() + @property def get_property( self, diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py index 1183afa0..19862f8c 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py @@ -15,27 +15,28 @@ # limitations under the License. # +import warnings from typing import Callable, Dict, Optional, Sequence, Tuple from google.api_core import grpc_helpers # type: ignore +from google.api_core import gapic_v1 # type: ignore from google import auth # type: ignore from google.auth import credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - import grpc # type: ignore from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import resources from google.protobuf import empty_pb2 as empty # type: ignore -from .base import AnalyticsAdminServiceTransport +from .base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO class AnalyticsAdminServiceGrpcTransport(AnalyticsAdminServiceTransport): """gRPC backend transport for AnalyticsAdminService. - Service Interface for the Analytics Admin API (App+Web). + 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 @@ -57,7 +58,9 @@ def __init__( channel: grpc.Channel = None, api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None + ssl_channel_credentials: grpc.ChannelCredentials = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the transport. @@ -76,16 +79,23 @@ def __init__( ignored if ``channel`` is provided. channel (Optional[grpc.Channel]): A ``Channel`` instance through which to make calls. - api_mtls_endpoint (Optional[str]): The mutual TLS endpoint. If - provided, it overrides the ``host`` argument and tries to create + 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]]]): 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. + 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. quota_project_id (Optional[str]): An optional project to use for billing and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport @@ -93,6 +103,8 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._ssl_channel_credentials = ssl_channel_credentials + if channel: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -100,7 +112,13 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel + self._ssl_channel_credentials = None elif api_mtls_endpoint: + warnings.warn( + "api_mtls_endpoint and client_cert_source are deprecated", + DeprecationWarning, + ) + host = ( api_mtls_endpoint if ":" in api_mtls_endpoint @@ -130,8 +148,36 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + self._ssl_channel_credentials = ssl_credentials + else: + host = host if ":" in host else host + ":443" + + if credentials is None: + credentials, _ = auth.default( + scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id + ) + + # create a new channel. The provided one is ignored. + self._grpc_channel = type(self).create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + ssl_credentials=ssl_channel_credentials, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._stubs = {} # type: Dict[str, Callable] + # Run the base constructor. super().__init__( host=host, @@ -139,10 +185,9 @@ def __init__( credentials_file=credentials_file, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + client_info=client_info, ) - self._stubs = {} # type: Dict[str, Callable] - @classmethod def create_channel( cls, @@ -151,11 +196,11 @@ def create_channel( credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, - **kwargs + **kwargs, ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (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 @@ -185,24 +230,13 @@ def create_channel( credentials_file=credentials_file, scopes=scopes, quota_project_id=quota_project_id, - **kwargs + **kwargs, ) @property def grpc_channel(self) -> grpc.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 designed to connect to this service. """ - # Sanity check: Only create a new channel if we do not already - # have one. - if not hasattr(self, "_grpc_channel"): - self._grpc_channel = self.create_channel( - self._host, credentials=self._credentials, - ) - - # Return the channel from cache. return self._grpc_channel @property @@ -212,8 +246,6 @@ def get_account( r"""Return a callable for the get account method over gRPC. Lookup for a single Account. - Throws "Target not found" if no such account found, or - if caller does not have permissions to access it. Returns: Callable[[~.GetAccountRequest], @@ -242,10 +274,10 @@ def list_accounts( 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 - App+Web properties. Soft-deleted (ie: "trashed") - accounts are excluded by default. Returns an empty list - if no relevant accounts are found. + 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], @@ -356,16 +388,43 @@ def provision_account_ticket( ) 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 "App+Web" Property. - Throws "Target not found" if no such property found, if - property is not of the type "App+Web", or if caller does - not have permissions to access it. + Lookup for a single "GA4" Property. Returns: Callable[[~.GetPropertyRequest], @@ -395,7 +454,7 @@ def list_properties( Returns child Properties under the specified parent Account. - Only "App+Web" properties will be returned. + 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 @@ -425,8 +484,8 @@ def create_property( ) -> Callable[[analytics_admin.CreatePropertyRequest], resources.Property]: r"""Return a callable for the create property method over gRPC. - Creates an "App+Web" property with the specified - location and attributes. + Creates an "GA4" property with the specified location + and attributes. Returns: Callable[[~.CreatePropertyRequest], @@ -463,7 +522,7 @@ def delete_property( purged. https://support.google.com/analytics/answer/6154772 Returns an error if the target is not found, or is not - an App+Web Property. + an GA4 Property. Returns: Callable[[~.DeletePropertyRequest], @@ -810,9 +869,6 @@ def get_web_data_stream( r"""Return a callable for the get web data stream method over gRPC. Lookup for a single WebDataStream - Throws "Target not found" if no such web data stream - found, or if the caller does not have permissions to - access it. Returns: Callable[[~.GetWebDataStreamRequest], @@ -957,9 +1013,6 @@ def get_ios_app_data_stream( r"""Return a callable for the get ios app data stream method over gRPC. Lookup for a single IosAppDataStream - Throws "Target not found" if no such iOS app data stream - found, or if the caller does not have permissions to - access it. Returns: Callable[[~.GetIosAppDataStreamRequest], @@ -1104,9 +1157,6 @@ def get_android_app_data_stream( r"""Return a callable for the get android app data stream method over gRPC. Lookup for a single AndroidAppDataStream - Throws "Target not found" if no such android app data - stream found, or if the caller does not have permissions - to access it. Returns: Callable[[~.GetAndroidAppDataStreamRequest], diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py index 93309a25..b70c6e26 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py @@ -15,9 +15,12 @@ # limitations under the License. # +import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore +from google import auth # type: ignore from google.auth import credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore @@ -28,14 +31,14 @@ from google.analytics.admin_v1alpha.types import resources from google.protobuf import empty_pb2 as empty # type: ignore -from .base import AnalyticsAdminServiceTransport +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 (App+Web). + 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 @@ -99,7 +102,9 @@ def __init__( channel: aio.Channel = None, api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the transport. @@ -119,16 +124,23 @@ def __init__( are passed to :func:`google.auth.default`. channel (Optional[aio.Channel]): A ``Channel`` instance through which to make calls. - api_mtls_endpoint (Optional[str]): The mutual TLS endpoint. If - provided, it overrides the ``host`` argument and tries to create + 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]]]): 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. + 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. quota_project_id (Optional[str]): An optional project to use for billing and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport @@ -136,6 +148,8 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._ssl_channel_credentials = ssl_channel_credentials + if channel: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -143,13 +157,24 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel + self._ssl_channel_credentials = None elif api_mtls_endpoint: + warnings.warn( + "api_mtls_endpoint and client_cert_source are deprecated", + DeprecationWarning, + ) + host = ( api_mtls_endpoint if ":" in api_mtls_endpoint else api_mtls_endpoint + ":443" ) + if credentials is None: + credentials, _ = auth.default( + scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id + ) + # Create SSL credentials with client_cert_source or application # default SSL credentials. if client_cert_source: @@ -168,6 +193,32 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + self._ssl_channel_credentials = ssl_credentials + else: + host = host if ":" in host else host + ":443" + + if credentials is None: + credentials, _ = auth.default( + scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id + ) + + # create a new channel. The provided one is ignored. + self._grpc_channel = type(self).create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + ssl_credentials=ssl_channel_credentials, + scopes=scopes or self.AUTH_SCOPES, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. @@ -177,6 +228,7 @@ def __init__( credentials_file=credentials_file, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + client_info=client_info, ) self._stubs = {} @@ -188,13 +240,6 @@ def grpc_channel(self) -> aio.Channel: This property caches on the instance; repeated calls return the same channel. """ - # Sanity check: Only create a new channel if we do not already - # have one. - if not hasattr(self, "_grpc_channel"): - self._grpc_channel = self.create_channel( - self._host, credentials=self._credentials, - ) - # Return the channel from cache. return self._grpc_channel @@ -205,8 +250,6 @@ def get_account( r"""Return a callable for the get account method over gRPC. Lookup for a single Account. - Throws "Target not found" if no such account found, or - if caller does not have permissions to access it. Returns: Callable[[~.GetAccountRequest], @@ -236,10 +279,10 @@ def list_accounts( 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 - App+Web properties. Soft-deleted (ie: "trashed") - accounts are excluded by default. Returns an empty list - if no relevant accounts are found. + 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], @@ -350,16 +393,43 @@ def provision_account_ticket( ) 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 "App+Web" Property. - Throws "Target not found" if no such property found, if - property is not of the type "App+Web", or if caller does - not have permissions to access it. + Lookup for a single "GA4" Property. Returns: Callable[[~.GetPropertyRequest], @@ -390,7 +460,7 @@ def list_properties( Returns child Properties under the specified parent Account. - Only "App+Web" properties will be returned. + 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 @@ -422,8 +492,8 @@ def create_property( ]: r"""Return a callable for the create property method over gRPC. - Creates an "App+Web" property with the specified - location and attributes. + Creates an "GA4" property with the specified location + and attributes. Returns: Callable[[~.CreatePropertyRequest], @@ -460,7 +530,7 @@ def delete_property( purged. https://support.google.com/analytics/answer/6154772 Returns an error if the target is not found, or is not - an App+Web Property. + an GA4 Property. Returns: Callable[[~.DeletePropertyRequest], @@ -819,9 +889,6 @@ def get_web_data_stream( r"""Return a callable for the get web data stream method over gRPC. Lookup for a single WebDataStream - Throws "Target not found" if no such web data stream - found, or if the caller does not have permissions to - access it. Returns: Callable[[~.GetWebDataStreamRequest], @@ -967,9 +1034,6 @@ def get_ios_app_data_stream( r"""Return a callable for the get ios app data stream method over gRPC. Lookup for a single IosAppDataStream - Throws "Target not found" if no such iOS app data stream - found, or if the caller does not have permissions to - access it. Returns: Callable[[~.GetIosAppDataStreamRequest], @@ -1119,9 +1183,6 @@ def get_android_app_data_stream( r"""Return a callable for the get android app data stream method over gRPC. Lookup for a single AndroidAppDataStream - Throws "Target not found" if no such android app data - stream found, or if the caller does not have permissions - to access it. Returns: Callable[[~.GetAndroidAppDataStreamRequest], diff --git a/google/analytics/admin_v1alpha/types/__init__.py b/google/analytics/admin_v1alpha/types/__init__.py index de1e4210..4de08010 100644 --- a/google/analytics/admin_v1alpha/types/__init__.py +++ b/google/analytics/admin_v1alpha/types/__init__.py @@ -28,6 +28,10 @@ GlobalSiteTag, GoogleAdsLink, DataSharingSettings, + AccountSummary, + PropertySummary, + MaximumUserAccess, + IndustryCategory, ) from .analytics_admin import ( GetAccountRequest, @@ -90,9 +94,10 @@ ListGoogleAdsLinksRequest, ListGoogleAdsLinksResponse, GetDataSharingSettingsRequest, + ListAccountSummariesRequest, + ListAccountSummariesResponse, ) - __all__ = ( "Account", "Property", @@ -106,6 +111,10 @@ "GlobalSiteTag", "GoogleAdsLink", "DataSharingSettings", + "AccountSummary", + "PropertySummary", + "MaximumUserAccess", + "IndustryCategory", "GetAccountRequest", "ListAccountsRequest", "ListAccountsResponse", @@ -166,4 +175,6 @@ "ListGoogleAdsLinksRequest", "ListGoogleAdsLinksResponse", "GetDataSharingSettingsRequest", + "ListAccountSummariesRequest", + "ListAccountSummariesResponse", ) diff --git a/google/analytics/admin_v1alpha/types/analytics_admin.py b/google/analytics/admin_v1alpha/types/analytics_admin.py index f70d8292..34e1646d 100644 --- a/google/analytics/admin_v1alpha/types/analytics_admin.py +++ b/google/analytics/admin_v1alpha/types/analytics_admin.py @@ -85,6 +85,8 @@ "ListGoogleAdsLinksRequest", "ListGoogleAdsLinksResponse", "GetDataSharingSettingsRequest", + "ListAccountSummariesRequest", + "ListAccountSummariesResponse", }, ) @@ -137,7 +139,7 @@ class ListAccountsResponse(proto.Message): r"""Request message for ListAccounts RPC. Attributes: - accounts (Sequence[~.resources.Account]): + 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 @@ -171,12 +173,13 @@ class UpdateAccountRequest(proto.Message): r"""Request message for UpdateAccount RPC. Attributes: - account (~.resources.Account): + 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 (~.field_mask.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. + 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. """ account = proto.Field(proto.MESSAGE, number=1, message=resources.Account,) @@ -188,7 +191,7 @@ class ProvisionAccountTicketRequest(proto.Message): r"""Request message for ProvisionAccountTicket RPC. Attributes: - account (~.resources.Account): + account (google.analytics.admin_v1alpha.types.Account): The account to create. redirect_uri (str): Redirect URI where the user will be sent @@ -236,12 +239,13 @@ class ListPropertiesRequest(proto.Message): ``firebase_project:``\ (The id or number of the linked firebase project). Some examples of filters: - - ``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. + :: + + | 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, @@ -275,7 +279,7 @@ class ListPropertiesResponse(proto.Message): r"""Response message for ListProperties RPC. Attributes: - properties (Sequence[~.resources.Property]): + properties (Sequence[google.analytics.admin_v1alpha.types.Property]): Results that matched the filter criteria and were accessible to the caller. next_page_token (str): @@ -299,12 +303,13 @@ class UpdatePropertyRequest(proto.Message): r"""Request message for UpdateProperty RPC. Attributes: - property (~.resources.Property): + 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 (~.field_mask.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. + 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. """ property = proto.Field(proto.MESSAGE, number=1, message=resources.Property,) @@ -316,7 +321,7 @@ class CreatePropertyRequest(proto.Message): r"""Request message for CreateProperty RPC. Attributes: - property (~.resources.Property): + property (google.analytics.admin_v1alpha.types.Property): Required. The property to create. Note: the supplied property must specify its parent. @@ -375,7 +380,7 @@ class BatchGetUserLinksResponse(proto.Message): r"""Response message for BatchGetUserLinks RPC. Attributes: - user_links (Sequence[~.resources.UserLink]): + user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): The requested user links. """ @@ -415,7 +420,7 @@ class ListUserLinksResponse(proto.Message): r"""Response message for ListUserLinks RPC. Attributes: - user_links (Sequence[~.resources.UserLink]): + 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): @@ -466,7 +471,7 @@ class AuditUserLinksResponse(proto.Message): r"""Response message for AuditUserLinks RPC. Attributes: - user_links (Sequence[~.resources.AuditUserLink]): + 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): @@ -500,9 +505,10 @@ class CreateUserLinkRequest(proto.Message): parent (str): Required. Example format: accounts/1234 notify_new_user (bool): - Optional. If notify_new_user is set, then email new user - that they've been given permissions on the resource. - user_link (~.resources.UserLink): + 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. """ @@ -525,12 +531,14 @@ class BatchCreateUserLinksRequest(proto.Message): empty or match this field. Example format: accounts/1234 notify_new_users (bool): - Optional. If notify_new_users is set, then email new users - that they've been given permissions on the resource. - requests (Sequence[~.analytics_admin.CreateUserLinkRequest]): - The requests specifying the user links to - create. A maximum of 1000 user links can be - created in a batch. + 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) @@ -538,7 +546,7 @@ class BatchCreateUserLinksRequest(proto.Message): notify_new_users = proto.Field(proto.BOOL, number=2) requests = proto.RepeatedField( - proto.MESSAGE, number=3, message=CreateUserLinkRequest, + proto.MESSAGE, number=3, message="CreateUserLinkRequest", ) @@ -546,7 +554,7 @@ class BatchCreateUserLinksResponse(proto.Message): r"""Response message for BatchCreateUserLinks RPC. Attributes: - user_links (Sequence[~.resources.UserLink]): + user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): The user links created. """ @@ -559,7 +567,7 @@ class UpdateUserLinkRequest(proto.Message): r"""Request message for UpdateUserLink RPC. Attributes: - user_link (~.resources.UserLink): + user_link (google.analytics.admin_v1alpha.types.UserLink): Required. The user link to update. """ @@ -576,16 +584,16 @@ class BatchUpdateUserLinksRequest(proto.Message): field in the UpdateUserLinkRequest messages must either be empty or match this field. Example format: accounts/1234 - requests (Sequence[~.analytics_admin.UpdateUserLinkRequest]): - The requests specifying the user links to - update. A maximum of 1000 user links can be - updated in a batch. + 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, + proto.MESSAGE, number=2, message="UpdateUserLinkRequest", ) @@ -593,7 +601,7 @@ class BatchUpdateUserLinksResponse(proto.Message): r"""Response message for BatchUpdateUserLinks RPC. Attributes: - user_links (Sequence[~.resources.UserLink]): + user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): The user links updated. """ @@ -624,16 +632,16 @@ class BatchDeleteUserLinksRequest(proto.Message): all values for user link names to delete must match this field. Example format: accounts/1234 - requests (Sequence[~.analytics_admin.DeleteUserLinkRequest]): - The requests specifying the user links to - update. A maximum of 1000 user links can be - updated in a batch. + 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, + proto.MESSAGE, number=2, message="DeleteUserLinkRequest", ) @@ -667,12 +675,13 @@ class UpdateWebDataStreamRequest(proto.Message): r"""Request message for UpdateWebDataStream RPC. Attributes: - web_data_stream (~.resources.WebDataStream): + 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 (~.field_mask.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. + 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. """ web_data_stream = proto.Field( @@ -686,7 +695,7 @@ class CreateWebDataStreamRequest(proto.Message): r"""Request message for CreateWebDataStream RPC. Attributes: - web_data_stream (~.resources.WebDataStream): + web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): Required. The web stream to create. parent (str): Required. The parent resource where this web @@ -733,7 +742,7 @@ class ListWebDataStreamsResponse(proto.Message): r"""Request message for ListWebDataStreams RPC. Attributes: - web_data_streams (Sequence[~.resources.WebDataStream]): + 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): @@ -785,12 +794,13 @@ class UpdateIosAppDataStreamRequest(proto.Message): r"""Request message for UpdateIosAppDataStream RPC. Attributes: - ios_app_data_stream (~.resources.IosAppDataStream): + 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 (~.field_mask.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. + 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. """ ios_app_data_stream = proto.Field( @@ -804,7 +814,7 @@ class CreateIosAppDataStreamRequest(proto.Message): r"""Request message for CreateIosAppDataStream RPC. Attributes: - ios_app_data_stream (~.resources.IosAppDataStream): + ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): Required. The iOS app data stream to create. parent (str): Required. The parent resource where this ios @@ -851,7 +861,7 @@ class ListIosAppDataStreamsResponse(proto.Message): r"""Request message for ListIosAppDataStreams RPC. Attributes: - ios_app_data_streams (Sequence[~.resources.IosAppDataStream]): + 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): @@ -903,13 +913,14 @@ class UpdateAndroidAppDataStreamRequest(proto.Message): r"""Request message for UpdateAndroidAppDataStream RPC. Attributes: - android_app_data_stream (~.resources.AndroidAppDataStream): + 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 (~.field_mask.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. + 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. """ android_app_data_stream = proto.Field( @@ -923,7 +934,7 @@ class CreateAndroidAppDataStreamRequest(proto.Message): r"""Request message for CreateAndroidAppDataStream RPC. Attributes: - android_app_data_stream (~.resources.AndroidAppDataStream): + android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): Required. The android app stream to create. parent (str): Required. The parent resource where this @@ -969,7 +980,7 @@ class ListAndroidAppDataStreamsResponse(proto.Message): r"""Request message for ListAndroidDataStreams RPC. Attributes: - android_app_data_streams (Sequence[~.resources.AndroidAppDataStream]): + 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): @@ -1007,12 +1018,13 @@ class UpdateEnhancedMeasurementSettingsRequest(proto.Message): r"""Request message for UpdateEnhancedMeasurementSettings RPC. Attributes: - enhanced_measurement_settings (~.resources.EnhancedMeasurementSettings): + 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 (~.field_mask.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. + 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. """ enhanced_measurement_settings = proto.Field( @@ -1029,7 +1041,7 @@ class CreateFirebaseLinkRequest(proto.Message): parent (str): Required. Format: properties/{property_id} Example: properties/1234 - firebase_link (~.resources.FirebaseLink): + firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): Required. The Firebase link to create. """ @@ -1044,11 +1056,12 @@ class UpdateFirebaseLinkRequest(proto.Message): r"""Request message for UpdateFirebaseLink RPC Attributes: - firebase_link (~.resources.FirebaseLink): + firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): Required. The Firebase link to update. - update_mask (~.field_mask.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. + 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. """ firebase_link = proto.Field( @@ -1078,24 +1091,52 @@ class ListFirebaseLinksRequest(proto.Message): 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[~.resources.FirebaseLink]): + 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. @@ -1117,7 +1158,7 @@ class CreateGoogleAdsLinkRequest(proto.Message): Attributes: parent (str): Required. Example format: properties/1234 - google_ads_link (~.resources.GoogleAdsLink): + google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): Required. The GoogleAdsLink to create. """ @@ -1132,11 +1173,12 @@ class UpdateGoogleAdsLinkRequest(proto.Message): r"""Request message for UpdateGoogleAdsLink RPC Attributes: - google_ads_link (~.resources.GoogleAdsLink): + google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): The GoogleAdsLink to update - update_mask (~.field_mask.FieldMask): - The list of fields to be updated. Omitted - fields will not be updated. + 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. """ google_ads_link = proto.Field( @@ -1190,7 +1232,7 @@ class ListGoogleAdsLinksResponse(proto.Message): r"""Response message for ListGoogleAdsLinks RPC. Attributes: - google_ads_links (Sequence[~.resources.GoogleAdsLink]): + 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 @@ -1222,4 +1264,53 @@ class GetDataSharingSettingsRequest(proto.Message): name = proto.Field(proto.STRING, number=1) +class ListAccountSummariesRequest(proto.Message): + r"""Request message for ListAccountSummaries RPC. + + Attributes: + page_size (int): + The maximum number of AccountSummary + resources to return. The service may return + fewer than this value, even if there are + additional pages. If unspecified, at most 50 + resources will be returned. The maximum value is + 200; (higher values will be coerced to the + maximum) + page_token (str): + A page token, received from a previous + ``ListAccountSummaries`` call. Provide this to retrieve the + subsequent page. When paginating, all other parameters + provided to ``ListAccountSummaries`` must match the call + that provided the page token. + """ + + page_size = proto.Field(proto.INT32, number=1) + + page_token = proto.Field(proto.STRING, number=2) + + +class ListAccountSummariesResponse(proto.Message): + r"""Response message for ListAccountSummaries RPC. + + Attributes: + account_summaries (Sequence[google.analytics.admin_v1alpha.types.AccountSummary]): + Account summaries of all accounts the caller + has access to. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + account_summaries = proto.RepeatedField( + proto.MESSAGE, number=1, message=resources.AccountSummary, + ) + + next_page_token = proto.Field(proto.STRING, number=2) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/analytics/admin_v1alpha/types/resources.py b/google/analytics/admin_v1alpha/types/resources.py index 4f8e1c4b..9290e7cd 100644 --- a/google/analytics/admin_v1alpha/types/resources.py +++ b/google/analytics/admin_v1alpha/types/resources.py @@ -25,8 +25,8 @@ __protobuf__ = proto.module( package="google.analytics.admin.v1alpha", manifest={ - "IndustryCategory", "MaximumUserAccess", + "IndustryCategory", "Account", "Property", "AndroidAppDataStream", @@ -39,10 +39,23 @@ "GlobalSiteTag", "GoogleAdsLink", "DataSharingSettings", + "AccountSummary", + "PropertySummary", }, ) +class MaximumUserAccess(proto.Enum): + r"""Maximum access settings that Firebase user receive on the + linked Analytics property. + """ + MAXIMUM_USER_ACCESS_UNSPECIFIED = 0 + NO_ACCESS = 1 + READ_AND_ANALYZE = 2 + EDITOR_WITHOUT_LINK_MANAGEMENT = 3 + EDITOR_INCLUDING_LINK_MANAGEMENT = 4 + + class IndustryCategory(proto.Enum): r"""The category selected for this property, used for industry benchmarking. @@ -76,17 +89,6 @@ class IndustryCategory(proto.Enum): SHOPPING = 26 -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 Account(proto.Message): r"""A resource message representing a Google Analytics account. @@ -95,19 +97,18 @@ class Account(proto.Message): Output only. Resource name of this account. Format: accounts/{account} Example: "accounts/100". - create_time (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when this account was originally created. - update_time (~.timestamp.Timestamp): + 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. - country_code (str): - Country of business. Must be a non-deprecated code for a UN - M.49 region. - https://unicode.org/cldr/charts/latest/supplemental/territory_containment_un_m_49.html + 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 @@ -123,23 +124,23 @@ class Account(proto.Message): display_name = proto.Field(proto.STRING, number=4) - country_code = proto.Field(proto.STRING, number=5) + 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 App+Web + 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 (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when the entity was originally created. - update_time (~.timestamp.Timestamp): + update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when entity payload fields were last updated. parent (str): @@ -153,7 +154,7 @@ class Property(proto.Message): this property. The max allowed display name length is 100 UTF-16 code units. - industry_category (~.resources.IndustryCategory): + industry_category (google.analytics.admin_v1alpha.types.IndustryCategory): Industry associated with this property Example: AUTOMOTIVE, FOOD_AND_DRINK time_zone (str): @@ -211,10 +212,10 @@ class AndroidAppDataStream(proto.Message): 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 (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when this stream was originally created. - update_time (~.timestamp.Timestamp): + update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when stream payload fields were last updated. package_name (str): @@ -253,10 +254,10 @@ class IosAppDataStream(proto.Message): 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 (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when this stream was originally created. - update_time (~.timestamp.Timestamp): + update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when stream payload fields were last updated. bundle_id (str): @@ -300,10 +301,10 @@ class WebDataStream(proto.Message): 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 (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when this stream was originally created. - update_time (~.timestamp.Timestamp): + update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when stream payload fields were last updated. default_uri (str): @@ -427,19 +428,10 @@ class EnhancedMeasurementSettings(proto.Message): If enabled, capture an outbound click event each time a visitor clicks a link that leads them away from your domain. - content_views_enabled (bool): - Capture events when your visitors view - content on your site that has structured data - (eg, articles, blog posts, product details - screens, etc.). 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). - form_interactions_enabled (bool): - If enabled, capture a view search results - event each time a visitor interacts with a form - on your site. video_engagement_enabled (bool): If enabled, capture video play, progress, and complete events as visitors view embedded videos @@ -449,35 +441,20 @@ class EnhancedMeasurementSettings(proto.Message): each time a link is clicked with a common document, compressed file, application, video, or audio extension. - data_tagged_element_clicks_enabled (bool): - If enabled, capture a click event each time a - visitor clicks a link or element that has data - attributes beginning with "data-ga". page_loads_enabled (bool): - If enabled, capture a page view event each - time a page loads. + 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. - articles_and_blogs_enabled (bool): - Capture events when your visitors view - content on your site that has articles or blog - posts. - products_and_ecommerce_enabled (bool): - Capture events when your visitors view - content on your site that has product details - screens, etc. search_query_parameter (str): Required. URL query parameters to interpret as site search parameters. Max length is 1024 characters. Must not be empty. - url_query_parameter (str): + uri_query_parameter (str): Additional URL query parameters. Max length is 1024 characters. - excluded_domains (str): - Domains to exclude from measurement. Max - length is 1024 characters. """ name = proto.Field(proto.STRING, number=1) @@ -490,35 +467,23 @@ class EnhancedMeasurementSettings(proto.Message): outbound_clicks_enabled = proto.Field(proto.BOOL, number=5) - content_views_enabled = proto.Field(proto.BOOL, number=6) - site_search_enabled = proto.Field(proto.BOOL, number=7) - form_interactions_enabled = proto.Field(proto.BOOL, number=8) - video_engagement_enabled = proto.Field(proto.BOOL, number=9) file_downloads_enabled = proto.Field(proto.BOOL, number=10) - data_tagged_element_clicks_enabled = proto.Field(proto.BOOL, number=11) - page_loads_enabled = proto.Field(proto.BOOL, number=12) page_changes_enabled = proto.Field(proto.BOOL, number=13) - articles_and_blogs_enabled = proto.Field(proto.BOOL, number=14) - - products_and_ecommerce_enabled = proto.Field(proto.BOOL, number=15) - search_query_parameter = proto.Field(proto.STRING, number=16) - url_query_parameter = proto.Field(proto.STRING, number=17) - - excluded_domains = proto.Field(proto.STRING, number=18) + uri_query_parameter = proto.Field(proto.STRING, number=17) class FirebaseLink(proto.Message): - r"""A link between an App+Web property and a Firebase project. + r"""A link between an GA4 property and a Firebase project. Attributes: name (str): @@ -532,11 +497,11 @@ class FirebaseLink(proto.Message): project_name that contains a project number. Format: 'projects/{project number}' Example: 'projects/1234' - create_time (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when this FirebaseLink was originally created. - maximum_user_access (~.resources.MaximumUserAccess): - Maximum user access to the App + Web property + maximum_user_access (google.analytics.admin_v1alpha.types.MaximumUserAccess): + Maximum user access to the GA4 property allowed to admins of the linked Firebase project. """ @@ -555,17 +520,23 @@ class GlobalSiteTag(proto.Message): 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. """ - snippet = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1) + + snippet = proto.Field(proto.STRING, number=2) class GoogleAdsLink(proto.Message): - r"""A link between an App+Web property and a Google Ads account. + r"""A link between an GA4 property and a Google Ads account. Attributes: name (str): @@ -573,14 +544,12 @@ class GoogleAdsLink(proto.Message): properties/{propertyId}/googleAdsLinks/{googleAdsLinkId} Note: googleAdsLinkId is not the Google Ads customer ID. - parent (str): - Immutable. Format: properties/{propertyId} 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 (~.wrappers.BoolValue): + ads_personalization_enabled (google.protobuf.wrappers_pb2.BoolValue): Enable personalized advertising features with this integration. Automatically publish my Google Analytics audience lists and Google @@ -593,18 +562,16 @@ class GoogleAdsLink(proto.Message): created the link. An empty string will be returned if the email address can't be retrieved. - create_time (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when this link was originally created. - update_time (~.timestamp.Timestamp): + update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when this link was last updated. """ name = proto.Field(proto.STRING, number=1) - parent = proto.Field(proto.STRING, number=2) - customer_id = proto.Field(proto.STRING, number=3) can_manage_clients = proto.Field(proto.BOOL, number=4) @@ -663,4 +630,53 @@ class DataSharingSettings(proto.Message): sharing_with_others_enabled = proto.Field(proto.BOOL, number=6) +class AccountSummary(proto.Message): + r"""A virtual resource representing an overview of an account and + all its child GA4 properties. + + Attributes: + name (str): + Resource name for this account summary. Format: + accountSummaries/{account_id} Example: + "accountSummaries/1000". + account (str): + Resource name of account referred to by this account summary + Format: accounts/{account_id} Example: "accounts/1000". + display_name (str): + Display name for the account referred to in + this account summary. + property_summaries (Sequence[google.analytics.admin_v1alpha.types.PropertySummary]): + List of summaries for child accounts of this + account. + """ + + name = proto.Field(proto.STRING, number=1) + + account = proto.Field(proto.STRING, number=2) + + display_name = proto.Field(proto.STRING, number=3) + + property_summaries = proto.RepeatedField( + proto.MESSAGE, number=4, message="PropertySummary", + ) + + +class PropertySummary(proto.Message): + r"""A virtual resource representing metadata for an GA4 property. + + Attributes: + property (str): + Resource name of property referred to by this property + summary Format: properties/{property_id} Example: + "properties/1000". + display_name (str): + Display name for the property referred to in + this account summary. + """ + + property = proto.Field(proto.STRING, number=1) + + display_name = proto.Field(proto.STRING, number=2) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 28579683..30117975 100644 --- a/noxfile.py +++ b/noxfile.py @@ -28,7 +28,18 @@ DEFAULT_PYTHON_VERSION = "3.8" SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] -UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8"] +UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] + +# 'docfx' is excluded since it only needs to run in 'docs-presubmit' +nox.options.sessions = [ + "unit", + "system", + "cover", + "lint", + "lint_setup_py", + "blacken", + "docs", +] @nox.session(python=DEFAULT_PYTHON_VERSION) @@ -72,16 +83,17 @@ def default(session): # Install all test dependencies, then install this package in-place. session.install("asyncmock", "pytest-asyncio") - session.install("mock", "pytest", "pytest-cov") + session.install( + "mock", "pytest", "pytest-cov", + ) session.install("-e", ".") # Run py.test against the unit tests. session.run( "py.test", "--quiet", - "--cov=google.analytics.admin", - "--cov=google.analytics", - "--cov=tests.unit", + "--cov=google/cloud", + "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", "--cov-report=", @@ -102,6 +114,10 @@ def system(session): """Run the system test suite.""" system_test_path = os.path.join("tests", "system.py") system_test_folder_path = os.path.join("tests", "system") + + # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. + if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": + session.skip("RUN_SYSTEM_TESTS is set to false, skipping") # Sanity check: Only run tests if the environment variable is set. if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): session.skip("Credentials must be set via environment variable") @@ -162,3 +178,38 @@ def docs(session): os.path.join("docs", ""), os.path.join("docs", "_build", "html", ""), ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def docfx(session): + """Build the docfx yaml files for this library.""" + + session.install("-e", ".") + # sphinx-docfx-yaml supports up to sphinx version 1.5.5. + # https://github.com/docascode/sphinx-docfx-yaml/issues/97 + session.install("sphinx==1.5.5", "alabaster", "recommonmark", "sphinx-docfx-yaml") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-T", # show full traceback on exception + "-N", # no colors + "-D", + ( + "extensions=sphinx.ext.autodoc," + "sphinx.ext.autosummary," + "docfx_yaml.extension," + "sphinx.ext.intersphinx," + "sphinx.ext.coverage," + "sphinx.ext.napoleon," + "sphinx.ext.todo," + "sphinx.ext.viewcode," + "recommonmark" + ), + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/samples/quickstart.py b/samples/quickstart.py new file mode 100644 index 00000000..5653af44 --- /dev/null +++ b/samples/quickstart.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python + +# Copyright 2020 Google Inc. All Rights Reserved. +# +# 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 API sample quickstart application. +Example usage: + python quickstart.py + +This application demonstrates the usage of the Analytics Admin API using +service account credentials. For more information on service accounts, see + +https://cloud.google.com/iam/docs/understanding-service-accounts + +The following document provides instructions on setting service account +credentials for your application: + + https://cloud.google.com/docs/authentication/production + +In a nutshell, you need to: +1. Create a service account and download the key JSON file. + +https://cloud.google.com/docs/authentication/production#creating_a_service_account + +2. Provide service account credentials using one of the following options: +- set the GOOGLE_APPLICATION_CREDENTIALS environment variable, the API +client will use the value of this variable to find the service account key +JSON file. + +https://cloud.google.com/docs/authentication/production#setting_the_environment_variable + +OR +- manually pass the path to the service account key JSON file to the API client +by specifying the keyFilename parameter in the constructor: +https://cloud.google.com/docs/authentication/production#passing_the_path_to_the_service_account_key_in_code + +To install the latest published package dependency, execute the following: + pip install google-analytics-admin +""" + +# [START ga_admin_list_accounts] +def list_accounts(): + """Lists the available Google Analytics accounts.""" + from google.analytics.admin import AnalyticsAdminServiceClient + # Using a default constructor instructs the client to use the credentials + # specified in GOOGLE_APPLICATION_CREDENTIALS environment variable. + client = AnalyticsAdminServiceClient() + + # Displays the configuration information for all Google Analytics accounts + # available to the authenticated user. + for account in client.list_accounts(): + print(account) +# [END ga_admin_list_accounts] + + +if __name__ == "__main__": + list_accounts() diff --git a/scripts/decrypt-secrets.sh b/scripts/decrypt-secrets.sh index ff599eb2..21f6d2a2 100755 --- a/scripts/decrypt-secrets.sh +++ b/scripts/decrypt-secrets.sh @@ -20,14 +20,27 @@ ROOT=$( dirname "$DIR" ) # Work from the project root. cd $ROOT +# Prevent it from overriding files. +# We recommend that sample authors use their own service account files and cloud project. +# In that case, they are supposed to prepare these files by themselves. +if [[ -f "testing/test-env.sh" ]] || \ + [[ -f "testing/service-account.json" ]] || \ + [[ -f "testing/client-secrets.json" ]]; then + echo "One or more target files exist, aborting." + exit 1 +fi + # Use SECRET_MANAGER_PROJECT if set, fallback to cloud-devrel-kokoro-resources. PROJECT_ID="${SECRET_MANAGER_PROJECT:-cloud-devrel-kokoro-resources}" gcloud secrets versions access latest --secret="python-docs-samples-test-env" \ + --project="${PROJECT_ID}" \ > testing/test-env.sh gcloud secrets versions access latest \ --secret="python-docs-samples-service-account" \ + --project="${PROJECT_ID}" \ > testing/service-account.json gcloud secrets versions access latest \ --secret="python-docs-samples-client-secrets" \ - > testing/client-secrets.json \ No newline at end of file + --project="${PROJECT_ID}" \ + > testing/client-secrets.json diff --git a/scripts/fixup_admin_v1alpha_keywords.py b/scripts/fixup_admin_v1alpha_keywords.py index d3883208..4aaee832 100644 --- a/scripts/fixup_admin_v1alpha_keywords.py +++ b/scripts/fixup_admin_v1alpha_keywords.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2020 Google LLC @@ -41,7 +42,7 @@ class adminCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'audit_user_links': ('parent', 'page_size', 'page_token', ), - 'batch_create_user_links': ('parent', 'notify_new_users', 'requests', ), + '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', ), @@ -70,8 +71,9 @@ class adminCallTransformer(cst.CSTTransformer): 'get_user_link': ('name', ), 'get_web_data_stream': ('name', ), 'list_accounts': ('page_size', 'page_token', 'show_deleted', ), + 'list_account_summaries': ('page_size', 'page_token', ), 'list_android_app_data_streams': ('parent', 'page_size', 'page_token', ), - 'list_firebase_links': ('parent', ), + 'list_firebase_links': ('parent', 'page_size', 'page_token', ), 'list_google_ads_links': ('parent', 'page_size', 'page_token', ), 'list_ios_app_data_streams': ('parent', 'page_size', 'page_token', ), 'list_properties': ('filter', 'page_size', 'page_token', 'show_deleted', ), @@ -82,7 +84,7 @@ class adminCallTransformer(cst.CSTTransformer): 'update_android_app_data_stream': ('android_app_data_stream', 'update_mask', ), 'update_enhanced_measurement_settings': ('enhanced_measurement_settings', 'update_mask', ), 'update_firebase_link': ('firebase_link', 'update_mask', ), - 'update_google_ads_link': ('google_ads_link', 'update_mask', ), + 'update_google_ads_link': ('update_mask', 'google_ads_link', ), 'update_ios_app_data_stream': ('ios_app_data_stream', 'update_mask', ), 'update_property': ('property', 'update_mask', ), 'update_user_link': ('user_link', ), diff --git a/setup.py b/setup.py index 6c7cfd4c..b0b68feb 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ import os import setuptools # type: ignore -version = "0.1.0" +version = "0.2.0" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -41,12 +41,10 @@ platforms="Posix; MacOS X; Windows", include_package_data=True, install_requires=( - "google-api-core[grpc] >= 1.22.0, < 2.0.0dev", - "libcst >= 0.2.5", - "proto-plus >= 1.3.2", + "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", + "proto-plus >= 1.4.0", ), python_requires=">=3.6", - scripts=["scripts/fixup_admin_v1alpha_keywords.py",], classifiers=[ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", diff --git a/synth.metadata b/synth.metadata index 51409445..64d95b8b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,22 +3,30 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/python-analytics-admin", - "sha": "37c5c6a341bd2df94953cd6dd7ac22033dd5dc7d" + "remote": "https://github.com/googleapis/python-analytics-admin.git", + "sha": "04d05d7436a752dba18cb04d0e6882b1670114d7" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "23e7356f4cf449d6e9977698c5d9383b566be7af", + "internalRef": "351651504" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "d07b7b7afa718686db7b095317f608a2f1b6b1cb" + "sha": "ba960d730416fe05c50547e975ce79fcee52c671" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "d07b7b7afa718686db7b095317f608a2f1b6b1cb" + "sha": "ba960d730416fe05c50547e975ce79fcee52c671" } } ], @@ -32,5 +40,95 @@ "generator": "bazel" } } + ], + "generatedFiles": [ + ".coveragerc", + ".flake8", + ".github/CONTRIBUTING.md", + ".github/ISSUE_TEMPLATE/bug_report.md", + ".github/ISSUE_TEMPLATE/feature_request.md", + ".github/ISSUE_TEMPLATE/support_request.md", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/release-please.yml", + ".github/snippet-bot.yml", + ".gitignore", + ".kokoro/build.sh", + ".kokoro/continuous/common.cfg", + ".kokoro/continuous/continuous.cfg", + ".kokoro/docker/docs/Dockerfile", + ".kokoro/docker/docs/fetch_gpg_keys.sh", + ".kokoro/docs/common.cfg", + ".kokoro/docs/docs-presubmit.cfg", + ".kokoro/docs/docs.cfg", + ".kokoro/populate-secrets.sh", + ".kokoro/presubmit/common.cfg", + ".kokoro/presubmit/presubmit.cfg", + ".kokoro/publish-docs.sh", + ".kokoro/release.sh", + ".kokoro/release/common.cfg", + ".kokoro/release/release.cfg", + ".kokoro/samples/lint/common.cfg", + ".kokoro/samples/lint/continuous.cfg", + ".kokoro/samples/lint/periodic.cfg", + ".kokoro/samples/lint/presubmit.cfg", + ".kokoro/samples/python3.6/common.cfg", + ".kokoro/samples/python3.6/continuous.cfg", + ".kokoro/samples/python3.6/periodic.cfg", + ".kokoro/samples/python3.6/presubmit.cfg", + ".kokoro/samples/python3.7/common.cfg", + ".kokoro/samples/python3.7/continuous.cfg", + ".kokoro/samples/python3.7/periodic.cfg", + ".kokoro/samples/python3.7/presubmit.cfg", + ".kokoro/samples/python3.8/common.cfg", + ".kokoro/samples/python3.8/continuous.cfg", + ".kokoro/samples/python3.8/periodic.cfg", + ".kokoro/samples/python3.8/presubmit.cfg", + ".kokoro/test-samples.sh", + ".kokoro/trampoline.sh", + ".kokoro/trampoline_v2.sh", + ".pre-commit-config.yaml", + ".trampolinerc", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.rst", + "LICENSE", + "MANIFEST.in", + "docs/_static/custom.css", + "docs/_templates/layout.html", + "docs/admin_v1alpha/analytics_admin_service.rst", + "docs/admin_v1alpha/services.rst", + "docs/admin_v1alpha/types.rst", + "docs/conf.py", + "docs/multiprocessing.rst", + "google/analytics/admin/__init__.py", + "google/analytics/admin/py.typed", + "google/analytics/admin_v1alpha/__init__.py", + "google/analytics/admin_v1alpha/py.typed", + "google/analytics/admin_v1alpha/services/__init__.py", + "google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py", + "google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py", + "google/analytics/admin_v1alpha/services/analytics_admin_service/client.py", + "google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py", + "google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py", + "google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py", + "google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py", + "google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py", + "google/analytics/admin_v1alpha/types/__init__.py", + "google/analytics/admin_v1alpha/types/analytics_admin.py", + "google/analytics/admin_v1alpha/types/resources.py", + "mypy.ini", + "noxfile.py", + "renovate.json", + "scripts/decrypt-secrets.sh", + "scripts/fixup_admin_v1alpha_keywords.py", + "scripts/readme-gen/readme_gen.py", + "scripts/readme-gen/templates/README.tmpl.rst", + "scripts/readme-gen/templates/auth.tmpl.rst", + "scripts/readme-gen/templates/auth_api_key.tmpl.rst", + "scripts/readme-gen/templates/install_deps.tmpl.rst", + "scripts/readme-gen/templates/install_portaudio.tmpl.rst", + "setup.cfg", + "testing/.gitignore", + "tests/unit/gapic/admin_v1alpha/__init__.py", + "tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py" ] } \ No newline at end of file diff --git a/tests/unit/gapic/admin_v1alpha/__init__.py b/tests/unit/gapic/admin_v1alpha/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/unit/gapic/admin_v1alpha/__init__.py @@ -0,0 +1 @@ + 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 b4bca36d..df80bb36 100644 --- a/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +++ b/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py @@ -52,6 +52,17 @@ 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" @@ -82,8 +93,21 @@ def test__get_default_mtls_endpoint(): ) +def test_analytics_admin_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = AnalyticsAdminServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "analyticsadmin.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [AnalyticsAdminServiceClient, AnalyticsAdminServiceAsyncClient] + "client_class", [AnalyticsAdminServiceClient, AnalyticsAdminServiceAsyncClient,] ) def test_analytics_admin_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -92,17 +116,20 @@ def test_analytics_admin_service_client_from_service_account_file(client_class): ) as factory: factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") - assert client._transport._credentials == creds + assert client.transport._credentials == creds client = client_class.from_service_account_json("dummy/file/path.json") - assert client._transport._credentials == creds + assert client.transport._credentials == creds - assert client._transport._host == "analyticsadmin.googleapis.com:443" + assert client.transport._host == "analyticsadmin.googleapis.com:443" def test_analytics_admin_service_client_get_transport_class(): transport = AnalyticsAdminServiceClient.get_transport_class() - assert transport == transports.AnalyticsAdminServiceGrpcTransport + available_transports = [ + transports.AnalyticsAdminServiceGrpcTransport, + ] + assert transport in available_transports transport = AnalyticsAdminServiceClient.get_transport_class("grpc") assert transport == transports.AnalyticsAdminServiceGrpcTransport @@ -123,6 +150,16 @@ def test_analytics_admin_service_client_get_transport_class(): ), ], ) +@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 ): @@ -147,14 +184,14 @@ def test_analytics_admin_service_client_client_options( credentials_file=None, host="squid.clam.whelk", scopes=None, - api_mtls_endpoint="squid.clam.whelk", - client_cert_source=None, + ssl_channel_credentials=None, quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, ) - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is + # 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": "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() @@ -163,14 +200,14 @@ def test_analytics_admin_service_client_client_options( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - api_mtls_endpoint=client.DEFAULT_ENDPOINT, - client_cert_source=None, + ssl_channel_credentials=None, quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, ) - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is + # 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": "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() @@ -179,90 +216,185 @@ def test_analytics_admin_service_client_client_options( credentials_file=None, host=client.DEFAULT_MTLS_ENDPOINT, scopes=None, - api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, - client_cert_source=None, + ssl_channel_credentials=None, quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, ) - # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is - # "auto", and client_cert_source is provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): + # 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, + ssl_channel_credentials=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,use_client_cert_env", + [ + ( + AnalyticsAdminServiceClient, + transports.AnalyticsAdminServiceGrpcTransport, + "grpc", + "true", + ), + ( + AnalyticsAdminServiceAsyncClient, + transports.AnalyticsAdminServiceGrpcAsyncIOTransport, + "grpc_asyncio", + "true", + ), + ( + AnalyticsAdminServiceClient, + transports.AnalyticsAdminServiceGrpcTransport, + "grpc", + "false", + ), + ( + AnalyticsAdminServiceAsyncClient, + transports.AnalyticsAdminServiceGrpcAsyncIOTransport, + "grpc_asyncio", + "false", + ), + ], +) +@mock.patch.object( + AnalyticsAdminServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(AnalyticsAdminServiceClient), +) +@mock.patch.object( + AnalyticsAdminServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(AnalyticsAdminServiceAsyncClient), +) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_analytics_admin_service_client_mtls_env_auto( + client_class, transport_class, transport_name, use_client_cert_env +): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): options = client_options.ClientOptions( client_cert_source=client_cert_source_callback ) with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, - client_cert_source=client_cert_source_callback, - quota_project_id=None, - ) - - # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is - # "auto", and default_client_cert_source is provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): - with mock.patch.object(transport_class, "__init__") as patched: + ssl_channel_creds = mock.Mock() with mock.patch( - "google.auth.transport.mtls.has_default_client_cert_source", - return_value=True, + "grpc.ssl_channel_credentials", return_value=ssl_channel_creds ): patched.return_value = None - client = client_class() + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_ssl_channel_creds = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_ssl_channel_creds = ssl_channel_creds + expected_host = client.DEFAULT_MTLS_ENDPOINT + patched.assert_called_once_with( credentials=None, credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, + host=expected_host, scopes=None, - api_mtls_endpoint=client.DEFAULT_MTLS_ENDPOINT, - client_cert_source=None, + ssl_channel_credentials=expected_ssl_channel_creds, quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, ) - # Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is - # "auto", but client_cert_source and default_client_cert_source are None. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "auto"}): + # 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=False, + "google.auth.transport.grpc.SslCredentials.__init__", return_value=None ): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - api_mtls_endpoint=client.DEFAULT_ENDPOINT, - client_cert_source=None, - quota_project_id=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - 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, - api_mtls_endpoint=client.DEFAULT_ENDPOINT, - client_cert_source=None, - quota_project_id="octopus", - ) + with mock.patch( + "google.auth.transport.grpc.SslCredentials.is_mtls", + new_callable=mock.PropertyMock, + ) as is_mtls_mock: + with mock.patch( + "google.auth.transport.grpc.SslCredentials.ssl_credentials", + new_callable=mock.PropertyMock, + ) as ssl_credentials_mock: + if use_client_cert_env == "false": + is_mtls_mock.return_value = False + ssl_credentials_mock.return_value = None + expected_host = client.DEFAULT_ENDPOINT + expected_ssl_channel_creds = None + else: + is_mtls_mock.return_value = True + ssl_credentials_mock.return_value = mock.Mock() + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_ssl_channel_creds = ( + ssl_credentials_mock.return_value + ) + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + ssl_channel_credentials=expected_ssl_channel_creds, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.grpc.SslCredentials.__init__", return_value=None + ): + with mock.patch( + "google.auth.transport.grpc.SslCredentials.is_mtls", + new_callable=mock.PropertyMock, + ) as is_mtls_mock: + is_mtls_mock.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, + ssl_channel_credentials=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) @pytest.mark.parametrize( @@ -293,9 +425,9 @@ def test_analytics_admin_service_client_client_options_scopes( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=["1", "2"], - api_mtls_endpoint=client.DEFAULT_ENDPOINT, - client_cert_source=None, + ssl_channel_credentials=None, quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -327,9 +459,9 @@ def test_analytics_admin_service_client_client_options_credentials_file( credentials_file="credentials.json", host=client.DEFAULT_ENDPOINT, scopes=None, - api_mtls_endpoint=client.DEFAULT_ENDPOINT, - client_cert_source=None, + ssl_channel_credentials=None, quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -346,28 +478,30 @@ def test_analytics_admin_service_client_client_options_from_dict(): credentials_file=None, host="squid.clam.whelk", scopes=None, - api_mtls_endpoint="squid.clam.whelk", - client_cert_source=None, + ssl_channel_credentials=None, quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, ) -def test_get_account(transport: str = "grpc"): +def test_get_account( + transport: str = "grpc", request_type=analytics_admin.GetAccountRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetAccountRequest() + 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: + 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", - country_code="country_code_value", + region_code="region_code_value", deleted=True, ) @@ -377,40 +511,45 @@ def test_get_account(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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.country_code == "country_code_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) + + @pytest.mark.asyncio -async def test_get_account_async(transport: str = "grpc_asyncio"): +async def test_get_account_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.GetAccountRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetAccountRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_account), "__call__" - ) as call: + 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", - country_code="country_code_value", + region_code="region_code_value", deleted=True, ) ) @@ -421,7 +560,7 @@ async def test_get_account_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.GetAccountRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Account) @@ -430,11 +569,16 @@ async def test_get_account_async(transport: str = "grpc_asyncio"): assert response.display_name == "display_name_value" - assert response.country_code == "country_code_value" + assert response.region_code == "region_code_value" assert response.deleted is True +@pytest.mark.asyncio +async def test_get_account_async_from_dict(): + await test_get_account_async(request_type=dict) + + def test_get_account_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -446,7 +590,7 @@ def test_get_account_field_headers(): 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: + with mock.patch.object(type(client.transport.get_account), "__call__") as call: call.return_value = resources.Account() client.get_account(request) @@ -473,9 +617,7 @@ async def test_get_account_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_account), "__call__" - ) as call: + 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) @@ -496,7 +638,7 @@ def test_get_account_flattened(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_account), "__call__") as call: + 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() @@ -532,9 +674,7 @@ async def test_get_account_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_account), "__call__" - ) as call: + 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() @@ -565,17 +705,19 @@ async def test_get_account_flattened_error_async(): ) -def test_list_accounts(transport: str = "grpc"): +def test_list_accounts( + transport: str = "grpc", request_type=analytics_admin.ListAccountsRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListAccountsRequest() + 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: + 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", @@ -587,28 +729,33 @@ def test_list_accounts(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_list_accounts_async(transport: str = "grpc_asyncio"): +async def test_list_accounts_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.ListAccountsRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListAccountsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_accounts), "__call__" - ) as call: + 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( @@ -622,7 +769,7 @@ async def test_list_accounts_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListAccountsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAccountsAsyncPager) @@ -630,11 +777,16 @@ async def test_list_accounts_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_accounts_async_from_dict(): + await test_list_accounts_async(request_type=dict) + + def test_list_accounts_pager(): client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_accounts), "__call__") as call: + 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( @@ -669,7 +821,7 @@ def test_list_accounts_pages(): client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_accounts), "__call__") as call: + 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( @@ -690,8 +842,8 @@ def test_list_accounts_pages(): 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 + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio @@ -702,9 +854,7 @@ async def test_list_accounts_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_accounts), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_accounts), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -743,9 +893,7 @@ async def test_list_accounts_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_accounts), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_accounts), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -767,23 +915,25 @@ async def test_list_accounts_async_pages(): 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 + 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"): +def test_delete_account( + transport: str = "grpc", request_type=analytics_admin.DeleteAccountRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteAccountRequest() + 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: + with mock.patch.object(type(client.transport.delete_account), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -793,26 +943,30 @@ def test_delete_account(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_delete_account_async(transport: str = "grpc_asyncio"): +async def test_delete_account_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.DeleteAccountRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteAccountRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_account), "__call__" - ) as call: + 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) @@ -822,12 +976,17 @@ async def test_delete_account_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeleteAccountRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_account_async_from_dict(): + await test_delete_account_async(request_type=dict) + + def test_delete_account_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -839,7 +998,7 @@ def test_delete_account_field_headers(): 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: + with mock.patch.object(type(client.transport.delete_account), "__call__") as call: call.return_value = None client.delete_account(request) @@ -866,9 +1025,7 @@ async def test_delete_account_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_account), "__call__" - ) as call: + 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) @@ -889,7 +1046,7 @@ def test_delete_account_flattened(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_account), "__call__") as call: + with mock.patch.object(type(client.transport.delete_account), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -925,9 +1082,7 @@ async def test_delete_account_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_account), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_account), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -958,22 +1113,24 @@ async def test_delete_account_flattened_error_async(): ) -def test_update_account(transport: str = "grpc"): +def test_update_account( + transport: str = "grpc", request_type=analytics_admin.UpdateAccountRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateAccountRequest() + 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: + 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", - country_code="country_code_value", + region_code="region_code_value", deleted=True, ) @@ -983,40 +1140,45 @@ def test_update_account(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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.country_code == "country_code_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) + + @pytest.mark.asyncio -async def test_update_account_async(transport: str = "grpc_asyncio"): +async def test_update_account_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.UpdateAccountRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateAccountRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_account), "__call__" - ) as call: + 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", - country_code="country_code_value", + region_code="region_code_value", deleted=True, ) ) @@ -1027,7 +1189,7 @@ async def test_update_account_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.UpdateAccountRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Account) @@ -1036,11 +1198,16 @@ async def test_update_account_async(transport: str = "grpc_asyncio"): assert response.display_name == "display_name_value" - assert response.country_code == "country_code_value" + assert response.region_code == "region_code_value" assert response.deleted is True +@pytest.mark.asyncio +async def test_update_account_async_from_dict(): + await test_update_account_async(request_type=dict) + + def test_update_account_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -1052,7 +1219,7 @@ def test_update_account_field_headers(): 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: + with mock.patch.object(type(client.transport.update_account), "__call__") as call: call.return_value = resources.Account() client.update_account(request) @@ -1081,9 +1248,7 @@ async def test_update_account_field_headers_async(): request.account.name = "account.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_account), "__call__" - ) as call: + 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) @@ -1106,7 +1271,7 @@ def test_update_account_flattened(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_account), "__call__") as call: + 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() @@ -1149,9 +1314,7 @@ async def test_update_account_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_account), "__call__" - ) as call: + 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() @@ -1189,18 +1352,20 @@ async def test_update_account_flattened_error_async(): ) -def test_provision_account_ticket(transport: str = "grpc"): +def test_provision_account_ticket( + transport: str = "grpc", request_type=analytics_admin.ProvisionAccountTicketRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ProvisionAccountTicketRequest() + 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__" + type(client.transport.provision_account_ticket), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ProvisionAccountTicketResponse( @@ -1213,27 +1378,35 @@ def test_provision_account_ticket(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_provision_account_ticket_async(transport: str = "grpc_asyncio"): +async def test_provision_account_ticket_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ProvisionAccountTicketRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ProvisionAccountTicketRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.provision_account_ticket), "__call__" + type(client.transport.provision_account_ticket), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1248,7 +1421,7 @@ async def test_provision_account_ticket_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ProvisionAccountTicketRequest() # Establish that the response is the type that we expect. assert isinstance(response, analytics_admin.ProvisionAccountTicketResponse) @@ -1256,119 +1429,385 @@ async def test_provision_account_ticket_async(transport: str = "grpc_asyncio"): assert response.account_ticket_id == "account_ticket_id_value" -def test_get_property(transport: str = "grpc"): +@pytest.mark.asyncio +async def test_provision_account_ticket_async_from_dict(): + await test_provision_account_ticket_async(request_type=dict) + + +def test_list_account_summaries( + transport: str = "grpc", request_type=analytics_admin.ListAccountSummariesRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetPropertyRequest() + 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: + with mock.patch.object( + type(client.transport.list_account_summaries), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.Property( - name="name_value", - parent="parent_value", - display_name="display_name_value", - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone="time_zone_value", - currency_code="currency_code_value", - deleted=True, + call.return_value = analytics_admin.ListAccountSummariesResponse( + next_page_token="next_page_token_value", ) - response = client.get_property(request) + 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] == request + assert args[0] == analytics_admin.ListAccountSummariesRequest() # 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 isinstance(response, pagers.ListAccountSummariesPager) - assert response.time_zone == "time_zone_value" + assert response.next_page_token == "next_page_token_value" - assert response.currency_code == "currency_code_value" - assert response.deleted is True +def test_list_account_summaries_from_dict(): + test_list_account_summaries(request_type=dict) @pytest.mark.asyncio -async def test_get_property_async(transport: str = "grpc_asyncio"): +async def test_list_account_summaries_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListAccountSummariesRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetPropertyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_property), "__call__" + type(client.transport.list_account_summaries), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Property( - name="name_value", - parent="parent_value", - display_name="display_name_value", - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone="time_zone_value", - currency_code="currency_code_value", - deleted=True, + analytics_admin.ListAccountSummariesResponse( + next_page_token="next_page_token_value", ) ) - response = await client.get_property(request) + 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] == request + assert args[0] == analytics_admin.ListAccountSummariesRequest() # 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 isinstance(response, pagers.ListAccountSummariesAsyncPager) - assert response.currency_code == "currency_code_value" + assert response.next_page_token == "next_page_token_value" - assert response.deleted is True +@pytest.mark.asyncio +async def test_list_account_summaries_async_from_dict(): + await test_list_account_summaries_async(request_type=dict) -def test_get_property_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.GetPropertyRequest() - request.name = "name/value" +def test_list_account_summaries_pager(): + client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_property), "__call__") as call: + with mock.patch.object( + type(client.transport.list_account_summaries), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], next_page_token="def", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[resources.AccountSummary(),], next_page_token="ghi", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + RuntimeError, + ) + + metadata = () + pager = client.list_account_summaries(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.AccountSummary) for i in results) + + +def test_list_account_summaries_pages(): + client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_account_summaries), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], next_page_token="def", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[resources.AccountSummary(),], next_page_token="ghi", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + RuntimeError, + ) + pages = list(client.list_account_summaries(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_account_summaries_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_account_summaries), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], next_page_token="def", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[resources.AccountSummary(),], next_page_token="ghi", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_account_summaries(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.AccountSummary) for i in responses) + + +@pytest.mark.asyncio +async def test_list_account_summaries_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_account_summaries), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], next_page_token="def", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[resources.AccountSummary(),], next_page_token="ghi", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_account_summaries(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_property( + transport: str = "grpc", request_type=analytics_admin.GetPropertyRequest +): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_property), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Property( + name="name_value", + parent="parent_value", + display_name="display_name_value", + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone="time_zone_value", + currency_code="currency_code_value", + deleted=True, + ) + + response = client.get_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetPropertyRequest() + + # Establish that the response is the type that we expect. + + assert isinstance(response, resources.Property) + + assert response.name == "name_value" + + assert response.parent == "parent_value" + + assert response.display_name == "display_name_value" + + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + + assert response.time_zone == "time_zone_value" + + assert response.currency_code == "currency_code_value" + + assert response.deleted is True + + +def test_get_property_from_dict(): + test_get_property(request_type=dict) + + +@pytest.mark.asyncio +async def test_get_property_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.GetPropertyRequest +): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_property), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Property( + name="name_value", + parent="parent_value", + display_name="display_name_value", + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone="time_zone_value", + currency_code="currency_code_value", + deleted=True, + ) + ) + + response = await client.get_property(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + + assert args[0] == analytics_admin.GetPropertyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Property) + + assert response.name == "name_value" + + assert response.parent == "parent_value" + + assert response.display_name == "display_name_value" + + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + + assert response.time_zone == "time_zone_value" + + assert response.currency_code == "currency_code_value" + + assert response.deleted is True + + +@pytest.mark.asyncio +async def test_get_property_async_from_dict(): + await test_get_property_async(request_type=dict) + + +def test_get_property_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetPropertyRequest() + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_property), "__call__") as call: call.return_value = resources.Property() client.get_property(request) @@ -1395,9 +1834,7 @@ async def test_get_property_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_property), "__call__" - ) as call: + 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) @@ -1418,7 +1855,7 @@ def test_get_property_flattened(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_property), "__call__") as call: + 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() @@ -1454,9 +1891,7 @@ async def test_get_property_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_property), "__call__" - ) as call: + 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() @@ -1487,17 +1922,19 @@ async def test_get_property_flattened_error_async(): ) -def test_list_properties(transport: str = "grpc"): +def test_list_properties( + transport: str = "grpc", request_type=analytics_admin.ListPropertiesRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListPropertiesRequest() + 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: + 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", @@ -1509,28 +1946,33 @@ def test_list_properties(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_list_properties_async(transport: str = "grpc_asyncio"): +async def test_list_properties_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.ListPropertiesRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListPropertiesRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_properties), "__call__" - ) as call: + 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( @@ -1544,7 +1986,7 @@ async def test_list_properties_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListPropertiesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListPropertiesAsyncPager) @@ -1552,11 +1994,16 @@ async def test_list_properties_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_properties_async_from_dict(): + await test_list_properties_async(request_type=dict) + + def test_list_properties_pager(): client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_properties), "__call__") as call: + 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( @@ -1593,7 +2040,7 @@ def test_list_properties_pages(): client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_properties), "__call__") as call: + 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( @@ -1616,8 +2063,8 @@ def test_list_properties_pages(): 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 + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio @@ -1628,9 +2075,7 @@ async def test_list_properties_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_properties), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_properties), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1671,9 +2116,7 @@ async def test_list_properties_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_properties), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_properties), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1697,23 +2140,25 @@ async def test_list_properties_async_pages(): 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 + 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"): +def test_create_property( + transport: str = "grpc", request_type=analytics_admin.CreatePropertyRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreatePropertyRequest() + 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: + 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", @@ -1731,9 +2176,10 @@ def test_create_property(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -1751,20 +2197,24 @@ def test_create_property(transport: str = "grpc"): assert response.deleted is True +def test_create_property_from_dict(): + test_create_property(request_type=dict) + + @pytest.mark.asyncio -async def test_create_property_async(transport: str = "grpc_asyncio"): +async def test_create_property_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.CreatePropertyRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreatePropertyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_property), "__call__" - ) as call: + 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( @@ -1784,7 +2234,7 @@ async def test_create_property_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.CreatePropertyRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Property) @@ -1804,13 +2254,18 @@ async def test_create_property_async(transport: str = "grpc_asyncio"): assert response.deleted is True +@pytest.mark.asyncio +async def test_create_property_async_from_dict(): + await test_create_property_async(request_type=dict) + + def test_create_property_flattened(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_property), "__call__") as call: + 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() @@ -1847,9 +2302,7 @@ async def test_create_property_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_property), "__call__" - ) as call: + 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() @@ -1883,17 +2336,19 @@ async def test_create_property_flattened_error_async(): ) -def test_delete_property(transport: str = "grpc"): +def test_delete_property( + transport: str = "grpc", request_type=analytics_admin.DeletePropertyRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeletePropertyRequest() + 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: + with mock.patch.object(type(client.transport.delete_property), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1903,26 +2358,30 @@ def test_delete_property(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeletePropertyRequest() # Establish that the response is the type that we expect. assert response is None +def test_delete_property_from_dict(): + test_delete_property(request_type=dict) + + @pytest.mark.asyncio -async def test_delete_property_async(transport: str = "grpc_asyncio"): +async def test_delete_property_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.DeletePropertyRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeletePropertyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_property), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_property), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1932,12 +2391,17 @@ async def test_delete_property_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeletePropertyRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_property_async_from_dict(): + await test_delete_property_async(request_type=dict) + + def test_delete_property_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -1949,7 +2413,7 @@ def test_delete_property_field_headers(): 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: + with mock.patch.object(type(client.transport.delete_property), "__call__") as call: call.return_value = None client.delete_property(request) @@ -1976,9 +2440,7 @@ async def test_delete_property_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_property), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_property), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_property(request) @@ -1999,7 +2461,7 @@ def test_delete_property_flattened(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_property), "__call__") as call: + with mock.patch.object(type(client.transport.delete_property), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -2035,9 +2497,7 @@ async def test_delete_property_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_property), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_property), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -2068,17 +2528,19 @@ async def test_delete_property_flattened_error_async(): ) -def test_update_property(transport: str = "grpc"): +def test_update_property( + transport: str = "grpc", request_type=analytics_admin.UpdatePropertyRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdatePropertyRequest() + 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: + 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", @@ -2096,9 +2558,10 @@ def test_update_property(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -2116,20 +2579,24 @@ def test_update_property(transport: str = "grpc"): assert response.deleted is True +def test_update_property_from_dict(): + test_update_property(request_type=dict) + + @pytest.mark.asyncio -async def test_update_property_async(transport: str = "grpc_asyncio"): +async def test_update_property_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.UpdatePropertyRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdatePropertyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_property), "__call__" - ) as call: + 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( @@ -2149,7 +2616,7 @@ async def test_update_property_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.UpdatePropertyRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Property) @@ -2169,6 +2636,11 @@ async def test_update_property_async(transport: str = "grpc_asyncio"): assert response.deleted is True +@pytest.mark.asyncio +async def test_update_property_async_from_dict(): + await test_update_property_async(request_type=dict) + + def test_update_property_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -2180,7 +2652,7 @@ def test_update_property_field_headers(): 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: + with mock.patch.object(type(client.transport.update_property), "__call__") as call: call.return_value = resources.Property() client.update_property(request) @@ -2209,9 +2681,7 @@ async def test_update_property_field_headers_async(): request.property.name = "property.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_property), "__call__" - ) as call: + 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) @@ -2234,7 +2704,7 @@ def test_update_property_flattened(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_property), "__call__") as call: + 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() @@ -2277,9 +2747,7 @@ async def test_update_property_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_property), "__call__" - ) as call: + 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() @@ -2317,17 +2785,19 @@ async def test_update_property_flattened_error_async(): ) -def test_get_user_link(transport: str = "grpc"): +def test_get_user_link( + transport: str = "grpc", request_type=analytics_admin.GetUserLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetUserLinkRequest() + 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: + 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", @@ -2341,9 +2811,10 @@ def test_get_user_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -2353,20 +2824,24 @@ def test_get_user_link(transport: str = "grpc"): assert response.direct_roles == ["direct_roles_value"] +def test_get_user_link_from_dict(): + test_get_user_link(request_type=dict) + + @pytest.mark.asyncio -async def test_get_user_link_async(transport: str = "grpc_asyncio"): +async def test_get_user_link_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.GetUserLinkRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetUserLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_user_link), "__call__" - ) as call: + 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( @@ -2382,7 +2857,7 @@ async def test_get_user_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.GetUserLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.UserLink) @@ -2394,6 +2869,11 @@ async def test_get_user_link_async(transport: str = "grpc_asyncio"): assert response.direct_roles == ["direct_roles_value"] +@pytest.mark.asyncio +async def test_get_user_link_async_from_dict(): + await test_get_user_link_async(request_type=dict) + + def test_get_user_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -2405,7 +2885,7 @@ def test_get_user_link_field_headers(): 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: + with mock.patch.object(type(client.transport.get_user_link), "__call__") as call: call.return_value = resources.UserLink() client.get_user_link(request) @@ -2432,9 +2912,7 @@ async def test_get_user_link_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_user_link), "__call__" - ) as call: + 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) @@ -2455,7 +2933,7 @@ def test_get_user_link_flattened(): ) # 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: + 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() @@ -2491,9 +2969,7 @@ async def test_get_user_link_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_user_link), "__call__" - ) as call: + 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() @@ -2524,18 +3000,20 @@ async def test_get_user_link_flattened_error_async(): ) -def test_batch_get_user_links(transport: str = "grpc"): +def test_batch_get_user_links( + transport: str = "grpc", request_type=analytics_admin.BatchGetUserLinksRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.BatchGetUserLinksRequest() + 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__" + type(client.transport.batch_get_user_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.BatchGetUserLinksResponse() @@ -2546,25 +3024,33 @@ def test_batch_get_user_links(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_batch_get_user_links_async(transport: str = "grpc_asyncio"): +async def test_batch_get_user_links_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.BatchGetUserLinksRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.BatchGetUserLinksRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_get_user_links), "__call__" + 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( @@ -2577,12 +3063,17 @@ async def test_batch_get_user_links_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.BatchGetUserLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) +@pytest.mark.asyncio +async def test_batch_get_user_links_async_from_dict(): + await test_batch_get_user_links_async(request_type=dict) + + def test_batch_get_user_links_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -2595,7 +3086,7 @@ def test_batch_get_user_links_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_get_user_links), "__call__" + type(client.transport.batch_get_user_links), "__call__" ) as call: call.return_value = analytics_admin.BatchGetUserLinksResponse() @@ -2624,7 +3115,7 @@ async def test_batch_get_user_links_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_get_user_links), "__call__" + type(client.transport.batch_get_user_links), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchGetUserLinksResponse() @@ -2642,17 +3133,19 @@ async def test_batch_get_user_links_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_user_links(transport: str = "grpc"): +def test_list_user_links( + transport: str = "grpc", request_type=analytics_admin.ListUserLinksRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListUserLinksRequest() + 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: + 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", @@ -2664,28 +3157,33 @@ def test_list_user_links(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_list_user_links_async(transport: str = "grpc_asyncio"): +async def test_list_user_links_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.ListUserLinksRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListUserLinksRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_user_links), "__call__" - ) as call: + 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( @@ -2699,7 +3197,7 @@ async def test_list_user_links_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListUserLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListUserLinksAsyncPager) @@ -2707,6 +3205,11 @@ async def test_list_user_links_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_user_links_async_from_dict(): + await test_list_user_links_async(request_type=dict) + + def test_list_user_links_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -2718,7 +3221,7 @@ def test_list_user_links_field_headers(): 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: + with mock.patch.object(type(client.transport.list_user_links), "__call__") as call: call.return_value = analytics_admin.ListUserLinksResponse() client.list_user_links(request) @@ -2745,9 +3248,7 @@ async def test_list_user_links_field_headers_async(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_user_links), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_user_links), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListUserLinksResponse() ) @@ -2770,7 +3271,7 @@ def test_list_user_links_flattened(): ) # 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: + 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() @@ -2806,9 +3307,7 @@ async def test_list_user_links_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_user_links), "__call__" - ) as call: + 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() @@ -2845,7 +3344,7 @@ def test_list_user_links_pager(): client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_user_links), "__call__") as call: + 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( @@ -2885,7 +3384,7 @@ def test_list_user_links_pages(): client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_user_links), "__call__") as call: + 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( @@ -2908,8 +3407,8 @@ def test_list_user_links_pages(): 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 + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio @@ -2920,9 +3419,7 @@ async def test_list_user_links_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_user_links), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_user_links), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2963,9 +3460,7 @@ async def test_list_user_links_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_user_links), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_user_links), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2989,25 +3484,25 @@ async def test_list_user_links_async_pages(): 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 + 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"): +def test_audit_user_links( + transport: str = "grpc", request_type=analytics_admin.AuditUserLinksRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.AuditUserLinksRequest() + 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: + 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", @@ -3019,28 +3514,33 @@ def test_audit_user_links(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_audit_user_links_async(transport: str = "grpc_asyncio"): +async def test_audit_user_links_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.AuditUserLinksRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.AuditUserLinksRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.audit_user_links), "__call__" - ) as call: + 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( @@ -3054,7 +3554,7 @@ async def test_audit_user_links_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.AuditUserLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.AuditUserLinksAsyncPager) @@ -3062,6 +3562,11 @@ async def test_audit_user_links_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_audit_user_links_async_from_dict(): + await test_audit_user_links_async(request_type=dict) + + def test_audit_user_links_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -3073,9 +3578,7 @@ def test_audit_user_links_field_headers(): 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: + with mock.patch.object(type(client.transport.audit_user_links), "__call__") as call: call.return_value = analytics_admin.AuditUserLinksResponse() client.audit_user_links(request) @@ -3102,9 +3605,7 @@ async def test_audit_user_links_field_headers_async(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.audit_user_links), "__call__" - ) as call: + with mock.patch.object(type(client.transport.audit_user_links), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.AuditUserLinksResponse() ) @@ -3125,9 +3626,7 @@ def test_audit_user_links_pager(): client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._transport.audit_user_links), "__call__" - ) as call: + 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( @@ -3167,9 +3666,7 @@ def test_audit_user_links_pages(): client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._transport.audit_user_links), "__call__" - ) as call: + 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( @@ -3192,8 +3689,8 @@ def test_audit_user_links_pages(): 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 + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio @@ -3204,9 +3701,7 @@ async def test_audit_user_links_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.audit_user_links), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.audit_user_links), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -3247,9 +3742,7 @@ async def test_audit_user_links_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.audit_user_links), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.audit_user_links), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -3273,25 +3766,25 @@ async def test_audit_user_links_async_pages(): 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 + 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"): +def test_create_user_link( + transport: str = "grpc", request_type=analytics_admin.CreateUserLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateUserLinkRequest() + 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: + 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", @@ -3305,9 +3798,10 @@ def test_create_user_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -3317,20 +3811,24 @@ def test_create_user_link(transport: str = "grpc"): assert response.direct_roles == ["direct_roles_value"] +def test_create_user_link_from_dict(): + test_create_user_link(request_type=dict) + + @pytest.mark.asyncio -async def test_create_user_link_async(transport: str = "grpc_asyncio"): +async def test_create_user_link_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.CreateUserLinkRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateUserLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_user_link), "__call__" - ) as call: + 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( @@ -3346,7 +3844,7 @@ async def test_create_user_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.CreateUserLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.UserLink) @@ -3358,6 +3856,11 @@ async def test_create_user_link_async(transport: str = "grpc_asyncio"): assert response.direct_roles == ["direct_roles_value"] +@pytest.mark.asyncio +async def test_create_user_link_async_from_dict(): + await test_create_user_link_async(request_type=dict) + + def test_create_user_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -3369,9 +3872,7 @@ def test_create_user_link_field_headers(): 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: + with mock.patch.object(type(client.transport.create_user_link), "__call__") as call: call.return_value = resources.UserLink() client.create_user_link(request) @@ -3398,9 +3899,7 @@ async def test_create_user_link_field_headers_async(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_user_link), "__call__" - ) as call: + 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) @@ -3421,9 +3920,7 @@ def test_create_user_link_flattened(): ) # 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: + 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() @@ -3465,9 +3962,7 @@ async def test_create_user_link_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_user_link), "__call__" - ) as call: + 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() @@ -3504,18 +3999,20 @@ async def test_create_user_link_flattened_error_async(): ) -def test_batch_create_user_links(transport: str = "grpc"): +def test_batch_create_user_links( + transport: str = "grpc", request_type=analytics_admin.BatchCreateUserLinksRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.BatchCreateUserLinksRequest() + 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__" + type(client.transport.batch_create_user_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.BatchCreateUserLinksResponse() @@ -3526,25 +4023,33 @@ def test_batch_create_user_links(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_batch_create_user_links_async(transport: str = "grpc_asyncio"): +async def test_batch_create_user_links_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.BatchCreateUserLinksRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.BatchCreateUserLinksRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_create_user_links), "__call__" + 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( @@ -3557,12 +4062,17 @@ async def test_batch_create_user_links_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.BatchCreateUserLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) +@pytest.mark.asyncio +async def test_batch_create_user_links_async_from_dict(): + await test_batch_create_user_links_async(request_type=dict) + + def test_batch_create_user_links_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -3575,7 +4085,7 @@ def test_batch_create_user_links_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_create_user_links), "__call__" + type(client.transport.batch_create_user_links), "__call__" ) as call: call.return_value = analytics_admin.BatchCreateUserLinksResponse() @@ -3604,7 +4114,7 @@ async def test_batch_create_user_links_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_create_user_links), "__call__" + type(client.transport.batch_create_user_links), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchCreateUserLinksResponse() @@ -3622,19 +4132,19 @@ async def test_batch_create_user_links_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_update_user_link(transport: str = "grpc"): +def test_update_user_link( + transport: str = "grpc", request_type=analytics_admin.UpdateUserLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateUserLinkRequest() + 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: + 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", @@ -3648,9 +4158,10 @@ def test_update_user_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -3660,20 +4171,24 @@ def test_update_user_link(transport: str = "grpc"): assert response.direct_roles == ["direct_roles_value"] +def test_update_user_link_from_dict(): + test_update_user_link(request_type=dict) + + @pytest.mark.asyncio -async def test_update_user_link_async(transport: str = "grpc_asyncio"): +async def test_update_user_link_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.UpdateUserLinkRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateUserLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_user_link), "__call__" - ) as call: + 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( @@ -3689,7 +4204,7 @@ async def test_update_user_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.UpdateUserLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.UserLink) @@ -3701,6 +4216,11 @@ async def test_update_user_link_async(transport: str = "grpc_asyncio"): assert response.direct_roles == ["direct_roles_value"] +@pytest.mark.asyncio +async def test_update_user_link_async_from_dict(): + await test_update_user_link_async(request_type=dict) + + def test_update_user_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -3712,9 +4232,7 @@ def test_update_user_link_field_headers(): 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: + with mock.patch.object(type(client.transport.update_user_link), "__call__") as call: call.return_value = resources.UserLink() client.update_user_link(request) @@ -3743,9 +4261,7 @@ async def test_update_user_link_field_headers_async(): 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._client._transport.update_user_link), "__call__" - ) as call: + 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) @@ -3768,9 +4284,7 @@ def test_update_user_link_flattened(): ) # 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: + 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() @@ -3807,9 +4321,7 @@ async def test_update_user_link_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_user_link), "__call__" - ) as call: + 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() @@ -3843,18 +4355,20 @@ async def test_update_user_link_flattened_error_async(): ) -def test_batch_update_user_links(transport: str = "grpc"): +def test_batch_update_user_links( + transport: str = "grpc", request_type=analytics_admin.BatchUpdateUserLinksRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.BatchUpdateUserLinksRequest() + 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__" + type(client.transport.batch_update_user_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.BatchUpdateUserLinksResponse() @@ -3865,25 +4379,33 @@ def test_batch_update_user_links(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_batch_update_user_links_async(transport: str = "grpc_asyncio"): +async def test_batch_update_user_links_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.BatchUpdateUserLinksRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.BatchUpdateUserLinksRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_update_user_links), "__call__" + 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( @@ -3896,12 +4418,17 @@ async def test_batch_update_user_links_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) +@pytest.mark.asyncio +async def test_batch_update_user_links_async_from_dict(): + await test_batch_update_user_links_async(request_type=dict) + + def test_batch_update_user_links_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -3914,7 +4441,7 @@ def test_batch_update_user_links_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_update_user_links), "__call__" + type(client.transport.batch_update_user_links), "__call__" ) as call: call.return_value = analytics_admin.BatchUpdateUserLinksResponse() @@ -3943,7 +4470,7 @@ async def test_batch_update_user_links_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_update_user_links), "__call__" + type(client.transport.batch_update_user_links), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchUpdateUserLinksResponse() @@ -3961,19 +4488,19 @@ async def test_batch_update_user_links_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_delete_user_link(transport: str = "grpc"): +def test_delete_user_link( + transport: str = "grpc", request_type=analytics_admin.DeleteUserLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteUserLinkRequest() + 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: + 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 @@ -3983,26 +4510,30 @@ def test_delete_user_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_delete_user_link_async(transport: str = "grpc_asyncio"): +async def test_delete_user_link_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.DeleteUserLinkRequest +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteUserLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_user_link), "__call__" - ) as call: + 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) @@ -4012,12 +4543,17 @@ async def test_delete_user_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeleteUserLinkRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_user_link_async_from_dict(): + await test_delete_user_link_async(request_type=dict) + + def test_delete_user_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -4029,9 +4565,7 @@ def test_delete_user_link_field_headers(): 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: + with mock.patch.object(type(client.transport.delete_user_link), "__call__") as call: call.return_value = None client.delete_user_link(request) @@ -4058,9 +4592,7 @@ async def test_delete_user_link_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_user_link), "__call__" - ) as call: + 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) @@ -4081,9 +4613,7 @@ def test_delete_user_link_flattened(): ) # 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: + 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 @@ -4119,9 +4649,7 @@ async def test_delete_user_link_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_user_link), "__call__" - ) as call: + 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 @@ -4152,18 +4680,20 @@ async def test_delete_user_link_flattened_error_async(): ) -def test_batch_delete_user_links(transport: str = "grpc"): +def test_batch_delete_user_links( + transport: str = "grpc", request_type=analytics_admin.BatchDeleteUserLinksRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.BatchDeleteUserLinksRequest() + 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__" + type(client.transport.batch_delete_user_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -4174,25 +4704,32 @@ def test_batch_delete_user_links(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_batch_delete_user_links_async(transport: str = "grpc_asyncio"): +async def test_batch_delete_user_links_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.BatchDeleteUserLinksRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.BatchDeleteUserLinksRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_delete_user_links), "__call__" + 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) @@ -4203,12 +4740,17 @@ async def test_batch_delete_user_links_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_batch_delete_user_links_async_from_dict(): + await test_batch_delete_user_links_async(request_type=dict) + + def test_batch_delete_user_links_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -4221,7 +4763,7 @@ def test_batch_delete_user_links_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_delete_user_links), "__call__" + type(client.transport.batch_delete_user_links), "__call__" ) as call: call.return_value = None @@ -4250,7 +4792,7 @@ async def test_batch_delete_user_links_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_delete_user_links), "__call__" + type(client.transport.batch_delete_user_links), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -4266,18 +4808,20 @@ async def test_batch_delete_user_links_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_get_web_data_stream(transport: str = "grpc"): +def test_get_web_data_stream( + transport: str = "grpc", request_type=analytics_admin.GetWebDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetWebDataStreamRequest() + 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__" + type(client.transport.get_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream( @@ -4294,9 +4838,10 @@ def test_get_web_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -4310,19 +4855,26 @@ def test_get_web_data_stream(transport: str = "grpc"): assert response.display_name == "display_name_value" +def test_get_web_data_stream_from_dict(): + test_get_web_data_stream(request_type=dict) + + @pytest.mark.asyncio -async def test_get_web_data_stream_async(transport: str = "grpc_asyncio"): +async def test_get_web_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetWebDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetWebDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_web_data_stream), "__call__" + 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( @@ -4341,7 +4893,7 @@ async def test_get_web_data_stream_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.GetWebDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.WebDataStream) @@ -4357,6 +4909,11 @@ async def test_get_web_data_stream_async(transport: str = "grpc_asyncio"): assert response.display_name == "display_name_value" +@pytest.mark.asyncio +async def test_get_web_data_stream_async_from_dict(): + await test_get_web_data_stream_async(request_type=dict) + + def test_get_web_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -4369,7 +4926,7 @@ def test_get_web_data_stream_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_web_data_stream), "__call__" + type(client.transport.get_web_data_stream), "__call__" ) as call: call.return_value = resources.WebDataStream() @@ -4398,7 +4955,7 @@ async def test_get_web_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_web_data_stream), "__call__" + type(client.transport.get_web_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.WebDataStream() @@ -4423,7 +4980,7 @@ def test_get_web_data_stream_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_web_data_stream), "__call__" + type(client.transport.get_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() @@ -4461,7 +5018,7 @@ async def test_get_web_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_web_data_stream), "__call__" + type(client.transport.get_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() @@ -4495,18 +5052,20 @@ async def test_get_web_data_stream_flattened_error_async(): ) -def test_delete_web_data_stream(transport: str = "grpc"): +def test_delete_web_data_stream( + transport: str = "grpc", request_type=analytics_admin.DeleteWebDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteWebDataStreamRequest() + 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__" + type(client.transport.delete_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -4517,25 +5076,32 @@ def test_delete_web_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_delete_web_data_stream_async(transport: str = "grpc_asyncio"): +async def test_delete_web_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteWebDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteWebDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_web_data_stream), "__call__" + 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) @@ -4546,12 +5112,17 @@ async def test_delete_web_data_stream_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeleteWebDataStreamRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_web_data_stream_async_from_dict(): + await test_delete_web_data_stream_async(request_type=dict) + + def test_delete_web_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -4564,7 +5135,7 @@ def test_delete_web_data_stream_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_web_data_stream), "__call__" + type(client.transport.delete_web_data_stream), "__call__" ) as call: call.return_value = None @@ -4593,7 +5164,7 @@ async def test_delete_web_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_web_data_stream), "__call__" + type(client.transport.delete_web_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -4616,7 +5187,7 @@ def test_delete_web_data_stream_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_web_data_stream), "__call__" + type(client.transport.delete_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -4654,7 +5225,7 @@ async def test_delete_web_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_web_data_stream), "__call__" + type(client.transport.delete_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -4686,18 +5257,20 @@ async def test_delete_web_data_stream_flattened_error_async(): ) -def test_update_web_data_stream(transport: str = "grpc"): +def test_update_web_data_stream( + transport: str = "grpc", request_type=analytics_admin.UpdateWebDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateWebDataStreamRequest() + 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__" + type(client.transport.update_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream( @@ -4714,9 +5287,10 @@ def test_update_web_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -4730,19 +5304,26 @@ def test_update_web_data_stream(transport: str = "grpc"): assert response.display_name == "display_name_value" +def test_update_web_data_stream_from_dict(): + test_update_web_data_stream(request_type=dict) + + @pytest.mark.asyncio -async def test_update_web_data_stream_async(transport: str = "grpc_asyncio"): +async def test_update_web_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateWebDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateWebDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_web_data_stream), "__call__" + 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( @@ -4761,7 +5342,7 @@ async def test_update_web_data_stream_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.UpdateWebDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.WebDataStream) @@ -4777,6 +5358,11 @@ async def test_update_web_data_stream_async(transport: str = "grpc_asyncio"): assert response.display_name == "display_name_value" +@pytest.mark.asyncio +async def test_update_web_data_stream_async_from_dict(): + await test_update_web_data_stream_async(request_type=dict) + + def test_update_web_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -4789,7 +5375,7 @@ def test_update_web_data_stream_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_web_data_stream), "__call__" + type(client.transport.update_web_data_stream), "__call__" ) as call: call.return_value = resources.WebDataStream() @@ -4821,7 +5407,7 @@ async def test_update_web_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_web_data_stream), "__call__" + type(client.transport.update_web_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.WebDataStream() @@ -4849,7 +5435,7 @@ def test_update_web_data_stream_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_web_data_stream), "__call__" + type(client.transport.update_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() @@ -4894,7 +5480,7 @@ async def test_update_web_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_web_data_stream), "__call__" + type(client.transport.update_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() @@ -4935,18 +5521,20 @@ async def test_update_web_data_stream_flattened_error_async(): ) -def test_create_web_data_stream(transport: str = "grpc"): +def test_create_web_data_stream( + transport: str = "grpc", request_type=analytics_admin.CreateWebDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateWebDataStreamRequest() + 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__" + type(client.transport.create_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream( @@ -4963,9 +5551,10 @@ def test_create_web_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -4979,19 +5568,26 @@ def test_create_web_data_stream(transport: str = "grpc"): assert response.display_name == "display_name_value" +def test_create_web_data_stream_from_dict(): + test_create_web_data_stream(request_type=dict) + + @pytest.mark.asyncio -async def test_create_web_data_stream_async(transport: str = "grpc_asyncio"): +async def test_create_web_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateWebDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateWebDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_web_data_stream), "__call__" + 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( @@ -5010,7 +5606,7 @@ async def test_create_web_data_stream_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.CreateWebDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.WebDataStream) @@ -5026,8 +5622,13 @@ async def test_create_web_data_stream_async(transport: str = "grpc_asyncio"): assert response.display_name == "display_name_value" -def test_create_web_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( +@pytest.mark.asyncio +async def test_create_web_data_stream_async_from_dict(): + await test_create_web_data_stream_async(request_type=dict) + + +def test_create_web_data_stream_field_headers(): + client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), ) @@ -5038,7 +5639,7 @@ def test_create_web_data_stream_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_web_data_stream), "__call__" + type(client.transport.create_web_data_stream), "__call__" ) as call: call.return_value = resources.WebDataStream() @@ -5067,7 +5668,7 @@ async def test_create_web_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_web_data_stream), "__call__" + type(client.transport.create_web_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.WebDataStream() @@ -5092,7 +5693,7 @@ def test_create_web_data_stream_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_web_data_stream), "__call__" + type(client.transport.create_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() @@ -5137,7 +5738,7 @@ async def test_create_web_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_web_data_stream), "__call__" + type(client.transport.create_web_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() @@ -5178,18 +5779,20 @@ async def test_create_web_data_stream_flattened_error_async(): ) -def test_list_web_data_streams(transport: str = "grpc"): +def test_list_web_data_streams( + transport: str = "grpc", request_type=analytics_admin.ListWebDataStreamsRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListWebDataStreamsRequest() + 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__" + type(client.transport.list_web_data_streams), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListWebDataStreamsResponse( @@ -5202,27 +5805,35 @@ def test_list_web_data_streams(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_list_web_data_streams_async(transport: str = "grpc_asyncio"): +async def test_list_web_data_streams_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListWebDataStreamsRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListWebDataStreamsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_web_data_streams), "__call__" + 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( @@ -5237,7 +5848,7 @@ async def test_list_web_data_streams_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListWebDataStreamsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListWebDataStreamsAsyncPager) @@ -5245,6 +5856,11 @@ async def test_list_web_data_streams_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_web_data_streams_async_from_dict(): + await test_list_web_data_streams_async(request_type=dict) + + def test_list_web_data_streams_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -5257,7 +5873,7 @@ def test_list_web_data_streams_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_web_data_streams), "__call__" + type(client.transport.list_web_data_streams), "__call__" ) as call: call.return_value = analytics_admin.ListWebDataStreamsResponse() @@ -5286,7 +5902,7 @@ async def test_list_web_data_streams_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_web_data_streams), "__call__" + type(client.transport.list_web_data_streams), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListWebDataStreamsResponse() @@ -5311,7 +5927,7 @@ def test_list_web_data_streams_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_web_data_streams), "__call__" + type(client.transport.list_web_data_streams), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListWebDataStreamsResponse() @@ -5349,7 +5965,7 @@ async def test_list_web_data_streams_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_web_data_streams), "__call__" + type(client.transport.list_web_data_streams), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListWebDataStreamsResponse() @@ -5388,7 +6004,7 @@ def test_list_web_data_streams_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_web_data_streams), "__call__" + type(client.transport.list_web_data_streams), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -5433,7 +6049,7 @@ def test_list_web_data_streams_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_web_data_streams), "__call__" + type(client.transport.list_web_data_streams), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -5460,8 +6076,8 @@ def test_list_web_data_streams_pages(): 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 + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio @@ -5472,7 +6088,7 @@ async def test_list_web_data_streams_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_web_data_streams), + type(client.transport.list_web_data_streams), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -5518,7 +6134,7 @@ async def test_list_web_data_streams_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_web_data_streams), + type(client.transport.list_web_data_streams), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -5547,24 +6163,26 @@ async def test_list_web_data_streams_async_pages(): 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 + 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"): +def test_get_ios_app_data_stream( + transport: str = "grpc", request_type=analytics_admin.GetIosAppDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetIosAppDataStreamRequest() + 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__" + type(client.transport.get_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream( @@ -5580,9 +6198,10 @@ def test_get_ios_app_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -5594,19 +6213,26 @@ def test_get_ios_app_data_stream(transport: str = "grpc"): 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) + + @pytest.mark.asyncio -async def test_get_ios_app_data_stream_async(transport: str = "grpc_asyncio"): +async def test_get_ios_app_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetIosAppDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetIosAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_ios_app_data_stream), "__call__" + 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( @@ -5624,7 +6250,7 @@ async def test_get_ios_app_data_stream_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.GetIosAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.IosAppDataStream) @@ -5638,6 +6264,11 @@ async def test_get_ios_app_data_stream_async(transport: str = "grpc_asyncio"): assert response.display_name == "display_name_value" +@pytest.mark.asyncio +async def test_get_ios_app_data_stream_async_from_dict(): + await test_get_ios_app_data_stream_async(request_type=dict) + + def test_get_ios_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -5650,7 +6281,7 @@ def test_get_ios_app_data_stream_field_headers(): # 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__" + type(client.transport.get_ios_app_data_stream), "__call__" ) as call: call.return_value = resources.IosAppDataStream() @@ -5679,7 +6310,7 @@ async def test_get_ios_app_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_ios_app_data_stream), "__call__" + type(client.transport.get_ios_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.IosAppDataStream() @@ -5704,7 +6335,7 @@ def test_get_ios_app_data_stream_flattened(): # 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__" + type(client.transport.get_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream() @@ -5742,7 +6373,7 @@ async def test_get_ios_app_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_ios_app_data_stream), "__call__" + type(client.transport.get_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream() @@ -5776,18 +6407,20 @@ async def test_get_ios_app_data_stream_flattened_error_async(): ) -def test_delete_ios_app_data_stream(transport: str = "grpc"): +def test_delete_ios_app_data_stream( + transport: str = "grpc", request_type=analytics_admin.DeleteIosAppDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteIosAppDataStreamRequest() + 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__" + type(client.transport.delete_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -5798,25 +6431,32 @@ def test_delete_ios_app_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_delete_ios_app_data_stream_async(transport: str = "grpc_asyncio"): +async def test_delete_ios_app_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteIosAppDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteIosAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_ios_app_data_stream), "__call__" + 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) @@ -5827,12 +6467,17 @@ async def test_delete_ios_app_data_stream_async(transport: str = "grpc_asyncio") assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeleteIosAppDataStreamRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_ios_app_data_stream_async_from_dict(): + await test_delete_ios_app_data_stream_async(request_type=dict) + + def test_delete_ios_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -5845,7 +6490,7 @@ def test_delete_ios_app_data_stream_field_headers(): # 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__" + type(client.transport.delete_ios_app_data_stream), "__call__" ) as call: call.return_value = None @@ -5874,7 +6519,7 @@ async def test_delete_ios_app_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_ios_app_data_stream), "__call__" + type(client.transport.delete_ios_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -5897,7 +6542,7 @@ def test_delete_ios_app_data_stream_flattened(): # 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__" + type(client.transport.delete_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -5935,7 +6580,7 @@ async def test_delete_ios_app_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_ios_app_data_stream), "__call__" + type(client.transport.delete_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -5967,18 +6612,20 @@ async def test_delete_ios_app_data_stream_flattened_error_async(): ) -def test_update_ios_app_data_stream(transport: str = "grpc"): +def test_update_ios_app_data_stream( + transport: str = "grpc", request_type=analytics_admin.UpdateIosAppDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateIosAppDataStreamRequest() + 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__" + type(client.transport.update_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream( @@ -5994,9 +6641,10 @@ def test_update_ios_app_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -6008,19 +6656,26 @@ def test_update_ios_app_data_stream(transport: str = "grpc"): 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) + + @pytest.mark.asyncio -async def test_update_ios_app_data_stream_async(transport: str = "grpc_asyncio"): +async def test_update_ios_app_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateIosAppDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateIosAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_ios_app_data_stream), "__call__" + 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( @@ -6038,7 +6693,7 @@ async def test_update_ios_app_data_stream_async(transport: str = "grpc_asyncio") assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.UpdateIosAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.IosAppDataStream) @@ -6052,6 +6707,11 @@ async def test_update_ios_app_data_stream_async(transport: str = "grpc_asyncio") assert response.display_name == "display_name_value" +@pytest.mark.asyncio +async def test_update_ios_app_data_stream_async_from_dict(): + await test_update_ios_app_data_stream_async(request_type=dict) + + def test_update_ios_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -6064,7 +6724,7 @@ def test_update_ios_app_data_stream_field_headers(): # 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__" + type(client.transport.update_ios_app_data_stream), "__call__" ) as call: call.return_value = resources.IosAppDataStream() @@ -6096,7 +6756,7 @@ async def test_update_ios_app_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_ios_app_data_stream), "__call__" + type(client.transport.update_ios_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.IosAppDataStream() @@ -6124,7 +6784,7 @@ def test_update_ios_app_data_stream_flattened(): # 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__" + type(client.transport.update_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream() @@ -6171,7 +6831,7 @@ async def test_update_ios_app_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_ios_app_data_stream), "__call__" + type(client.transport.update_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream() @@ -6214,18 +6874,20 @@ async def test_update_ios_app_data_stream_flattened_error_async(): ) -def test_create_ios_app_data_stream(transport: str = "grpc"): +def test_create_ios_app_data_stream( + transport: str = "grpc", request_type=analytics_admin.CreateIosAppDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateIosAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_ios_app_data_stream), "__call__" + type(client.transport.create_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream( @@ -6241,9 +6903,10 @@ def test_create_ios_app_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.IosAppDataStream) assert response.name == "name_value" @@ -6255,19 +6918,26 @@ def test_create_ios_app_data_stream(transport: str = "grpc"): assert response.display_name == "display_name_value" +def test_create_ios_app_data_stream_from_dict(): + test_create_ios_app_data_stream(request_type=dict) + + @pytest.mark.asyncio -async def test_create_ios_app_data_stream_async(transport: str = "grpc_asyncio"): +async def test_create_ios_app_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateIosAppDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateIosAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_ios_app_data_stream), "__call__" + type(client.transport.create_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -6285,7 +6955,7 @@ async def test_create_ios_app_data_stream_async(transport: str = "grpc_asyncio") assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.IosAppDataStream) @@ -6299,6 +6969,11 @@ async def test_create_ios_app_data_stream_async(transport: str = "grpc_asyncio") assert response.display_name == "display_name_value" +@pytest.mark.asyncio +async def test_create_ios_app_data_stream_async_from_dict(): + await test_create_ios_app_data_stream_async(request_type=dict) + + def test_create_ios_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -6311,7 +6986,7 @@ def test_create_ios_app_data_stream_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_ios_app_data_stream), "__call__" + type(client.transport.create_ios_app_data_stream), "__call__" ) as call: call.return_value = resources.IosAppDataStream() @@ -6340,7 +7015,7 @@ async def test_create_ios_app_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_ios_app_data_stream), "__call__" + type(client.transport.create_ios_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.IosAppDataStream() @@ -6365,7 +7040,7 @@ def test_create_ios_app_data_stream_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_ios_app_data_stream), "__call__" + type(client.transport.create_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream() @@ -6412,7 +7087,7 @@ async def test_create_ios_app_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_ios_app_data_stream), "__call__" + type(client.transport.create_ios_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream() @@ -6455,18 +7130,20 @@ async def test_create_ios_app_data_stream_flattened_error_async(): ) -def test_list_ios_app_data_streams(transport: str = "grpc"): +def test_list_ios_app_data_streams( + transport: str = "grpc", request_type=analytics_admin.ListIosAppDataStreamsRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListIosAppDataStreamsRequest() + 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__" + 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( @@ -6479,27 +7156,35 @@ def test_list_ios_app_data_streams(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_list_ios_app_data_streams_async(transport: str = "grpc_asyncio"): +async def test_list_ios_app_data_streams_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListIosAppDataStreamsRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListIosAppDataStreamsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_ios_app_data_streams), "__call__" + 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( @@ -6514,7 +7199,7 @@ async def test_list_ios_app_data_streams_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListIosAppDataStreamsAsyncPager) @@ -6522,6 +7207,11 @@ async def test_list_ios_app_data_streams_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_ios_app_data_streams_async_from_dict(): + await test_list_ios_app_data_streams_async(request_type=dict) + + def test_list_ios_app_data_streams_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -6534,7 +7224,7 @@ def test_list_ios_app_data_streams_field_headers(): # 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__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: call.return_value = analytics_admin.ListIosAppDataStreamsResponse() @@ -6563,7 +7253,7 @@ async def test_list_ios_app_data_streams_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_ios_app_data_streams), "__call__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListIosAppDataStreamsResponse() @@ -6588,7 +7278,7 @@ def test_list_ios_app_data_streams_flattened(): # 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__" + 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() @@ -6626,7 +7316,7 @@ async def test_list_ios_app_data_streams_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_ios_app_data_streams), "__call__" + 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() @@ -6665,7 +7355,7 @@ def test_list_ios_app_data_streams_pager(): # 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__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -6711,7 +7401,7 @@ def test_list_ios_app_data_streams_pages(): # 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__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -6739,8 +7429,8 @@ def test_list_ios_app_data_streams_pages(): 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 + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio @@ -6751,7 +7441,7 @@ async def test_list_ios_app_data_streams_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_ios_app_data_streams), + type(client.transport.list_ios_app_data_streams), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -6798,7 +7488,7 @@ async def test_list_ios_app_data_streams_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_ios_app_data_streams), + type(client.transport.list_ios_app_data_streams), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -6828,24 +7518,26 @@ async def test_list_ios_app_data_streams_async_pages(): 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 + 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"): +def test_get_android_app_data_stream( + transport: str = "grpc", request_type=analytics_admin.GetAndroidAppDataStreamRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetAndroidAppDataStreamRequest() + 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__" + type(client.transport.get_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream( @@ -6861,9 +7553,10 @@ def test_get_android_app_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -6875,19 +7568,26 @@ def test_get_android_app_data_stream(transport: str = "grpc"): 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) + + @pytest.mark.asyncio -async def test_get_android_app_data_stream_async(transport: str = "grpc_asyncio"): +async def test_get_android_app_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetAndroidAppDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetAndroidAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_android_app_data_stream), "__call__" + 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( @@ -6905,7 +7605,7 @@ async def test_get_android_app_data_stream_async(transport: str = "grpc_asyncio" assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.GetAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.AndroidAppDataStream) @@ -6919,6 +7619,11 @@ async def test_get_android_app_data_stream_async(transport: str = "grpc_asyncio" assert response.display_name == "display_name_value" +@pytest.mark.asyncio +async def test_get_android_app_data_stream_async_from_dict(): + await test_get_android_app_data_stream_async(request_type=dict) + + def test_get_android_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -6931,7 +7636,7 @@ def test_get_android_app_data_stream_field_headers(): # 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__" + type(client.transport.get_android_app_data_stream), "__call__" ) as call: call.return_value = resources.AndroidAppDataStream() @@ -6960,7 +7665,7 @@ async def test_get_android_app_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_android_app_data_stream), "__call__" + type(client.transport.get_android_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.AndroidAppDataStream() @@ -6985,7 +7690,7 @@ def test_get_android_app_data_stream_flattened(): # 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__" + type(client.transport.get_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream() @@ -7023,7 +7728,7 @@ async def test_get_android_app_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_android_app_data_stream), "__call__" + type(client.transport.get_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream() @@ -7057,18 +7762,21 @@ async def test_get_android_app_data_stream_flattened_error_async(): ) -def test_delete_android_app_data_stream(transport: str = "grpc"): +def test_delete_android_app_data_stream( + transport: str = "grpc", + request_type=analytics_admin.DeleteAndroidAppDataStreamRequest, +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteAndroidAppDataStreamRequest() + 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__" + type(client.transport.delete_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -7079,25 +7787,32 @@ def test_delete_android_app_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_delete_android_app_data_stream_async(transport: str = "grpc_asyncio"): +async def test_delete_android_app_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteAndroidAppDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteAndroidAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_android_app_data_stream), "__call__" + 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) @@ -7108,12 +7823,17 @@ async def test_delete_android_app_data_stream_async(transport: str = "grpc_async assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeleteAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_android_app_data_stream_async_from_dict(): + await test_delete_android_app_data_stream_async(request_type=dict) + + def test_delete_android_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -7126,7 +7846,7 @@ def test_delete_android_app_data_stream_field_headers(): # 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__" + type(client.transport.delete_android_app_data_stream), "__call__" ) as call: call.return_value = None @@ -7155,7 +7875,7 @@ async def test_delete_android_app_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_android_app_data_stream), "__call__" + type(client.transport.delete_android_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -7178,7 +7898,7 @@ def test_delete_android_app_data_stream_flattened(): # 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__" + type(client.transport.delete_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -7216,7 +7936,7 @@ async def test_delete_android_app_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_android_app_data_stream), "__call__" + type(client.transport.delete_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -7248,18 +7968,21 @@ async def test_delete_android_app_data_stream_flattened_error_async(): ) -def test_update_android_app_data_stream(transport: str = "grpc"): +def test_update_android_app_data_stream( + transport: str = "grpc", + request_type=analytics_admin.UpdateAndroidAppDataStreamRequest, +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateAndroidAppDataStreamRequest() + 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__" + type(client.transport.update_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream( @@ -7275,9 +7998,10 @@ def test_update_android_app_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -7289,19 +8013,26 @@ def test_update_android_app_data_stream(transport: str = "grpc"): 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) + + @pytest.mark.asyncio -async def test_update_android_app_data_stream_async(transport: str = "grpc_asyncio"): +async def test_update_android_app_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateAndroidAppDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateAndroidAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_android_app_data_stream), "__call__" + 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( @@ -7319,7 +8050,7 @@ async def test_update_android_app_data_stream_async(transport: str = "grpc_async assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.UpdateAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.AndroidAppDataStream) @@ -7333,6 +8064,11 @@ async def test_update_android_app_data_stream_async(transport: str = "grpc_async assert response.display_name == "display_name_value" +@pytest.mark.asyncio +async def test_update_android_app_data_stream_async_from_dict(): + await test_update_android_app_data_stream_async(request_type=dict) + + def test_update_android_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -7345,7 +8081,7 @@ def test_update_android_app_data_stream_field_headers(): # 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__" + type(client.transport.update_android_app_data_stream), "__call__" ) as call: call.return_value = resources.AndroidAppDataStream() @@ -7377,7 +8113,7 @@ async def test_update_android_app_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_android_app_data_stream), "__call__" + type(client.transport.update_android_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.AndroidAppDataStream() @@ -7405,7 +8141,7 @@ def test_update_android_app_data_stream_flattened(): # 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__" + type(client.transport.update_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream() @@ -7452,7 +8188,7 @@ async def test_update_android_app_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_android_app_data_stream), "__call__" + type(client.transport.update_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream() @@ -7495,18 +8231,21 @@ async def test_update_android_app_data_stream_flattened_error_async(): ) -def test_create_android_app_data_stream(transport: str = "grpc"): +def test_create_android_app_data_stream( + transport: str = "grpc", + request_type=analytics_admin.CreateAndroidAppDataStreamRequest, +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateAndroidAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_android_app_data_stream), "__call__" + type(client.transport.create_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream( @@ -7522,9 +8261,10 @@ def test_create_android_app_data_stream(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.AndroidAppDataStream) assert response.name == "name_value" @@ -7536,19 +8276,26 @@ def test_create_android_app_data_stream(transport: str = "grpc"): assert response.display_name == "display_name_value" +def test_create_android_app_data_stream_from_dict(): + test_create_android_app_data_stream(request_type=dict) + + @pytest.mark.asyncio -async def test_create_android_app_data_stream_async(transport: str = "grpc_asyncio"): +async def test_create_android_app_data_stream_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateAndroidAppDataStreamRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateAndroidAppDataStreamRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_android_app_data_stream), "__call__" + type(client.transport.create_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -7566,7 +8313,7 @@ async def test_create_android_app_data_stream_async(transport: str = "grpc_async assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.AndroidAppDataStream) @@ -7580,6 +8327,11 @@ async def test_create_android_app_data_stream_async(transport: str = "grpc_async assert response.display_name == "display_name_value" +@pytest.mark.asyncio +async def test_create_android_app_data_stream_async_from_dict(): + await test_create_android_app_data_stream_async(request_type=dict) + + def test_create_android_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -7592,7 +8344,7 @@ def test_create_android_app_data_stream_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_android_app_data_stream), "__call__" + type(client.transport.create_android_app_data_stream), "__call__" ) as call: call.return_value = resources.AndroidAppDataStream() @@ -7621,7 +8373,7 @@ async def test_create_android_app_data_stream_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_android_app_data_stream), "__call__" + type(client.transport.create_android_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.AndroidAppDataStream() @@ -7646,7 +8398,7 @@ def test_create_android_app_data_stream_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_android_app_data_stream), "__call__" + type(client.transport.create_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream() @@ -7693,7 +8445,7 @@ async def test_create_android_app_data_stream_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_android_app_data_stream), "__call__" + type(client.transport.create_android_app_data_stream), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream() @@ -7736,18 +8488,21 @@ async def test_create_android_app_data_stream_flattened_error_async(): ) -def test_list_android_app_data_streams(transport: str = "grpc"): +def test_list_android_app_data_streams( + transport: str = "grpc", + request_type=analytics_admin.ListAndroidAppDataStreamsRequest, +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListAndroidAppDataStreamsRequest() + 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__" + 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( @@ -7760,27 +8515,35 @@ def test_list_android_app_data_streams(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_list_android_app_data_streams_async(transport: str = "grpc_asyncio"): +async def test_list_android_app_data_streams_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListAndroidAppDataStreamsRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListAndroidAppDataStreamsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_android_app_data_streams), "__call__" + 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( @@ -7795,7 +8558,7 @@ async def test_list_android_app_data_streams_async(transport: str = "grpc_asynci assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListAndroidAppDataStreamsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAndroidAppDataStreamsAsyncPager) @@ -7803,6 +8566,11 @@ async def test_list_android_app_data_streams_async(transport: str = "grpc_asynci assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_android_app_data_streams_async_from_dict(): + await test_list_android_app_data_streams_async(request_type=dict) + + def test_list_android_app_data_streams_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -7815,7 +8583,7 @@ def test_list_android_app_data_streams_field_headers(): # 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__" + type(client.transport.list_android_app_data_streams), "__call__" ) as call: call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() @@ -7844,7 +8612,7 @@ async def test_list_android_app_data_streams_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_android_app_data_streams), "__call__" + type(client.transport.list_android_app_data_streams), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListAndroidAppDataStreamsResponse() @@ -7869,7 +8637,7 @@ def test_list_android_app_data_streams_flattened(): # 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__" + 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() @@ -7907,7 +8675,7 @@ async def test_list_android_app_data_streams_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_android_app_data_streams), "__call__" + 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() @@ -7946,7 +8714,7 @@ def test_list_android_app_data_streams_pager(): # 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__" + type(client.transport.list_android_app_data_streams), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -7992,7 +8760,7 @@ def test_list_android_app_data_streams_pages(): # 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__" + type(client.transport.list_android_app_data_streams), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -8020,8 +8788,8 @@ def test_list_android_app_data_streams_pages(): 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 + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio @@ -8032,7 +8800,7 @@ async def test_list_android_app_data_streams_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_android_app_data_streams), + type(client.transport.list_android_app_data_streams), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -8079,7 +8847,7 @@ async def test_list_android_app_data_streams_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_android_app_data_streams), + type(client.transport.list_android_app_data_streams), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -8109,26 +8877,29 @@ async def test_list_android_app_data_streams_async_pages(): RuntimeError, ) pages = [] - async for page in ( + 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 + 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"): +def test_get_enhanced_measurement_settings( + transport: str = "grpc", + request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest, +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetEnhancedMeasurementSettingsRequest() + 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__" + type(client.transport.get_enhanced_measurement_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.EnhancedMeasurementSettings( @@ -8137,19 +8908,13 @@ def test_get_enhanced_measurement_settings(transport: str = "grpc"): page_views_enabled=True, scrolls_enabled=True, outbound_clicks_enabled=True, - content_views_enabled=True, site_search_enabled=True, - form_interactions_enabled=True, video_engagement_enabled=True, file_downloads_enabled=True, - data_tagged_element_clicks_enabled=True, page_loads_enabled=True, page_changes_enabled=True, - articles_and_blogs_enabled=True, - products_and_ecommerce_enabled=True, search_query_parameter="search_query_parameter_value", - url_query_parameter="url_query_parameter_value", - excluded_domains="excluded_domains_value", + uri_query_parameter="uri_query_parameter_value", ) response = client.get_enhanced_measurement_settings(request) @@ -8158,9 +8923,10 @@ def test_get_enhanced_measurement_settings(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -8173,46 +8939,41 @@ def test_get_enhanced_measurement_settings(transport: str = "grpc"): assert response.outbound_clicks_enabled is True - assert response.content_views_enabled is True - assert response.site_search_enabled is True - assert response.form_interactions_enabled is True - assert response.video_engagement_enabled is True assert response.file_downloads_enabled is True - assert response.data_tagged_element_clicks_enabled is True - assert response.page_loads_enabled is True assert response.page_changes_enabled is True - assert response.articles_and_blogs_enabled is True - - assert response.products_and_ecommerce_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.url_query_parameter == "url_query_parameter_value" + assert response.uri_query_parameter == "uri_query_parameter_value" + - assert response.excluded_domains == "excluded_domains_value" +def test_get_enhanced_measurement_settings_from_dict(): + test_get_enhanced_measurement_settings(request_type=dict) @pytest.mark.asyncio -async def test_get_enhanced_measurement_settings_async(transport: str = "grpc_asyncio"): +async def test_get_enhanced_measurement_settings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetEnhancedMeasurementSettingsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_enhanced_measurement_settings), "__call__" + 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( @@ -8222,19 +8983,13 @@ async def test_get_enhanced_measurement_settings_async(transport: str = "grpc_as page_views_enabled=True, scrolls_enabled=True, outbound_clicks_enabled=True, - content_views_enabled=True, site_search_enabled=True, - form_interactions_enabled=True, video_engagement_enabled=True, file_downloads_enabled=True, - data_tagged_element_clicks_enabled=True, page_loads_enabled=True, page_changes_enabled=True, - articles_and_blogs_enabled=True, - products_and_ecommerce_enabled=True, search_query_parameter="search_query_parameter_value", - url_query_parameter="url_query_parameter_value", - excluded_domains="excluded_domains_value", + uri_query_parameter="uri_query_parameter_value", ) ) @@ -8244,7 +8999,7 @@ async def test_get_enhanced_measurement_settings_async(transport: str = "grpc_as assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.EnhancedMeasurementSettings) @@ -8259,31 +9014,24 @@ async def test_get_enhanced_measurement_settings_async(transport: str = "grpc_as assert response.outbound_clicks_enabled is True - assert response.content_views_enabled is True - assert response.site_search_enabled is True - assert response.form_interactions_enabled is True - assert response.video_engagement_enabled is True assert response.file_downloads_enabled is True - assert response.data_tagged_element_clicks_enabled is True - assert response.page_loads_enabled is True assert response.page_changes_enabled is True - assert response.articles_and_blogs_enabled is True - - assert response.products_and_ecommerce_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.url_query_parameter == "url_query_parameter_value" + assert response.uri_query_parameter == "uri_query_parameter_value" + - assert response.excluded_domains == "excluded_domains_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(): @@ -8298,7 +9046,7 @@ def test_get_enhanced_measurement_settings_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_enhanced_measurement_settings), "__call__" + type(client.transport.get_enhanced_measurement_settings), "__call__" ) as call: call.return_value = resources.EnhancedMeasurementSettings() @@ -8327,7 +9075,7 @@ async def test_get_enhanced_measurement_settings_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_enhanced_measurement_settings), "__call__" + type(client.transport.get_enhanced_measurement_settings), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.EnhancedMeasurementSettings() @@ -8352,7 +9100,7 @@ def test_get_enhanced_measurement_settings_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_enhanced_measurement_settings), "__call__" + type(client.transport.get_enhanced_measurement_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.EnhancedMeasurementSettings() @@ -8390,7 +9138,7 @@ async def test_get_enhanced_measurement_settings_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_enhanced_measurement_settings), "__call__" + type(client.transport.get_enhanced_measurement_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.EnhancedMeasurementSettings() @@ -8424,18 +9172,21 @@ async def test_get_enhanced_measurement_settings_flattened_error_async(): ) -def test_update_enhanced_measurement_settings(transport: str = "grpc"): +def test_update_enhanced_measurement_settings( + transport: str = "grpc", + request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest, +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + 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__" + type(client.transport.update_enhanced_measurement_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.EnhancedMeasurementSettings( @@ -8444,19 +9195,13 @@ def test_update_enhanced_measurement_settings(transport: str = "grpc"): page_views_enabled=True, scrolls_enabled=True, outbound_clicks_enabled=True, - content_views_enabled=True, site_search_enabled=True, - form_interactions_enabled=True, video_engagement_enabled=True, file_downloads_enabled=True, - data_tagged_element_clicks_enabled=True, page_loads_enabled=True, page_changes_enabled=True, - articles_and_blogs_enabled=True, - products_and_ecommerce_enabled=True, search_query_parameter="search_query_parameter_value", - url_query_parameter="url_query_parameter_value", - excluded_domains="excluded_domains_value", + uri_query_parameter="uri_query_parameter_value", ) response = client.update_enhanced_measurement_settings(request) @@ -8465,9 +9210,10 @@ def test_update_enhanced_measurement_settings(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -8480,36 +9226,29 @@ def test_update_enhanced_measurement_settings(transport: str = "grpc"): assert response.outbound_clicks_enabled is True - assert response.content_views_enabled is True - assert response.site_search_enabled is True - assert response.form_interactions_enabled is True - assert response.video_engagement_enabled is True assert response.file_downloads_enabled is True - assert response.data_tagged_element_clicks_enabled is True - assert response.page_loads_enabled is True assert response.page_changes_enabled is True - assert response.articles_and_blogs_enabled is True - - assert response.products_and_ecommerce_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.url_query_parameter == "url_query_parameter_value" + assert response.uri_query_parameter == "uri_query_parameter_value" - assert response.excluded_domains == "excluded_domains_value" + +def test_update_enhanced_measurement_settings_from_dict(): + test_update_enhanced_measurement_settings(request_type=dict) @pytest.mark.asyncio async def test_update_enhanced_measurement_settings_async( transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest, ): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, @@ -8517,11 +9256,11 @@ async def test_update_enhanced_measurement_settings_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_enhanced_measurement_settings), "__call__" + 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( @@ -8531,19 +9270,13 @@ async def test_update_enhanced_measurement_settings_async( page_views_enabled=True, scrolls_enabled=True, outbound_clicks_enabled=True, - content_views_enabled=True, site_search_enabled=True, - form_interactions_enabled=True, video_engagement_enabled=True, file_downloads_enabled=True, - data_tagged_element_clicks_enabled=True, page_loads_enabled=True, page_changes_enabled=True, - articles_and_blogs_enabled=True, - products_and_ecommerce_enabled=True, search_query_parameter="search_query_parameter_value", - url_query_parameter="url_query_parameter_value", - excluded_domains="excluded_domains_value", + uri_query_parameter="uri_query_parameter_value", ) ) @@ -8553,7 +9286,7 @@ async def test_update_enhanced_measurement_settings_async( assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.EnhancedMeasurementSettings) @@ -8568,31 +9301,24 @@ async def test_update_enhanced_measurement_settings_async( assert response.outbound_clicks_enabled is True - assert response.content_views_enabled is True - assert response.site_search_enabled is True - assert response.form_interactions_enabled is True - assert response.video_engagement_enabled is True assert response.file_downloads_enabled is True - assert response.data_tagged_element_clicks_enabled is True - assert response.page_loads_enabled is True assert response.page_changes_enabled is True - assert response.articles_and_blogs_enabled is True - - assert response.products_and_ecommerce_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.url_query_parameter == "url_query_parameter_value" + assert response.uri_query_parameter == "uri_query_parameter_value" - assert response.excluded_domains == "excluded_domains_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(): @@ -8609,7 +9335,7 @@ def test_update_enhanced_measurement_settings_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_enhanced_measurement_settings), "__call__" + type(client.transport.update_enhanced_measurement_settings), "__call__" ) as call: call.return_value = resources.EnhancedMeasurementSettings() @@ -8643,7 +9369,7 @@ async def test_update_enhanced_measurement_settings_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_enhanced_measurement_settings), "__call__" + type(client.transport.update_enhanced_measurement_settings), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.EnhancedMeasurementSettings() @@ -8671,7 +9397,7 @@ def test_update_enhanced_measurement_settings_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_enhanced_measurement_settings), "__call__" + type(client.transport.update_enhanced_measurement_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.EnhancedMeasurementSettings() @@ -8724,7 +9450,7 @@ async def test_update_enhanced_measurement_settings_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_enhanced_measurement_settings), "__call__" + type(client.transport.update_enhanced_measurement_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.EnhancedMeasurementSettings() @@ -8773,18 +9499,20 @@ async def test_update_enhanced_measurement_settings_flattened_error_async(): ) -def test_create_firebase_link(transport: str = "grpc"): +def test_create_firebase_link( + transport: str = "grpc", request_type=analytics_admin.CreateFirebaseLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateFirebaseLinkRequest() + 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__" + type(client.transport.create_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.FirebaseLink( @@ -8799,9 +9527,10 @@ def test_create_firebase_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -8811,19 +9540,26 @@ def test_create_firebase_link(transport: str = "grpc"): assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS +def test_create_firebase_link_from_dict(): + test_create_firebase_link(request_type=dict) + + @pytest.mark.asyncio -async def test_create_firebase_link_async(transport: str = "grpc_asyncio"): +async def test_create_firebase_link_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateFirebaseLinkRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateFirebaseLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_firebase_link), "__call__" + type(client.transport.create_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -8840,7 +9576,7 @@ async def test_create_firebase_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.CreateFirebaseLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.FirebaseLink) @@ -8852,6 +9588,11 @@ async def test_create_firebase_link_async(transport: str = "grpc_asyncio"): assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS +@pytest.mark.asyncio +async def test_create_firebase_link_async_from_dict(): + await test_create_firebase_link_async(request_type=dict) + + def test_create_firebase_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -8864,7 +9605,7 @@ def test_create_firebase_link_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_firebase_link), "__call__" + type(client.transport.create_firebase_link), "__call__" ) as call: call.return_value = resources.FirebaseLink() @@ -8893,7 +9634,7 @@ async def test_create_firebase_link_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_firebase_link), "__call__" + type(client.transport.create_firebase_link), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.FirebaseLink() @@ -8918,7 +9659,7 @@ def test_create_firebase_link_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_firebase_link), "__call__" + type(client.transport.create_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.FirebaseLink() @@ -8963,7 +9704,7 @@ async def test_create_firebase_link_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_firebase_link), "__call__" + type(client.transport.create_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.FirebaseLink() @@ -9004,18 +9745,20 @@ async def test_create_firebase_link_flattened_error_async(): ) -def test_update_firebase_link(transport: str = "grpc"): +def test_update_firebase_link( + transport: str = "grpc", request_type=analytics_admin.UpdateFirebaseLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateFirebaseLinkRequest() + 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__" + type(client.transport.update_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.FirebaseLink( @@ -9030,9 +9773,10 @@ def test_update_firebase_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -9042,19 +9786,26 @@ def test_update_firebase_link(transport: str = "grpc"): assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS +def test_update_firebase_link_from_dict(): + test_update_firebase_link(request_type=dict) + + @pytest.mark.asyncio -async def test_update_firebase_link_async(transport: str = "grpc_asyncio"): +async def test_update_firebase_link_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateFirebaseLinkRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateFirebaseLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_firebase_link), "__call__" + type(client.transport.update_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -9071,7 +9822,7 @@ async def test_update_firebase_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.FirebaseLink) @@ -9083,6 +9834,11 @@ async def test_update_firebase_link_async(transport: str = "grpc_asyncio"): assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS +@pytest.mark.asyncio +async def test_update_firebase_link_async_from_dict(): + await test_update_firebase_link_async(request_type=dict) + + def test_update_firebase_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -9095,7 +9851,7 @@ def test_update_firebase_link_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_firebase_link), "__call__" + type(client.transport.update_firebase_link), "__call__" ) as call: call.return_value = resources.FirebaseLink() @@ -9127,7 +9883,7 @@ async def test_update_firebase_link_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_firebase_link), "__call__" + type(client.transport.update_firebase_link), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.FirebaseLink() @@ -9155,7 +9911,7 @@ def test_update_firebase_link_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_firebase_link), "__call__" + type(client.transport.update_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.FirebaseLink() @@ -9200,7 +9956,7 @@ async def test_update_firebase_link_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_firebase_link), "__call__" + type(client.transport.update_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.FirebaseLink() @@ -9241,18 +9997,20 @@ async def test_update_firebase_link_flattened_error_async(): ) -def test_delete_firebase_link(transport: str = "grpc"): +def test_delete_firebase_link( + transport: str = "grpc", request_type=analytics_admin.DeleteFirebaseLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteFirebaseLinkRequest() + 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__" + type(client.transport.delete_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -9263,25 +10021,32 @@ def test_delete_firebase_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_delete_firebase_link_async(transport: str = "grpc_asyncio"): +async def test_delete_firebase_link_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteFirebaseLinkRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteFirebaseLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_firebase_link), "__call__" + 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) @@ -9292,12 +10057,17 @@ async def test_delete_firebase_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_firebase_link_async_from_dict(): + await test_delete_firebase_link_async(request_type=dict) + + def test_delete_firebase_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -9310,7 +10080,7 @@ def test_delete_firebase_link_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_firebase_link), "__call__" + type(client.transport.delete_firebase_link), "__call__" ) as call: call.return_value = None @@ -9339,7 +10109,7 @@ async def test_delete_firebase_link_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_firebase_link), "__call__" + type(client.transport.delete_firebase_link), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -9362,7 +10132,7 @@ def test_delete_firebase_link_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_firebase_link), "__call__" + type(client.transport.delete_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -9400,7 +10170,7 @@ async def test_delete_firebase_link_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_firebase_link), "__call__" + type(client.transport.delete_firebase_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -9432,21 +10202,25 @@ async def test_delete_firebase_link_flattened_error_async(): ) -def test_list_firebase_links(transport: str = "grpc"): +def test_list_firebase_links( + transport: str = "grpc", request_type=analytics_admin.ListFirebaseLinksRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListFirebaseLinksRequest() + 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__" + 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 = analytics_admin.ListFirebaseLinksResponse( + next_page_token="next_page_token_value", + ) response = client.list_firebase_links(request) @@ -9454,29 +10228,41 @@ def test_list_firebase_links(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListFirebaseLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.ListFirebaseLinksResponse) + + 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) @pytest.mark.asyncio -async def test_list_firebase_links_async(transport: str = "grpc_asyncio"): +async def test_list_firebase_links_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListFirebaseLinksRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListFirebaseLinksRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_firebase_links), "__call__" + 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() + analytics_admin.ListFirebaseLinksResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_firebase_links(request) @@ -9485,10 +10271,17 @@ async def test_list_firebase_links_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListFirebaseLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.ListFirebaseLinksResponse) + 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(): @@ -9503,7 +10296,7 @@ def test_list_firebase_links_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_firebase_links), "__call__" + type(client.transport.list_firebase_links), "__call__" ) as call: call.return_value = analytics_admin.ListFirebaseLinksResponse() @@ -9532,7 +10325,7 @@ async def test_list_firebase_links_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_firebase_links), "__call__" + type(client.transport.list_firebase_links), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListFirebaseLinksResponse() @@ -9557,7 +10350,7 @@ def test_list_firebase_links_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_firebase_links), "__call__" + type(client.transport.list_firebase_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListFirebaseLinksResponse() @@ -9595,7 +10388,7 @@ async def test_list_firebase_links_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_firebase_links), "__call__" + type(client.transport.list_firebase_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListFirebaseLinksResponse() @@ -9629,21 +10422,183 @@ async def test_list_firebase_links_flattened_error_async(): ) -def test_get_global_site_tag(transport: str = "grpc"): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetGlobalSiteTagRequest() +def test_list_firebase_links_pager(): + client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_global_site_tag), "__call__" + type(client.transport.list_firebase_links), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = resources.GlobalSiteTag(snippet="snippet_value",) + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], next_page_token="def", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[resources.FirebaseLink(),], next_page_token="ghi", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[resources.FirebaseLink(), resources.FirebaseLink(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_firebase_links(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.FirebaseLink) for i in results) + + +def test_list_firebase_links_pages(): + client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], next_page_token="def", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[resources.FirebaseLink(),], next_page_token="ghi", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[resources.FirebaseLink(), resources.FirebaseLink(),], + ), + RuntimeError, + ) + pages = list(client.list_firebase_links(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_firebase_links_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], next_page_token="def", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[resources.FirebaseLink(),], next_page_token="ghi", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[resources.FirebaseLink(), resources.FirebaseLink(),], + ), + RuntimeError, + ) + async_pager = await client.list_firebase_links(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.FirebaseLink) for i in responses) + + +@pytest.mark.asyncio +async def test_list_firebase_links_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firebase_links), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], next_page_token="def", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[resources.FirebaseLink(),], next_page_token="ghi", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[resources.FirebaseLink(), resources.FirebaseLink(),], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_firebase_links(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_global_site_tag( + transport: str = "grpc", request_type=analytics_admin.GetGlobalSiteTagRequest +): + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_global_site_tag), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GlobalSiteTag( + name="name_value", snippet="snippet_value", + ) response = client.get_global_site_tag(request) @@ -9651,31 +10606,41 @@ def test_get_global_site_tag(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_get_global_site_tag_async(transport: str = "grpc_asyncio"): +async def test_get_global_site_tag_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetGlobalSiteTagRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetGlobalSiteTagRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_global_site_tag), "__call__" + 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(snippet="snippet_value",) + resources.GlobalSiteTag(name="name_value", snippet="snippet_value",) ) response = await client.get_global_site_tag(request) @@ -9684,14 +10649,21 @@ async def test_get_global_site_tag_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.GetGlobalSiteTagRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.GlobalSiteTag) + assert response.name == "name_value" + assert response.snippet == "snippet_value" +@pytest.mark.asyncio +async def test_get_global_site_tag_async_from_dict(): + await test_get_global_site_tag_async(request_type=dict) + + def test_get_global_site_tag_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -9704,7 +10676,7 @@ def test_get_global_site_tag_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_global_site_tag), "__call__" + type(client.transport.get_global_site_tag), "__call__" ) as call: call.return_value = resources.GlobalSiteTag() @@ -9733,7 +10705,7 @@ async def test_get_global_site_tag_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_global_site_tag), "__call__" + type(client.transport.get_global_site_tag), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.GlobalSiteTag() @@ -9758,7 +10730,7 @@ def test_get_global_site_tag_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_global_site_tag), "__call__" + type(client.transport.get_global_site_tag), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GlobalSiteTag() @@ -9796,7 +10768,7 @@ async def test_get_global_site_tag_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_global_site_tag), "__call__" + type(client.transport.get_global_site_tag), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GlobalSiteTag() @@ -9830,23 +10802,24 @@ async def test_get_global_site_tag_flattened_error_async(): ) -def test_create_google_ads_link(transport: str = "grpc"): +def test_create_google_ads_link( + transport: str = "grpc", request_type=analytics_admin.CreateGoogleAdsLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateGoogleAdsLinkRequest() + 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__" + 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", - parent="parent_value", customer_id="customer_id_value", can_manage_clients=True, email_address="email_address_value", @@ -9858,15 +10831,14 @@ def test_create_google_ads_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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.parent == "parent_value" - assert response.customer_id == "customer_id_value" assert response.can_manage_clients is True @@ -9874,25 +10846,31 @@ def test_create_google_ads_link(transport: str = "grpc"): assert response.email_address == "email_address_value" +def test_create_google_ads_link_from_dict(): + test_create_google_ads_link(request_type=dict) + + @pytest.mark.asyncio -async def test_create_google_ads_link_async(transport: str = "grpc_asyncio"): +async def test_create_google_ads_link_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateGoogleAdsLinkRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.CreateGoogleAdsLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_google_ads_link), "__call__" + 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", - parent="parent_value", customer_id="customer_id_value", can_manage_clients=True, email_address="email_address_value", @@ -9905,15 +10883,13 @@ async def test_create_google_ads_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + 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.parent == "parent_value" - assert response.customer_id == "customer_id_value" assert response.can_manage_clients is True @@ -9921,6 +10897,11 @@ async def test_create_google_ads_link_async(transport: str = "grpc_asyncio"): assert response.email_address == "email_address_value" +@pytest.mark.asyncio +async def test_create_google_ads_link_async_from_dict(): + await test_create_google_ads_link_async(request_type=dict) + + def test_create_google_ads_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -9933,7 +10914,7 @@ def test_create_google_ads_link_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_google_ads_link), "__call__" + type(client.transport.create_google_ads_link), "__call__" ) as call: call.return_value = resources.GoogleAdsLink() @@ -9962,7 +10943,7 @@ async def test_create_google_ads_link_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_google_ads_link), "__call__" + type(client.transport.create_google_ads_link), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.GoogleAdsLink() @@ -9987,7 +10968,7 @@ def test_create_google_ads_link_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_google_ads_link), "__call__" + type(client.transport.create_google_ads_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GoogleAdsLink() @@ -10032,7 +11013,7 @@ async def test_create_google_ads_link_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_google_ads_link), "__call__" + type(client.transport.create_google_ads_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GoogleAdsLink() @@ -10073,23 +11054,24 @@ async def test_create_google_ads_link_flattened_error_async(): ) -def test_update_google_ads_link(transport: str = "grpc"): +def test_update_google_ads_link( + transport: str = "grpc", request_type=analytics_admin.UpdateGoogleAdsLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateGoogleAdsLinkRequest() + 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__" + 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", - parent="parent_value", customer_id="customer_id_value", can_manage_clients=True, email_address="email_address_value", @@ -10101,15 +11083,14 @@ def test_update_google_ads_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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.parent == "parent_value" - assert response.customer_id == "customer_id_value" assert response.can_manage_clients is True @@ -10117,25 +11098,31 @@ def test_update_google_ads_link(transport: str = "grpc"): assert response.email_address == "email_address_value" +def test_update_google_ads_link_from_dict(): + test_update_google_ads_link(request_type=dict) + + @pytest.mark.asyncio -async def test_update_google_ads_link_async(transport: str = "grpc_asyncio"): +async def test_update_google_ads_link_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateGoogleAdsLinkRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.UpdateGoogleAdsLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_google_ads_link), "__call__" + 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", - parent="parent_value", customer_id="customer_id_value", can_manage_clients=True, email_address="email_address_value", @@ -10148,15 +11135,13 @@ async def test_update_google_ads_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + 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.parent == "parent_value" - assert response.customer_id == "customer_id_value" assert response.can_manage_clients is True @@ -10164,6 +11149,11 @@ async def test_update_google_ads_link_async(transport: str = "grpc_asyncio"): assert response.email_address == "email_address_value" +@pytest.mark.asyncio +async def test_update_google_ads_link_async_from_dict(): + await test_update_google_ads_link_async(request_type=dict) + + def test_update_google_ads_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -10176,7 +11166,7 @@ def test_update_google_ads_link_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_google_ads_link), "__call__" + type(client.transport.update_google_ads_link), "__call__" ) as call: call.return_value = resources.GoogleAdsLink() @@ -10208,7 +11198,7 @@ async def test_update_google_ads_link_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_google_ads_link), "__call__" + type(client.transport.update_google_ads_link), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.GoogleAdsLink() @@ -10236,7 +11226,7 @@ def test_update_google_ads_link_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_google_ads_link), "__call__" + type(client.transport.update_google_ads_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GoogleAdsLink() @@ -10281,7 +11271,7 @@ async def test_update_google_ads_link_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_google_ads_link), "__call__" + type(client.transport.update_google_ads_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GoogleAdsLink() @@ -10322,18 +11312,20 @@ async def test_update_google_ads_link_flattened_error_async(): ) -def test_delete_google_ads_link(transport: str = "grpc"): +def test_delete_google_ads_link( + transport: str = "grpc", request_type=analytics_admin.DeleteGoogleAdsLinkRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteGoogleAdsLinkRequest() + 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__" + type(client.transport.delete_google_ads_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -10344,25 +11336,32 @@ def test_delete_google_ads_link(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_delete_google_ads_link_async(transport: str = "grpc_asyncio"): +async def test_delete_google_ads_link_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteGoogleAdsLinkRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.DeleteGoogleAdsLinkRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_google_ads_link), "__call__" + 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) @@ -10373,12 +11372,17 @@ async def test_delete_google_ads_link_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_google_ads_link_async_from_dict(): + await test_delete_google_ads_link_async(request_type=dict) + + def test_delete_google_ads_link_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -10391,7 +11395,7 @@ def test_delete_google_ads_link_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_google_ads_link), "__call__" + type(client.transport.delete_google_ads_link), "__call__" ) as call: call.return_value = None @@ -10420,7 +11424,7 @@ async def test_delete_google_ads_link_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_google_ads_link), "__call__" + type(client.transport.delete_google_ads_link), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -10443,7 +11447,7 @@ def test_delete_google_ads_link_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_google_ads_link), "__call__" + type(client.transport.delete_google_ads_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -10481,7 +11485,7 @@ async def test_delete_google_ads_link_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_google_ads_link), "__call__" + type(client.transport.delete_google_ads_link), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -10513,18 +11517,20 @@ async def test_delete_google_ads_link_flattened_error_async(): ) -def test_list_google_ads_links(transport: str = "grpc"): +def test_list_google_ads_links( + transport: str = "grpc", request_type=analytics_admin.ListGoogleAdsLinksRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListGoogleAdsLinksRequest() + 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__" + type(client.transport.list_google_ads_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListGoogleAdsLinksResponse( @@ -10537,27 +11543,35 @@ def test_list_google_ads_links(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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) + + @pytest.mark.asyncio -async def test_list_google_ads_links_async(transport: str = "grpc_asyncio"): +async def test_list_google_ads_links_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListGoogleAdsLinksRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.ListGoogleAdsLinksRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_google_ads_links), "__call__" + 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( @@ -10572,7 +11586,7 @@ async def test_list_google_ads_links_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListGoogleAdsLinksAsyncPager) @@ -10580,6 +11594,11 @@ async def test_list_google_ads_links_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_google_ads_links_async_from_dict(): + await test_list_google_ads_links_async(request_type=dict) + + def test_list_google_ads_links_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -10592,7 +11611,7 @@ def test_list_google_ads_links_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_google_ads_links), "__call__" + type(client.transport.list_google_ads_links), "__call__" ) as call: call.return_value = analytics_admin.ListGoogleAdsLinksResponse() @@ -10621,7 +11640,7 @@ async def test_list_google_ads_links_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_google_ads_links), "__call__" + type(client.transport.list_google_ads_links), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListGoogleAdsLinksResponse() @@ -10646,7 +11665,7 @@ def test_list_google_ads_links_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_google_ads_links), "__call__" + type(client.transport.list_google_ads_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListGoogleAdsLinksResponse() @@ -10684,7 +11703,7 @@ async def test_list_google_ads_links_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_google_ads_links), "__call__" + type(client.transport.list_google_ads_links), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListGoogleAdsLinksResponse() @@ -10723,7 +11742,7 @@ def test_list_google_ads_links_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_google_ads_links), "__call__" + type(client.transport.list_google_ads_links), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -10768,7 +11787,7 @@ def test_list_google_ads_links_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_google_ads_links), "__call__" + type(client.transport.list_google_ads_links), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -10795,8 +11814,8 @@ def test_list_google_ads_links_pages(): 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 + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio @@ -10807,7 +11826,7 @@ async def test_list_google_ads_links_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_google_ads_links), + type(client.transport.list_google_ads_links), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -10853,7 +11872,7 @@ async def test_list_google_ads_links_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_google_ads_links), + type(client.transport.list_google_ads_links), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -10882,24 +11901,26 @@ async def test_list_google_ads_links_async_pages(): 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 + 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"): +def test_get_data_sharing_settings( + transport: str = "grpc", request_type=analytics_admin.GetDataSharingSettingsRequest +): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetDataSharingSettingsRequest() + 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__" + type(client.transport.get_data_sharing_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.DataSharingSettings( @@ -10917,9 +11938,10 @@ def test_get_data_sharing_settings(transport: str = "grpc"): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == request + 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" @@ -10935,19 +11957,26 @@ def test_get_data_sharing_settings(transport: str = "grpc"): assert response.sharing_with_others_enabled is True +def test_get_data_sharing_settings_from_dict(): + test_get_data_sharing_settings(request_type=dict) + + @pytest.mark.asyncio -async def test_get_data_sharing_settings_async(transport: str = "grpc_asyncio"): +async def test_get_data_sharing_settings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetDataSharingSettingsRequest, +): client = AnalyticsAdminServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = analytics_admin.GetDataSharingSettingsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_data_sharing_settings), "__call__" + 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( @@ -10967,7 +11996,7 @@ async def test_get_data_sharing_settings_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == analytics_admin.GetDataSharingSettingsRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.DataSharingSettings) @@ -10985,6 +12014,11 @@ async def test_get_data_sharing_settings_async(transport: str = "grpc_asyncio"): assert response.sharing_with_others_enabled is True +@pytest.mark.asyncio +async def test_get_data_sharing_settings_async_from_dict(): + await test_get_data_sharing_settings_async(request_type=dict) + + def test_get_data_sharing_settings_field_headers(): client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), @@ -10997,7 +12031,7 @@ def test_get_data_sharing_settings_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_data_sharing_settings), "__call__" + type(client.transport.get_data_sharing_settings), "__call__" ) as call: call.return_value = resources.DataSharingSettings() @@ -11026,7 +12060,7 @@ async def test_get_data_sharing_settings_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_data_sharing_settings), "__call__" + type(client.transport.get_data_sharing_settings), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.DataSharingSettings() @@ -11051,7 +12085,7 @@ def test_get_data_sharing_settings_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_data_sharing_settings), "__call__" + type(client.transport.get_data_sharing_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.DataSharingSettings() @@ -11089,7 +12123,7 @@ async def test_get_data_sharing_settings_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_data_sharing_settings), "__call__" + type(client.transport.get_data_sharing_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.DataSharingSettings() @@ -11159,7 +12193,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = AnalyticsAdminServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -11177,12 +12211,27 @@ def test_transport_get_channel(): assert channel +@pytest.mark.parametrize( + "transport_class", + [ + transports.AnalyticsAdminServiceGrpcTransport, + transports.AnalyticsAdminServiceGrpcAsyncIOTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(auth, "default") as adc: + adc.return_value = (credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = AnalyticsAdminServiceClient( credentials=credentials.AnonymousCredentials(), ) - assert isinstance(client._transport, transports.AnalyticsAdminServiceGrpcTransport,) + assert isinstance(client.transport, transports.AnalyticsAdminServiceGrpcTransport,) def test_analytics_admin_service_base_transport_error(): @@ -11196,9 +12245,13 @@ def test_analytics_admin_service_base_transport_error(): def test_analytics_admin_service_base_transport(): # Instantiate the base transport. - transport = transports.AnalyticsAdminServiceTransport( - credentials=credentials.AnonymousCredentials(), - ) + with mock.patch( + "google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport.__init__" + ) as Transport: + Transport.return_value = None + transport = transports.AnalyticsAdminServiceTransport( + credentials=credentials.AnonymousCredentials(), + ) # Every method on the transport should just blindly # raise NotImplementedError. @@ -11208,6 +12261,7 @@ def test_analytics_admin_service_base_transport(): "delete_account", "update_account", "provision_account_ticket", + "list_account_summaries", "get_property", "list_properties", "create_property", @@ -11258,7 +12312,12 @@ def test_analytics_admin_service_base_transport(): def test_analytics_admin_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file - with mock.patch.object(auth, "load_credentials_from_file") as load_creds: + with mock.patch.object( + auth, "load_credentials_from_file" + ) as load_creds, mock.patch( + "google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None load_creds.return_value = (credentials.AnonymousCredentials(), None) transport = transports.AnalyticsAdminServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", @@ -11275,6 +12334,17 @@ def test_analytics_admin_service_base_transport_with_credentials_file(): ) +def test_analytics_admin_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(auth, "default") as adc, mock.patch( + "google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + adc.return_value = (credentials.AnonymousCredentials(), None) + transport = transports.AnalyticsAdminServiceTransport() + adc.assert_called_once() + + def test_analytics_admin_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(auth, "default") as adc: @@ -11317,7 +12387,7 @@ def test_analytics_admin_service_host_no_port(): api_endpoint="analyticsadmin.googleapis.com" ), ) - assert client._transport._host == "analyticsadmin.googleapis.com:443" + assert client.transport._host == "analyticsadmin.googleapis.com:443" def test_analytics_admin_service_host_with_port(): @@ -11327,210 +12397,182 @@ def test_analytics_admin_service_host_with_port(): api_endpoint="analyticsadmin.googleapis.com:8000" ), ) - assert client._transport._host == "analyticsadmin.googleapis.com:8000" + assert client.transport._host == "analyticsadmin.googleapis.com:8000" def test_analytics_admin_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) - # Check that if channel is provided, mtls endpoint and client_cert_source - # won't be used. - callback = mock.MagicMock() + # Check that channel is used if provided. transport = transports.AnalyticsAdminServiceGrpcTransport( - host="squid.clam.whelk", - channel=channel, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=callback, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" - assert not callback.called + assert transport._ssl_channel_credentials == None def test_analytics_admin_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) - # Check that if channel is provided, mtls endpoint and client_cert_source - # won't be used. - callback = mock.MagicMock() + # Check that channel is used if provided. transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=callback, + host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" - assert not callback.called + assert transport._ssl_channel_credentials == None -@mock.patch("grpc.ssl_channel_credentials", autospec=True) -@mock.patch("google.api_core.grpc_helpers.create_channel", autospec=True) -def test_analytics_admin_service_grpc_transport_channel_mtls_with_client_cert_source( - grpc_create_channel, grpc_ssl_channel_cred +@pytest.mark.parametrize( + "transport_class", + [ + transports.AnalyticsAdminServiceGrpcTransport, + transports.AnalyticsAdminServiceGrpcAsyncIOTransport, + ], +) +def test_analytics_admin_service_transport_channel_mtls_with_client_cert_source( + transport_class, ): - # Check that if channel is None, but api_mtls_endpoint and client_cert_source - # are provided, then a mTLS channel will be created. - mock_cred = mock.Mock() + with mock.patch( + "grpc.ssl_channel_credentials", autospec=True + ) as grpc_ssl_channel_cred: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(auth, "default") as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=( + "https://www.googleapis.com/auth/analytics.edit", + "https://www.googleapis.com/auth/analytics.manage.users", + "https://www.googleapis.com/auth/analytics.manage.users.readonly", + "https://www.googleapis.com/auth/analytics.readonly", + ), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + +@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() - grpc_ssl_channel_cred.return_value = mock_ssl_cred + 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, + ) - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=( + "https://www.googleapis.com/auth/analytics.edit", + "https://www.googleapis.com/auth/analytics.manage.users", + "https://www.googleapis.com/auth/analytics.manage.users.readonly", + "https://www.googleapis.com/auth/analytics.readonly", + ), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel - transport = transports.AnalyticsAdminServiceGrpcTransport( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - 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=mock_cred, - credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/analytics.edit", - "https://www.googleapis.com/auth/analytics.manage.users", - "https://www.googleapis.com/auth/analytics.manage.users.readonly", - "https://www.googleapis.com/auth/analytics.readonly", - ), - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - ) - assert transport.grpc_channel == mock_grpc_channel +def test_account_path(): + account = "squid" -@mock.patch("grpc.ssl_channel_credentials", autospec=True) -@mock.patch("google.api_core.grpc_helpers_async.create_channel", autospec=True) -def test_analytics_admin_service_grpc_asyncio_transport_channel_mtls_with_client_cert_source( - grpc_create_channel, grpc_ssl_channel_cred -): - # Check that if channel is None, but api_mtls_endpoint and client_cert_source - # are provided, then a mTLS channel will be created. - mock_cred = mock.Mock() + expected = "accounts/{account}".format(account=account,) + actual = AnalyticsAdminServiceClient.account_path(account) + assert expected == actual - 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 +def test_parse_account_path(): + expected = { + "account": "clam", + } + path = AnalyticsAdminServiceClient.account_path(**expected) - transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - 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=mock_cred, - credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/analytics.edit", - "https://www.googleapis.com/auth/analytics.manage.users", - "https://www.googleapis.com/auth/analytics.manage.users.readonly", - "https://www.googleapis.com/auth/analytics.readonly", - ), - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - ) - assert transport.grpc_channel == mock_grpc_channel + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_account_path(path) + assert expected == actual -@pytest.mark.parametrize( - "api_mtls_endpoint", ["mtls.squid.clam.whelk", "mtls.squid.clam.whelk:443"] -) -@mock.patch("google.api_core.grpc_helpers.create_channel", autospec=True) -def test_analytics_admin_service_grpc_transport_channel_mtls_with_adc( - grpc_create_channel, api_mtls_endpoint -): - # Check that if channel and client_cert_source are None, but api_mtls_endpoint - # is provided, then a mTLS channel will be created with SSL ADC. - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel +def test_account_summary_path(): + account_summary = "whelk" - # Mock google.auth.transport.grpc.SslCredentials 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), - ): - mock_cred = mock.Mock() - transport = transports.AnalyticsAdminServiceGrpcTransport( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint=api_mtls_endpoint, - client_cert_source=None, - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/analytics.edit", - "https://www.googleapis.com/auth/analytics.manage.users", - "https://www.googleapis.com/auth/analytics.manage.users.readonly", - "https://www.googleapis.com/auth/analytics.readonly", - ), - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - ) - assert transport.grpc_channel == mock_grpc_channel + expected = "accountSummaries/{account_summary}".format( + account_summary=account_summary, + ) + actual = AnalyticsAdminServiceClient.account_summary_path(account_summary) + assert expected == actual -@pytest.mark.parametrize( - "api_mtls_endpoint", ["mtls.squid.clam.whelk", "mtls.squid.clam.whelk:443"] -) -@mock.patch("google.api_core.grpc_helpers_async.create_channel", autospec=True) -def test_analytics_admin_service_grpc_asyncio_transport_channel_mtls_with_adc( - grpc_create_channel, api_mtls_endpoint -): - # Check that if channel and client_cert_source are None, but api_mtls_endpoint - # is provided, then a mTLS channel will be created with SSL ADC. - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel +def test_parse_account_summary_path(): + expected = { + "account_summary": "octopus", + } + path = AnalyticsAdminServiceClient.account_summary_path(**expected) - # Mock google.auth.transport.grpc.SslCredentials 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), - ): - mock_cred = mock.Mock() - transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint=api_mtls_endpoint, - client_cert_source=None, - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/analytics.edit", - "https://www.googleapis.com/auth/analytics.manage.users", - "https://www.googleapis.com/auth/analytics.manage.users.readonly", - "https://www.googleapis.com/auth/analytics.readonly", - ), - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - ) - assert transport.grpc_channel == mock_grpc_channel + # 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 = "squid" - android_app_data_stream = "clam" + 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, @@ -11543,8 +12585,8 @@ def test_android_app_data_stream_path(): def test_parse_android_app_data_stream_path(): expected = { - "property": "whelk", - "android_app_data_stream": "octopus", + "property": "cuttlefish", + "android_app_data_stream": "mussel", } path = AnalyticsAdminServiceClient.android_app_data_stream_path(**expected) @@ -11553,76 +12595,95 @@ def test_parse_android_app_data_stream_path(): assert expected == actual -def test_property_path(): - property = "squid" +def test_data_sharing_settings_path(): + account = "winkle" - expected = "properties/{property}".format(property=property,) - actual = AnalyticsAdminServiceClient.property_path(property) + expected = "accounts/{account}/dataSharingSettings".format(account=account,) + actual = AnalyticsAdminServiceClient.data_sharing_settings_path(account) assert expected == actual -def test_parse_property_path(): +def test_parse_data_sharing_settings_path(): expected = { - "property": "clam", + "account": "nautilus", } - path = AnalyticsAdminServiceClient.property_path(**expected) + path = AnalyticsAdminServiceClient.data_sharing_settings_path(**expected) # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_property_path(path) + actual = AnalyticsAdminServiceClient.parse_data_sharing_settings_path(path) assert expected == actual -def test_user_link_path(): - account = "squid" - user_link = "clam" +def test_enhanced_measurement_settings_path(): + property = "scallop" + web_data_stream = "abalone" - expected = "accounts/{account}/userLinks/{user_link}".format( - account=account, user_link=user_link, + 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 ) - actual = AnalyticsAdminServiceClient.user_link_path(account, user_link) assert expected == actual -def test_parse_user_link_path(): +def test_parse_enhanced_measurement_settings_path(): expected = { - "account": "whelk", - "user_link": "octopus", + "property": "squid", + "web_data_stream": "clam", } - path = AnalyticsAdminServiceClient.user_link_path(**expected) + path = AnalyticsAdminServiceClient.enhanced_measurement_settings_path(**expected) # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_user_link_path(path) + actual = AnalyticsAdminServiceClient.parse_enhanced_measurement_settings_path(path) assert expected == actual -def test_enhanced_measurement_settings_path(): - property = "squid" - web_data_stream = "clam" +def test_firebase_link_path(): + property = "whelk" + firebase_link = "octopus" - 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 + 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_enhanced_measurement_settings_path(): +def test_parse_firebase_link_path(): expected = { - "property": "whelk", - "web_data_stream": "octopus", + "property": "oyster", + "firebase_link": "nudibranch", } - path = AnalyticsAdminServiceClient.enhanced_measurement_settings_path(**expected) + path = AnalyticsAdminServiceClient.firebase_link_path(**expected) # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_enhanced_measurement_settings_path(path) + actual = AnalyticsAdminServiceClient.parse_firebase_link_path(path) + assert expected == actual + + +def test_global_site_tag_path(): + property = "cuttlefish" + + expected = "properties/{property}/globalSiteTag".format(property=property,) + actual = AnalyticsAdminServiceClient.global_site_tag_path(property) + assert expected == actual + + +def test_parse_global_site_tag_path(): + expected = { + "property": "mussel", + } + path = AnalyticsAdminServiceClient.global_site_tag_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_global_site_tag_path(path) assert expected == actual def test_google_ads_link_path(): - property = "squid" - google_ads_link = "clam" + property = "winkle" + google_ads_link = "nautilus" expected = "properties/{property}/googleAdsLinks/{google_ads_link}".format( property=property, google_ads_link=google_ads_link, @@ -11633,8 +12694,8 @@ def test_google_ads_link_path(): def test_parse_google_ads_link_path(): expected = { - "property": "whelk", - "google_ads_link": "octopus", + "property": "scallop", + "google_ads_link": "abalone", } path = AnalyticsAdminServiceClient.google_ads_link_path(**expected) @@ -11643,32 +12704,76 @@ def test_parse_google_ads_link_path(): assert expected == actual -def test_firebase_link_path(): +def test_ios_app_data_stream_path(): property = "squid" - firebase_link = "clam" + ios_app_data_stream = "clam" - expected = "properties/{property}/firebaseLinks/{firebase_link}".format( - property=property, firebase_link=firebase_link, + 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 ) - actual = AnalyticsAdminServiceClient.firebase_link_path(property, firebase_link) assert expected == actual -def test_parse_firebase_link_path(): +def test_parse_ios_app_data_stream_path(): expected = { "property": "whelk", - "firebase_link": "octopus", + "ios_app_data_stream": "octopus", } - path = AnalyticsAdminServiceClient.firebase_link_path(**expected) + path = AnalyticsAdminServiceClient.ios_app_data_stream_path(**expected) # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_firebase_link_path(path) + actual = AnalyticsAdminServiceClient.parse_ios_app_data_stream_path(path) + assert expected == actual + + +def test_property_path(): + property = "oyster" + + expected = "properties/{property}".format(property=property,) + actual = AnalyticsAdminServiceClient.property_path(property) + assert expected == actual + + +def test_parse_property_path(): + expected = { + "property": "nudibranch", + } + path = AnalyticsAdminServiceClient.property_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_property_path(path) + assert expected == actual + + +def test_user_link_path(): + account = "cuttlefish" + user_link = "mussel" + + expected = "accounts/{account}/userLinks/{user_link}".format( + account=account, user_link=user_link, + ) + actual = AnalyticsAdminServiceClient.user_link_path(account, user_link) + assert expected == actual + + +def test_parse_user_link_path(): + expected = { + "account": "winkle", + "user_link": "nautilus", + } + path = AnalyticsAdminServiceClient.user_link_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_user_link_path(path) assert expected == actual def test_web_data_stream_path(): - property = "squid" - web_data_stream = "clam" + property = "scallop" + web_data_stream = "abalone" expected = "properties/{property}/webDataStreams/{web_data_stream}".format( property=property, web_data_stream=web_data_stream, @@ -11679,8 +12784,8 @@ def test_web_data_stream_path(): def test_parse_web_data_stream_path(): expected = { - "property": "whelk", - "web_data_stream": "octopus", + "property": "squid", + "web_data_stream": "clam", } path = AnalyticsAdminServiceClient.web_data_stream_path(**expected) @@ -11689,45 +12794,123 @@ def test_parse_web_data_stream_path(): assert expected == actual -def test_ios_app_data_stream_path(): - property = "squid" - ios_app_data_stream = "clam" +def test_common_billing_account_path(): + billing_account = "whelk" - 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 + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, ) + actual = AnalyticsAdminServiceClient.common_billing_account_path(billing_account) assert expected == actual -def test_parse_ios_app_data_stream_path(): +def test_parse_common_billing_account_path(): expected = { - "property": "whelk", - "ios_app_data_stream": "octopus", + "billing_account": "octopus", } - path = AnalyticsAdminServiceClient.ios_app_data_stream_path(**expected) + path = AnalyticsAdminServiceClient.common_billing_account_path(**expected) # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_ios_app_data_stream_path(path) + actual = AnalyticsAdminServiceClient.parse_common_billing_account_path(path) assert expected == actual -def test_account_path(): - account = "squid" +def test_common_folder_path(): + folder = "oyster" - expected = "accounts/{account}".format(account=account,) - actual = AnalyticsAdminServiceClient.account_path(account) + expected = "folders/{folder}".format(folder=folder,) + actual = AnalyticsAdminServiceClient.common_folder_path(folder) assert expected == actual -def test_parse_account_path(): +def test_parse_common_folder_path(): expected = { - "account": "clam", + "folder": "nudibranch", } - path = AnalyticsAdminServiceClient.account_path(**expected) + path = AnalyticsAdminServiceClient.common_folder_path(**expected) # Check that the path construction is reversible. - actual = AnalyticsAdminServiceClient.parse_account_path(path) + actual = AnalyticsAdminServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "cuttlefish" + + expected = "organizations/{organization}".format(organization=organization,) + actual = AnalyticsAdminServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "mussel", + } + path = AnalyticsAdminServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "winkle" + + expected = "projects/{project}".format(project=project,) + actual = AnalyticsAdminServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nautilus", + } + path = AnalyticsAdminServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "scallop" + location = "abalone" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = AnalyticsAdminServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "squid", + "location": "clam", + } + path = AnalyticsAdminServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_common_location_path(path) assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object( + transports.AnalyticsAdminServiceTransport, "_prep_wrapped_messages" + ) as prep: + client = AnalyticsAdminServiceClient( + credentials=credentials.AnonymousCredentials(), client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object( + transports.AnalyticsAdminServiceTransport, "_prep_wrapped_messages" + ) as prep: + transport_class = AnalyticsAdminServiceClient.get_transport_class() + transport = transport_class( + credentials=credentials.AnonymousCredentials(), client_info=client_info, + ) + prep.assert_called_once_with(client_info)