From f787a0413462698f21448bd2f3ba7d2ac824e7c0 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Wed, 1 Sep 2021 17:51:46 -0700 Subject: [PATCH 01/14] update test configuration --- samples/noxfile_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/noxfile_config.py b/samples/noxfile_config.py index b883a88e..475aaaa9 100644 --- a/samples/noxfile_config.py +++ b/samples/noxfile_config.py @@ -8,13 +8,13 @@ # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a # build specific Cloud project. You can also use your own string # to use your own Cloud project. - "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', # A dictionary you want to inject into your test. Don't put any # secrets here. These values will override predefined values. "envs": { - "GA_TEST_PROPERTY_ID": "222596558", - "GA_TEST_ACCOUNT_ID": "123", + "GA_TEST_PROPERTY_ID": "276206997", + "GA_TEST_ACCOUNT_ID": "199820965", "GA_TEST_USER_LINK_ID": "123", "GA_TEST_ANDROID_APP_DATA_STREAM_ID": "123", "GA_TEST_IOS_APP_DATA_STREAM_ID": "123", From 79093d1980763fbdf57988d56d6e50293077264f Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 2 Sep 2021 05:44:25 -0400 Subject: [PATCH 02/14] remove custom noxfile configs for now --- samples/noxfile_config.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/samples/noxfile_config.py b/samples/noxfile_config.py index 475aaaa9..635b6c6a 100644 --- a/samples/noxfile_config.py +++ b/samples/noxfile_config.py @@ -1,13 +1,4 @@ TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": True, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', # A dictionary you want to inject into your test. Don't put any From 8f1f9579293a6c5e665ed3a3028af6ea57767c40 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 2 Sep 2021 09:51:49 +0000 Subject: [PATCH 03/14] remove MaximumUserAccess rom sample --- samples/properties_firebase_links_list.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/samples/properties_firebase_links_list.py b/samples/properties_firebase_links_list.py index 0d5c2f17..560363c3 100644 --- a/samples/properties_firebase_links_list.py +++ b/samples/properties_firebase_links_list.py @@ -22,7 +22,6 @@ """ # [START analyticsadmin_properties_firebase_links_list] from google.analytics.admin import AnalyticsAdminServiceClient -from google.analytics.admin_v1alpha.types import MaximumUserAccess def run_sample(): @@ -49,10 +48,6 @@ def print_firebase_link(firebase_link): """Prints the Firebase link details.""" print(f"Resource name: {firebase_link.name}") print(f"Firebase project: {firebase_link.project}") - print( - f"Maximum user access to the GA4 property: " - f"{MaximumUserAccess(firebase_link.maximum_user_access).name}" - ) print(f"Create time: {firebase_link.create_time}") From b674e0d2597237be4c70ddff0f0255bd3b9dee1b Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 2 Sep 2021 05:53:37 -0400 Subject: [PATCH 04/14] add comment in noxfile_config.py --- samples/noxfile_config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/noxfile_config.py b/samples/noxfile_config.py index 635b6c6a..600de5ec 100644 --- a/samples/noxfile_config.py +++ b/samples/noxfile_config.py @@ -1,4 +1,8 @@ TEST_CONFIG_OVERRIDE = { + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', # A dictionary you want to inject into your test. Don't put any From de94a9595e67d931b6bacd79febf8ada07b72810 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 2 Sep 2021 10:04:42 +0000 Subject: [PATCH 05/14] run blacken session --- samples/noxfile.py | 44 +++++++++++-------- ...ms_update_enhanced_measurement_settings.py | 1 - samples/quickstart.py | 25 ++++++----- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/samples/noxfile.py b/samples/noxfile.py index e73436a1..b008613f 100644 --- a/samples/noxfile.py +++ b/samples/noxfile.py @@ -39,17 +39,15 @@ TEST_CONFIG = { # You can opt out from the test for specific Python versions. - 'ignored_versions': [], - + "ignored_versions": [], # Old samples are opted out of enforcing Python type hints # All new samples should feature them - 'enforce_type_hints': False, - + "enforce_type_hints": False, # An envvar key for determining the project id to use. Change it # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a # build specific Cloud project. You can also use your own string # to use your own Cloud project. - 'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT', + "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', # If you need to use a specific version of pip, # change pip_version_override to the string representation @@ -57,13 +55,13 @@ "pip_version_override": None, # A dictionary you want to inject into your test. Don't put any # secrets here. These values will override predefined values. - 'envs': {}, + "envs": {}, } try: # Ensure we can import noxfile_config in the project's directory. - sys.path.append('.') + sys.path.append(".") from noxfile_config import TEST_CONFIG_OVERRIDE except ImportError as e: print("No user noxfile_config found: detail: {}".format(e)) @@ -78,12 +76,12 @@ def get_pytest_env_vars() -> Dict[str, str]: ret = {} # Override the GCLOUD_PROJECT and the alias. - env_key = TEST_CONFIG['gcloud_project_env'] + env_key = TEST_CONFIG["gcloud_project_env"] # This should error out if not set. - ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key] + ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key] # Apply user supplied envs. - ret.update(TEST_CONFIG['envs']) + ret.update(TEST_CONFIG["envs"]) return ret @@ -92,11 +90,14 @@ def get_pytest_env_vars() -> Dict[str, str]: ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] # Any default versions that should be ignored. -IGNORED_VERSIONS = TEST_CONFIG['ignored_versions'] +IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS]) -INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ("True", "true") +INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ( + "True", + "true", +) # # Style Checks # @@ -141,7 +142,7 @@ def _determine_local_import_names(start_dir: str) -> List[str]: @nox.session def lint(session: nox.sessions.Session) -> None: - if not TEST_CONFIG['enforce_type_hints']: + if not TEST_CONFIG["enforce_type_hints"]: session.install("flake8", "flake8-import-order") else: session.install("flake8", "flake8-import-order", "flake8-annotations") @@ -150,9 +151,11 @@ def lint(session: nox.sessions.Session) -> None: args = FLAKE8_COMMON_ARGS + [ "--application-import-names", ",".join(local_names), - "." + ".", ] session.run("flake8", *args) + + # # Black # @@ -165,6 +168,7 @@ def blacken(session: nox.sessions.Session) -> None: session.run("black", *python_files) + # # Sample Tests # @@ -173,7 +177,9 @@ def blacken(session: nox.sessions.Session) -> None: PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"] -def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None: +def _session_tests( + session: nox.sessions.Session, post_install: Callable = None +) -> None: if TEST_CONFIG["pip_version_override"]: pip_version = TEST_CONFIG["pip_version_override"] session.install(f"pip=={pip_version}") @@ -203,7 +209,7 @@ def _session_tests(session: nox.sessions.Session, post_install: Callable = None) # on travis where slow and flaky tests are excluded. # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html success_codes=[0, 5], - env=get_pytest_env_vars() + env=get_pytest_env_vars(), ) @@ -213,9 +219,9 @@ def py(session: nox.sessions.Session) -> None: if session.python in TESTED_VERSIONS: _session_tests(session) else: - session.skip("SKIPPED: {} tests are disabled for this sample.".format( - session.python - )) + session.skip( + "SKIPPED: {} tests are disabled for this sample.".format(session.python) + ) # diff --git a/samples/properties_web_data_streams_update_enhanced_measurement_settings.py b/samples/properties_web_data_streams_update_enhanced_measurement_settings.py index f02e1fb0..354cebf2 100644 --- a/samples/properties_web_data_streams_update_enhanced_measurement_settings.py +++ b/samples/properties_web_data_streams_update_enhanced_measurement_settings.py @@ -26,7 +26,6 @@ from google.protobuf.field_mask_pb2 import FieldMask - def run_sample(): """Runs the sample.""" diff --git a/samples/quickstart.py b/samples/quickstart.py index 5653af44..1d6605b7 100644 --- a/samples/quickstart.py +++ b/samples/quickstart.py @@ -51,18 +51,21 @@ # [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) + """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() + list_accounts() From 761d8aa99d1c94929cef786c0c73dd12c492902c Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 2 Sep 2021 10:16:13 +0000 Subject: [PATCH 06/14] lint --- samples/quickstart.py | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/quickstart.py b/samples/quickstart.py index 1d6605b7..0e22289a 100644 --- a/samples/quickstart.py +++ b/samples/quickstart.py @@ -49,6 +49,7 @@ pip install google-analytics-admin """ + # [START ga_admin_list_accounts] def list_accounts(): """Lists the available Google Analytics accounts.""" From ee91693742a93165b4c446bd69ab5249c1a20a61 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 2 Sep 2021 10:27:40 +0000 Subject: [PATCH 07/14] add pytest --- samples/requirements-test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 samples/requirements-test.txt diff --git a/samples/requirements-test.txt b/samples/requirements-test.txt new file mode 100644 index 00000000..9299a7a8 --- /dev/null +++ b/samples/requirements-test.txt @@ -0,0 +1 @@ +pytest==6.2.5 \ No newline at end of file From 7a7c6d2bcfc2bd5d32f98d3209edb7f7e6a1271e Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Mon, 4 Oct 2021 17:51:21 -0700 Subject: [PATCH 08/14] Update noxfile_config.py --- samples/noxfile_config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/noxfile_config.py b/samples/noxfile_config.py index 600de5ec..04520022 100644 --- a/samples/noxfile_config.py +++ b/samples/noxfile_config.py @@ -10,9 +10,9 @@ "envs": { "GA_TEST_PROPERTY_ID": "276206997", "GA_TEST_ACCOUNT_ID": "199820965", - "GA_TEST_USER_LINK_ID": "123", - "GA_TEST_ANDROID_APP_DATA_STREAM_ID": "123", - "GA_TEST_IOS_APP_DATA_STREAM_ID": "123", - "GA_TEST_WEB_DATA_STREAM_ID": "123", + "GA_TEST_USER_LINK_ID": "105231969274497648555", + "GA_TEST_ANDROID_APP_DATA_STREAM_ID": "2828100949", + "GA_TEST_IOS_APP_DATA_STREAM_ID": "2828089289", + "GA_TEST_WEB_DATA_STREAM_ID": "2377024575", }, } From 9366fdc3e40b0474f201393b944a2532b93afe91 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Mon, 4 Oct 2021 17:57:39 -0700 Subject: [PATCH 09/14] Update noxfile_config.py --- samples/noxfile_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/noxfile_config.py b/samples/noxfile_config.py index 04520022..62d635ce 100644 --- a/samples/noxfile_config.py +++ b/samples/noxfile_config.py @@ -13,6 +13,6 @@ "GA_TEST_USER_LINK_ID": "105231969274497648555", "GA_TEST_ANDROID_APP_DATA_STREAM_ID": "2828100949", "GA_TEST_IOS_APP_DATA_STREAM_ID": "2828089289", - "GA_TEST_WEB_DATA_STREAM_ID": "2377024575", + "GA_TEST_WEB_DATA_STREAM_ID": "2828068992", }, } From a88d15e5c010ed0c2df943a26f3a9e6618c8a97a Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Tue, 5 Oct 2021 01:56:51 -0700 Subject: [PATCH 10/14] delete enhanced measurement settings samples as this functionality is no longer supported in v1alpha --- ...reams_get_enhanced_measurement_settings.py | 79 ------------------- ..._get_enhanced_measurement_settings_test.py | 29 ------- ...ms_update_enhanced_measurement_settings.py | 72 ----------------- ...date_enhanced_measurement_settings_test.py | 30 ------- 4 files changed, 210 deletions(-) delete mode 100644 samples/properties_web_data_streams_get_enhanced_measurement_settings.py delete mode 100644 samples/properties_web_data_streams_get_enhanced_measurement_settings_test.py delete mode 100644 samples/properties_web_data_streams_update_enhanced_measurement_settings.py delete mode 100644 samples/properties_web_data_streams_update_enhanced_measurement_settings_test.py diff --git a/samples/properties_web_data_streams_get_enhanced_measurement_settings.py b/samples/properties_web_data_streams_get_enhanced_measurement_settings.py deleted file mode 100644 index 65d7225d..00000000 --- a/samples/properties_web_data_streams_get_enhanced_measurement_settings.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2021 Google LLC 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 application which prints the enhanced -measurement settings for the web stream. - -See https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/properties.webDataStreams/getEnhancedMeasurementSettings -for more information. -""" -# [START analyticsadmin_properties_web_data_streams_get_enhanced_measurement_settings] -from google.analytics.admin import AnalyticsAdminServiceClient - - -def run_sample(): - """Runs the sample.""" - # TODO(developer): Replace this variable with your Google Analytics 4 - # property ID (e.g. "123456") before running the sample. - property_id = "YOUR-GA4-PROPERTY-ID" - - # TODO(developer): Replace this variable with your web data stream ID - # (e.g. "123456") before running the sample. - stream_id = "YOUR-WEB-DATA-STREAM-ID" - - get_enhanced_measurement_settings(property_id, stream_id) - - -def get_enhanced_measurement_settings(property_id, stream_id): - """Retrieves the enhanced measurement settings for the web stream.""" - client = AnalyticsAdminServiceClient() - enhanced_measurement_settings = client.get_enhanced_measurement_settings( - name=f"properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings" - ) - - print("Result:") - print_enhanced_measurement_settings(enhanced_measurement_settings) - - -def print_enhanced_measurement_settings(enhanced_measurement_settings): - """Prints the enhanced measurement settings for a web stream.""" - print(f"Resource name: {enhanced_measurement_settings.name}") - print(f"Stream enabled: {enhanced_measurement_settings.streamEnabled}") - print(f"Page views enabled: {enhanced_measurement_settings.pageViewsEnabled}") - print(f"Scrolls enabled: {enhanced_measurement_settings.scrollsEnabled}") - print( - f"Outbound clicks enabled: {enhanced_measurement_settings.outboundClicksEnabled}" - ) - print(f"Site search enabled: {enhanced_measurement_settings.siteSearchEnabled}") - print( - f"Video engagement enabled: {enhanced_measurement_settings.videoEngagementEnabled}" - ) - print( - f"File downloads enabled: {enhanced_measurement_settings.fileDownloadsEnabled}" - ) - print(f"Page loads enabled: {enhanced_measurement_settings.pageLoadsEnabled}") - print(f"Page changes enabled: {enhanced_measurement_settings.pageChangesEnabled}") - print( - f"Search query parameter: {enhanced_measurement_settings.searchQueryParameter}" - ) - print(f"Uri query parameter: {enhanced_measurement_settings.uriQueryParameter}") - - -# [END analyticsadmin_properties_web_data_streams_get_enhanced_measurement_settings] - - -if __name__ == "__main__": - run_sample() diff --git a/samples/properties_web_data_streams_get_enhanced_measurement_settings_test.py b/samples/properties_web_data_streams_get_enhanced_measurement_settings_test.py deleted file mode 100644 index 34d7ccd4..00000000 --- a/samples/properties_web_data_streams_get_enhanced_measurement_settings_test.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2021 Google LLC 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. - -import os - -import properties_web_data_streams_get_enhanced_measurement_settings - - -TEST_PROPERTY_ID = os.getenv("GA_TEST_PROPERTY_ID") -TEST_WEB_DATA_STREAM_ID = os.getenv("GA_TEST_WEB_DATA_STREAM_ID") - - -def test_properties_web_data_streams_get_enhanced_measurement_settings(capsys): - properties_web_data_streams_get_enhanced_measurement_settings.get_enhanced_measurement_settings( - TEST_PROPERTY_ID, TEST_WEB_DATA_STREAM_ID - ) - out, _ = capsys.readouterr() - assert "Result" in out diff --git a/samples/properties_web_data_streams_update_enhanced_measurement_settings.py b/samples/properties_web_data_streams_update_enhanced_measurement_settings.py deleted file mode 100644 index 354cebf2..00000000 --- a/samples/properties_web_data_streams_update_enhanced_measurement_settings.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2021 Google LLC 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 application which updates the enhanced -measurement settings for the web stream. - -See https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/properties.webDataStreams/updateEnhancedMeasurementSettings -for more information. -""" -# [START analyticsadmin_properties_web_data_streams_update_enhanced_measurement_settings] -from google.analytics.admin import AnalyticsAdminServiceClient -from google.analytics.admin_v1alpha.types import EnhancedMeasurementSettings -from google.protobuf.field_mask_pb2 import FieldMask - - -def run_sample(): - """Runs the sample.""" - - # !!! ATTENTION !!! - # Running this sample may change/delete your Google Analytics account - # configuration. Make sure to not use the Google Analytics property ID from - # your production environment below. - - # TODO(developer): Replace this variable with your Google Analytics 4 - # property ID (e.g. "123456") before running the sample. - property_id = "YOUR-GA4-PROPERTY-ID" - - # TODO(developer): Replace this variable with your web data stream ID - # (e.g. "123456") before running the sample. - stream_id = "YOUR-WEB-DATA-STREAM-ID" - - update_enhanced_measurement_settings(property_id, stream_id) - - -def update_enhanced_measurement_settings(property_id, stream_id): - """Updates the enhanced measurement settings for the web stream.""" - client = AnalyticsAdminServiceClient() - # This call updates the `streamEnabled`, `fileDownloadsEnabled` measurement - # settings of the web data stream, as indicated by the value of the - # `update_mask` field. The web data stream to update is specified in the - # `name` field of the `EnhancedMeasurementSettings` instance. - enhanced_measurement_settings = client.update_enhanced_measurement_settings( - enhanced_measurement_settings=EnhancedMeasurementSettings( - name=f"properties/{property_id}/webDataStreams/{stream_id}/enhancedMeasurementSettings", - stream_enabled=False, - file_downloads_enabled=False, - ), - update_mask=FieldMask(paths=["stream_enabled", "file_downloads_enabled"]), - ) - - print("Result:") - print(enhanced_measurement_settings) - - -# [END analyticsadmin_properties_web_data_streams_update_enhanced_measurement_settings] - - -if __name__ == "__main__": - run_sample() diff --git a/samples/properties_web_data_streams_update_enhanced_measurement_settings_test.py b/samples/properties_web_data_streams_update_enhanced_measurement_settings_test.py deleted file mode 100644 index d692a0eb..00000000 --- a/samples/properties_web_data_streams_update_enhanced_measurement_settings_test.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2021 Google LLC 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. - -import pytest - -import properties_web_data_streams_update_enhanced_measurement_settings - - -FAKE_PROPERTY_ID = "1" -FAKE_STREAM_ID = "1" - - -def test_properties_web_data_streams_update(): - # This test ensures that the call is valid and reaches the server, even - # though the operation does not succeed due to permission error. - with pytest.raises(Exception, match="403 The caller does not have permission"): - properties_web_data_streams_update_enhanced_measurement_settings.update_enhanced_measurement_settings( - FAKE_PROPERTY_ID, FAKE_STREAM_ID - ) From e76ba965c6d8c715e46854083753a0f8cd43545d Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Tue, 5 Oct 2021 02:03:26 -0700 Subject: [PATCH 11/14] fix the samples tests --- samples/noxfile_config.py | 3 ++- samples/properties_ios_app_data_streams_get.py | 2 +- samples/properties_user_links_batch_get_test.py | 2 +- samples/properties_user_links_get_test.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/samples/noxfile_config.py b/samples/noxfile_config.py index 62d635ce..f2184825 100644 --- a/samples/noxfile_config.py +++ b/samples/noxfile_config.py @@ -10,7 +10,8 @@ "envs": { "GA_TEST_PROPERTY_ID": "276206997", "GA_TEST_ACCOUNT_ID": "199820965", - "GA_TEST_USER_LINK_ID": "105231969274497648555", + "GA_TEST_USER_LINK_ID": "103401743041912607932", + "GA_TEST_PROPERTY_USER_LINK_ID": "105231969274497648555", "GA_TEST_ANDROID_APP_DATA_STREAM_ID": "2828100949", "GA_TEST_IOS_APP_DATA_STREAM_ID": "2828089289", "GA_TEST_WEB_DATA_STREAM_ID": "2828068992", diff --git a/samples/properties_ios_app_data_streams_get.py b/samples/properties_ios_app_data_streams_get.py index 02b775da..50a617af 100644 --- a/samples/properties_ios_app_data_streams_get.py +++ b/samples/properties_ios_app_data_streams_get.py @@ -53,7 +53,7 @@ def print_ios_app_data_stream(ios_app_data_stream): print(f"Resource name: {ios_app_data_stream.name}") print(f"Display name: {ios_app_data_stream.display_name}") print(f"Firebase app ID: {ios_app_data_stream.firebase_app_id}") - print(f"Bundle ID: {ios_app_data_stream.bundleId}") + print(f"Bundle ID: {ios_app_data_stream.bundle_id}") print(f"Create time: {ios_app_data_stream.create_time}") print(f"Update time: {ios_app_data_stream.update_time}") diff --git a/samples/properties_user_links_batch_get_test.py b/samples/properties_user_links_batch_get_test.py index a862070d..4c8c4bb5 100644 --- a/samples/properties_user_links_batch_get_test.py +++ b/samples/properties_user_links_batch_get_test.py @@ -17,7 +17,7 @@ import properties_user_links_batch_get TEST_PROPERTY_ID = os.getenv("GA_TEST_PROPERTY_ID") -TEST_USER_LINK_ID = os.getenv("GA_USER_LINK_ID") +TEST_USER_LINK_ID = os.getenv("GA_TEST_PROPERTY_USER_LINK_ID") def test_properties_user_links_batch_get(capsys): diff --git a/samples/properties_user_links_get_test.py b/samples/properties_user_links_get_test.py index dca1ca87..14c99708 100644 --- a/samples/properties_user_links_get_test.py +++ b/samples/properties_user_links_get_test.py @@ -17,7 +17,7 @@ import properties_user_links_get TEST_PROPERTY_ID = os.getenv("GA_TEST_PROPERTY_ID") -TEST_USER_LINK_ID = os.getenv("GA_USER_LINK_ID") +TEST_USER_LINK_ID = os.getenv("GA_TEST_PROPERTY_USER_LINK_ID") def test_properties_user_links_get(capsys): From 3836b7255af693beb5c75e0e1ba85fcec39dc383 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Tue, 5 Oct 2021 02:09:24 -0700 Subject: [PATCH 12/14] do not use the `maximum_user_access` field and `update` operation in properties.firebase_links tests as this is no longer supported in v1alpha --- samples/properties_firebase_links_create.py | 3 +- samples/properties_firebase_links_update.py | 71 ------------------- .../properties_firebase_links_update_test.py | 30 -------- 3 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 samples/properties_firebase_links_update.py delete mode 100644 samples/properties_firebase_links_update_test.py diff --git a/samples/properties_firebase_links_create.py b/samples/properties_firebase_links_create.py index d259612d..9dc7c773 100644 --- a/samples/properties_firebase_links_create.py +++ b/samples/properties_firebase_links_create.py @@ -50,8 +50,7 @@ def create_firebase_link(property_id, firebase_project_id): firebase_link = client.create_firebase_link( parent=f"properties/{property_id}", firebase_link=FirebaseLink( - project=f"projects/{firebase_project_id}", - maximum_user_access="READ_AND_ANALYZE", + project=f"projects/{firebase_project_id}" ), ) diff --git a/samples/properties_firebase_links_update.py b/samples/properties_firebase_links_update.py deleted file mode 100644 index 085f74d5..00000000 --- a/samples/properties_firebase_links_update.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2021 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 application which updates the Firebase -link on the specified Google Analytics 4 property. - -See https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/properties.firebaseLinks/update -for more information. -""" -# [START analyticsadmin_properties_firebase_links_update] -from google.analytics.admin import AnalyticsAdminServiceClient -from google.analytics.admin_v1alpha.types import FirebaseLink -from google.protobuf.field_mask_pb2 import FieldMask - - -def run_sample(): - """Runs the sample.""" - - # !!! ATTENTION !!! - # Running this sample may change/delete your Google Analytics account - # configuration. Make sure to not use the Google Analytics property ID from - # your production environment below. - - # TODO(developer): Replace this variable with your Google Analytics 4 - # property ID (e.g. "123456") before running the sample. - property_id = "YOUR-GA4-PROPERTY-ID" - - # TODO(developer): Replace this variable with your Firebase link ID - # (e.g. "123456") before running the sample. - firebase_link_id = "YOUR-FIREBASE-LINK-ID" - - update_firebase_link(property_id, firebase_link_id) - - -def update_firebase_link(property_id, firebase_link_id): - """Updates the Firebase link.""" - client = AnalyticsAdminServiceClient() - # This call updates the maximum user access to the GA4 property of the - # Firebase link as indicated by the value of the `update_mask` field. - # The Firebase link to update is specified in the `name` field of the - # `FirebaseLink` instance. - firebase_link = client.update_firebase_link( - firebase_link=FirebaseLink( - name=f"properties/{property_id}/firebaseLinks/{firebase_link_id}", - maximum_user_access="EDITOR_WITHOUT_LINK_MANAGEMENT", - ), - update_mask=FieldMask(paths=["maximum_user_access"]), - ) - - print("Result:") - print(firebase_link) - - -# [END analyticsadmin_properties_firebase_links_update] - - -if __name__ == "__main__": - run_sample() diff --git a/samples/properties_firebase_links_update_test.py b/samples/properties_firebase_links_update_test.py deleted file mode 100644 index dc07fb60..00000000 --- a/samples/properties_firebase_links_update_test.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2021 Google LLC 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. - -import pytest - -import properties_firebase_links_update - - -FAKE_PROPERTY_ID = "1" -FAKE_FIREBASE_LINK_ID = "1" - - -def test_properties_firebase_links_update(): - # This test ensures that the call is valid and reaches the server, even - # though the operation does not succeed due to permission error. - with pytest.raises(Exception, match="403 The caller does not have permission"): - properties_firebase_links_update.update_firebase_link( - FAKE_PROPERTY_ID, FAKE_FIREBASE_LINK_ID - ) From d235358cb403231dd0ff3f5dbf68f6c251c2614e Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Tue, 5 Oct 2021 02:12:54 -0700 Subject: [PATCH 13/14] use `creator_email_address` instead of `email_address` field in properties.google_ads_links_list() test as the field has been renamed in v1alpha --- samples/properties_google_ads_links_list.py | 2 +- samples/properties_google_ads_links_list_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/properties_google_ads_links_list.py b/samples/properties_google_ads_links_list.py index 1aa7e065..7109f1e3 100644 --- a/samples/properties_google_ads_links_list.py +++ b/samples/properties_google_ads_links_list.py @@ -50,7 +50,7 @@ def print_google_ads_link(google_ads_link): print(f"Google Ads customer ID: {google_ads_link.customer_id}") print(f"Can manage clients: {google_ads_link.can_manage_clients}") print(f"Ads personalization enabled: {google_ads_link.ads_personalization_enabled}") - print(f"Email address of the link creator: {google_ads_link.email_address}") + print(f"Email address of the link creator: {google_ads_link.creator_email_address}") print(f"Create time: {google_ads_link.create_time}") print(f"Update time: {google_ads_link.update_time}") diff --git a/samples/properties_google_ads_links_list_test.py b/samples/properties_google_ads_links_list_test.py index 1f850a4f..5396da0e 100644 --- a/samples/properties_google_ads_links_list_test.py +++ b/samples/properties_google_ads_links_list_test.py @@ -19,7 +19,7 @@ TEST_PROPERTY_ID = os.getenv("GA_TEST_PROPERTY_ID") -def test_properties_firebase_links_list(capsys): +def test_properties_google_ads_links_list(capsys): properties_google_ads_links_list.list_google_ads_links(TEST_PROPERTY_ID) out, _ = capsys.readouterr() assert "Result" in out From d5b923afacf4a17a5c367e74092aa08bf8aa16e0 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Tue, 5 Oct 2021 02:13:34 -0700 Subject: [PATCH 14/14] fix the samples test --- samples/noxfile.py | 3 --- samples/properties_firebase_links_create.py | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/samples/noxfile.py b/samples/noxfile.py index 1b76bef8..1fd8956f 100644 --- a/samples/noxfile.py +++ b/samples/noxfile.py @@ -98,13 +98,10 @@ def get_pytest_env_vars() -> Dict[str, str]: "True", "true", ) -<<<<<<<<< Temporary merge branch 1 -========= # Error if a python version is missing nox.options.error_on_missing_interpreters = True ->>>>>>>>> Temporary merge branch 2 # # Style Checks # diff --git a/samples/properties_firebase_links_create.py b/samples/properties_firebase_links_create.py index 9dc7c773..843179e1 100644 --- a/samples/properties_firebase_links_create.py +++ b/samples/properties_firebase_links_create.py @@ -49,9 +49,7 @@ def create_firebase_link(property_id, firebase_project_id): client = AnalyticsAdminServiceClient() firebase_link = client.create_firebase_link( parent=f"properties/{property_id}", - firebase_link=FirebaseLink( - project=f"projects/{firebase_project_id}" - ), + firebase_link=FirebaseLink(project=f"projects/{firebase_project_id}"), ) print("Result:")