From 06f5c9e9e304b0a7cd858115d7dd70b808ab307f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 27 May 2021 02:28:07 +0000 Subject: [PATCH] feat: add MeasurementProtocolSecret methods to the API (#71) PiperOrigin-RevId: 375776214 Source-Link: https://github.com/googleapis/googleapis/commit/c3bf1b727510ffc0e2020affff906fbc649cd563 Source-Link: https://github.com/googleapis/googleapis-gen/commit/23248c2d6af2ceb679b5bbc226ce505089d9ffe0 feat: add `GetGoogleSignalsSettings`, `UpdateGoogleSignalsSettings` methods to the API feat: add `ConversionEvent` methods to the API feat: add `CustomDimension` methods to the API feat: add `CustomMetric` methods to the API feat: add `GoogleSignalsState`, `GoogleSignalsConsent` types feat: add `GoogleSignalsSettings` type feat: add `MeasurementProtocolSecret` type feat: add `ConversionEvent` type feat: add `CustomDimension` type feat: add `CustomMetric` type feat: extend `ChangeHistoryResourceType` enum fix: label `email_address` field of `UserLink` type as immutable fix: label `name` field of `UserLink` type as output only --- .../admin_v1alpha/analytics_admin_service.rst | 1 - .../google/analytics/admin/__init__.py | 178 +- .../analytics/admin_v1alpha/__init__.py | 97 +- .../admin_v1alpha/gapic_metadata.json | 703 ++ .../admin_v1alpha/services/__init__.py | 1 - .../analytics_admin_service/__init__.py | 2 - .../analytics_admin_service/async_client.py | 2046 +++- .../analytics_admin_service/client.py | 2264 +++- .../analytics_admin_service/pagers.py | 674 +- .../transports/__init__.py | 2 - .../transports/base.py | 704 +- .../transports/grpc.py | 775 +- .../transports/grpc_asyncio.py | 803 +- .../analytics/admin_v1alpha/types/__init__.py | 84 +- .../admin_v1alpha/types/analytics_admin.py | 874 +- .../admin_v1alpha/types/resources.py | 663 +- .../scripts/fixup_admin_v1alpha_keywords.py | 121 +- .../google-analytics-admin/tests/__init__.py | 15 + .../tests/unit/__init__.py | 15 + .../tests/unit/gapic/__init__.py | 15 + .../unit/gapic/admin_v1alpha/__init__.py | 1 - .../test_analytics_admin_service.py | 9221 +++++++++++++---- 22 files changed, 15675 insertions(+), 3584 deletions(-) create mode 100644 packages/google-analytics-admin/google/analytics/admin_v1alpha/gapic_metadata.json create mode 100644 packages/google-analytics-admin/tests/__init__.py create mode 100644 packages/google-analytics-admin/tests/unit/__init__.py create mode 100644 packages/google-analytics-admin/tests/unit/gapic/__init__.py diff --git a/packages/google-analytics-admin/docs/admin_v1alpha/analytics_admin_service.rst b/packages/google-analytics-admin/docs/admin_v1alpha/analytics_admin_service.rst index 25d3cf207b90..d771e00c9b42 100644 --- a/packages/google-analytics-admin/docs/admin_v1alpha/analytics_admin_service.rst +++ b/packages/google-analytics-admin/docs/admin_v1alpha/analytics_admin_service.rst @@ -5,7 +5,6 @@ AnalyticsAdminService :members: :inherited-members: - .. automodule:: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers :members: :inherited-members: diff --git a/packages/google-analytics-admin/google/analytics/admin/__init__.py b/packages/google-analytics-admin/google/analytics/admin/__init__.py index 2a25656a11c3..5442bf41ec66 100644 --- a/packages/google-analytics-admin/google/analytics/admin/__init__.py +++ b/packages/google-analytics-admin/google/analytics/admin/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,11 +14,18 @@ # limitations under the License. # +from google.analytics.admin_v1alpha.services.analytics_admin_service.client import ( + AnalyticsAdminServiceClient, +) from google.analytics.admin_v1alpha.services.analytics_admin_service.async_client import ( AnalyticsAdminServiceAsyncClient, ) -from google.analytics.admin_v1alpha.services.analytics_admin_service.client import ( - AnalyticsAdminServiceClient, + +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ArchiveCustomDimensionRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ArchiveCustomMetricRequest, ) from google.analytics.admin_v1alpha.types.analytics_admin import AuditUserLinksRequest from google.analytics.admin_v1alpha.types.analytics_admin import AuditUserLinksResponse @@ -45,7 +51,13 @@ BatchUpdateUserLinksResponse, ) from google.analytics.admin_v1alpha.types.analytics_admin import ( - CreateAndroidAppDataStreamRequest, + CreateConversionEventRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + CreateCustomDimensionRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + CreateCustomMetricRequest, ) from google.analytics.admin_v1alpha.types.analytics_admin import ( CreateFirebaseLinkRequest, @@ -54,7 +66,7 @@ CreateGoogleAdsLinkRequest, ) from google.analytics.admin_v1alpha.types.analytics_admin import ( - CreateIosAppDataStreamRequest, + CreateMeasurementProtocolSecretRequest, ) from google.analytics.admin_v1alpha.types.analytics_admin import CreatePropertyRequest from google.analytics.admin_v1alpha.types.analytics_admin import CreateUserLinkRequest @@ -65,6 +77,9 @@ from google.analytics.admin_v1alpha.types.analytics_admin import ( DeleteAndroidAppDataStreamRequest, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + DeleteConversionEventRequest, +) from google.analytics.admin_v1alpha.types.analytics_admin import ( DeleteFirebaseLinkRequest, ) @@ -74,6 +89,9 @@ from google.analytics.admin_v1alpha.types.analytics_admin import ( DeleteIosAppDataStreamRequest, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + DeleteMeasurementProtocolSecretRequest, +) from google.analytics.admin_v1alpha.types.analytics_admin import DeletePropertyRequest from google.analytics.admin_v1alpha.types.analytics_admin import DeleteUserLinkRequest from google.analytics.admin_v1alpha.types.analytics_admin import ( @@ -83,6 +101,13 @@ from google.analytics.admin_v1alpha.types.analytics_admin import ( GetAndroidAppDataStreamRequest, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + GetConversionEventRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + GetCustomDimensionRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import GetCustomMetricRequest from google.analytics.admin_v1alpha.types.analytics_admin import ( GetDataSharingSettingsRequest, ) @@ -90,26 +115,50 @@ GetEnhancedMeasurementSettingsRequest, ) from google.analytics.admin_v1alpha.types.analytics_admin import GetGlobalSiteTagRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ( + GetGoogleSignalsSettingsRequest, +) from google.analytics.admin_v1alpha.types.analytics_admin import ( GetIosAppDataStreamRequest, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + GetMeasurementProtocolSecretRequest, +) from google.analytics.admin_v1alpha.types.analytics_admin import GetPropertyRequest from google.analytics.admin_v1alpha.types.analytics_admin import GetUserLinkRequest from google.analytics.admin_v1alpha.types.analytics_admin import GetWebDataStreamRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsRequest +from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsResponse from google.analytics.admin_v1alpha.types.analytics_admin import ( ListAccountSummariesRequest, ) from google.analytics.admin_v1alpha.types.analytics_admin import ( ListAccountSummariesResponse, ) -from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsRequest -from google.analytics.admin_v1alpha.types.analytics_admin import ListAccountsResponse from google.analytics.admin_v1alpha.types.analytics_admin import ( ListAndroidAppDataStreamsRequest, ) from google.analytics.admin_v1alpha.types.analytics_admin import ( ListAndroidAppDataStreamsResponse, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListConversionEventsRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListConversionEventsResponse, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListCustomDimensionsRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListCustomDimensionsResponse, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListCustomMetricsRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListCustomMetricsResponse, +) from google.analytics.admin_v1alpha.types.analytics_admin import ( ListFirebaseLinksRequest, ) @@ -128,6 +177,12 @@ from google.analytics.admin_v1alpha.types.analytics_admin import ( ListIosAppDataStreamsResponse, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListMeasurementProtocolSecretsRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + ListMeasurementProtocolSecretsResponse, +) from google.analytics.admin_v1alpha.types.analytics_admin import ListPropertiesRequest from google.analytics.admin_v1alpha.types.analytics_admin import ListPropertiesResponse from google.analytics.admin_v1alpha.types.analytics_admin import ListUserLinksRequest @@ -144,10 +199,22 @@ from google.analytics.admin_v1alpha.types.analytics_admin import ( ProvisionAccountTicketResponse, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + SearchChangeHistoryEventsRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + SearchChangeHistoryEventsResponse, +) from google.analytics.admin_v1alpha.types.analytics_admin import UpdateAccountRequest from google.analytics.admin_v1alpha.types.analytics_admin import ( UpdateAndroidAppDataStreamRequest, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + UpdateCustomDimensionRequest, +) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + UpdateCustomMetricRequest, +) from google.analytics.admin_v1alpha.types.analytics_admin import ( UpdateEnhancedMeasurementSettingsRequest, ) @@ -157,9 +224,15 @@ from google.analytics.admin_v1alpha.types.analytics_admin import ( UpdateGoogleAdsLinkRequest, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + UpdateGoogleSignalsSettingsRequest, +) from google.analytics.admin_v1alpha.types.analytics_admin import ( UpdateIosAppDataStreamRequest, ) +from google.analytics.admin_v1alpha.types.analytics_admin import ( + UpdateMeasurementProtocolSecretRequest, +) from google.analytics.admin_v1alpha.types.analytics_admin import UpdatePropertyRequest from google.analytics.admin_v1alpha.types.analytics_admin import UpdateUserLinkRequest from google.analytics.admin_v1alpha.types.analytics_admin import ( @@ -169,26 +242,36 @@ from google.analytics.admin_v1alpha.types.resources import AccountSummary from google.analytics.admin_v1alpha.types.resources import AndroidAppDataStream from google.analytics.admin_v1alpha.types.resources import AuditUserLink +from google.analytics.admin_v1alpha.types.resources import ChangeHistoryChange +from google.analytics.admin_v1alpha.types.resources import ChangeHistoryEvent +from google.analytics.admin_v1alpha.types.resources import ConversionEvent +from google.analytics.admin_v1alpha.types.resources import CustomDimension +from google.analytics.admin_v1alpha.types.resources import CustomMetric from google.analytics.admin_v1alpha.types.resources import DataSharingSettings from google.analytics.admin_v1alpha.types.resources import EnhancedMeasurementSettings from google.analytics.admin_v1alpha.types.resources import FirebaseLink from google.analytics.admin_v1alpha.types.resources import GlobalSiteTag from google.analytics.admin_v1alpha.types.resources import GoogleAdsLink -from google.analytics.admin_v1alpha.types.resources import IndustryCategory +from google.analytics.admin_v1alpha.types.resources import GoogleSignalsSettings from google.analytics.admin_v1alpha.types.resources import IosAppDataStream -from google.analytics.admin_v1alpha.types.resources import MaximumUserAccess +from google.analytics.admin_v1alpha.types.resources import MeasurementProtocolSecret from google.analytics.admin_v1alpha.types.resources import Property from google.analytics.admin_v1alpha.types.resources import PropertySummary from google.analytics.admin_v1alpha.types.resources import UserLink from google.analytics.admin_v1alpha.types.resources import WebDataStream +from google.analytics.admin_v1alpha.types.resources import ActionType +from google.analytics.admin_v1alpha.types.resources import ActorType +from google.analytics.admin_v1alpha.types.resources import ChangeHistoryResourceType +from google.analytics.admin_v1alpha.types.resources import GoogleSignalsConsent +from google.analytics.admin_v1alpha.types.resources import GoogleSignalsState +from google.analytics.admin_v1alpha.types.resources import IndustryCategory +from google.analytics.admin_v1alpha.types.resources import MaximumUserAccess __all__ = ( - "Account", - "AccountSummary", - "AnalyticsAdminServiceAsyncClient", "AnalyticsAdminServiceClient", - "AndroidAppDataStream", - "AuditUserLink", + "AnalyticsAdminServiceAsyncClient", + "ArchiveCustomDimensionRequest", + "ArchiveCustomMetricRequest", "AuditUserLinksRequest", "AuditUserLinksResponse", "BatchCreateUserLinksRequest", @@ -198,69 +281,108 @@ "BatchGetUserLinksResponse", "BatchUpdateUserLinksRequest", "BatchUpdateUserLinksResponse", - "CreateAndroidAppDataStreamRequest", + "CreateConversionEventRequest", + "CreateCustomDimensionRequest", + "CreateCustomMetricRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", - "CreateIosAppDataStreamRequest", + "CreateMeasurementProtocolSecretRequest", "CreatePropertyRequest", "CreateUserLinkRequest", "CreateWebDataStreamRequest", - "DataSharingSettings", "DeleteAccountRequest", "DeleteAndroidAppDataStreamRequest", + "DeleteConversionEventRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", "DeleteIosAppDataStreamRequest", + "DeleteMeasurementProtocolSecretRequest", "DeletePropertyRequest", "DeleteUserLinkRequest", "DeleteWebDataStreamRequest", - "EnhancedMeasurementSettings", - "FirebaseLink", "GetAccountRequest", "GetAndroidAppDataStreamRequest", + "GetConversionEventRequest", + "GetCustomDimensionRequest", + "GetCustomMetricRequest", "GetDataSharingSettingsRequest", "GetEnhancedMeasurementSettingsRequest", "GetGlobalSiteTagRequest", + "GetGoogleSignalsSettingsRequest", "GetIosAppDataStreamRequest", + "GetMeasurementProtocolSecretRequest", "GetPropertyRequest", "GetUserLinkRequest", "GetWebDataStreamRequest", - "GlobalSiteTag", - "GoogleAdsLink", - "IndustryCategory", - "IosAppDataStream", - "ListAccountSummariesRequest", - "ListAccountSummariesResponse", "ListAccountsRequest", "ListAccountsResponse", + "ListAccountSummariesRequest", + "ListAccountSummariesResponse", "ListAndroidAppDataStreamsRequest", "ListAndroidAppDataStreamsResponse", + "ListConversionEventsRequest", + "ListConversionEventsResponse", + "ListCustomDimensionsRequest", + "ListCustomDimensionsResponse", + "ListCustomMetricsRequest", + "ListCustomMetricsResponse", "ListFirebaseLinksRequest", "ListFirebaseLinksResponse", "ListGoogleAdsLinksRequest", "ListGoogleAdsLinksResponse", "ListIosAppDataStreamsRequest", "ListIosAppDataStreamsResponse", + "ListMeasurementProtocolSecretsRequest", + "ListMeasurementProtocolSecretsResponse", "ListPropertiesRequest", "ListPropertiesResponse", "ListUserLinksRequest", "ListUserLinksResponse", "ListWebDataStreamsRequest", "ListWebDataStreamsResponse", - "MaximumUserAccess", - "Property", - "PropertySummary", "ProvisionAccountTicketRequest", "ProvisionAccountTicketResponse", + "SearchChangeHistoryEventsRequest", + "SearchChangeHistoryEventsResponse", "UpdateAccountRequest", "UpdateAndroidAppDataStreamRequest", + "UpdateCustomDimensionRequest", + "UpdateCustomMetricRequest", "UpdateEnhancedMeasurementSettingsRequest", "UpdateFirebaseLinkRequest", "UpdateGoogleAdsLinkRequest", + "UpdateGoogleSignalsSettingsRequest", "UpdateIosAppDataStreamRequest", + "UpdateMeasurementProtocolSecretRequest", "UpdatePropertyRequest", "UpdateUserLinkRequest", "UpdateWebDataStreamRequest", + "Account", + "AccountSummary", + "AndroidAppDataStream", + "AuditUserLink", + "ChangeHistoryChange", + "ChangeHistoryEvent", + "ConversionEvent", + "CustomDimension", + "CustomMetric", + "DataSharingSettings", + "EnhancedMeasurementSettings", + "FirebaseLink", + "GlobalSiteTag", + "GoogleAdsLink", + "GoogleSignalsSettings", + "IosAppDataStream", + "MeasurementProtocolSecret", + "Property", + "PropertySummary", "UserLink", "WebDataStream", + "ActionType", + "ActorType", + "ChangeHistoryResourceType", + "GoogleSignalsConsent", + "GoogleSignalsState", + "IndustryCategory", + "MaximumUserAccess", ) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/__init__.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/__init__.py index 9132398ec310..a758c678b045 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/__init__.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +15,10 @@ # from .services.analytics_admin_service import AnalyticsAdminServiceClient +from .services.analytics_admin_service import AnalyticsAdminServiceAsyncClient + +from .types.analytics_admin import ArchiveCustomDimensionRequest +from .types.analytics_admin import ArchiveCustomMetricRequest from .types.analytics_admin import AuditUserLinksRequest from .types.analytics_admin import AuditUserLinksResponse from .types.analytics_admin import BatchCreateUserLinksRequest @@ -25,42 +28,59 @@ from .types.analytics_admin import BatchGetUserLinksResponse from .types.analytics_admin import BatchUpdateUserLinksRequest from .types.analytics_admin import BatchUpdateUserLinksResponse -from .types.analytics_admin import CreateAndroidAppDataStreamRequest +from .types.analytics_admin import CreateConversionEventRequest +from .types.analytics_admin import CreateCustomDimensionRequest +from .types.analytics_admin import CreateCustomMetricRequest from .types.analytics_admin import CreateFirebaseLinkRequest from .types.analytics_admin import CreateGoogleAdsLinkRequest -from .types.analytics_admin import CreateIosAppDataStreamRequest +from .types.analytics_admin import CreateMeasurementProtocolSecretRequest from .types.analytics_admin import CreatePropertyRequest from .types.analytics_admin import CreateUserLinkRequest from .types.analytics_admin import CreateWebDataStreamRequest from .types.analytics_admin import DeleteAccountRequest from .types.analytics_admin import DeleteAndroidAppDataStreamRequest +from .types.analytics_admin import DeleteConversionEventRequest from .types.analytics_admin import DeleteFirebaseLinkRequest from .types.analytics_admin import DeleteGoogleAdsLinkRequest from .types.analytics_admin import DeleteIosAppDataStreamRequest +from .types.analytics_admin import DeleteMeasurementProtocolSecretRequest from .types.analytics_admin import DeletePropertyRequest from .types.analytics_admin import DeleteUserLinkRequest from .types.analytics_admin import DeleteWebDataStreamRequest from .types.analytics_admin import GetAccountRequest from .types.analytics_admin import GetAndroidAppDataStreamRequest +from .types.analytics_admin import GetConversionEventRequest +from .types.analytics_admin import GetCustomDimensionRequest +from .types.analytics_admin import GetCustomMetricRequest from .types.analytics_admin import GetDataSharingSettingsRequest from .types.analytics_admin import GetEnhancedMeasurementSettingsRequest from .types.analytics_admin import GetGlobalSiteTagRequest +from .types.analytics_admin import GetGoogleSignalsSettingsRequest from .types.analytics_admin import GetIosAppDataStreamRequest +from .types.analytics_admin import GetMeasurementProtocolSecretRequest from .types.analytics_admin import GetPropertyRequest from .types.analytics_admin import GetUserLinkRequest from .types.analytics_admin import GetWebDataStreamRequest -from .types.analytics_admin import ListAccountSummariesRequest -from .types.analytics_admin import ListAccountSummariesResponse from .types.analytics_admin import ListAccountsRequest from .types.analytics_admin import ListAccountsResponse +from .types.analytics_admin import ListAccountSummariesRequest +from .types.analytics_admin import ListAccountSummariesResponse from .types.analytics_admin import ListAndroidAppDataStreamsRequest from .types.analytics_admin import ListAndroidAppDataStreamsResponse +from .types.analytics_admin import ListConversionEventsRequest +from .types.analytics_admin import ListConversionEventsResponse +from .types.analytics_admin import ListCustomDimensionsRequest +from .types.analytics_admin import ListCustomDimensionsResponse +from .types.analytics_admin import ListCustomMetricsRequest +from .types.analytics_admin import ListCustomMetricsResponse from .types.analytics_admin import ListFirebaseLinksRequest from .types.analytics_admin import ListFirebaseLinksResponse from .types.analytics_admin import ListGoogleAdsLinksRequest from .types.analytics_admin import ListGoogleAdsLinksResponse from .types.analytics_admin import ListIosAppDataStreamsRequest from .types.analytics_admin import ListIosAppDataStreamsResponse +from .types.analytics_admin import ListMeasurementProtocolSecretsRequest +from .types.analytics_admin import ListMeasurementProtocolSecretsResponse from .types.analytics_admin import ListPropertiesRequest from .types.analytics_admin import ListPropertiesResponse from .types.analytics_admin import ListUserLinksRequest @@ -69,12 +89,18 @@ from .types.analytics_admin import ListWebDataStreamsResponse from .types.analytics_admin import ProvisionAccountTicketRequest from .types.analytics_admin import ProvisionAccountTicketResponse +from .types.analytics_admin import SearchChangeHistoryEventsRequest +from .types.analytics_admin import SearchChangeHistoryEventsResponse from .types.analytics_admin import UpdateAccountRequest from .types.analytics_admin import UpdateAndroidAppDataStreamRequest +from .types.analytics_admin import UpdateCustomDimensionRequest +from .types.analytics_admin import UpdateCustomMetricRequest from .types.analytics_admin import UpdateEnhancedMeasurementSettingsRequest from .types.analytics_admin import UpdateFirebaseLinkRequest from .types.analytics_admin import UpdateGoogleAdsLinkRequest +from .types.analytics_admin import UpdateGoogleSignalsSettingsRequest from .types.analytics_admin import UpdateIosAppDataStreamRequest +from .types.analytics_admin import UpdateMeasurementProtocolSecretRequest from .types.analytics_admin import UpdatePropertyRequest from .types.analytics_admin import UpdateUserLinkRequest from .types.analytics_admin import UpdateWebDataStreamRequest @@ -82,24 +108,41 @@ from .types.resources import AccountSummary from .types.resources import AndroidAppDataStream from .types.resources import AuditUserLink +from .types.resources import ChangeHistoryChange +from .types.resources import ChangeHistoryEvent +from .types.resources import ConversionEvent +from .types.resources import CustomDimension +from .types.resources import CustomMetric from .types.resources import DataSharingSettings from .types.resources import EnhancedMeasurementSettings from .types.resources import FirebaseLink from .types.resources import GlobalSiteTag from .types.resources import GoogleAdsLink -from .types.resources import IndustryCategory +from .types.resources import GoogleSignalsSettings from .types.resources import IosAppDataStream -from .types.resources import MaximumUserAccess +from .types.resources import MeasurementProtocolSecret from .types.resources import Property from .types.resources import PropertySummary from .types.resources import UserLink from .types.resources import WebDataStream - +from .types.resources import ActionType +from .types.resources import ActorType +from .types.resources import ChangeHistoryResourceType +from .types.resources import GoogleSignalsConsent +from .types.resources import GoogleSignalsState +from .types.resources import IndustryCategory +from .types.resources import MaximumUserAccess __all__ = ( + "AnalyticsAdminServiceAsyncClient", "Account", "AccountSummary", + "ActionType", + "ActorType", + "AnalyticsAdminServiceClient", "AndroidAppDataStream", + "ArchiveCustomDimensionRequest", + "ArchiveCustomMetricRequest", "AuditUserLink", "AuditUserLinksRequest", "AuditUserLinksResponse", @@ -110,19 +153,29 @@ "BatchGetUserLinksResponse", "BatchUpdateUserLinksRequest", "BatchUpdateUserLinksResponse", - "CreateAndroidAppDataStreamRequest", + "ChangeHistoryChange", + "ChangeHistoryEvent", + "ChangeHistoryResourceType", + "ConversionEvent", + "CreateConversionEventRequest", + "CreateCustomDimensionRequest", + "CreateCustomMetricRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", - "CreateIosAppDataStreamRequest", + "CreateMeasurementProtocolSecretRequest", "CreatePropertyRequest", "CreateUserLinkRequest", "CreateWebDataStreamRequest", + "CustomDimension", + "CustomMetric", "DataSharingSettings", "DeleteAccountRequest", "DeleteAndroidAppDataStreamRequest", + "DeleteConversionEventRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", "DeleteIosAppDataStreamRequest", + "DeleteMeasurementProtocolSecretRequest", "DeletePropertyRequest", "DeleteUserLinkRequest", "DeleteWebDataStreamRequest", @@ -130,15 +183,23 @@ "FirebaseLink", "GetAccountRequest", "GetAndroidAppDataStreamRequest", + "GetConversionEventRequest", + "GetCustomDimensionRequest", + "GetCustomMetricRequest", "GetDataSharingSettingsRequest", "GetEnhancedMeasurementSettingsRequest", "GetGlobalSiteTagRequest", + "GetGoogleSignalsSettingsRequest", "GetIosAppDataStreamRequest", + "GetMeasurementProtocolSecretRequest", "GetPropertyRequest", "GetUserLinkRequest", "GetWebDataStreamRequest", "GlobalSiteTag", "GoogleAdsLink", + "GoogleSignalsConsent", + "GoogleSignalsSettings", + "GoogleSignalsState", "IndustryCategory", "IosAppDataStream", "ListAccountSummariesRequest", @@ -147,12 +208,20 @@ "ListAccountsResponse", "ListAndroidAppDataStreamsRequest", "ListAndroidAppDataStreamsResponse", + "ListConversionEventsRequest", + "ListConversionEventsResponse", + "ListCustomDimensionsRequest", + "ListCustomDimensionsResponse", + "ListCustomMetricsRequest", + "ListCustomMetricsResponse", "ListFirebaseLinksRequest", "ListFirebaseLinksResponse", "ListGoogleAdsLinksRequest", "ListGoogleAdsLinksResponse", "ListIosAppDataStreamsRequest", "ListIosAppDataStreamsResponse", + "ListMeasurementProtocolSecretsRequest", + "ListMeasurementProtocolSecretsResponse", "ListPropertiesRequest", "ListPropertiesResponse", "ListUserLinksRequest", @@ -160,20 +229,26 @@ "ListWebDataStreamsRequest", "ListWebDataStreamsResponse", "MaximumUserAccess", + "MeasurementProtocolSecret", "Property", "PropertySummary", "ProvisionAccountTicketRequest", "ProvisionAccountTicketResponse", + "SearchChangeHistoryEventsRequest", + "SearchChangeHistoryEventsResponse", "UpdateAccountRequest", "UpdateAndroidAppDataStreamRequest", + "UpdateCustomDimensionRequest", + "UpdateCustomMetricRequest", "UpdateEnhancedMeasurementSettingsRequest", "UpdateFirebaseLinkRequest", "UpdateGoogleAdsLinkRequest", + "UpdateGoogleSignalsSettingsRequest", "UpdateIosAppDataStreamRequest", + "UpdateMeasurementProtocolSecretRequest", "UpdatePropertyRequest", "UpdateUserLinkRequest", "UpdateWebDataStreamRequest", "UserLink", "WebDataStream", - "AnalyticsAdminServiceClient", ) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/gapic_metadata.json b/packages/google-analytics-admin/google/analytics/admin_v1alpha/gapic_metadata.json new file mode 100644 index 000000000000..fb4e612c35c3 --- /dev/null +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/gapic_metadata.json @@ -0,0 +1,703 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.analytics.admin_v1alpha", + "protoPackage": "google.analytics.admin.v1alpha", + "schema": "1.0", + "services": { + "AnalyticsAdminService": { + "clients": { + "grpc": { + "libraryClient": "AnalyticsAdminServiceClient", + "rpcs": { + "ArchiveCustomDimension": { + "methods": [ + "archive_custom_dimension" + ] + }, + "ArchiveCustomMetric": { + "methods": [ + "archive_custom_metric" + ] + }, + "AuditUserLinks": { + "methods": [ + "audit_user_links" + ] + }, + "BatchCreateUserLinks": { + "methods": [ + "batch_create_user_links" + ] + }, + "BatchDeleteUserLinks": { + "methods": [ + "batch_delete_user_links" + ] + }, + "BatchGetUserLinks": { + "methods": [ + "batch_get_user_links" + ] + }, + "BatchUpdateUserLinks": { + "methods": [ + "batch_update_user_links" + ] + }, + "CreateConversionEvent": { + "methods": [ + "create_conversion_event" + ] + }, + "CreateCustomDimension": { + "methods": [ + "create_custom_dimension" + ] + }, + "CreateCustomMetric": { + "methods": [ + "create_custom_metric" + ] + }, + "CreateFirebaseLink": { + "methods": [ + "create_firebase_link" + ] + }, + "CreateGoogleAdsLink": { + "methods": [ + "create_google_ads_link" + ] + }, + "CreateMeasurementProtocolSecret": { + "methods": [ + "create_measurement_protocol_secret" + ] + }, + "CreateProperty": { + "methods": [ + "create_property" + ] + }, + "CreateUserLink": { + "methods": [ + "create_user_link" + ] + }, + "CreateWebDataStream": { + "methods": [ + "create_web_data_stream" + ] + }, + "DeleteAccount": { + "methods": [ + "delete_account" + ] + }, + "DeleteAndroidAppDataStream": { + "methods": [ + "delete_android_app_data_stream" + ] + }, + "DeleteConversionEvent": { + "methods": [ + "delete_conversion_event" + ] + }, + "DeleteFirebaseLink": { + "methods": [ + "delete_firebase_link" + ] + }, + "DeleteGoogleAdsLink": { + "methods": [ + "delete_google_ads_link" + ] + }, + "DeleteIosAppDataStream": { + "methods": [ + "delete_ios_app_data_stream" + ] + }, + "DeleteMeasurementProtocolSecret": { + "methods": [ + "delete_measurement_protocol_secret" + ] + }, + "DeleteProperty": { + "methods": [ + "delete_property" + ] + }, + "DeleteUserLink": { + "methods": [ + "delete_user_link" + ] + }, + "DeleteWebDataStream": { + "methods": [ + "delete_web_data_stream" + ] + }, + "GetAccount": { + "methods": [ + "get_account" + ] + }, + "GetAndroidAppDataStream": { + "methods": [ + "get_android_app_data_stream" + ] + }, + "GetConversionEvent": { + "methods": [ + "get_conversion_event" + ] + }, + "GetCustomDimension": { + "methods": [ + "get_custom_dimension" + ] + }, + "GetCustomMetric": { + "methods": [ + "get_custom_metric" + ] + }, + "GetDataSharingSettings": { + "methods": [ + "get_data_sharing_settings" + ] + }, + "GetEnhancedMeasurementSettings": { + "methods": [ + "get_enhanced_measurement_settings" + ] + }, + "GetGlobalSiteTag": { + "methods": [ + "get_global_site_tag" + ] + }, + "GetGoogleSignalsSettings": { + "methods": [ + "get_google_signals_settings" + ] + }, + "GetIosAppDataStream": { + "methods": [ + "get_ios_app_data_stream" + ] + }, + "GetMeasurementProtocolSecret": { + "methods": [ + "get_measurement_protocol_secret" + ] + }, + "GetProperty": { + "methods": [ + "get_property" + ] + }, + "GetUserLink": { + "methods": [ + "get_user_link" + ] + }, + "GetWebDataStream": { + "methods": [ + "get_web_data_stream" + ] + }, + "ListAccountSummaries": { + "methods": [ + "list_account_summaries" + ] + }, + "ListAccounts": { + "methods": [ + "list_accounts" + ] + }, + "ListAndroidAppDataStreams": { + "methods": [ + "list_android_app_data_streams" + ] + }, + "ListConversionEvents": { + "methods": [ + "list_conversion_events" + ] + }, + "ListCustomDimensions": { + "methods": [ + "list_custom_dimensions" + ] + }, + "ListCustomMetrics": { + "methods": [ + "list_custom_metrics" + ] + }, + "ListFirebaseLinks": { + "methods": [ + "list_firebase_links" + ] + }, + "ListGoogleAdsLinks": { + "methods": [ + "list_google_ads_links" + ] + }, + "ListIosAppDataStreams": { + "methods": [ + "list_ios_app_data_streams" + ] + }, + "ListMeasurementProtocolSecrets": { + "methods": [ + "list_measurement_protocol_secrets" + ] + }, + "ListProperties": { + "methods": [ + "list_properties" + ] + }, + "ListUserLinks": { + "methods": [ + "list_user_links" + ] + }, + "ListWebDataStreams": { + "methods": [ + "list_web_data_streams" + ] + }, + "ProvisionAccountTicket": { + "methods": [ + "provision_account_ticket" + ] + }, + "SearchChangeHistoryEvents": { + "methods": [ + "search_change_history_events" + ] + }, + "UpdateAccount": { + "methods": [ + "update_account" + ] + }, + "UpdateAndroidAppDataStream": { + "methods": [ + "update_android_app_data_stream" + ] + }, + "UpdateCustomDimension": { + "methods": [ + "update_custom_dimension" + ] + }, + "UpdateCustomMetric": { + "methods": [ + "update_custom_metric" + ] + }, + "UpdateEnhancedMeasurementSettings": { + "methods": [ + "update_enhanced_measurement_settings" + ] + }, + "UpdateFirebaseLink": { + "methods": [ + "update_firebase_link" + ] + }, + "UpdateGoogleAdsLink": { + "methods": [ + "update_google_ads_link" + ] + }, + "UpdateGoogleSignalsSettings": { + "methods": [ + "update_google_signals_settings" + ] + }, + "UpdateIosAppDataStream": { + "methods": [ + "update_ios_app_data_stream" + ] + }, + "UpdateMeasurementProtocolSecret": { + "methods": [ + "update_measurement_protocol_secret" + ] + }, + "UpdateProperty": { + "methods": [ + "update_property" + ] + }, + "UpdateUserLink": { + "methods": [ + "update_user_link" + ] + }, + "UpdateWebDataStream": { + "methods": [ + "update_web_data_stream" + ] + } + } + }, + "grpc-async": { + "libraryClient": "AnalyticsAdminServiceAsyncClient", + "rpcs": { + "ArchiveCustomDimension": { + "methods": [ + "archive_custom_dimension" + ] + }, + "ArchiveCustomMetric": { + "methods": [ + "archive_custom_metric" + ] + }, + "AuditUserLinks": { + "methods": [ + "audit_user_links" + ] + }, + "BatchCreateUserLinks": { + "methods": [ + "batch_create_user_links" + ] + }, + "BatchDeleteUserLinks": { + "methods": [ + "batch_delete_user_links" + ] + }, + "BatchGetUserLinks": { + "methods": [ + "batch_get_user_links" + ] + }, + "BatchUpdateUserLinks": { + "methods": [ + "batch_update_user_links" + ] + }, + "CreateConversionEvent": { + "methods": [ + "create_conversion_event" + ] + }, + "CreateCustomDimension": { + "methods": [ + "create_custom_dimension" + ] + }, + "CreateCustomMetric": { + "methods": [ + "create_custom_metric" + ] + }, + "CreateFirebaseLink": { + "methods": [ + "create_firebase_link" + ] + }, + "CreateGoogleAdsLink": { + "methods": [ + "create_google_ads_link" + ] + }, + "CreateMeasurementProtocolSecret": { + "methods": [ + "create_measurement_protocol_secret" + ] + }, + "CreateProperty": { + "methods": [ + "create_property" + ] + }, + "CreateUserLink": { + "methods": [ + "create_user_link" + ] + }, + "CreateWebDataStream": { + "methods": [ + "create_web_data_stream" + ] + }, + "DeleteAccount": { + "methods": [ + "delete_account" + ] + }, + "DeleteAndroidAppDataStream": { + "methods": [ + "delete_android_app_data_stream" + ] + }, + "DeleteConversionEvent": { + "methods": [ + "delete_conversion_event" + ] + }, + "DeleteFirebaseLink": { + "methods": [ + "delete_firebase_link" + ] + }, + "DeleteGoogleAdsLink": { + "methods": [ + "delete_google_ads_link" + ] + }, + "DeleteIosAppDataStream": { + "methods": [ + "delete_ios_app_data_stream" + ] + }, + "DeleteMeasurementProtocolSecret": { + "methods": [ + "delete_measurement_protocol_secret" + ] + }, + "DeleteProperty": { + "methods": [ + "delete_property" + ] + }, + "DeleteUserLink": { + "methods": [ + "delete_user_link" + ] + }, + "DeleteWebDataStream": { + "methods": [ + "delete_web_data_stream" + ] + }, + "GetAccount": { + "methods": [ + "get_account" + ] + }, + "GetAndroidAppDataStream": { + "methods": [ + "get_android_app_data_stream" + ] + }, + "GetConversionEvent": { + "methods": [ + "get_conversion_event" + ] + }, + "GetCustomDimension": { + "methods": [ + "get_custom_dimension" + ] + }, + "GetCustomMetric": { + "methods": [ + "get_custom_metric" + ] + }, + "GetDataSharingSettings": { + "methods": [ + "get_data_sharing_settings" + ] + }, + "GetEnhancedMeasurementSettings": { + "methods": [ + "get_enhanced_measurement_settings" + ] + }, + "GetGlobalSiteTag": { + "methods": [ + "get_global_site_tag" + ] + }, + "GetGoogleSignalsSettings": { + "methods": [ + "get_google_signals_settings" + ] + }, + "GetIosAppDataStream": { + "methods": [ + "get_ios_app_data_stream" + ] + }, + "GetMeasurementProtocolSecret": { + "methods": [ + "get_measurement_protocol_secret" + ] + }, + "GetProperty": { + "methods": [ + "get_property" + ] + }, + "GetUserLink": { + "methods": [ + "get_user_link" + ] + }, + "GetWebDataStream": { + "methods": [ + "get_web_data_stream" + ] + }, + "ListAccountSummaries": { + "methods": [ + "list_account_summaries" + ] + }, + "ListAccounts": { + "methods": [ + "list_accounts" + ] + }, + "ListAndroidAppDataStreams": { + "methods": [ + "list_android_app_data_streams" + ] + }, + "ListConversionEvents": { + "methods": [ + "list_conversion_events" + ] + }, + "ListCustomDimensions": { + "methods": [ + "list_custom_dimensions" + ] + }, + "ListCustomMetrics": { + "methods": [ + "list_custom_metrics" + ] + }, + "ListFirebaseLinks": { + "methods": [ + "list_firebase_links" + ] + }, + "ListGoogleAdsLinks": { + "methods": [ + "list_google_ads_links" + ] + }, + "ListIosAppDataStreams": { + "methods": [ + "list_ios_app_data_streams" + ] + }, + "ListMeasurementProtocolSecrets": { + "methods": [ + "list_measurement_protocol_secrets" + ] + }, + "ListProperties": { + "methods": [ + "list_properties" + ] + }, + "ListUserLinks": { + "methods": [ + "list_user_links" + ] + }, + "ListWebDataStreams": { + "methods": [ + "list_web_data_streams" + ] + }, + "ProvisionAccountTicket": { + "methods": [ + "provision_account_ticket" + ] + }, + "SearchChangeHistoryEvents": { + "methods": [ + "search_change_history_events" + ] + }, + "UpdateAccount": { + "methods": [ + "update_account" + ] + }, + "UpdateAndroidAppDataStream": { + "methods": [ + "update_android_app_data_stream" + ] + }, + "UpdateCustomDimension": { + "methods": [ + "update_custom_dimension" + ] + }, + "UpdateCustomMetric": { + "methods": [ + "update_custom_metric" + ] + }, + "UpdateEnhancedMeasurementSettings": { + "methods": [ + "update_enhanced_measurement_settings" + ] + }, + "UpdateFirebaseLink": { + "methods": [ + "update_firebase_link" + ] + }, + "UpdateGoogleAdsLink": { + "methods": [ + "update_google_ads_link" + ] + }, + "UpdateGoogleSignalsSettings": { + "methods": [ + "update_google_signals_settings" + ] + }, + "UpdateIosAppDataStream": { + "methods": [ + "update_ios_app_data_stream" + ] + }, + "UpdateMeasurementProtocolSecret": { + "methods": [ + "update_measurement_protocol_secret" + ] + }, + "UpdateProperty": { + "methods": [ + "update_property" + ] + }, + "UpdateUserLink": { + "methods": [ + "update_user_link" + ] + }, + "UpdateWebDataStream": { + "methods": [ + "update_web_data_stream" + ] + } + } + } + } + } + } +} diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/__init__.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/__init__.py index 42ffdf2bc43d..4de65971c238 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/__init__.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py index 19cf00374569..013ae51161cb 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import AnalyticsAdminServiceClient from .async_client import AnalyticsAdminServiceAsyncClient diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py index 00e876e7a7ff..244f09c1cf88 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,19 +20,18 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import resources -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore - +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore from .transports.base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport from .client import AnalyticsAdminServiceClient @@ -62,6 +59,22 @@ class AnalyticsAdminServiceAsyncClient: parse_android_app_data_stream_path = staticmethod( AnalyticsAdminServiceClient.parse_android_app_data_stream_path ) + conversion_event_path = staticmethod( + AnalyticsAdminServiceClient.conversion_event_path + ) + parse_conversion_event_path = staticmethod( + AnalyticsAdminServiceClient.parse_conversion_event_path + ) + custom_dimension_path = staticmethod( + AnalyticsAdminServiceClient.custom_dimension_path + ) + parse_custom_dimension_path = staticmethod( + AnalyticsAdminServiceClient.parse_custom_dimension_path + ) + custom_metric_path = staticmethod(AnalyticsAdminServiceClient.custom_metric_path) + parse_custom_metric_path = staticmethod( + AnalyticsAdminServiceClient.parse_custom_metric_path + ) data_sharing_settings_path = staticmethod( AnalyticsAdminServiceClient.data_sharing_settings_path ) @@ -90,12 +103,24 @@ class AnalyticsAdminServiceAsyncClient: parse_google_ads_link_path = staticmethod( AnalyticsAdminServiceClient.parse_google_ads_link_path ) + google_signals_settings_path = staticmethod( + AnalyticsAdminServiceClient.google_signals_settings_path + ) + parse_google_signals_settings_path = staticmethod( + AnalyticsAdminServiceClient.parse_google_signals_settings_path + ) ios_app_data_stream_path = staticmethod( AnalyticsAdminServiceClient.ios_app_data_stream_path ) parse_ios_app_data_stream_path = staticmethod( AnalyticsAdminServiceClient.parse_ios_app_data_stream_path ) + measurement_protocol_secret_path = staticmethod( + AnalyticsAdminServiceClient.measurement_protocol_secret_path + ) + parse_measurement_protocol_secret_path = staticmethod( + AnalyticsAdminServiceClient.parse_measurement_protocol_secret_path + ) property_path = staticmethod(AnalyticsAdminServiceClient.property_path) parse_property_path = staticmethod(AnalyticsAdminServiceClient.parse_property_path) user_link_path = staticmethod(AnalyticsAdminServiceClient.user_link_path) @@ -108,31 +133,26 @@ class AnalyticsAdminServiceAsyncClient: parse_web_data_stream_path = staticmethod( AnalyticsAdminServiceClient.parse_web_data_stream_path ) - common_billing_account_path = staticmethod( AnalyticsAdminServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( AnalyticsAdminServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(AnalyticsAdminServiceClient.common_folder_path) parse_common_folder_path = staticmethod( AnalyticsAdminServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( AnalyticsAdminServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( AnalyticsAdminServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(AnalyticsAdminServiceClient.common_project_path) parse_common_project_path = staticmethod( AnalyticsAdminServiceClient.parse_common_project_path ) - common_location_path = staticmethod( AnalyticsAdminServiceClient.common_location_path ) @@ -142,7 +162,8 @@ class AnalyticsAdminServiceAsyncClient: @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -157,7 +178,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -174,7 +195,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> AnalyticsAdminServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: AnalyticsAdminServiceTransport: The transport used by the client instance. @@ -189,12 +210,12 @@ def transport(self) -> AnalyticsAdminServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, AnalyticsAdminServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the analytics admin service client. + """Instantiates the analytics admin service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -226,7 +247,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = AnalyticsAdminServiceClient( credentials=credentials, transport=transport, @@ -256,7 +276,6 @@ async def get_account( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -283,7 +302,6 @@ async def get_account( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -325,7 +343,6 @@ async def list_accounts( request (:class:`google.analytics.admin_v1alpha.types.ListAccountsRequest`): The request object. Request message for ListAccounts RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -341,7 +358,6 @@ async def list_accounts( """ # Create or coerce a protobuf request object. - request = analytics_admin.ListAccountsRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -397,7 +413,6 @@ async def delete_account( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -418,7 +433,6 @@ async def delete_account( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -446,7 +460,7 @@ async def update_account( request: analytics_admin.UpdateAccountRequest = None, *, account: resources.Account = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -474,7 +488,6 @@ async def update_account( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -501,7 +514,6 @@ async def update_account( # 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: @@ -543,7 +555,6 @@ async def provision_account_ticket( request (:class:`google.analytics.admin_v1alpha.types.ProvisionAccountTicketRequest`): The request object. Request message for ProvisionAccountTicket RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -557,7 +568,6 @@ async def provision_account_ticket( """ # Create or coerce a protobuf request object. - request = analytics_admin.ProvisionAccountTicketRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -589,7 +599,6 @@ async def list_account_summaries( 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. @@ -606,7 +615,6 @@ async def list_account_summaries( """ # Create or coerce a protobuf request object. - request = analytics_admin.ListAccountSummariesRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -650,7 +658,6 @@ async def get_property( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -677,7 +684,6 @@ async def get_property( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -721,7 +727,6 @@ async def list_properties( request (:class:`google.analytics.admin_v1alpha.types.ListPropertiesRequest`): The request object. Request message for ListProperties RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -738,7 +743,6 @@ async def list_properties( """ # Create or coerce a protobuf request object. - request = analytics_admin.ListPropertiesRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -785,7 +789,6 @@ async def create_property( This corresponds to the ``property`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -812,7 +815,6 @@ async def create_property( # If we have keyword arguments corresponding to fields on the # request, apply these. - if property is not None: request.property = property @@ -838,7 +840,7 @@ async def delete_property( retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + ) -> resources.Property: r"""Marks target Property as soft-deleted (ie: "trashed") and returns it. This API does not have a method to restore soft-deleted @@ -864,12 +866,17 @@ async def delete_property( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.Property: + A resource message representing a + Google Analytics GA4 property. + """ # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have @@ -885,7 +892,6 @@ async def delete_property( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -904,16 +910,17 @@ async def delete_property( ) # Send the request. - await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response async def update_property( self, request: analytics_admin.UpdatePropertyRequest = None, *, property: resources.Property = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -942,7 +949,6 @@ async def update_property( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -969,7 +975,6 @@ async def update_property( # 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: @@ -1019,7 +1024,6 @@ async def get_user_link( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1047,7 +1051,6 @@ async def get_user_link( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1086,7 +1089,6 @@ async def batch_get_user_links( request (:class:`google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest`): The request object. Request message for BatchGetUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1100,7 +1102,6 @@ async def batch_get_user_links( """ # Create or coerce a protobuf request object. - request = analytics_admin.BatchGetUserLinksRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1145,7 +1146,6 @@ async def list_user_links( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1175,7 +1175,6 @@ async def list_user_links( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1229,7 +1228,6 @@ async def audit_user_links( request (:class:`google.analytics.admin_v1alpha.types.AuditUserLinksRequest`): The request object. Request message for AuditUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1246,7 +1244,6 @@ async def audit_user_links( """ # Create or coerce a protobuf request object. - request = analytics_admin.AuditUserLinksRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1315,7 +1312,6 @@ async def create_user_link( This corresponds to the ``user_link`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1343,7 +1339,6 @@ async def create_user_link( # 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: @@ -1386,7 +1381,6 @@ async def batch_create_user_links( request (:class:`google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest`): The request object. Request message for BatchCreateUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1400,7 +1394,6 @@ async def batch_create_user_links( """ # Create or coerce a protobuf request object. - request = analytics_admin.BatchCreateUserLinksRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1443,7 +1436,6 @@ async def update_user_link( This corresponds to the ``user_link`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1471,7 +1463,6 @@ async def update_user_link( # If we have keyword arguments corresponding to fields on the # request, apply these. - if user_link is not None: request.user_link = user_link @@ -1512,7 +1503,6 @@ async def batch_update_user_links( request (:class:`google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest`): The request object. Request message for BatchUpdateUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1526,7 +1516,6 @@ async def batch_update_user_links( """ # Create or coerce a protobuf request object. - request = analytics_admin.BatchUpdateUserLinksRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1571,7 +1560,6 @@ async def delete_user_link( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1592,7 +1580,6 @@ async def delete_user_link( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1630,7 +1617,6 @@ async def batch_delete_user_links( request (:class:`google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest`): The request object. Request message for BatchDeleteUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1638,7 +1624,6 @@ async def batch_delete_user_links( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - request = analytics_admin.BatchDeleteUserLinksRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1684,7 +1669,6 @@ async def get_web_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1711,7 +1695,6 @@ async def get_web_data_stream( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1759,7 +1742,6 @@ async def delete_web_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1780,7 +1762,6 @@ async def delete_web_data_stream( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1808,7 +1789,7 @@ async def update_web_data_stream( request: analytics_admin.UpdateWebDataStreamRequest = None, *, web_data_stream: resources.WebDataStream = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1836,7 +1817,6 @@ async def update_web_data_stream( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1863,7 +1843,6 @@ async def update_web_data_stream( # 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: @@ -1921,7 +1900,6 @@ async def create_web_data_stream( This corresponds to the ``web_data_stream`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1948,7 +1926,6 @@ async def create_web_data_stream( # 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: @@ -2002,7 +1979,6 @@ async def list_web_data_streams( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2032,7 +2008,6 @@ async def list_web_data_streams( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2086,7 +2061,6 @@ async def get_ios_app_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2113,7 +2087,6 @@ async def get_ios_app_data_stream( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2161,7 +2134,6 @@ async def delete_ios_app_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2182,7 +2154,6 @@ async def delete_ios_app_data_stream( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2210,7 +2181,7 @@ async def update_ios_app_data_stream( request: analytics_admin.UpdateIosAppDataStreamRequest = None, *, ios_app_data_stream: resources.IosAppDataStream = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2239,7 +2210,6 @@ async def update_ios_app_data_stream( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2266,7 +2236,6 @@ async def update_ios_app_data_stream( # 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: @@ -2294,99 +2263,6 @@ async def update_ios_app_data_stream( # Done; return the response. return response - async def create_ios_app_data_stream( - self, - request: analytics_admin.CreateIosAppDataStreamRequest = None, - *, - parent: str = None, - ios_app_data_stream: resources.IosAppDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IosAppDataStream: - r"""Creates an iOS app stream with the specified location - and attributes. - Note that an iOS app stream must be linked to a Firebase - app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateIosAppDataStreamRequest`): - The request object. Request message for - CreateIosAppDataStream RPC. - parent (:class:`str`): - Required. The parent resource where - this ios app data stream will be - created. Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - ios_app_data_stream (:class:`google.analytics.admin_v1alpha.types.IosAppDataStream`): - Required. The iOS app data stream to - create. - - This corresponds to the ``ios_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.IosAppDataStream: - A resource message representing a - Google Analytics IOS app stream. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, ios_app_data_stream]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = analytics_admin.CreateIosAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if ios_app_data_stream is not None: - request.ios_app_data_stream = ios_app_data_stream - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_ios_app_data_stream, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - async def list_ios_app_data_streams( self, request: analytics_admin.ListIosAppDataStreamsRequest = None, @@ -2415,7 +2291,6 @@ async def list_ios_app_data_streams( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2445,7 +2320,6 @@ async def list_ios_app_data_streams( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2499,7 +2373,6 @@ async def get_android_app_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2526,7 +2399,6 @@ async def get_android_app_data_stream( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2574,7 +2446,6 @@ async def delete_android_app_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2595,7 +2466,6 @@ async def delete_android_app_data_stream( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2623,7 +2493,7 @@ async def update_android_app_data_stream( request: analytics_admin.UpdateAndroidAppDataStreamRequest = None, *, android_app_data_stream: resources.AndroidAppDataStream = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2652,7 +2522,6 @@ async def update_android_app_data_stream( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2679,7 +2548,6 @@ async def update_android_app_data_stream( # 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: @@ -2712,99 +2580,6 @@ async def update_android_app_data_stream( # Done; return the response. return response - async def create_android_app_data_stream( - self, - request: analytics_admin.CreateAndroidAppDataStreamRequest = None, - *, - parent: str = None, - android_app_data_stream: resources.AndroidAppDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.AndroidAppDataStream: - r"""Creates an Android app stream with the specified - location and attributes. - Note that an Android app stream must be linked to a - Firebase app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Args: - request (:class:`google.analytics.admin_v1alpha.types.CreateAndroidAppDataStreamRequest`): - The request object. Request message for - CreateAndroidAppDataStream RPC. - parent (:class:`str`): - Required. The parent resource where - this android app data stream will be - created. Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - android_app_data_stream (:class:`google.analytics.admin_v1alpha.types.AndroidAppDataStream`): - Required. The android app stream to - create. - - This corresponds to the ``android_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.AndroidAppDataStream: - A resource message representing a - Google Analytics Android app stream. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, android_app_data_stream]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - request = analytics_admin.CreateAndroidAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if android_app_data_stream is not None: - request.android_app_data_stream = android_app_data_stream - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_android_app_data_stream, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - async def list_android_app_data_streams( self, request: analytics_admin.ListAndroidAppDataStreamsRequest = None, @@ -2833,7 +2608,6 @@ async def list_android_app_data_streams( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2863,7 +2637,6 @@ async def list_android_app_data_streams( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2919,7 +2692,6 @@ async def get_enhanced_measurement_settings( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2948,7 +2720,6 @@ async def get_enhanced_measurement_settings( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2977,7 +2748,7 @@ async def update_enhanced_measurement_settings( request: analytics_admin.UpdateEnhancedMeasurementSettingsRequest = None, *, enhanced_measurement_settings: resources.EnhancedMeasurementSettings = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -3007,7 +2778,6 @@ async def update_enhanced_measurement_settings( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3036,7 +2806,6 @@ async def update_enhanced_measurement_settings( # 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: @@ -3100,7 +2869,6 @@ async def create_firebase_link( This corresponds to the ``firebase_link`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3127,7 +2895,6 @@ async def create_firebase_link( # 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: @@ -3158,7 +2925,7 @@ async def update_firebase_link( request: analytics_admin.UpdateFirebaseLinkRequest = None, *, firebase_link: resources.FirebaseLink = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -3186,7 +2953,6 @@ async def update_firebase_link( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3213,7 +2979,6 @@ async def update_firebase_link( # 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: @@ -3264,7 +3029,6 @@ async def delete_firebase_link( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3285,7 +3049,6 @@ async def delete_firebase_link( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -3331,7 +3094,6 @@ async def list_firebase_links( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3361,7 +3123,6 @@ async def list_firebase_links( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -3418,7 +3179,6 @@ async def get_global_site_tag( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3446,7 +3206,6 @@ async def get_global_site_tag( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -3500,7 +3259,6 @@ async def create_google_ads_link( This corresponds to the ``google_ads_link`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3527,7 +3285,6 @@ async def create_google_ads_link( # 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: @@ -3558,7 +3315,7 @@ async def update_google_ads_link( request: analytics_admin.UpdateGoogleAdsLinkRequest = None, *, google_ads_link: resources.GoogleAdsLink = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -3584,7 +3341,6 @@ async def update_google_ads_link( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3611,7 +3367,6 @@ async def update_google_ads_link( # 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: @@ -3661,7 +3416,6 @@ async def delete_google_ads_link( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3682,7 +3436,6 @@ async def delete_google_ads_link( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -3727,7 +3480,6 @@ async def list_google_ads_links( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3757,7 +3509,6 @@ async def list_google_ads_links( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -3813,7 +3564,6 @@ async def get_data_sharing_settings( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3841,7 +3591,6 @@ async def get_data_sharing_settings( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -3865,6 +3614,1685 @@ async def get_data_sharing_settings( # Done; return the response. return response + async def get_measurement_protocol_secret( + self, + request: analytics_admin.GetMeasurementProtocolSecretRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Lookup for a single "GA4" MeasurementProtocolSecret. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetMeasurementProtocolSecretRequest`): + The request object. Request message for + GetMeasurementProtocolSecret RPC. + name (:class:`str`): + Required. The name of the measurement + protocol secret to lookup. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) + may be a parent. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.GetMeasurementProtocolSecretRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_measurement_protocol_secret, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_measurement_protocol_secrets( + self, + request: analytics_admin.ListMeasurementProtocolSecretsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMeasurementProtocolSecretsAsyncPager: + r"""Returns child MeasurementProtocolSecrets under the + specified parent Property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest`): + The request object. Request message for + ListMeasurementProtocolSecret RPC + parent (:class:`str`): + Required. The resource name of the + parent stream. Any type of stream + (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListMeasurementProtocolSecretsAsyncPager: + Response message for + ListMeasurementProtocolSecret RPC + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.ListMeasurementProtocolSecretsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_measurement_protocol_secrets, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListMeasurementProtocolSecretsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_measurement_protocol_secret( + self, + request: analytics_admin.CreateMeasurementProtocolSecretRequest = None, + *, + parent: str = None, + measurement_protocol_secret: resources.MeasurementProtocolSecret = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Creates a measurement protocol secret. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest`): + The request object. Request message for + CreateMeasurementProtocolSecret RPC + parent (:class:`str`): + Required. The parent resource where + this secret will be created. Any type of + stream (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream} + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + measurement_protocol_secret (:class:`google.analytics.admin_v1alpha.types.MeasurementProtocolSecret`): + Required. The measurement protocol + secret to create. + + This corresponds to the ``measurement_protocol_secret`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, measurement_protocol_secret]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.CreateMeasurementProtocolSecretRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if measurement_protocol_secret is not None: + request.measurement_protocol_secret = measurement_protocol_secret + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_measurement_protocol_secret, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def delete_measurement_protocol_secret( + self, + request: analytics_admin.DeleteMeasurementProtocolSecretRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes target MeasurementProtocolSecret. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteMeasurementProtocolSecretRequest`): + The request object. Request message for + DeleteMeasurementProtocolSecret RPC + name (:class:`str`): + Required. The name of the + MeasurementProtocolSecret to delete. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) + may be a parent. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.DeleteMeasurementProtocolSecretRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_measurement_protocol_secret, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + async def update_measurement_protocol_secret( + self, + request: analytics_admin.UpdateMeasurementProtocolSecretRequest = None, + *, + measurement_protocol_secret: resources.MeasurementProtocolSecret = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Updates a measurement protocol secret. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateMeasurementProtocolSecretRequest`): + The request object. Request message for + UpdateMeasurementProtocolSecret RPC + measurement_protocol_secret (:class:`google.analytics.admin_v1alpha.types.MeasurementProtocolSecret`): + Required. The measurement protocol + secret to update. + + This corresponds to the ``measurement_protocol_secret`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + Omitted fields will not be updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([measurement_protocol_secret, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.UpdateMeasurementProtocolSecretRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if measurement_protocol_secret is not None: + request.measurement_protocol_secret = measurement_protocol_secret + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_measurement_protocol_secret, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ( + "measurement_protocol_secret.name", + request.measurement_protocol_secret.name, + ), + ) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def search_change_history_events( + self, + request: analytics_admin.SearchChangeHistoryEventsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.SearchChangeHistoryEventsAsyncPager: + r"""Searches through all changes to an account or its + children given the specified set of filters. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest`): + The request object. Request message for + SearchChangeHistoryEvents RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.SearchChangeHistoryEventsAsyncPager: + Response message for SearchAccounts + RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = analytics_admin.SearchChangeHistoryEventsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.search_change_history_events, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("account", request.account),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.SearchChangeHistoryEventsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_google_signals_settings( + self, + request: analytics_admin.GetGoogleSignalsSettingsRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleSignalsSettings: + r"""Lookup for Google Signals settings for a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetGoogleSignalsSettingsRequest`): + The request object. Request message for + GetGoogleSignalsSettings RPC + name (:class:`str`): + Required. The name of the google + signals settings to retrieve. Format: + properties/{property}/googleSignalsSettings + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.GoogleSignalsSettings: + Settings values for Google Signals. + This is a singleton resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.GetGoogleSignalsSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_google_signals_settings, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def update_google_signals_settings( + self, + request: analytics_admin.UpdateGoogleSignalsSettingsRequest = None, + *, + google_signals_settings: resources.GoogleSignalsSettings = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleSignalsSettings: + r"""Updates Google Signals settings for a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateGoogleSignalsSettingsRequest`): + The request object. Request message for + UpdateGoogleSignalsSettings RPC + google_signals_settings (:class:`google.analytics.admin_v1alpha.types.GoogleSignalsSettings`): + Required. The settings to update. The ``name`` field is + used to identify the settings to be updated. + + This corresponds to the ``google_signals_settings`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.GoogleSignalsSettings: + Settings values for Google Signals. + This is a singleton resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([google_signals_settings, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.UpdateGoogleSignalsSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if google_signals_settings is not None: + request.google_signals_settings = google_signals_settings + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_google_signals_settings, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ( + "google_signals_settings.name", + request.google_signals_settings.name, + ), + ) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def create_conversion_event( + self, + request: analytics_admin.CreateConversionEventRequest = None, + *, + parent: str = None, + conversion_event: resources.ConversionEvent = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ConversionEvent: + r"""Creates a conversion event with the specified + attributes. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateConversionEventRequest`): + The request object. Request message for + CreateConversionEvent RPC + parent (:class:`str`): + Required. The resource name of the + parent property where this conversion + event will be created. Format: + properties/123 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversion_event (:class:`google.analytics.admin_v1alpha.types.ConversionEvent`): + Required. The conversion event to + create. + + This corresponds to the ``conversion_event`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.ConversionEvent: + A conversion event in a Google + Analytics property. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, conversion_event]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.CreateConversionEventRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if conversion_event is not None: + request.conversion_event = conversion_event + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_conversion_event, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def get_conversion_event( + self, + request: analytics_admin.GetConversionEventRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ConversionEvent: + r"""Retrieve a single conversion event. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetConversionEventRequest`): + The request object. Request message for + GetConversionEvent RPC + name (:class:`str`): + Required. The resource name of the conversion event to + retrieve. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.ConversionEvent: + A conversion event in a Google + Analytics property. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.GetConversionEventRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_conversion_event, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def delete_conversion_event( + self, + request: analytics_admin.DeleteConversionEventRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a conversion event in a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.DeleteConversionEventRequest`): + The request object. Request message for + DeleteConversionEvent RPC + name (:class:`str`): + Required. The resource name of the conversion event to + delete. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.DeleteConversionEventRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_conversion_event, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + async def list_conversion_events( + self, + request: analytics_admin.ListConversionEventsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConversionEventsAsyncPager: + r"""Returns a list of conversion events in the specified + parent property. + Returns an empty list if no conversion events are found. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListConversionEventsRequest`): + The request object. Request message for + ListConversionEvents RPC + parent (:class:`str`): + Required. The resource name of the + parent property. Example: + 'properties/123' + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListConversionEventsAsyncPager: + Response message for + ListConversionEvents RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.ListConversionEventsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_conversion_events, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListConversionEventsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_custom_dimension( + self, + request: analytics_admin.CreateCustomDimensionRequest = None, + *, + parent: str = None, + custom_dimension: resources.CustomDimension = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Creates a CustomDimension. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest`): + The request object. Request message for + CreateCustomDimension RPC. + parent (:class:`str`): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + custom_dimension (:class:`google.analytics.admin_v1alpha.types.CustomDimension`): + Required. The CustomDimension to + create. + + This corresponds to the ``custom_dimension`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, custom_dimension]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.CreateCustomDimensionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_dimension is not None: + request.custom_dimension = custom_dimension + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_custom_dimension, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def update_custom_dimension( + self, + request: analytics_admin.UpdateCustomDimensionRequest = None, + *, + custom_dimension: resources.CustomDimension = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Updates a CustomDimension on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateCustomDimensionRequest`): + The request object. Request message for + UpdateCustomDimension RPC. + custom_dimension (:class:`google.analytics.admin_v1alpha.types.CustomDimension`): + The CustomDimension to update + This corresponds to the ``custom_dimension`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([custom_dimension, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.UpdateCustomDimensionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if custom_dimension is not None: + request.custom_dimension = custom_dimension + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_custom_dimension, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("custom_dimension.name", request.custom_dimension.name),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_custom_dimensions( + self, + request: analytics_admin.ListCustomDimensionsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomDimensionsAsyncPager: + r"""Lists CustomDimensions on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest`): + The request object. Request message for + ListCustomDimensions RPC. + parent (:class:`str`): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomDimensionsAsyncPager: + Response message for + ListCustomDimensions RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.ListCustomDimensionsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_custom_dimensions, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCustomDimensionsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def archive_custom_dimension( + self, + request: analytics_admin.ArchiveCustomDimensionRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Archives a CustomDimension on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ArchiveCustomDimensionRequest`): + The request object. Request message for + ArchiveCustomDimension RPC. + name (:class:`str`): + Required. The name of the + CustomDimension to archive. Example + format: + properties/1234/customDimensions/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.ArchiveCustomDimensionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.archive_custom_dimension, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + async def get_custom_dimension( + self, + request: analytics_admin.GetCustomDimensionRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Lookup for a single CustomDimension. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetCustomDimensionRequest`): + The request object. Request message for + GetCustomDimension RPC. + name (:class:`str`): + Required. The name of the + CustomDimension to get. Example format: + properties/1234/customDimensions/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.GetCustomDimensionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_custom_dimension, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def create_custom_metric( + self, + request: analytics_admin.CreateCustomMetricRequest = None, + *, + parent: str = None, + custom_metric: resources.CustomMetric = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Creates a CustomMetric. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.CreateCustomMetricRequest`): + The request object. Request message for + CreateCustomMetric RPC. + parent (:class:`str`): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + custom_metric (:class:`google.analytics.admin_v1alpha.types.CustomMetric`): + Required. The CustomMetric to create. + This corresponds to the ``custom_metric`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, custom_metric]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.CreateCustomMetricRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_metric is not None: + request.custom_metric = custom_metric + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_custom_metric, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def update_custom_metric( + self, + request: analytics_admin.UpdateCustomMetricRequest = None, + *, + custom_metric: resources.CustomMetric = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Updates a CustomMetric on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.UpdateCustomMetricRequest`): + The request object. Request message for + UpdateCustomMetric RPC. + custom_metric (:class:`google.analytics.admin_v1alpha.types.CustomMetric`): + The CustomMetric to update + This corresponds to the ``custom_metric`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be updated. Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([custom_metric, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.UpdateCustomMetricRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if custom_metric is not None: + request.custom_metric = custom_metric + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_custom_metric, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("custom_metric.name", request.custom_metric.name),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_custom_metrics( + self, + request: analytics_admin.ListCustomMetricsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomMetricsAsyncPager: + r"""Lists CustomMetrics on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ListCustomMetricsRequest`): + The request object. Request message for + ListCustomMetrics RPC. + parent (:class:`str`): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomMetricsAsyncPager: + Response message for + ListCustomMetrics RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.ListCustomMetricsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_custom_metrics, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCustomMetricsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def archive_custom_metric( + self, + request: analytics_admin.ArchiveCustomMetricRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Archives a CustomMetric on a property. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.ArchiveCustomMetricRequest`): + The request object. Request message for + ArchiveCustomMetric RPC. + name (:class:`str`): + Required. The name of the + CustomMetric to archive. Example format: + properties/1234/customMetrics/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.ArchiveCustomMetricRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.archive_custom_metric, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + async def get_custom_metric( + self, + request: analytics_admin.GetCustomMetricRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Lookup for a single CustomMetric. + + Args: + request (:class:`google.analytics.admin_v1alpha.types.GetCustomMetricRequest`): + The request object. Request message for GetCustomMetric + RPC. + name (:class:`str`): + Required. The name of the + CustomMetric to get. Example format: + properties/1234/customMetrics/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.GetCustomMetricRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_custom_metric, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py index bec4df6f51ed..5e965b7559e6 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -35,10 +33,9 @@ from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import resources -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore - +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore from .transports.base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import AnalyticsAdminServiceGrpcTransport from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport @@ -61,7 +58,7 @@ class AnalyticsAdminServiceClientMeta(type): def get_transport_class( cls, label: str = None, ) -> Type[AnalyticsAdminServiceTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -84,7 +81,8 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta): @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS endpoint. + """Converts api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. Args: @@ -118,7 +116,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -135,7 +134,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -154,34 +153,35 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> AnalyticsAdminServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - AnalyticsAdminServiceTransport: The transport used by the client instance. + AnalyticsAdminServiceTransport: The transport used by the client + instance. """ return self._transport @staticmethod def account_path(account: str,) -> str: - """Return a fully-qualified account string.""" + """Returns a fully-qualified account string.""" return "accounts/{account}".format(account=account,) @staticmethod def parse_account_path(path: str) -> Dict[str, str]: - """Parse a account path into its component segments.""" + """Parses a account path into its component segments.""" m = re.match(r"^accounts/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod def account_summary_path(account_summary: str,) -> str: - """Return a fully-qualified account_summary string.""" + """Returns a fully-qualified account_summary string.""" return "accountSummaries/{account_summary}".format( account_summary=account_summary, ) @staticmethod def parse_account_summary_path(path: str) -> Dict[str, str]: - """Parse a account_summary path into its component segments.""" + """Parses a account_summary path into its component segments.""" m = re.match(r"^accountSummaries/(?P.+?)$", path) return m.groupdict() if m else {} @@ -189,41 +189,79 @@ def parse_account_summary_path(path: str) -> Dict[str, str]: def android_app_data_stream_path( property: str, android_app_data_stream: str, ) -> str: - """Return a fully-qualified android_app_data_stream string.""" + """Returns a fully-qualified android_app_data_stream string.""" return "properties/{property}/androidAppDataStreams/{android_app_data_stream}".format( property=property, android_app_data_stream=android_app_data_stream, ) @staticmethod def parse_android_app_data_stream_path(path: str) -> Dict[str, str]: - """Parse a android_app_data_stream path into its component segments.""" + """Parses a android_app_data_stream path into its component segments.""" m = re.match( r"^properties/(?P.+?)/androidAppDataStreams/(?P.+?)$", path, ) return m.groupdict() if m else {} + @staticmethod + def conversion_event_path(property: str, conversion_event: str,) -> str: + """Returns a fully-qualified conversion_event string.""" + return "properties/{property}/conversionEvents/{conversion_event}".format( + property=property, conversion_event=conversion_event, + ) + + @staticmethod + def parse_conversion_event_path(path: str) -> Dict[str, str]: + """Parses a conversion_event path into its component segments.""" + m = re.match( + r"^properties/(?P.+?)/conversionEvents/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def custom_dimension_path(property: str,) -> str: + """Returns a fully-qualified custom_dimension string.""" + return "properties/{property}/customDimensions".format(property=property,) + + @staticmethod + def parse_custom_dimension_path(path: str) -> Dict[str, str]: + """Parses a custom_dimension path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/customDimensions$", path) + return m.groupdict() if m else {} + + @staticmethod + def custom_metric_path(property: str,) -> str: + """Returns a fully-qualified custom_metric string.""" + return "properties/{property}/customMetrics".format(property=property,) + + @staticmethod + def parse_custom_metric_path(path: str) -> Dict[str, str]: + """Parses a custom_metric path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/customMetrics$", path) + return m.groupdict() if m else {} + @staticmethod def data_sharing_settings_path(account: str,) -> str: - """Return a fully-qualified data_sharing_settings string.""" + """Returns a fully-qualified data_sharing_settings string.""" return "accounts/{account}/dataSharingSettings".format(account=account,) @staticmethod def parse_data_sharing_settings_path(path: str) -> Dict[str, str]: - """Parse a data_sharing_settings path into its component segments.""" + """Parses a data_sharing_settings path into its component segments.""" m = re.match(r"^accounts/(?P.+?)/dataSharingSettings$", path) return m.groupdict() if m else {} @staticmethod def enhanced_measurement_settings_path(property: str, web_data_stream: str,) -> str: - """Return a fully-qualified enhanced_measurement_settings string.""" + """Returns a fully-qualified enhanced_measurement_settings string.""" return "properties/{property}/webDataStreams/{web_data_stream}/enhancedMeasurementSettings".format( property=property, web_data_stream=web_data_stream, ) @staticmethod def parse_enhanced_measurement_settings_path(path: str) -> Dict[str, str]: - """Parse a enhanced_measurement_settings path into its component segments.""" + """Parses a enhanced_measurement_settings path into its component segments.""" m = re.match( r"^properties/(?P.+?)/webDataStreams/(?P.+?)/enhancedMeasurementSettings$", path, @@ -232,14 +270,14 @@ def parse_enhanced_measurement_settings_path(path: str) -> Dict[str, str]: @staticmethod def firebase_link_path(property: str, firebase_link: str,) -> str: - """Return a fully-qualified firebase_link string.""" + """Returns a fully-qualified firebase_link string.""" return "properties/{property}/firebaseLinks/{firebase_link}".format( property=property, firebase_link=firebase_link, ) @staticmethod def parse_firebase_link_path(path: str) -> Dict[str, str]: - """Parse a firebase_link path into its component segments.""" + """Parses a firebase_link path into its component segments.""" m = re.match( r"^properties/(?P.+?)/firebaseLinks/(?P.+?)$", path ) @@ -247,81 +285,112 @@ def parse_firebase_link_path(path: str) -> Dict[str, str]: @staticmethod def global_site_tag_path(property: str,) -> str: - """Return a fully-qualified global_site_tag string.""" + """Returns a fully-qualified global_site_tag string.""" return "properties/{property}/globalSiteTag".format(property=property,) @staticmethod def parse_global_site_tag_path(path: str) -> Dict[str, str]: - """Parse a global_site_tag path into its component segments.""" + """Parses a global_site_tag path into its component segments.""" m = re.match(r"^properties/(?P.+?)/globalSiteTag$", path) return m.groupdict() if m else {} @staticmethod def google_ads_link_path(property: str, google_ads_link: str,) -> str: - """Return a fully-qualified google_ads_link string.""" + """Returns a fully-qualified google_ads_link string.""" return "properties/{property}/googleAdsLinks/{google_ads_link}".format( property=property, google_ads_link=google_ads_link, ) @staticmethod def parse_google_ads_link_path(path: str) -> Dict[str, str]: - """Parse a google_ads_link path into its component segments.""" + """Parses a google_ads_link path into its component segments.""" m = re.match( r"^properties/(?P.+?)/googleAdsLinks/(?P.+?)$", path, ) return m.groupdict() if m else {} + @staticmethod + def google_signals_settings_path(property: str,) -> str: + """Returns a fully-qualified google_signals_settings string.""" + return "properties/{property}/googleSignalsSettings".format(property=property,) + + @staticmethod + def parse_google_signals_settings_path(path: str) -> Dict[str, str]: + """Parses a google_signals_settings path into its component segments.""" + m = re.match(r"^properties/(?P.+?)/googleSignalsSettings$", path) + return m.groupdict() if m else {} + @staticmethod def ios_app_data_stream_path(property: str, ios_app_data_stream: str,) -> str: - """Return a fully-qualified ios_app_data_stream string.""" + """Returns a fully-qualified ios_app_data_stream string.""" return "properties/{property}/iosAppDataStreams/{ios_app_data_stream}".format( property=property, ios_app_data_stream=ios_app_data_stream, ) @staticmethod def parse_ios_app_data_stream_path(path: str) -> Dict[str, str]: - """Parse a ios_app_data_stream path into its component segments.""" + """Parses a ios_app_data_stream path into its component segments.""" m = re.match( r"^properties/(?P.+?)/iosAppDataStreams/(?P.+?)$", path, ) return m.groupdict() if m else {} + @staticmethod + def measurement_protocol_secret_path( + property: str, web_data_stream: str, measurement_protocol_secret: str, + ) -> str: + """Returns a fully-qualified measurement_protocol_secret string.""" + return "properties/{property}/webDataStreams/{web_data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}".format( + property=property, + web_data_stream=web_data_stream, + measurement_protocol_secret=measurement_protocol_secret, + ) + + @staticmethod + def parse_measurement_protocol_secret_path(path: str) -> Dict[str, str]: + """Parses a measurement_protocol_secret path into its component segments.""" + m = re.match( + r"^properties/(?P.+?)/webDataStreams/(?P.+?)/measurementProtocolSecrets/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def property_path(property: str,) -> str: - """Return a fully-qualified property string.""" + """Returns a fully-qualified property string.""" return "properties/{property}".format(property=property,) @staticmethod def parse_property_path(path: str) -> Dict[str, str]: - """Parse a property path into its component segments.""" + """Parses a property path into its component segments.""" m = re.match(r"^properties/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod def user_link_path(account: str, user_link: str,) -> str: - """Return a fully-qualified user_link string.""" + """Returns a fully-qualified user_link string.""" return "accounts/{account}/userLinks/{user_link}".format( account=account, user_link=user_link, ) @staticmethod def parse_user_link_path(path: str) -> Dict[str, str]: - """Parse a user_link path into its component segments.""" + """Parses a user_link path into its component segments.""" m = re.match(r"^accounts/(?P.+?)/userLinks/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod def web_data_stream_path(property: str, web_data_stream: str,) -> str: - """Return a fully-qualified web_data_stream string.""" + """Returns a fully-qualified web_data_stream string.""" return "properties/{property}/webDataStreams/{web_data_stream}".format( property=property, web_data_stream=web_data_stream, ) @staticmethod def parse_web_data_stream_path(path: str) -> Dict[str, str]: - """Parse a web_data_stream path into its component segments.""" + """Parses a web_data_stream path into its component segments.""" m = re.match( r"^properties/(?P.+?)/webDataStreams/(?P.+?)$", path, @@ -330,7 +399,7 @@ def parse_web_data_stream_path(path: str) -> Dict[str, str]: @staticmethod def common_billing_account_path(billing_account: str,) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -343,7 +412,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: @staticmethod def common_folder_path(folder: str,) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format(folder=folder,) @staticmethod @@ -354,7 +423,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: @staticmethod def common_organization_path(organization: str,) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format(organization=organization,) @staticmethod @@ -365,7 +434,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: @staticmethod def common_project_path(project: str,) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format(project=project,) @staticmethod @@ -376,7 +445,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]: @staticmethod def common_location_path(project: str, location: str,) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -390,12 +459,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, AnalyticsAdminServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the analytics admin service client. + """Instantiates the analytics admin service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -450,9 +519,10 @@ def __init__( client_cert_source_func = client_options.client_cert_source else: is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -464,12 +534,14 @@ def __init__( elif use_mtls_env == "always": api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT else: raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" ) # Save or instantiate the transport. @@ -484,8 +556,8 @@ def __init__( ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: @@ -522,7 +594,6 @@ def get_account( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -551,10 +622,8 @@ def get_account( # there are no flattened fields. if not isinstance(request, analytics_admin.GetAccountRequest): request = analytics_admin.GetAccountRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -592,7 +661,6 @@ def list_accounts( request (google.analytics.admin_v1alpha.types.ListAccountsRequest): The request object. Request message for ListAccounts RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -608,7 +676,6 @@ def list_accounts( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a analytics_admin.ListAccountsRequest. # There's no risk of modifying the input as we've already verified @@ -665,7 +732,6 @@ def delete_account( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -688,10 +754,8 @@ def delete_account( # there are no flattened fields. if not isinstance(request, analytics_admin.DeleteAccountRequest): request = analytics_admin.DeleteAccountRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -715,7 +779,7 @@ def update_account( request: analytics_admin.UpdateAccountRequest = None, *, account: resources.Account = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -743,7 +807,6 @@ def update_account( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -772,10 +835,8 @@ def update_account( # there are no flattened fields. if not isinstance(request, analytics_admin.UpdateAccountRequest): request = analytics_admin.UpdateAccountRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if account is not None: request.account = account if update_mask is not None: @@ -813,7 +874,6 @@ def provision_account_ticket( request (google.analytics.admin_v1alpha.types.ProvisionAccountTicketRequest): The request object. Request message for ProvisionAccountTicket RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -827,7 +887,6 @@ def provision_account_ticket( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a analytics_admin.ProvisionAccountTicketRequest. # There's no risk of modifying the input as we've already verified @@ -860,7 +919,6 @@ def list_account_summaries( 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. @@ -877,7 +935,6 @@ def list_account_summaries( """ # 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 @@ -922,7 +979,6 @@ def get_property( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -951,10 +1007,8 @@ def get_property( # there are no flattened fields. if not isinstance(request, analytics_admin.GetPropertyRequest): request = analytics_admin.GetPropertyRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -994,7 +1048,6 @@ def list_properties( request (google.analytics.admin_v1alpha.types.ListPropertiesRequest): The request object. Request message for ListProperties RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1011,7 +1064,6 @@ def list_properties( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a analytics_admin.ListPropertiesRequest. # There's no risk of modifying the input as we've already verified @@ -1059,7 +1111,6 @@ def create_property( This corresponds to the ``property`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1088,10 +1139,8 @@ def create_property( # there are no flattened fields. if not isinstance(request, analytics_admin.CreatePropertyRequest): request = analytics_admin.CreatePropertyRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if property is not None: request.property = property @@ -1113,7 +1162,7 @@ def delete_property( retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + ) -> resources.Property: r"""Marks target Property as soft-deleted (ie: "trashed") and returns it. This API does not have a method to restore soft-deleted @@ -1139,12 +1188,17 @@ def delete_property( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.Property: + A resource message representing a + Google Analytics GA4 property. + """ # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have @@ -1162,10 +1216,8 @@ def delete_property( # there are no flattened fields. if not isinstance(request, analytics_admin.DeletePropertyRequest): request = analytics_admin.DeletePropertyRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1180,16 +1232,17 @@ def delete_property( ) # Send the request. - rpc( - request, retry=retry, timeout=timeout, metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response def update_property( self, request: analytics_admin.UpdatePropertyRequest = None, *, property: resources.Property = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1218,7 +1271,6 @@ def update_property( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1247,10 +1299,8 @@ def update_property( # there are no flattened fields. if not isinstance(request, analytics_admin.UpdatePropertyRequest): request = analytics_admin.UpdatePropertyRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if property is not None: request.property = property if update_mask is not None: @@ -1296,7 +1346,6 @@ def get_user_link( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1326,10 +1375,8 @@ def get_user_link( # there are no flattened fields. if not isinstance(request, analytics_admin.GetUserLinkRequest): request = analytics_admin.GetUserLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1364,7 +1411,6 @@ def batch_get_user_links( request (google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest): The request object. Request message for BatchGetUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1378,7 +1424,6 @@ def batch_get_user_links( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a analytics_admin.BatchGetUserLinksRequest. # There's no risk of modifying the input as we've already verified @@ -1424,7 +1469,6 @@ def list_user_links( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1456,10 +1500,8 @@ def list_user_links( # there are no flattened fields. if not isinstance(request, analytics_admin.ListUserLinksRequest): request = analytics_admin.ListUserLinksRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1509,7 +1551,6 @@ def audit_user_links( request (google.analytics.admin_v1alpha.types.AuditUserLinksRequest): The request object. Request message for AuditUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1526,7 +1567,6 @@ def audit_user_links( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a analytics_admin.AuditUserLinksRequest. # There's no risk of modifying the input as we've already verified @@ -1596,7 +1636,6 @@ def create_user_link( This corresponds to the ``user_link`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1626,10 +1665,8 @@ def create_user_link( # there are no flattened fields. if not isinstance(request, analytics_admin.CreateUserLinkRequest): request = analytics_admin.CreateUserLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if user_link is not None: @@ -1668,7 +1705,6 @@ def batch_create_user_links( request (google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest): The request object. Request message for BatchCreateUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1682,7 +1718,6 @@ def batch_create_user_links( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a analytics_admin.BatchCreateUserLinksRequest. # There's no risk of modifying the input as we've already verified @@ -1726,7 +1761,6 @@ def update_user_link( This corresponds to the ``user_link`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1756,10 +1790,8 @@ def update_user_link( # there are no flattened fields. if not isinstance(request, analytics_admin.UpdateUserLinkRequest): request = analytics_admin.UpdateUserLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if user_link is not None: request.user_link = user_link @@ -1796,7 +1828,6 @@ def batch_update_user_links( request (google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest): The request object. Request message for BatchUpdateUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1810,7 +1841,6 @@ def batch_update_user_links( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a analytics_admin.BatchUpdateUserLinksRequest. # There's no risk of modifying the input as we've already verified @@ -1856,7 +1886,6 @@ def delete_user_link( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1879,10 +1908,8 @@ def delete_user_link( # there are no flattened fields. if not isinstance(request, analytics_admin.DeleteUserLinkRequest): request = analytics_admin.DeleteUserLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1916,7 +1943,6 @@ def batch_delete_user_links( request (google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest): The request object. Request message for BatchDeleteUserLinks RPC. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1924,7 +1950,6 @@ def batch_delete_user_links( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a analytics_admin.BatchDeleteUserLinksRequest. # There's no risk of modifying the input as we've already verified @@ -1971,7 +1996,6 @@ def get_web_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2000,10 +2024,8 @@ def get_web_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.GetWebDataStreamRequest): request = analytics_admin.GetWebDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2047,7 +2069,6 @@ def delete_web_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2070,10 +2091,8 @@ def delete_web_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.DeleteWebDataStreamRequest): request = analytics_admin.DeleteWebDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2097,7 +2116,7 @@ def update_web_data_stream( request: analytics_admin.UpdateWebDataStreamRequest = None, *, web_data_stream: resources.WebDataStream = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2125,7 +2144,6 @@ def update_web_data_stream( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2154,10 +2172,8 @@ def update_web_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.UpdateWebDataStreamRequest): request = analytics_admin.UpdateWebDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if web_data_stream is not None: request.web_data_stream = web_data_stream if update_mask is not None: @@ -2211,7 +2227,6 @@ def create_web_data_stream( This corresponds to the ``web_data_stream`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2240,10 +2255,8 @@ def create_web_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.CreateWebDataStreamRequest): request = analytics_admin.CreateWebDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if web_data_stream is not None: @@ -2293,7 +2306,6 @@ def list_web_data_streams( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2325,10 +2337,8 @@ def list_web_data_streams( # there are no flattened fields. if not isinstance(request, analytics_admin.ListWebDataStreamsRequest): request = analytics_admin.ListWebDataStreamsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2378,7 +2388,6 @@ def get_ios_app_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2407,10 +2416,8 @@ def get_ios_app_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.GetIosAppDataStreamRequest): request = analytics_admin.GetIosAppDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2454,7 +2461,6 @@ def delete_ios_app_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2477,10 +2483,8 @@ def delete_ios_app_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.DeleteIosAppDataStreamRequest): request = analytics_admin.DeleteIosAppDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2506,7 +2510,7 @@ def update_ios_app_data_stream( request: analytics_admin.UpdateIosAppDataStreamRequest = None, *, ios_app_data_stream: resources.IosAppDataStream = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2535,7 +2539,6 @@ def update_ios_app_data_stream( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2564,10 +2567,8 @@ def update_ios_app_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.UpdateIosAppDataStreamRequest): request = analytics_admin.UpdateIosAppDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if ios_app_data_stream is not None: request.ios_app_data_stream = ios_app_data_stream if update_mask is not None: @@ -2593,102 +2594,6 @@ def update_ios_app_data_stream( # Done; return the response. return response - def create_ios_app_data_stream( - self, - request: analytics_admin.CreateIosAppDataStreamRequest = None, - *, - parent: str = None, - ios_app_data_stream: resources.IosAppDataStream = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IosAppDataStream: - r"""Creates an iOS app stream with the specified location - and attributes. - Note that an iOS app stream must be linked to a Firebase - app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Args: - request (google.analytics.admin_v1alpha.types.CreateIosAppDataStreamRequest): - The request object. Request message for - CreateIosAppDataStream RPC. - parent (str): - Required. The parent resource where - this ios app data stream will be - created. Format: properties/123 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): - Required. The iOS app data stream to - create. - - This corresponds to the ``ios_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.IosAppDataStream: - A resource message representing a - Google Analytics IOS app stream. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, ios_app_data_stream]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.CreateIosAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateIosAppDataStreamRequest): - request = analytics_admin.CreateIosAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if ios_app_data_stream is not None: - request.ios_app_data_stream = ios_app_data_stream - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[ - self._transport.create_ios_app_data_stream - ] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - def list_ios_app_data_streams( self, request: analytics_admin.ListIosAppDataStreamsRequest = None, @@ -2717,7 +2622,6 @@ def list_ios_app_data_streams( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2749,10 +2653,8 @@ def list_ios_app_data_streams( # there are no flattened fields. if not isinstance(request, analytics_admin.ListIosAppDataStreamsRequest): request = analytics_admin.ListIosAppDataStreamsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2804,7 +2706,6 @@ def get_android_app_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2833,10 +2734,8 @@ def get_android_app_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.GetAndroidAppDataStreamRequest): request = analytics_admin.GetAndroidAppDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2882,7 +2781,6 @@ def delete_android_app_data_stream( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2905,10 +2803,8 @@ def delete_android_app_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.DeleteAndroidAppDataStreamRequest): request = analytics_admin.DeleteAndroidAppDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2934,7 +2830,7 @@ def update_android_app_data_stream( request: analytics_admin.UpdateAndroidAppDataStreamRequest = None, *, android_app_data_stream: resources.AndroidAppDataStream = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2963,7 +2859,6 @@ def update_android_app_data_stream( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2992,10 +2887,8 @@ def update_android_app_data_stream( # there are no flattened fields. if not isinstance(request, analytics_admin.UpdateAndroidAppDataStreamRequest): request = analytics_admin.UpdateAndroidAppDataStreamRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if android_app_data_stream is not None: request.android_app_data_stream = android_app_data_stream if update_mask is not None: @@ -3026,131 +2919,34 @@ def update_android_app_data_stream( # Done; return the response. return response - def create_android_app_data_stream( + def list_android_app_data_streams( self, - request: analytics_admin.CreateAndroidAppDataStreamRequest = None, + request: analytics_admin.ListAndroidAppDataStreamsRequest = None, *, parent: str = None, - android_app_data_stream: resources.AndroidAppDataStream = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.AndroidAppDataStream: - r"""Creates an Android app stream with the specified - location and attributes. - Note that an Android app stream must be linked to a - Firebase app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). + ) -> pagers.ListAndroidAppDataStreamsPager: + r"""Returns child android app streams under the specified + parent property. + Android app streams will be excluded if the caller does + not have access. Returns an empty list if no relevant + android app streams are found. Args: - request (google.analytics.admin_v1alpha.types.CreateAndroidAppDataStreamRequest): + request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): The request object. Request message for - CreateAndroidAppDataStream RPC. + ListAndroidAppDataStreams RPC. parent (str): - Required. The parent resource where - this android app data stream will be - created. Format: properties/123 + Required. The name of the parent + property. For example, to limit results + to app streams under the property with + Id 123: "properties/123" This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): - Required. The android app stream to - create. - - This corresponds to the ``android_app_data_stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.analytics.admin_v1alpha.types.AndroidAppDataStream: - A resource message representing a - Google Analytics Android app stream. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, android_app_data_stream]) - if request is not None and has_flattened_params: - raise ValueError( - "If the `request` argument is set, then none of " - "the individual field arguments should be set." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a analytics_admin.CreateAndroidAppDataStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, analytics_admin.CreateAndroidAppDataStreamRequest): - request = analytics_admin.CreateAndroidAppDataStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - - if parent is not None: - request.parent = parent - if android_app_data_stream is not None: - request.android_app_data_stream = android_app_data_stream - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[ - self._transport.create_android_app_data_stream - ] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), - ) - - # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def list_android_app_data_streams( - self, - request: analytics_admin.ListAndroidAppDataStreamsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAndroidAppDataStreamsPager: - r"""Returns child android app streams under the specified - parent property. - Android app streams will be excluded if the caller does - not have access. Returns an empty list if no relevant - android app streams are found. - - Args: - request (google.analytics.admin_v1alpha.types.ListAndroidAppDataStreamsRequest): - The request object. Request message for - ListAndroidAppDataStreams RPC. - parent (str): - Required. The name of the parent - property. For example, to limit results - to app streams under the property with - Id 123: "properties/123" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3182,10 +2978,8 @@ def list_android_app_data_streams( # there are no flattened fields. if not isinstance(request, analytics_admin.ListAndroidAppDataStreamsRequest): request = analytics_admin.ListAndroidAppDataStreamsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -3239,7 +3033,6 @@ def get_enhanced_measurement_settings( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3272,10 +3065,8 @@ def get_enhanced_measurement_settings( request, analytics_admin.GetEnhancedMeasurementSettingsRequest ): request = analytics_admin.GetEnhancedMeasurementSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -3302,7 +3093,7 @@ def update_enhanced_measurement_settings( request: analytics_admin.UpdateEnhancedMeasurementSettingsRequest = None, *, enhanced_measurement_settings: resources.EnhancedMeasurementSettings = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -3332,7 +3123,6 @@ def update_enhanced_measurement_settings( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3365,10 +3155,8 @@ def update_enhanced_measurement_settings( request, analytics_admin.UpdateEnhancedMeasurementSettingsRequest ): request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if enhanced_measurement_settings is not None: request.enhanced_measurement_settings = enhanced_measurement_settings if update_mask is not None: @@ -3430,7 +3218,6 @@ def create_firebase_link( This corresponds to the ``firebase_link`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3459,10 +3246,8 @@ def create_firebase_link( # there are no flattened fields. if not isinstance(request, analytics_admin.CreateFirebaseLinkRequest): request = analytics_admin.CreateFirebaseLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if firebase_link is not None: @@ -3489,7 +3274,7 @@ def update_firebase_link( request: analytics_admin.UpdateFirebaseLinkRequest = None, *, firebase_link: resources.FirebaseLink = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -3517,7 +3302,6 @@ def update_firebase_link( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3546,10 +3330,8 @@ def update_firebase_link( # there are no flattened fields. if not isinstance(request, analytics_admin.UpdateFirebaseLinkRequest): request = analytics_admin.UpdateFirebaseLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if firebase_link is not None: request.firebase_link = firebase_link if update_mask is not None: @@ -3596,7 +3378,6 @@ def delete_firebase_link( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3619,10 +3400,8 @@ def delete_firebase_link( # there are no flattened fields. if not isinstance(request, analytics_admin.DeleteFirebaseLinkRequest): request = analytics_admin.DeleteFirebaseLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -3664,7 +3443,6 @@ def list_firebase_links( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3696,10 +3474,8 @@ def list_firebase_links( # there are no flattened fields. if not isinstance(request, analytics_admin.ListFirebaseLinksRequest): request = analytics_admin.ListFirebaseLinksRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -3752,7 +3528,6 @@ def get_global_site_tag( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3782,10 +3557,8 @@ def get_global_site_tag( # there are no flattened fields. if not isinstance(request, analytics_admin.GetGlobalSiteTagRequest): request = analytics_admin.GetGlobalSiteTagRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -3835,7 +3608,6 @@ def create_google_ads_link( This corresponds to the ``google_ads_link`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3864,10 +3636,8 @@ def create_google_ads_link( # there are no flattened fields. if not isinstance(request, analytics_admin.CreateGoogleAdsLinkRequest): request = analytics_admin.CreateGoogleAdsLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if google_ads_link is not None: @@ -3894,7 +3664,7 @@ def update_google_ads_link( request: analytics_admin.UpdateGoogleAdsLinkRequest = None, *, google_ads_link: resources.GoogleAdsLink = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -3920,7 +3690,6 @@ def update_google_ads_link( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3949,10 +3718,8 @@ def update_google_ads_link( # there are no flattened fields. if not isinstance(request, analytics_admin.UpdateGoogleAdsLinkRequest): request = analytics_admin.UpdateGoogleAdsLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if google_ads_link is not None: request.google_ads_link = google_ads_link if update_mask is not None: @@ -3998,7 +3765,6 @@ def delete_google_ads_link( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4021,10 +3787,8 @@ def delete_google_ads_link( # there are no flattened fields. if not isinstance(request, analytics_admin.DeleteGoogleAdsLinkRequest): request = analytics_admin.DeleteGoogleAdsLinkRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -4065,7 +3829,6 @@ def list_google_ads_links( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4097,10 +3860,8 @@ def list_google_ads_links( # there are no flattened fields. if not isinstance(request, analytics_admin.ListGoogleAdsLinksRequest): request = analytics_admin.ListGoogleAdsLinksRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -4152,7 +3913,6 @@ def get_data_sharing_settings( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4182,10 +3942,8 @@ def get_data_sharing_settings( # there are no flattened fields. if not isinstance(request, analytics_admin.GetDataSharingSettingsRequest): request = analytics_admin.GetDataSharingSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -4207,6 +3965,1710 @@ def get_data_sharing_settings( # Done; return the response. return response + def get_measurement_protocol_secret( + self, + request: analytics_admin.GetMeasurementProtocolSecretRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Lookup for a single "GA4" MeasurementProtocolSecret. + + Args: + request (google.analytics.admin_v1alpha.types.GetMeasurementProtocolSecretRequest): + The request object. Request message for + GetMeasurementProtocolSecret RPC. + name (str): + Required. The name of the measurement + protocol secret to lookup. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) + may be a parent. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.GetMeasurementProtocolSecretRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetMeasurementProtocolSecretRequest): + request = analytics_admin.GetMeasurementProtocolSecretRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.get_measurement_protocol_secret + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_measurement_protocol_secrets( + self, + request: analytics_admin.ListMeasurementProtocolSecretsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMeasurementProtocolSecretsPager: + r"""Returns child MeasurementProtocolSecrets under the + specified parent Property. + + Args: + request (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest): + The request object. Request message for + ListMeasurementProtocolSecret RPC + parent (str): + Required. The resource name of the + parent stream. Any type of stream + (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListMeasurementProtocolSecretsPager: + Response message for + ListMeasurementProtocolSecret RPC + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ListMeasurementProtocolSecretsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance( + request, analytics_admin.ListMeasurementProtocolSecretsRequest + ): + request = analytics_admin.ListMeasurementProtocolSecretsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.list_measurement_protocol_secrets + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListMeasurementProtocolSecretsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def create_measurement_protocol_secret( + self, + request: analytics_admin.CreateMeasurementProtocolSecretRequest = None, + *, + parent: str = None, + measurement_protocol_secret: resources.MeasurementProtocolSecret = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Creates a measurement protocol secret. + + Args: + request (google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest): + The request object. Request message for + CreateMeasurementProtocolSecret RPC + parent (str): + Required. The parent resource where + this secret will be created. Any type of + stream (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream} + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + Required. The measurement protocol + secret to create. + + This corresponds to the ``measurement_protocol_secret`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, measurement_protocol_secret]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.CreateMeasurementProtocolSecretRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance( + request, analytics_admin.CreateMeasurementProtocolSecretRequest + ): + request = analytics_admin.CreateMeasurementProtocolSecretRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if measurement_protocol_secret is not None: + request.measurement_protocol_secret = measurement_protocol_secret + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.create_measurement_protocol_secret + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def delete_measurement_protocol_secret( + self, + request: analytics_admin.DeleteMeasurementProtocolSecretRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes target MeasurementProtocolSecret. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteMeasurementProtocolSecretRequest): + The request object. Request message for + DeleteMeasurementProtocolSecret RPC + name (str): + Required. The name of the + MeasurementProtocolSecret to delete. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) + may be a parent. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteMeasurementProtocolSecretRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance( + request, analytics_admin.DeleteMeasurementProtocolSecretRequest + ): + request = analytics_admin.DeleteMeasurementProtocolSecretRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.delete_measurement_protocol_secret + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + def update_measurement_protocol_secret( + self, + request: analytics_admin.UpdateMeasurementProtocolSecretRequest = None, + *, + measurement_protocol_secret: resources.MeasurementProtocolSecret = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.MeasurementProtocolSecret: + r"""Updates a measurement protocol secret. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateMeasurementProtocolSecretRequest): + The request object. Request message for + UpdateMeasurementProtocolSecret RPC + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + Required. The measurement protocol + secret to update. + + This corresponds to the ``measurement_protocol_secret`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + Omitted fields will not be updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: + A secret value used for sending hits + to Measurement Protocol. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([measurement_protocol_secret, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.UpdateMeasurementProtocolSecretRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance( + request, analytics_admin.UpdateMeasurementProtocolSecretRequest + ): + request = analytics_admin.UpdateMeasurementProtocolSecretRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if measurement_protocol_secret is not None: + request.measurement_protocol_secret = measurement_protocol_secret + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.update_measurement_protocol_secret + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ( + "measurement_protocol_secret.name", + request.measurement_protocol_secret.name, + ), + ) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def search_change_history_events( + self, + request: analytics_admin.SearchChangeHistoryEventsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.SearchChangeHistoryEventsPager: + r"""Searches through all changes to an account or its + children given the specified set of filters. + + Args: + request (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest): + The request object. Request message for + SearchChangeHistoryEvents RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.SearchChangeHistoryEventsPager: + Response message for SearchAccounts + RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.SearchChangeHistoryEventsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.SearchChangeHistoryEventsRequest): + request = analytics_admin.SearchChangeHistoryEventsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.search_change_history_events + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("account", request.account),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.SearchChangeHistoryEventsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def get_google_signals_settings( + self, + request: analytics_admin.GetGoogleSignalsSettingsRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleSignalsSettings: + r"""Lookup for Google Signals settings for a property. + + Args: + request (google.analytics.admin_v1alpha.types.GetGoogleSignalsSettingsRequest): + The request object. Request message for + GetGoogleSignalsSettings RPC + name (str): + Required. The name of the google + signals settings to retrieve. Format: + properties/{property}/googleSignalsSettings + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.GoogleSignalsSettings: + Settings values for Google Signals. + This is a singleton resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.GetGoogleSignalsSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetGoogleSignalsSettingsRequest): + request = analytics_admin.GetGoogleSignalsSettingsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.get_google_signals_settings + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def update_google_signals_settings( + self, + request: analytics_admin.UpdateGoogleSignalsSettingsRequest = None, + *, + google_signals_settings: resources.GoogleSignalsSettings = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.GoogleSignalsSettings: + r"""Updates Google Signals settings for a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateGoogleSignalsSettingsRequest): + The request object. Request message for + UpdateGoogleSignalsSettings RPC + google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): + Required. The settings to update. The ``name`` field is + used to identify the settings to be updated. + + This corresponds to the ``google_signals_settings`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names + must be in snake case (e.g., "field_to_update"). Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.GoogleSignalsSettings: + Settings values for Google Signals. + This is a singleton resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([google_signals_settings, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.UpdateGoogleSignalsSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateGoogleSignalsSettingsRequest): + request = analytics_admin.UpdateGoogleSignalsSettingsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if google_signals_settings is not None: + request.google_signals_settings = google_signals_settings + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.update_google_signals_settings + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ( + "google_signals_settings.name", + request.google_signals_settings.name, + ), + ) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def create_conversion_event( + self, + request: analytics_admin.CreateConversionEventRequest = None, + *, + parent: str = None, + conversion_event: resources.ConversionEvent = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ConversionEvent: + r"""Creates a conversion event with the specified + attributes. + + Args: + request (google.analytics.admin_v1alpha.types.CreateConversionEventRequest): + The request object. Request message for + CreateConversionEvent RPC + parent (str): + Required. The resource name of the + parent property where this conversion + event will be created. Format: + properties/123 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): + Required. The conversion event to + create. + + This corresponds to the ``conversion_event`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.ConversionEvent: + A conversion event in a Google + Analytics property. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, conversion_event]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.CreateConversionEventRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateConversionEventRequest): + request = analytics_admin.CreateConversionEventRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if conversion_event is not None: + request.conversion_event = conversion_event + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_conversion_event] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def get_conversion_event( + self, + request: analytics_admin.GetConversionEventRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ConversionEvent: + r"""Retrieve a single conversion event. + + Args: + request (google.analytics.admin_v1alpha.types.GetConversionEventRequest): + The request object. Request message for + GetConversionEvent RPC + name (str): + Required. The resource name of the conversion event to + retrieve. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.ConversionEvent: + A conversion event in a Google + Analytics property. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.GetConversionEventRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetConversionEventRequest): + request = analytics_admin.GetConversionEventRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_conversion_event] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def delete_conversion_event( + self, + request: analytics_admin.DeleteConversionEventRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a conversion event in a property. + + Args: + request (google.analytics.admin_v1alpha.types.DeleteConversionEventRequest): + The request object. Request message for + DeleteConversionEvent RPC + name (str): + Required. The resource name of the conversion event to + delete. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/456" + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.DeleteConversionEventRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteConversionEventRequest): + request = analytics_admin.DeleteConversionEventRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_conversion_event] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + def list_conversion_events( + self, + request: analytics_admin.ListConversionEventsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConversionEventsPager: + r"""Returns a list of conversion events in the specified + parent property. + Returns an empty list if no conversion events are found. + + Args: + request (google.analytics.admin_v1alpha.types.ListConversionEventsRequest): + The request object. Request message for + ListConversionEvents RPC + parent (str): + Required. The resource name of the + parent property. Example: + 'properties/123' + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListConversionEventsPager: + Response message for + ListConversionEvents RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ListConversionEventsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListConversionEventsRequest): + request = analytics_admin.ListConversionEventsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_conversion_events] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListConversionEventsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def create_custom_dimension( + self, + request: analytics_admin.CreateCustomDimensionRequest = None, + *, + parent: str = None, + custom_dimension: resources.CustomDimension = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Creates a CustomDimension. + + Args: + request (google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest): + The request object. Request message for + CreateCustomDimension RPC. + parent (str): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + Required. The CustomDimension to + create. + + This corresponds to the ``custom_dimension`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, custom_dimension]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.CreateCustomDimensionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateCustomDimensionRequest): + request = analytics_admin.CreateCustomDimensionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_dimension is not None: + request.custom_dimension = custom_dimension + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_custom_dimension] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def update_custom_dimension( + self, + request: analytics_admin.UpdateCustomDimensionRequest = None, + *, + custom_dimension: resources.CustomDimension = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Updates a CustomDimension on a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateCustomDimensionRequest): + The request object. Request message for + UpdateCustomDimension RPC. + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + The CustomDimension to update + This corresponds to the ``custom_dimension`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([custom_dimension, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.UpdateCustomDimensionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateCustomDimensionRequest): + request = analytics_admin.UpdateCustomDimensionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if custom_dimension is not None: + request.custom_dimension = custom_dimension + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_custom_dimension] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("custom_dimension.name", request.custom_dimension.name),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_custom_dimensions( + self, + request: analytics_admin.ListCustomDimensionsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomDimensionsPager: + r"""Lists CustomDimensions on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest): + The request object. Request message for + ListCustomDimensions RPC. + parent (str): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomDimensionsPager: + Response message for + ListCustomDimensions RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ListCustomDimensionsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListCustomDimensionsRequest): + request = analytics_admin.ListCustomDimensionsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_custom_dimensions] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListCustomDimensionsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def archive_custom_dimension( + self, + request: analytics_admin.ArchiveCustomDimensionRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Archives a CustomDimension on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ArchiveCustomDimensionRequest): + The request object. Request message for + ArchiveCustomDimension RPC. + name (str): + Required. The name of the + CustomDimension to archive. Example + format: + properties/1234/customDimensions/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ArchiveCustomDimensionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ArchiveCustomDimensionRequest): + request = analytics_admin.ArchiveCustomDimensionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.archive_custom_dimension] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + def get_custom_dimension( + self, + request: analytics_admin.GetCustomDimensionRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomDimension: + r"""Lookup for a single CustomDimension. + + Args: + request (google.analytics.admin_v1alpha.types.GetCustomDimensionRequest): + The request object. Request message for + GetCustomDimension RPC. + name (str): + Required. The name of the + CustomDimension to get. Example format: + properties/1234/customDimensions/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomDimension: + A definition for a CustomDimension. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.GetCustomDimensionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetCustomDimensionRequest): + request = analytics_admin.GetCustomDimensionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_custom_dimension] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def create_custom_metric( + self, + request: analytics_admin.CreateCustomMetricRequest = None, + *, + parent: str = None, + custom_metric: resources.CustomMetric = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Creates a CustomMetric. + + Args: + request (google.analytics.admin_v1alpha.types.CreateCustomMetricRequest): + The request object. Request message for + CreateCustomMetric RPC. + parent (str): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + Required. The CustomMetric to create. + This corresponds to the ``custom_metric`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, custom_metric]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.CreateCustomMetricRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateCustomMetricRequest): + request = analytics_admin.CreateCustomMetricRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_metric is not None: + request.custom_metric = custom_metric + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_custom_metric] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def update_custom_metric( + self, + request: analytics_admin.UpdateCustomMetricRequest = None, + *, + custom_metric: resources.CustomMetric = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Updates a CustomMetric on a property. + + Args: + request (google.analytics.admin_v1alpha.types.UpdateCustomMetricRequest): + The request object. Request message for + UpdateCustomMetric RPC. + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + The CustomMetric to update + This corresponds to the ``custom_metric`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Omitted + fields will not be updated. To replace the entire + entity, use one path with the string "*" to match all + fields. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([custom_metric, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.UpdateCustomMetricRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateCustomMetricRequest): + request = analytics_admin.UpdateCustomMetricRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if custom_metric is not None: + request.custom_metric = custom_metric + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_custom_metric] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("custom_metric.name", request.custom_metric.name),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_custom_metrics( + self, + request: analytics_admin.ListCustomMetricsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomMetricsPager: + r"""Lists CustomMetrics on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ListCustomMetricsRequest): + The request object. Request message for + ListCustomMetrics RPC. + parent (str): + Required. Example format: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomMetricsPager: + Response message for + ListCustomMetrics RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ListCustomMetricsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListCustomMetricsRequest): + request = analytics_admin.ListCustomMetricsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_custom_metrics] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListCustomMetricsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def archive_custom_metric( + self, + request: analytics_admin.ArchiveCustomMetricRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Archives a CustomMetric on a property. + + Args: + request (google.analytics.admin_v1alpha.types.ArchiveCustomMetricRequest): + The request object. Request message for + ArchiveCustomMetric RPC. + name (str): + Required. The name of the + CustomMetric to archive. Example format: + properties/1234/customMetrics/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.ArchiveCustomMetricRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ArchiveCustomMetricRequest): + request = analytics_admin.ArchiveCustomMetricRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.archive_custom_metric] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + def get_custom_metric( + self, + request: analytics_admin.GetCustomMetricRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CustomMetric: + r"""Lookup for a single CustomMetric. + + Args: + request (google.analytics.admin_v1alpha.types.GetCustomMetricRequest): + The request object. Request message for GetCustomMetric + RPC. + name (str): + Required. The name of the + CustomMetric to get. Example format: + properties/1234/customMetrics/5678 + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.CustomMetric: + A definition for a custom metric. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.GetCustomMetricRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetCustomMetricRequest): + request = analytics_admin.GetCustomMetricRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_custom_metric] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py index 583dee16dccd..ab45c77f3e6d 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -118,7 +116,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -246,7 +244,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -376,7 +374,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -504,7 +502,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -632,7 +630,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -760,7 +758,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -888,7 +886,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -1020,7 +1018,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -1150,7 +1148,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -1278,7 +1276,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -1316,3 +1314,655 @@ async def async_generator(): def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListMeasurementProtocolSecretsPager: + """A pager for iterating through ``list_measurement_protocol_secrets`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``measurement_protocol_secrets`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListMeasurementProtocolSecrets`` requests and continue to iterate + through the ``measurement_protocol_secrets`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., analytics_admin.ListMeasurementProtocolSecretsResponse], + request: analytics_admin.ListMeasurementProtocolSecretsRequest, + response: analytics_admin.ListMeasurementProtocolSecretsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListMeasurementProtocolSecretsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListMeasurementProtocolSecretsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.MeasurementProtocolSecret]: + for page in self.pages: + yield from page.measurement_protocol_secrets + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListMeasurementProtocolSecretsAsyncPager: + """A pager for iterating through ``list_measurement_protocol_secrets`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``measurement_protocol_secrets`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListMeasurementProtocolSecrets`` requests and continue to iterate + through the ``measurement_protocol_secrets`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[analytics_admin.ListMeasurementProtocolSecretsResponse] + ], + request: analytics_admin.ListMeasurementProtocolSecretsRequest, + response: analytics_admin.ListMeasurementProtocolSecretsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListMeasurementProtocolSecretsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListMeasurementProtocolSecretsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[analytics_admin.ListMeasurementProtocolSecretsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.MeasurementProtocolSecret]: + async def async_generator(): + async for page in self.pages: + for response in page.measurement_protocol_secrets: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class SearchChangeHistoryEventsPager: + """A pager for iterating through ``search_change_history_events`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``change_history_events`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``SearchChangeHistoryEvents`` requests and continue to iterate + through the ``change_history_events`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., analytics_admin.SearchChangeHistoryEventsResponse], + request: analytics_admin.SearchChangeHistoryEventsRequest, + response: analytics_admin.SearchChangeHistoryEventsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.SearchChangeHistoryEventsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.SearchChangeHistoryEventsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.ChangeHistoryEvent]: + for page in self.pages: + yield from page.change_history_events + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class SearchChangeHistoryEventsAsyncPager: + """A pager for iterating through ``search_change_history_events`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``change_history_events`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``SearchChangeHistoryEvents`` requests and continue to iterate + through the ``change_history_events`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[analytics_admin.SearchChangeHistoryEventsResponse] + ], + request: analytics_admin.SearchChangeHistoryEventsRequest, + response: analytics_admin.SearchChangeHistoryEventsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.SearchChangeHistoryEventsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[analytics_admin.SearchChangeHistoryEventsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.ChangeHistoryEvent]: + async def async_generator(): + async for page in self.pages: + for response in page.change_history_events: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListConversionEventsPager: + """A pager for iterating through ``list_conversion_events`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``conversion_events`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListConversionEvents`` requests and continue to iterate + through the ``conversion_events`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., analytics_admin.ListConversionEventsResponse], + request: analytics_admin.ListConversionEventsRequest, + response: analytics_admin.ListConversionEventsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListConversionEventsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListConversionEventsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListConversionEventsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListConversionEventsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.ConversionEvent]: + for page in self.pages: + yield from page.conversion_events + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListConversionEventsAsyncPager: + """A pager for iterating through ``list_conversion_events`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``conversion_events`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListConversionEvents`` requests and continue to iterate + through the ``conversion_events`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListConversionEventsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[analytics_admin.ListConversionEventsResponse]], + request: analytics_admin.ListConversionEventsRequest, + response: analytics_admin.ListConversionEventsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListConversionEventsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListConversionEventsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListConversionEventsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[analytics_admin.ListConversionEventsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.ConversionEvent]: + async def async_generator(): + async for page in self.pages: + for response in page.conversion_events: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListCustomDimensionsPager: + """A pager for iterating through ``list_custom_dimensions`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``custom_dimensions`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCustomDimensions`` requests and continue to iterate + through the ``custom_dimensions`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., analytics_admin.ListCustomDimensionsResponse], + request: analytics_admin.ListCustomDimensionsRequest, + response: analytics_admin.ListCustomDimensionsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListCustomDimensionsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListCustomDimensionsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.CustomDimension]: + for page in self.pages: + yield from page.custom_dimensions + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListCustomDimensionsAsyncPager: + """A pager for iterating through ``list_custom_dimensions`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``custom_dimensions`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCustomDimensions`` requests and continue to iterate + through the ``custom_dimensions`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[analytics_admin.ListCustomDimensionsResponse]], + request: analytics_admin.ListCustomDimensionsRequest, + response: analytics_admin.ListCustomDimensionsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListCustomDimensionsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListCustomDimensionsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListCustomDimensionsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterable[analytics_admin.ListCustomDimensionsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.CustomDimension]: + async def async_generator(): + async for page in self.pages: + for response in page.custom_dimensions: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListCustomMetricsPager: + """A pager for iterating through ``list_custom_metrics`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``custom_metrics`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCustomMetrics`` requests and continue to iterate + through the ``custom_metrics`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., analytics_admin.ListCustomMetricsResponse], + request: analytics_admin.ListCustomMetricsRequest, + response: analytics_admin.ListCustomMetricsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListCustomMetricsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListCustomMetricsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListCustomMetricsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[analytics_admin.ListCustomMetricsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.CustomMetric]: + for page in self.pages: + yield from page.custom_metrics + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListCustomMetricsAsyncPager: + """A pager for iterating through ``list_custom_metrics`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``custom_metrics`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCustomMetrics`` requests and continue to iterate + through the ``custom_metrics`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListCustomMetricsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[analytics_admin.ListCustomMetricsResponse]], + request: analytics_admin.ListCustomMetricsRequest, + response: analytics_admin.ListCustomMetricsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.analytics.admin_v1alpha.types.ListCustomMetricsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListCustomMetricsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = analytics_admin.ListCustomMetricsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[analytics_admin.ListCustomMetricsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.CustomMetric]: + async def async_generator(): + async for page in self.pages: + for response in page.custom_metrics: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py index e1e55440a92b..4d29785e13da 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py index 825ff2b95584..90c401be8afe 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import resources -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -37,6 +36,17 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class AnalyticsAdminServiceTransport(abc.ABC): """Abstract transport class for AnalyticsAdminService.""" @@ -48,21 +58,24 @@ class AnalyticsAdminServiceTransport(abc.ABC): "https://www.googleapis.com/auth/analytics.readonly", ) + DEFAULT_HOST: str = "analyticsadmin.googleapis.com" + def __init__( self, *, - host: str = "analyticsadmin.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -71,7 +84,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -85,29 +98,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -224,11 +284,6 @@ def _prep_wrapped_messages(self, client_info): 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, @@ -249,11 +304,6 @@ def _prep_wrapped_messages(self, client_info): 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, @@ -315,25 +365,131 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.get_measurement_protocol_secret: gapic_v1.method.wrap_method( + self.get_measurement_protocol_secret, + default_timeout=None, + client_info=client_info, + ), + self.list_measurement_protocol_secrets: gapic_v1.method.wrap_method( + self.list_measurement_protocol_secrets, + default_timeout=None, + client_info=client_info, + ), + self.create_measurement_protocol_secret: gapic_v1.method.wrap_method( + self.create_measurement_protocol_secret, + default_timeout=None, + client_info=client_info, + ), + self.delete_measurement_protocol_secret: gapic_v1.method.wrap_method( + self.delete_measurement_protocol_secret, + default_timeout=None, + client_info=client_info, + ), + self.update_measurement_protocol_secret: gapic_v1.method.wrap_method( + self.update_measurement_protocol_secret, + default_timeout=None, + client_info=client_info, + ), + self.search_change_history_events: gapic_v1.method.wrap_method( + self.search_change_history_events, + default_timeout=None, + client_info=client_info, + ), + self.get_google_signals_settings: gapic_v1.method.wrap_method( + self.get_google_signals_settings, + default_timeout=None, + client_info=client_info, + ), + self.update_google_signals_settings: gapic_v1.method.wrap_method( + self.update_google_signals_settings, + default_timeout=None, + client_info=client_info, + ), + self.create_conversion_event: gapic_v1.method.wrap_method( + self.create_conversion_event, + default_timeout=None, + client_info=client_info, + ), + self.get_conversion_event: gapic_v1.method.wrap_method( + self.get_conversion_event, + default_timeout=None, + client_info=client_info, + ), + self.delete_conversion_event: gapic_v1.method.wrap_method( + self.delete_conversion_event, + default_timeout=None, + client_info=client_info, + ), + self.list_conversion_events: gapic_v1.method.wrap_method( + self.list_conversion_events, + default_timeout=None, + client_info=client_info, + ), + self.create_custom_dimension: gapic_v1.method.wrap_method( + self.create_custom_dimension, + default_timeout=None, + client_info=client_info, + ), + self.update_custom_dimension: gapic_v1.method.wrap_method( + self.update_custom_dimension, + default_timeout=None, + client_info=client_info, + ), + self.list_custom_dimensions: gapic_v1.method.wrap_method( + self.list_custom_dimensions, + default_timeout=None, + client_info=client_info, + ), + self.archive_custom_dimension: gapic_v1.method.wrap_method( + self.archive_custom_dimension, + default_timeout=None, + client_info=client_info, + ), + self.get_custom_dimension: gapic_v1.method.wrap_method( + self.get_custom_dimension, + default_timeout=None, + client_info=client_info, + ), + self.create_custom_metric: gapic_v1.method.wrap_method( + self.create_custom_metric, + default_timeout=None, + client_info=client_info, + ), + self.update_custom_metric: gapic_v1.method.wrap_method( + self.update_custom_metric, + default_timeout=None, + client_info=client_info, + ), + self.list_custom_metrics: gapic_v1.method.wrap_method( + self.list_custom_metrics, default_timeout=None, client_info=client_info, + ), + self.archive_custom_metric: gapic_v1.method.wrap_method( + self.archive_custom_metric, + default_timeout=None, + client_info=client_info, + ), + self.get_custom_metric: gapic_v1.method.wrap_method( + self.get_custom_metric, default_timeout=None, client_info=client_info, + ), } @property def get_account( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetAccountRequest], - typing.Union[resources.Account, typing.Awaitable[resources.Account]], + Union[resources.Account, Awaitable[resources.Account]], ]: raise NotImplementedError() @property def list_accounts( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListAccountsRequest], - typing.Union[ + Union[ analytics_admin.ListAccountsResponse, - typing.Awaitable[analytics_admin.ListAccountsResponse], + Awaitable[analytics_admin.ListAccountsResponse], ], ]: raise NotImplementedError() @@ -341,29 +497,29 @@ def list_accounts( @property def delete_account( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.DeleteAccountRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def update_account( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdateAccountRequest], - typing.Union[resources.Account, typing.Awaitable[resources.Account]], + Union[resources.Account, Awaitable[resources.Account]], ]: raise NotImplementedError() @property def provision_account_ticket( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ProvisionAccountTicketRequest], - typing.Union[ + Union[ analytics_admin.ProvisionAccountTicketResponse, - typing.Awaitable[analytics_admin.ProvisionAccountTicketResponse], + Awaitable[analytics_admin.ProvisionAccountTicketResponse], ], ]: raise NotImplementedError() @@ -371,11 +527,11 @@ def provision_account_ticket( @property def list_account_summaries( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListAccountSummariesRequest], - typing.Union[ + Union[ analytics_admin.ListAccountSummariesResponse, - typing.Awaitable[analytics_admin.ListAccountSummariesResponse], + Awaitable[analytics_admin.ListAccountSummariesResponse], ], ]: raise NotImplementedError() @@ -383,20 +539,20 @@ def list_account_summaries( @property def get_property( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetPropertyRequest], - typing.Union[resources.Property, typing.Awaitable[resources.Property]], + Union[resources.Property, Awaitable[resources.Property]], ]: raise NotImplementedError() @property def list_properties( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListPropertiesRequest], - typing.Union[ + Union[ analytics_admin.ListPropertiesResponse, - typing.Awaitable[analytics_admin.ListPropertiesResponse], + Awaitable[analytics_admin.ListPropertiesResponse], ], ]: raise NotImplementedError() @@ -404,47 +560,47 @@ def list_properties( @property def create_property( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.CreatePropertyRequest], - typing.Union[resources.Property, typing.Awaitable[resources.Property]], + Union[resources.Property, Awaitable[resources.Property]], ]: raise NotImplementedError() @property def delete_property( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.DeletePropertyRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[resources.Property, Awaitable[resources.Property]], ]: raise NotImplementedError() @property def update_property( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdatePropertyRequest], - typing.Union[resources.Property, typing.Awaitable[resources.Property]], + Union[resources.Property, Awaitable[resources.Property]], ]: raise NotImplementedError() @property def get_user_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetUserLinkRequest], - typing.Union[resources.UserLink, typing.Awaitable[resources.UserLink]], + Union[resources.UserLink, Awaitable[resources.UserLink]], ]: raise NotImplementedError() @property def batch_get_user_links( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.BatchGetUserLinksRequest], - typing.Union[ + Union[ analytics_admin.BatchGetUserLinksResponse, - typing.Awaitable[analytics_admin.BatchGetUserLinksResponse], + Awaitable[analytics_admin.BatchGetUserLinksResponse], ], ]: raise NotImplementedError() @@ -452,11 +608,11 @@ def batch_get_user_links( @property def list_user_links( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListUserLinksRequest], - typing.Union[ + Union[ analytics_admin.ListUserLinksResponse, - typing.Awaitable[analytics_admin.ListUserLinksResponse], + Awaitable[analytics_admin.ListUserLinksResponse], ], ]: raise NotImplementedError() @@ -464,11 +620,11 @@ def list_user_links( @property def audit_user_links( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.AuditUserLinksRequest], - typing.Union[ + Union[ analytics_admin.AuditUserLinksResponse, - typing.Awaitable[analytics_admin.AuditUserLinksResponse], + Awaitable[analytics_admin.AuditUserLinksResponse], ], ]: raise NotImplementedError() @@ -476,20 +632,20 @@ def audit_user_links( @property def create_user_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.CreateUserLinkRequest], - typing.Union[resources.UserLink, typing.Awaitable[resources.UserLink]], + Union[resources.UserLink, Awaitable[resources.UserLink]], ]: raise NotImplementedError() @property def batch_create_user_links( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.BatchCreateUserLinksRequest], - typing.Union[ + Union[ analytics_admin.BatchCreateUserLinksResponse, - typing.Awaitable[analytics_admin.BatchCreateUserLinksResponse], + Awaitable[analytics_admin.BatchCreateUserLinksResponse], ], ]: raise NotImplementedError() @@ -497,20 +653,20 @@ def batch_create_user_links( @property def update_user_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdateUserLinkRequest], - typing.Union[resources.UserLink, typing.Awaitable[resources.UserLink]], + Union[resources.UserLink, Awaitable[resources.UserLink]], ]: raise NotImplementedError() @property def batch_update_user_links( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.BatchUpdateUserLinksRequest], - typing.Union[ + Union[ analytics_admin.BatchUpdateUserLinksResponse, - typing.Awaitable[analytics_admin.BatchUpdateUserLinksResponse], + Awaitable[analytics_admin.BatchUpdateUserLinksResponse], ], ]: raise NotImplementedError() @@ -518,71 +674,65 @@ def batch_update_user_links( @property def delete_user_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.DeleteUserLinkRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def batch_delete_user_links( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.BatchDeleteUserLinksRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def get_web_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetWebDataStreamRequest], - typing.Union[ - resources.WebDataStream, typing.Awaitable[resources.WebDataStream] - ], + Union[resources.WebDataStream, Awaitable[resources.WebDataStream]], ]: raise NotImplementedError() @property def delete_web_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.DeleteWebDataStreamRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def update_web_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdateWebDataStreamRequest], - typing.Union[ - resources.WebDataStream, typing.Awaitable[resources.WebDataStream] - ], + Union[resources.WebDataStream, Awaitable[resources.WebDataStream]], ]: raise NotImplementedError() @property def create_web_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.CreateWebDataStreamRequest], - typing.Union[ - resources.WebDataStream, typing.Awaitable[resources.WebDataStream] - ], + Union[resources.WebDataStream, Awaitable[resources.WebDataStream]], ]: raise NotImplementedError() @property def list_web_data_streams( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListWebDataStreamsRequest], - typing.Union[ + Union[ analytics_admin.ListWebDataStreamsResponse, - typing.Awaitable[analytics_admin.ListWebDataStreamsResponse], + Awaitable[analytics_admin.ListWebDataStreamsResponse], ], ]: raise NotImplementedError() @@ -590,53 +740,38 @@ def list_web_data_streams( @property def get_ios_app_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetIosAppDataStreamRequest], - typing.Union[ - resources.IosAppDataStream, typing.Awaitable[resources.IosAppDataStream] - ], + Union[resources.IosAppDataStream, Awaitable[resources.IosAppDataStream]], ]: raise NotImplementedError() @property def delete_ios_app_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.DeleteIosAppDataStreamRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def update_ios_app_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdateIosAppDataStreamRequest], - typing.Union[ - resources.IosAppDataStream, typing.Awaitable[resources.IosAppDataStream] - ], - ]: - raise NotImplementedError() - - @property - def create_ios_app_data_stream( - self, - ) -> typing.Callable[ - [analytics_admin.CreateIosAppDataStreamRequest], - typing.Union[ - resources.IosAppDataStream, typing.Awaitable[resources.IosAppDataStream] - ], + Union[resources.IosAppDataStream, Awaitable[resources.IosAppDataStream]], ]: raise NotImplementedError() @property def list_ios_app_data_streams( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListIosAppDataStreamsRequest], - typing.Union[ + Union[ analytics_admin.ListIosAppDataStreamsResponse, - typing.Awaitable[analytics_admin.ListIosAppDataStreamsResponse], + Awaitable[analytics_admin.ListIosAppDataStreamsResponse], ], ]: raise NotImplementedError() @@ -644,11 +779,10 @@ def list_ios_app_data_streams( @property def get_android_app_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetAndroidAppDataStreamRequest], - typing.Union[ - resources.AndroidAppDataStream, - typing.Awaitable[resources.AndroidAppDataStream], + Union[ + resources.AndroidAppDataStream, Awaitable[resources.AndroidAppDataStream] ], ]: raise NotImplementedError() @@ -656,32 +790,19 @@ def get_android_app_data_stream( @property def delete_android_app_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.DeleteAndroidAppDataStreamRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def update_android_app_data_stream( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdateAndroidAppDataStreamRequest], - typing.Union[ - resources.AndroidAppDataStream, - typing.Awaitable[resources.AndroidAppDataStream], - ], - ]: - raise NotImplementedError() - - @property - def create_android_app_data_stream( - self, - ) -> typing.Callable[ - [analytics_admin.CreateAndroidAppDataStreamRequest], - typing.Union[ - resources.AndroidAppDataStream, - typing.Awaitable[resources.AndroidAppDataStream], + Union[ + resources.AndroidAppDataStream, Awaitable[resources.AndroidAppDataStream] ], ]: raise NotImplementedError() @@ -689,11 +810,11 @@ def create_android_app_data_stream( @property def list_android_app_data_streams( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListAndroidAppDataStreamsRequest], - typing.Union[ + Union[ analytics_admin.ListAndroidAppDataStreamsResponse, - typing.Awaitable[analytics_admin.ListAndroidAppDataStreamsResponse], + Awaitable[analytics_admin.ListAndroidAppDataStreamsResponse], ], ]: raise NotImplementedError() @@ -701,11 +822,11 @@ def list_android_app_data_streams( @property def get_enhanced_measurement_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetEnhancedMeasurementSettingsRequest], - typing.Union[ + Union[ resources.EnhancedMeasurementSettings, - typing.Awaitable[resources.EnhancedMeasurementSettings], + Awaitable[resources.EnhancedMeasurementSettings], ], ]: raise NotImplementedError() @@ -713,11 +834,11 @@ def get_enhanced_measurement_settings( @property def update_enhanced_measurement_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdateEnhancedMeasurementSettingsRequest], - typing.Union[ + Union[ resources.EnhancedMeasurementSettings, - typing.Awaitable[resources.EnhancedMeasurementSettings], + Awaitable[resources.EnhancedMeasurementSettings], ], ]: raise NotImplementedError() @@ -725,38 +846,38 @@ def update_enhanced_measurement_settings( @property def create_firebase_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.CreateFirebaseLinkRequest], - typing.Union[resources.FirebaseLink, typing.Awaitable[resources.FirebaseLink]], + Union[resources.FirebaseLink, Awaitable[resources.FirebaseLink]], ]: raise NotImplementedError() @property def update_firebase_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdateFirebaseLinkRequest], - typing.Union[resources.FirebaseLink, typing.Awaitable[resources.FirebaseLink]], + Union[resources.FirebaseLink, Awaitable[resources.FirebaseLink]], ]: raise NotImplementedError() @property def delete_firebase_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.DeleteFirebaseLinkRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def list_firebase_links( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListFirebaseLinksRequest], - typing.Union[ + Union[ analytics_admin.ListFirebaseLinksResponse, - typing.Awaitable[analytics_admin.ListFirebaseLinksResponse], + Awaitable[analytics_admin.ListFirebaseLinksResponse], ], ]: raise NotImplementedError() @@ -764,53 +885,47 @@ def list_firebase_links( @property def get_global_site_tag( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetGlobalSiteTagRequest], - typing.Union[ - resources.GlobalSiteTag, typing.Awaitable[resources.GlobalSiteTag] - ], + Union[resources.GlobalSiteTag, Awaitable[resources.GlobalSiteTag]], ]: raise NotImplementedError() @property def create_google_ads_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.CreateGoogleAdsLinkRequest], - typing.Union[ - resources.GoogleAdsLink, typing.Awaitable[resources.GoogleAdsLink] - ], + Union[resources.GoogleAdsLink, Awaitable[resources.GoogleAdsLink]], ]: raise NotImplementedError() @property def update_google_ads_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.UpdateGoogleAdsLinkRequest], - typing.Union[ - resources.GoogleAdsLink, typing.Awaitable[resources.GoogleAdsLink] - ], + Union[resources.GoogleAdsLink, Awaitable[resources.GoogleAdsLink]], ]: raise NotImplementedError() @property def delete_google_ads_link( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.DeleteGoogleAdsLinkRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def list_google_ads_links( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.ListGoogleAdsLinksRequest], - typing.Union[ + Union[ analytics_admin.ListGoogleAdsLinksResponse, - typing.Awaitable[analytics_admin.ListGoogleAdsLinksResponse], + Awaitable[analytics_admin.ListGoogleAdsLinksResponse], ], ]: raise NotImplementedError() @@ -818,14 +933,237 @@ def list_google_ads_links( @property def get_data_sharing_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [analytics_admin.GetDataSharingSettingsRequest], - typing.Union[ - resources.DataSharingSettings, - typing.Awaitable[resources.DataSharingSettings], + Union[resources.DataSharingSettings, Awaitable[resources.DataSharingSettings]], + ]: + raise NotImplementedError() + + @property + def get_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.GetMeasurementProtocolSecretRequest], + Union[ + resources.MeasurementProtocolSecret, + Awaitable[resources.MeasurementProtocolSecret], + ], + ]: + raise NotImplementedError() + + @property + def list_measurement_protocol_secrets( + self, + ) -> Callable[ + [analytics_admin.ListMeasurementProtocolSecretsRequest], + Union[ + analytics_admin.ListMeasurementProtocolSecretsResponse, + Awaitable[analytics_admin.ListMeasurementProtocolSecretsResponse], ], ]: raise NotImplementedError() + @property + def create_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.CreateMeasurementProtocolSecretRequest], + Union[ + resources.MeasurementProtocolSecret, + Awaitable[resources.MeasurementProtocolSecret], + ], + ]: + raise NotImplementedError() + + @property + def delete_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.DeleteMeasurementProtocolSecretRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def update_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.UpdateMeasurementProtocolSecretRequest], + Union[ + resources.MeasurementProtocolSecret, + Awaitable[resources.MeasurementProtocolSecret], + ], + ]: + raise NotImplementedError() + + @property + def search_change_history_events( + self, + ) -> Callable[ + [analytics_admin.SearchChangeHistoryEventsRequest], + Union[ + analytics_admin.SearchChangeHistoryEventsResponse, + Awaitable[analytics_admin.SearchChangeHistoryEventsResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_google_signals_settings( + self, + ) -> Callable[ + [analytics_admin.GetGoogleSignalsSettingsRequest], + Union[ + resources.GoogleSignalsSettings, Awaitable[resources.GoogleSignalsSettings] + ], + ]: + raise NotImplementedError() + + @property + def update_google_signals_settings( + self, + ) -> Callable[ + [analytics_admin.UpdateGoogleSignalsSettingsRequest], + Union[ + resources.GoogleSignalsSettings, Awaitable[resources.GoogleSignalsSettings] + ], + ]: + raise NotImplementedError() + + @property + def create_conversion_event( + self, + ) -> Callable[ + [analytics_admin.CreateConversionEventRequest], + Union[resources.ConversionEvent, Awaitable[resources.ConversionEvent]], + ]: + raise NotImplementedError() + + @property + def get_conversion_event( + self, + ) -> Callable[ + [analytics_admin.GetConversionEventRequest], + Union[resources.ConversionEvent, Awaitable[resources.ConversionEvent]], + ]: + raise NotImplementedError() + + @property + def delete_conversion_event( + self, + ) -> Callable[ + [analytics_admin.DeleteConversionEventRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def list_conversion_events( + self, + ) -> Callable[ + [analytics_admin.ListConversionEventsRequest], + Union[ + analytics_admin.ListConversionEventsResponse, + Awaitable[analytics_admin.ListConversionEventsResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.CreateCustomDimensionRequest], + Union[resources.CustomDimension, Awaitable[resources.CustomDimension]], + ]: + raise NotImplementedError() + + @property + def update_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.UpdateCustomDimensionRequest], + Union[resources.CustomDimension, Awaitable[resources.CustomDimension]], + ]: + raise NotImplementedError() + + @property + def list_custom_dimensions( + self, + ) -> Callable[ + [analytics_admin.ListCustomDimensionsRequest], + Union[ + analytics_admin.ListCustomDimensionsResponse, + Awaitable[analytics_admin.ListCustomDimensionsResponse], + ], + ]: + raise NotImplementedError() + + @property + def archive_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.ArchiveCustomDimensionRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def get_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.GetCustomDimensionRequest], + Union[resources.CustomDimension, Awaitable[resources.CustomDimension]], + ]: + raise NotImplementedError() + + @property + def create_custom_metric( + self, + ) -> Callable[ + [analytics_admin.CreateCustomMetricRequest], + Union[resources.CustomMetric, Awaitable[resources.CustomMetric]], + ]: + raise NotImplementedError() + + @property + def update_custom_metric( + self, + ) -> Callable[ + [analytics_admin.UpdateCustomMetricRequest], + Union[resources.CustomMetric, Awaitable[resources.CustomMetric]], + ]: + raise NotImplementedError() + + @property + def list_custom_metrics( + self, + ) -> Callable[ + [analytics_admin.ListCustomMetricsRequest], + Union[ + analytics_admin.ListCustomMetricsResponse, + Awaitable[analytics_admin.ListCustomMetricsResponse], + ], + ]: + raise NotImplementedError() + + @property + def archive_custom_metric( + self, + ) -> Callable[ + [analytics_admin.ArchiveCustomMetricRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def get_custom_metric( + self, + ) -> Callable[ + [analytics_admin.GetCustomMetricRequest], + Union[resources.CustomMetric, Awaitable[resources.CustomMetric]], + ]: + raise NotImplementedError() + __all__ = ("AnalyticsAdminServiceTransport",) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py index 91b930d9f757..218597879600 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import resources -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore from .base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO @@ -52,7 +49,7 @@ def __init__( self, *, host: str = "analyticsadmin.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -66,7 +63,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -176,7 +174,7 @@ def __init__( def create_channel( cls, host: str = "analyticsadmin.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -207,13 +205,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -284,7 +284,7 @@ def list_accounts( @property def delete_account( self, - ) -> Callable[[analytics_admin.DeleteAccountRequest], empty.Empty]: + ) -> Callable[[analytics_admin.DeleteAccountRequest], empty_pb2.Empty]: r"""Return a callable for the delete account method over gRPC. Marks target Account as soft-deleted (ie: "trashed") @@ -313,7 +313,7 @@ def delete_account( self._stubs["delete_account"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccount", request_serializer=analytics_admin.DeleteAccountRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_account"] @@ -492,7 +492,7 @@ def create_property( @property def delete_property( self, - ) -> Callable[[analytics_admin.DeletePropertyRequest], empty.Empty]: + ) -> Callable[[analytics_admin.DeletePropertyRequest], resources.Property]: r"""Return a callable for the delete property method over gRPC. Marks target Property as soft-deleted (ie: "trashed") @@ -510,7 +510,7 @@ def delete_property( Returns: Callable[[~.DeletePropertyRequest], - ~.Empty]: + ~.Property]: A function that, when called, will call the underlying RPC on the server. """ @@ -522,7 +522,7 @@ def delete_property( self._stubs["delete_property"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteProperty", request_serializer=analytics_admin.DeletePropertyRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=resources.Property.deserialize, ) return self._stubs["delete_property"] @@ -796,7 +796,7 @@ def batch_update_user_links( @property def delete_user_link( self, - ) -> Callable[[analytics_admin.DeleteUserLinkRequest], empty.Empty]: + ) -> Callable[[analytics_admin.DeleteUserLinkRequest], empty_pb2.Empty]: r"""Return a callable for the delete user link method over gRPC. Deletes a user link on an account or property. @@ -815,14 +815,14 @@ def delete_user_link( self._stubs["delete_user_link"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteUserLink", request_serializer=analytics_admin.DeleteUserLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_user_link"] @property def batch_delete_user_links( self, - ) -> Callable[[analytics_admin.BatchDeleteUserLinksRequest], empty.Empty]: + ) -> Callable[[analytics_admin.BatchDeleteUserLinksRequest], empty_pb2.Empty]: r"""Return a callable for the batch delete user links method over gRPC. Deletes information about multiple users' links to an @@ -842,7 +842,7 @@ def batch_delete_user_links( self._stubs["batch_delete_user_links"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteUserLinks", request_serializer=analytics_admin.BatchDeleteUserLinksRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["batch_delete_user_links"] @@ -875,7 +875,7 @@ def get_web_data_stream( @property def delete_web_data_stream( self, - ) -> Callable[[analytics_admin.DeleteWebDataStreamRequest], empty.Empty]: + ) -> Callable[[analytics_admin.DeleteWebDataStreamRequest], empty_pb2.Empty]: r"""Return a callable for the delete web data stream method over gRPC. Deletes a web stream on a property. @@ -894,7 +894,7 @@ def delete_web_data_stream( self._stubs["delete_web_data_stream"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteWebDataStream", request_serializer=analytics_admin.DeleteWebDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_web_data_stream"] @@ -1019,7 +1019,7 @@ def get_ios_app_data_stream( @property def delete_ios_app_data_stream( self, - ) -> Callable[[analytics_admin.DeleteIosAppDataStreamRequest], empty.Empty]: + ) -> Callable[[analytics_admin.DeleteIosAppDataStreamRequest], empty_pb2.Empty]: r"""Return a callable for the delete ios app data stream method over gRPC. Deletes an iOS app stream on a property. @@ -1038,7 +1038,7 @@ def delete_ios_app_data_stream( self._stubs["delete_ios_app_data_stream"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteIosAppDataStream", request_serializer=analytics_admin.DeleteIosAppDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_ios_app_data_stream"] @@ -1070,43 +1070,6 @@ def update_ios_app_data_stream( ) return self._stubs["update_ios_app_data_stream"] - @property - def create_ios_app_data_stream( - self, - ) -> Callable[ - [analytics_admin.CreateIosAppDataStreamRequest], resources.IosAppDataStream - ]: - r"""Return a callable for the create ios app data stream method over gRPC. - - Creates an iOS app stream with the specified location - and attributes. - Note that an iOS app stream must be linked to a Firebase - app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Returns: - Callable[[~.CreateIosAppDataStreamRequest], - ~.IosAppDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_ios_app_data_stream" not in self._stubs: - self._stubs["create_ios_app_data_stream"] = self.grpc_channel.unary_unary( - "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateIosAppDataStream", - request_serializer=analytics_admin.CreateIosAppDataStreamRequest.serialize, - response_deserializer=resources.IosAppDataStream.deserialize, - ) - return self._stubs["create_ios_app_data_stream"] - @property def list_ios_app_data_streams( self, @@ -1171,7 +1134,7 @@ def get_android_app_data_stream( @property def delete_android_app_data_stream( self, - ) -> Callable[[analytics_admin.DeleteAndroidAppDataStreamRequest], empty.Empty]: + ) -> Callable[[analytics_admin.DeleteAndroidAppDataStreamRequest], empty_pb2.Empty]: r"""Return a callable for the delete android app data stream method over gRPC. Deletes an android app stream on a property. @@ -1192,7 +1155,7 @@ def delete_android_app_data_stream( ] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAndroidAppDataStream", request_serializer=analytics_admin.DeleteAndroidAppDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_android_app_data_stream"] @@ -1227,46 +1190,6 @@ def update_android_app_data_stream( ) return self._stubs["update_android_app_data_stream"] - @property - def create_android_app_data_stream( - self, - ) -> Callable[ - [analytics_admin.CreateAndroidAppDataStreamRequest], - resources.AndroidAppDataStream, - ]: - r"""Return a callable for the create android app data stream method over gRPC. - - Creates an Android app stream with the specified - location and attributes. - Note that an Android app stream must be linked to a - Firebase app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Returns: - Callable[[~.CreateAndroidAppDataStreamRequest], - ~.AndroidAppDataStream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_android_app_data_stream" not in self._stubs: - self._stubs[ - "create_android_app_data_stream" - ] = self.grpc_channel.unary_unary( - "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAndroidAppDataStream", - request_serializer=analytics_admin.CreateAndroidAppDataStreamRequest.serialize, - response_deserializer=resources.AndroidAppDataStream.deserialize, - ) - return self._stubs["create_android_app_data_stream"] - @property def list_android_app_data_streams( self, @@ -1426,7 +1349,7 @@ def update_firebase_link( @property def delete_firebase_link( self, - ) -> Callable[[analytics_admin.DeleteFirebaseLinkRequest], empty.Empty]: + ) -> Callable[[analytics_admin.DeleteFirebaseLinkRequest], empty_pb2.Empty]: r"""Return a callable for the delete firebase link method over gRPC. Deletes a FirebaseLink on a property @@ -1445,7 +1368,7 @@ def delete_firebase_link( self._stubs["delete_firebase_link"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteFirebaseLink", request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_firebase_link"] @@ -1565,7 +1488,7 @@ def update_google_ads_link( @property def delete_google_ads_link( self, - ) -> Callable[[analytics_admin.DeleteGoogleAdsLinkRequest], empty.Empty]: + ) -> Callable[[analytics_admin.DeleteGoogleAdsLinkRequest], empty_pb2.Empty]: r"""Return a callable for the delete google ads link method over gRPC. Deletes a GoogleAdsLink on a property @@ -1584,7 +1507,7 @@ def delete_google_ads_link( self._stubs["delete_google_ads_link"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteGoogleAdsLink", request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_google_ads_link"] @@ -1646,5 +1569,641 @@ def get_data_sharing_settings( ) return self._stubs["get_data_sharing_settings"] + @property + def get_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.GetMeasurementProtocolSecretRequest], + resources.MeasurementProtocolSecret, + ]: + r"""Return a callable for the get measurement protocol + secret method over gRPC. + + Lookup for a single "GA4" MeasurementProtocolSecret. + + Returns: + Callable[[~.GetMeasurementProtocolSecretRequest], + ~.MeasurementProtocolSecret]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_measurement_protocol_secret" not in self._stubs: + self._stubs[ + "get_measurement_protocol_secret" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetMeasurementProtocolSecret", + request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs["get_measurement_protocol_secret"] + + @property + def list_measurement_protocol_secrets( + self, + ) -> Callable[ + [analytics_admin.ListMeasurementProtocolSecretsRequest], + analytics_admin.ListMeasurementProtocolSecretsResponse, + ]: + r"""Return a callable for the list measurement protocol + secrets method over gRPC. + + Returns child MeasurementProtocolSecrets under the + specified parent Property. + + Returns: + Callable[[~.ListMeasurementProtocolSecretsRequest], + ~.ListMeasurementProtocolSecretsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_measurement_protocol_secrets" not in self._stubs: + self._stubs[ + "list_measurement_protocol_secrets" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListMeasurementProtocolSecrets", + request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, + response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, + ) + return self._stubs["list_measurement_protocol_secrets"] + + @property + def create_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.CreateMeasurementProtocolSecretRequest], + resources.MeasurementProtocolSecret, + ]: + r"""Return a callable for the create measurement protocol + secret method over gRPC. + + Creates a measurement protocol secret. + + Returns: + Callable[[~.CreateMeasurementProtocolSecretRequest], + ~.MeasurementProtocolSecret]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_measurement_protocol_secret" not in self._stubs: + self._stubs[ + "create_measurement_protocol_secret" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateMeasurementProtocolSecret", + request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs["create_measurement_protocol_secret"] + + @property + def delete_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.DeleteMeasurementProtocolSecretRequest], empty_pb2.Empty + ]: + r"""Return a callable for the delete measurement protocol + secret method over gRPC. + + Deletes target MeasurementProtocolSecret. + + Returns: + Callable[[~.DeleteMeasurementProtocolSecretRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_measurement_protocol_secret" not in self._stubs: + self._stubs[ + "delete_measurement_protocol_secret" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteMeasurementProtocolSecret", + request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_measurement_protocol_secret"] + + @property + def update_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.UpdateMeasurementProtocolSecretRequest], + resources.MeasurementProtocolSecret, + ]: + r"""Return a callable for the update measurement protocol + secret method over gRPC. + + Updates a measurement protocol secret. + + Returns: + Callable[[~.UpdateMeasurementProtocolSecretRequest], + ~.MeasurementProtocolSecret]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_measurement_protocol_secret" not in self._stubs: + self._stubs[ + "update_measurement_protocol_secret" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateMeasurementProtocolSecret", + request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs["update_measurement_protocol_secret"] + + @property + def search_change_history_events( + self, + ) -> Callable[ + [analytics_admin.SearchChangeHistoryEventsRequest], + analytics_admin.SearchChangeHistoryEventsResponse, + ]: + r"""Return a callable for the search change history events method over gRPC. + + Searches through all changes to an account or its + children given the specified set of filters. + + Returns: + Callable[[~.SearchChangeHistoryEventsRequest], + ~.SearchChangeHistoryEventsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "search_change_history_events" not in self._stubs: + self._stubs["search_change_history_events"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/SearchChangeHistoryEvents", + request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, + response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, + ) + return self._stubs["search_change_history_events"] + + @property + def get_google_signals_settings( + self, + ) -> Callable[ + [analytics_admin.GetGoogleSignalsSettingsRequest], + resources.GoogleSignalsSettings, + ]: + r"""Return a callable for the get google signals settings method over gRPC. + + Lookup for Google Signals settings for a property. + + Returns: + Callable[[~.GetGoogleSignalsSettingsRequest], + ~.GoogleSignalsSettings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_google_signals_settings" not in self._stubs: + self._stubs["get_google_signals_settings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGoogleSignalsSettings", + request_serializer=analytics_admin.GetGoogleSignalsSettingsRequest.serialize, + response_deserializer=resources.GoogleSignalsSettings.deserialize, + ) + return self._stubs["get_google_signals_settings"] + + @property + def update_google_signals_settings( + self, + ) -> Callable[ + [analytics_admin.UpdateGoogleSignalsSettingsRequest], + resources.GoogleSignalsSettings, + ]: + r"""Return a callable for the update google signals settings method over gRPC. + + Updates Google Signals settings for a property. + + Returns: + Callable[[~.UpdateGoogleSignalsSettingsRequest], + ~.GoogleSignalsSettings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_google_signals_settings" not in self._stubs: + self._stubs[ + "update_google_signals_settings" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleSignalsSettings", + request_serializer=analytics_admin.UpdateGoogleSignalsSettingsRequest.serialize, + response_deserializer=resources.GoogleSignalsSettings.deserialize, + ) + return self._stubs["update_google_signals_settings"] + + @property + def create_conversion_event( + self, + ) -> Callable[ + [analytics_admin.CreateConversionEventRequest], resources.ConversionEvent + ]: + r"""Return a callable for the create conversion event method over gRPC. + + Creates a conversion event with the specified + attributes. + + Returns: + Callable[[~.CreateConversionEventRequest], + ~.ConversionEvent]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_conversion_event" not in self._stubs: + self._stubs["create_conversion_event"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConversionEvent", + request_serializer=analytics_admin.CreateConversionEventRequest.serialize, + response_deserializer=resources.ConversionEvent.deserialize, + ) + return self._stubs["create_conversion_event"] + + @property + def get_conversion_event( + self, + ) -> Callable[ + [analytics_admin.GetConversionEventRequest], resources.ConversionEvent + ]: + r"""Return a callable for the get conversion event method over gRPC. + + Retrieve a single conversion event. + + Returns: + Callable[[~.GetConversionEventRequest], + ~.ConversionEvent]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_conversion_event" not in self._stubs: + self._stubs["get_conversion_event"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetConversionEvent", + request_serializer=analytics_admin.GetConversionEventRequest.serialize, + response_deserializer=resources.ConversionEvent.deserialize, + ) + return self._stubs["get_conversion_event"] + + @property + def delete_conversion_event( + self, + ) -> Callable[[analytics_admin.DeleteConversionEventRequest], empty_pb2.Empty]: + r"""Return a callable for the delete conversion event method over gRPC. + + Deletes a conversion event in a property. + + Returns: + Callable[[~.DeleteConversionEventRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_conversion_event" not in self._stubs: + self._stubs["delete_conversion_event"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConversionEvent", + request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_conversion_event"] + + @property + def list_conversion_events( + self, + ) -> Callable[ + [analytics_admin.ListConversionEventsRequest], + analytics_admin.ListConversionEventsResponse, + ]: + r"""Return a callable for the list conversion events method over gRPC. + + Returns a list of conversion events in the specified + parent property. + Returns an empty list if no conversion events are found. + + Returns: + Callable[[~.ListConversionEventsRequest], + ~.ListConversionEventsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_conversion_events" not in self._stubs: + self._stubs["list_conversion_events"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConversionEvents", + request_serializer=analytics_admin.ListConversionEventsRequest.serialize, + response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, + ) + return self._stubs["list_conversion_events"] + + @property + def create_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.CreateCustomDimensionRequest], resources.CustomDimension + ]: + r"""Return a callable for the create custom dimension method over gRPC. + + Creates a CustomDimension. + + Returns: + Callable[[~.CreateCustomDimensionRequest], + ~.CustomDimension]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_custom_dimension" not in self._stubs: + self._stubs["create_custom_dimension"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomDimension", + request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs["create_custom_dimension"] + + @property + def update_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.UpdateCustomDimensionRequest], resources.CustomDimension + ]: + r"""Return a callable for the update custom dimension method over gRPC. + + Updates a CustomDimension on a property. + + Returns: + Callable[[~.UpdateCustomDimensionRequest], + ~.CustomDimension]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_custom_dimension" not in self._stubs: + self._stubs["update_custom_dimension"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomDimension", + request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs["update_custom_dimension"] + + @property + def list_custom_dimensions( + self, + ) -> Callable[ + [analytics_admin.ListCustomDimensionsRequest], + analytics_admin.ListCustomDimensionsResponse, + ]: + r"""Return a callable for the list custom dimensions method over gRPC. + + Lists CustomDimensions on a property. + + Returns: + Callable[[~.ListCustomDimensionsRequest], + ~.ListCustomDimensionsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_custom_dimensions" not in self._stubs: + self._stubs["list_custom_dimensions"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomDimensions", + request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, + response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, + ) + return self._stubs["list_custom_dimensions"] + + @property + def archive_custom_dimension( + self, + ) -> Callable[[analytics_admin.ArchiveCustomDimensionRequest], empty_pb2.Empty]: + r"""Return a callable for the archive custom dimension method over gRPC. + + Archives a CustomDimension on a property. + + Returns: + Callable[[~.ArchiveCustomDimensionRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "archive_custom_dimension" not in self._stubs: + self._stubs["archive_custom_dimension"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomDimension", + request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["archive_custom_dimension"] + + @property + def get_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.GetCustomDimensionRequest], resources.CustomDimension + ]: + r"""Return a callable for the get custom dimension method over gRPC. + + Lookup for a single CustomDimension. + + Returns: + Callable[[~.GetCustomDimensionRequest], + ~.CustomDimension]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_custom_dimension" not in self._stubs: + self._stubs["get_custom_dimension"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomDimension", + request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs["get_custom_dimension"] + + @property + def create_custom_metric( + self, + ) -> Callable[[analytics_admin.CreateCustomMetricRequest], resources.CustomMetric]: + r"""Return a callable for the create custom metric method over gRPC. + + Creates a CustomMetric. + + Returns: + Callable[[~.CreateCustomMetricRequest], + ~.CustomMetric]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_custom_metric" not in self._stubs: + self._stubs["create_custom_metric"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomMetric", + request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs["create_custom_metric"] + + @property + def update_custom_metric( + self, + ) -> Callable[[analytics_admin.UpdateCustomMetricRequest], resources.CustomMetric]: + r"""Return a callable for the update custom metric method over gRPC. + + Updates a CustomMetric on a property. + + Returns: + Callable[[~.UpdateCustomMetricRequest], + ~.CustomMetric]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_custom_metric" not in self._stubs: + self._stubs["update_custom_metric"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomMetric", + request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs["update_custom_metric"] + + @property + def list_custom_metrics( + self, + ) -> Callable[ + [analytics_admin.ListCustomMetricsRequest], + analytics_admin.ListCustomMetricsResponse, + ]: + r"""Return a callable for the list custom metrics method over gRPC. + + Lists CustomMetrics on a property. + + Returns: + Callable[[~.ListCustomMetricsRequest], + ~.ListCustomMetricsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_custom_metrics" not in self._stubs: + self._stubs["list_custom_metrics"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomMetrics", + request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, + response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, + ) + return self._stubs["list_custom_metrics"] + + @property + def archive_custom_metric( + self, + ) -> Callable[[analytics_admin.ArchiveCustomMetricRequest], empty_pb2.Empty]: + r"""Return a callable for the archive custom metric method over gRPC. + + Archives a CustomMetric on a property. + + Returns: + Callable[[~.ArchiveCustomMetricRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "archive_custom_metric" not in self._stubs: + self._stubs["archive_custom_metric"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomMetric", + request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["archive_custom_metric"] + + @property + def get_custom_metric( + self, + ) -> Callable[[analytics_admin.GetCustomMetricRequest], resources.CustomMetric]: + r"""Return a callable for the get custom metric method over gRPC. + + Lookup for a single CustomMetric. + + Returns: + Callable[[~.GetCustomMetricRequest], + ~.CustomMetric]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_custom_metric" not in self._stubs: + self._stubs["get_custom_metric"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomMetric", + request_serializer=analytics_admin.GetCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs["get_custom_metric"] + __all__ = ("AnalyticsAdminServiceGrpcTransport",) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py index d6eaccb82c54..de690c94de03 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import resources -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore from .base import AnalyticsAdminServiceTransport, DEFAULT_CLIENT_INFO from .grpc import AnalyticsAdminServiceGrpcTransport @@ -55,7 +52,7 @@ class AnalyticsAdminServiceGrpcAsyncIOTransport(AnalyticsAdminServiceTransport): def create_channel( cls, host: str = "analyticsadmin.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -82,13 +79,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -96,7 +95,7 @@ def __init__( self, *, host: str = "analyticsadmin.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -110,7 +109,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -168,7 +168,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -289,7 +288,7 @@ def list_accounts( @property def delete_account( self, - ) -> Callable[[analytics_admin.DeleteAccountRequest], Awaitable[empty.Empty]]: + ) -> Callable[[analytics_admin.DeleteAccountRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete account method over gRPC. Marks target Account as soft-deleted (ie: "trashed") @@ -318,7 +317,7 @@ def delete_account( self._stubs["delete_account"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccount", request_serializer=analytics_admin.DeleteAccountRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_account"] @@ -500,7 +499,9 @@ def create_property( @property def delete_property( self, - ) -> Callable[[analytics_admin.DeletePropertyRequest], Awaitable[empty.Empty]]: + ) -> Callable[ + [analytics_admin.DeletePropertyRequest], Awaitable[resources.Property] + ]: r"""Return a callable for the delete property method over gRPC. Marks target Property as soft-deleted (ie: "trashed") @@ -518,7 +519,7 @@ def delete_property( Returns: Callable[[~.DeletePropertyRequest], - Awaitable[~.Empty]]: + Awaitable[~.Property]]: A function that, when called, will call the underlying RPC on the server. """ @@ -530,7 +531,7 @@ def delete_property( self._stubs["delete_property"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteProperty", request_serializer=analytics_admin.DeletePropertyRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=resources.Property.deserialize, ) return self._stubs["delete_property"] @@ -812,7 +813,7 @@ def batch_update_user_links( @property def delete_user_link( self, - ) -> Callable[[analytics_admin.DeleteUserLinkRequest], Awaitable[empty.Empty]]: + ) -> Callable[[analytics_admin.DeleteUserLinkRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete user link method over gRPC. Deletes a user link on an account or property. @@ -831,7 +832,7 @@ def delete_user_link( self._stubs["delete_user_link"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteUserLink", request_serializer=analytics_admin.DeleteUserLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_user_link"] @@ -839,7 +840,7 @@ def delete_user_link( def batch_delete_user_links( self, ) -> Callable[ - [analytics_admin.BatchDeleteUserLinksRequest], Awaitable[empty.Empty] + [analytics_admin.BatchDeleteUserLinksRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the batch delete user links method over gRPC. @@ -860,7 +861,7 @@ def batch_delete_user_links( self._stubs["batch_delete_user_links"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteUserLinks", request_serializer=analytics_admin.BatchDeleteUserLinksRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["batch_delete_user_links"] @@ -895,7 +896,9 @@ def get_web_data_stream( @property def delete_web_data_stream( self, - ) -> Callable[[analytics_admin.DeleteWebDataStreamRequest], Awaitable[empty.Empty]]: + ) -> Callable[ + [analytics_admin.DeleteWebDataStreamRequest], Awaitable[empty_pb2.Empty] + ]: r"""Return a callable for the delete web data stream method over gRPC. Deletes a web stream on a property. @@ -914,7 +917,7 @@ def delete_web_data_stream( self._stubs["delete_web_data_stream"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteWebDataStream", request_serializer=analytics_admin.DeleteWebDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_web_data_stream"] @@ -1041,7 +1044,7 @@ def get_ios_app_data_stream( def delete_ios_app_data_stream( self, ) -> Callable[ - [analytics_admin.DeleteIosAppDataStreamRequest], Awaitable[empty.Empty] + [analytics_admin.DeleteIosAppDataStreamRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the delete ios app data stream method over gRPC. @@ -1061,7 +1064,7 @@ def delete_ios_app_data_stream( self._stubs["delete_ios_app_data_stream"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteIosAppDataStream", request_serializer=analytics_admin.DeleteIosAppDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_ios_app_data_stream"] @@ -1094,44 +1097,6 @@ def update_ios_app_data_stream( ) return self._stubs["update_ios_app_data_stream"] - @property - def create_ios_app_data_stream( - self, - ) -> Callable[ - [analytics_admin.CreateIosAppDataStreamRequest], - Awaitable[resources.IosAppDataStream], - ]: - r"""Return a callable for the create ios app data stream method over gRPC. - - Creates an iOS app stream with the specified location - and attributes. - Note that an iOS app stream must be linked to a Firebase - app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Returns: - Callable[[~.CreateIosAppDataStreamRequest], - Awaitable[~.IosAppDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_ios_app_data_stream" not in self._stubs: - self._stubs["create_ios_app_data_stream"] = self.grpc_channel.unary_unary( - "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateIosAppDataStream", - request_serializer=analytics_admin.CreateIosAppDataStreamRequest.serialize, - response_deserializer=resources.IosAppDataStream.deserialize, - ) - return self._stubs["create_ios_app_data_stream"] - @property def list_ios_app_data_streams( self, @@ -1198,7 +1163,7 @@ def get_android_app_data_stream( def delete_android_app_data_stream( self, ) -> Callable[ - [analytics_admin.DeleteAndroidAppDataStreamRequest], Awaitable[empty.Empty] + [analytics_admin.DeleteAndroidAppDataStreamRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the delete android app data stream method over gRPC. @@ -1220,7 +1185,7 @@ def delete_android_app_data_stream( ] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAndroidAppDataStream", request_serializer=analytics_admin.DeleteAndroidAppDataStreamRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_android_app_data_stream"] @@ -1255,46 +1220,6 @@ def update_android_app_data_stream( ) return self._stubs["update_android_app_data_stream"] - @property - def create_android_app_data_stream( - self, - ) -> Callable[ - [analytics_admin.CreateAndroidAppDataStreamRequest], - Awaitable[resources.AndroidAppDataStream], - ]: - r"""Return a callable for the create android app data stream method over gRPC. - - Creates an Android app stream with the specified - location and attributes. - Note that an Android app stream must be linked to a - Firebase app to receive traffic. - - To create a working app stream, make sure your property - is linked to a Firebase project. Then, use the Firebase - API to create a Firebase app, which will also create an - appropriate data stream in Analytics (may take up to 24 - hours). - - Returns: - Callable[[~.CreateAndroidAppDataStreamRequest], - Awaitable[~.AndroidAppDataStream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "create_android_app_data_stream" not in self._stubs: - self._stubs[ - "create_android_app_data_stream" - ] = self.grpc_channel.unary_unary( - "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAndroidAppDataStream", - request_serializer=analytics_admin.CreateAndroidAppDataStreamRequest.serialize, - response_deserializer=resources.AndroidAppDataStream.deserialize, - ) - return self._stubs["create_android_app_data_stream"] - @property def list_android_app_data_streams( self, @@ -1458,7 +1383,9 @@ def update_firebase_link( @property def delete_firebase_link( self, - ) -> Callable[[analytics_admin.DeleteFirebaseLinkRequest], Awaitable[empty.Empty]]: + ) -> Callable[ + [analytics_admin.DeleteFirebaseLinkRequest], Awaitable[empty_pb2.Empty] + ]: r"""Return a callable for the delete firebase link method over gRPC. Deletes a FirebaseLink on a property @@ -1477,7 +1404,7 @@ def delete_firebase_link( self._stubs["delete_firebase_link"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteFirebaseLink", request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_firebase_link"] @@ -1599,7 +1526,9 @@ def update_google_ads_link( @property def delete_google_ads_link( self, - ) -> Callable[[analytics_admin.DeleteGoogleAdsLinkRequest], Awaitable[empty.Empty]]: + ) -> Callable[ + [analytics_admin.DeleteGoogleAdsLinkRequest], Awaitable[empty_pb2.Empty] + ]: r"""Return a callable for the delete google ads link method over gRPC. Deletes a GoogleAdsLink on a property @@ -1618,7 +1547,7 @@ def delete_google_ads_link( self._stubs["delete_google_ads_link"] = self.grpc_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteGoogleAdsLink", request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_google_ads_link"] @@ -1681,5 +1610,659 @@ def get_data_sharing_settings( ) return self._stubs["get_data_sharing_settings"] + @property + def get_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.GetMeasurementProtocolSecretRequest], + Awaitable[resources.MeasurementProtocolSecret], + ]: + r"""Return a callable for the get measurement protocol + secret method over gRPC. + + Lookup for a single "GA4" MeasurementProtocolSecret. + + Returns: + Callable[[~.GetMeasurementProtocolSecretRequest], + Awaitable[~.MeasurementProtocolSecret]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_measurement_protocol_secret" not in self._stubs: + self._stubs[ + "get_measurement_protocol_secret" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetMeasurementProtocolSecret", + request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs["get_measurement_protocol_secret"] + + @property + def list_measurement_protocol_secrets( + self, + ) -> Callable[ + [analytics_admin.ListMeasurementProtocolSecretsRequest], + Awaitable[analytics_admin.ListMeasurementProtocolSecretsResponse], + ]: + r"""Return a callable for the list measurement protocol + secrets method over gRPC. + + Returns child MeasurementProtocolSecrets under the + specified parent Property. + + Returns: + Callable[[~.ListMeasurementProtocolSecretsRequest], + Awaitable[~.ListMeasurementProtocolSecretsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_measurement_protocol_secrets" not in self._stubs: + self._stubs[ + "list_measurement_protocol_secrets" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListMeasurementProtocolSecrets", + request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, + response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, + ) + return self._stubs["list_measurement_protocol_secrets"] + + @property + def create_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.CreateMeasurementProtocolSecretRequest], + Awaitable[resources.MeasurementProtocolSecret], + ]: + r"""Return a callable for the create measurement protocol + secret method over gRPC. + + Creates a measurement protocol secret. + + Returns: + Callable[[~.CreateMeasurementProtocolSecretRequest], + Awaitable[~.MeasurementProtocolSecret]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_measurement_protocol_secret" not in self._stubs: + self._stubs[ + "create_measurement_protocol_secret" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateMeasurementProtocolSecret", + request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs["create_measurement_protocol_secret"] + + @property + def delete_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.DeleteMeasurementProtocolSecretRequest], + Awaitable[empty_pb2.Empty], + ]: + r"""Return a callable for the delete measurement protocol + secret method over gRPC. + + Deletes target MeasurementProtocolSecret. + + Returns: + Callable[[~.DeleteMeasurementProtocolSecretRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_measurement_protocol_secret" not in self._stubs: + self._stubs[ + "delete_measurement_protocol_secret" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteMeasurementProtocolSecret", + request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_measurement_protocol_secret"] + + @property + def update_measurement_protocol_secret( + self, + ) -> Callable[ + [analytics_admin.UpdateMeasurementProtocolSecretRequest], + Awaitable[resources.MeasurementProtocolSecret], + ]: + r"""Return a callable for the update measurement protocol + secret method over gRPC. + + Updates a measurement protocol secret. + + Returns: + Callable[[~.UpdateMeasurementProtocolSecretRequest], + Awaitable[~.MeasurementProtocolSecret]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_measurement_protocol_secret" not in self._stubs: + self._stubs[ + "update_measurement_protocol_secret" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateMeasurementProtocolSecret", + request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, + response_deserializer=resources.MeasurementProtocolSecret.deserialize, + ) + return self._stubs["update_measurement_protocol_secret"] + + @property + def search_change_history_events( + self, + ) -> Callable[ + [analytics_admin.SearchChangeHistoryEventsRequest], + Awaitable[analytics_admin.SearchChangeHistoryEventsResponse], + ]: + r"""Return a callable for the search change history events method over gRPC. + + Searches through all changes to an account or its + children given the specified set of filters. + + Returns: + Callable[[~.SearchChangeHistoryEventsRequest], + Awaitable[~.SearchChangeHistoryEventsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "search_change_history_events" not in self._stubs: + self._stubs["search_change_history_events"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/SearchChangeHistoryEvents", + request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, + response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, + ) + return self._stubs["search_change_history_events"] + + @property + def get_google_signals_settings( + self, + ) -> Callable[ + [analytics_admin.GetGoogleSignalsSettingsRequest], + Awaitable[resources.GoogleSignalsSettings], + ]: + r"""Return a callable for the get google signals settings method over gRPC. + + Lookup for Google Signals settings for a property. + + Returns: + Callable[[~.GetGoogleSignalsSettingsRequest], + Awaitable[~.GoogleSignalsSettings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_google_signals_settings" not in self._stubs: + self._stubs["get_google_signals_settings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGoogleSignalsSettings", + request_serializer=analytics_admin.GetGoogleSignalsSettingsRequest.serialize, + response_deserializer=resources.GoogleSignalsSettings.deserialize, + ) + return self._stubs["get_google_signals_settings"] + + @property + def update_google_signals_settings( + self, + ) -> Callable[ + [analytics_admin.UpdateGoogleSignalsSettingsRequest], + Awaitable[resources.GoogleSignalsSettings], + ]: + r"""Return a callable for the update google signals settings method over gRPC. + + Updates Google Signals settings for a property. + + Returns: + Callable[[~.UpdateGoogleSignalsSettingsRequest], + Awaitable[~.GoogleSignalsSettings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_google_signals_settings" not in self._stubs: + self._stubs[ + "update_google_signals_settings" + ] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleSignalsSettings", + request_serializer=analytics_admin.UpdateGoogleSignalsSettingsRequest.serialize, + response_deserializer=resources.GoogleSignalsSettings.deserialize, + ) + return self._stubs["update_google_signals_settings"] + + @property + def create_conversion_event( + self, + ) -> Callable[ + [analytics_admin.CreateConversionEventRequest], + Awaitable[resources.ConversionEvent], + ]: + r"""Return a callable for the create conversion event method over gRPC. + + Creates a conversion event with the specified + attributes. + + Returns: + Callable[[~.CreateConversionEventRequest], + Awaitable[~.ConversionEvent]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_conversion_event" not in self._stubs: + self._stubs["create_conversion_event"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConversionEvent", + request_serializer=analytics_admin.CreateConversionEventRequest.serialize, + response_deserializer=resources.ConversionEvent.deserialize, + ) + return self._stubs["create_conversion_event"] + + @property + def get_conversion_event( + self, + ) -> Callable[ + [analytics_admin.GetConversionEventRequest], + Awaitable[resources.ConversionEvent], + ]: + r"""Return a callable for the get conversion event method over gRPC. + + Retrieve a single conversion event. + + Returns: + Callable[[~.GetConversionEventRequest], + Awaitable[~.ConversionEvent]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_conversion_event" not in self._stubs: + self._stubs["get_conversion_event"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetConversionEvent", + request_serializer=analytics_admin.GetConversionEventRequest.serialize, + response_deserializer=resources.ConversionEvent.deserialize, + ) + return self._stubs["get_conversion_event"] + + @property + def delete_conversion_event( + self, + ) -> Callable[ + [analytics_admin.DeleteConversionEventRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete conversion event method over gRPC. + + Deletes a conversion event in a property. + + Returns: + Callable[[~.DeleteConversionEventRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_conversion_event" not in self._stubs: + self._stubs["delete_conversion_event"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConversionEvent", + request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_conversion_event"] + + @property + def list_conversion_events( + self, + ) -> Callable[ + [analytics_admin.ListConversionEventsRequest], + Awaitable[analytics_admin.ListConversionEventsResponse], + ]: + r"""Return a callable for the list conversion events method over gRPC. + + Returns a list of conversion events in the specified + parent property. + Returns an empty list if no conversion events are found. + + Returns: + Callable[[~.ListConversionEventsRequest], + Awaitable[~.ListConversionEventsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_conversion_events" not in self._stubs: + self._stubs["list_conversion_events"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConversionEvents", + request_serializer=analytics_admin.ListConversionEventsRequest.serialize, + response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, + ) + return self._stubs["list_conversion_events"] + + @property + def create_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.CreateCustomDimensionRequest], + Awaitable[resources.CustomDimension], + ]: + r"""Return a callable for the create custom dimension method over gRPC. + + Creates a CustomDimension. + + Returns: + Callable[[~.CreateCustomDimensionRequest], + Awaitable[~.CustomDimension]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_custom_dimension" not in self._stubs: + self._stubs["create_custom_dimension"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomDimension", + request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs["create_custom_dimension"] + + @property + def update_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.UpdateCustomDimensionRequest], + Awaitable[resources.CustomDimension], + ]: + r"""Return a callable for the update custom dimension method over gRPC. + + Updates a CustomDimension on a property. + + Returns: + Callable[[~.UpdateCustomDimensionRequest], + Awaitable[~.CustomDimension]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_custom_dimension" not in self._stubs: + self._stubs["update_custom_dimension"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomDimension", + request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs["update_custom_dimension"] + + @property + def list_custom_dimensions( + self, + ) -> Callable[ + [analytics_admin.ListCustomDimensionsRequest], + Awaitable[analytics_admin.ListCustomDimensionsResponse], + ]: + r"""Return a callable for the list custom dimensions method over gRPC. + + Lists CustomDimensions on a property. + + Returns: + Callable[[~.ListCustomDimensionsRequest], + Awaitable[~.ListCustomDimensionsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_custom_dimensions" not in self._stubs: + self._stubs["list_custom_dimensions"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomDimensions", + request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, + response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, + ) + return self._stubs["list_custom_dimensions"] + + @property + def archive_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.ArchiveCustomDimensionRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the archive custom dimension method over gRPC. + + Archives a CustomDimension on a property. + + Returns: + Callable[[~.ArchiveCustomDimensionRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "archive_custom_dimension" not in self._stubs: + self._stubs["archive_custom_dimension"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomDimension", + request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["archive_custom_dimension"] + + @property + def get_custom_dimension( + self, + ) -> Callable[ + [analytics_admin.GetCustomDimensionRequest], + Awaitable[resources.CustomDimension], + ]: + r"""Return a callable for the get custom dimension method over gRPC. + + Lookup for a single CustomDimension. + + Returns: + Callable[[~.GetCustomDimensionRequest], + Awaitable[~.CustomDimension]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_custom_dimension" not in self._stubs: + self._stubs["get_custom_dimension"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomDimension", + request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, + response_deserializer=resources.CustomDimension.deserialize, + ) + return self._stubs["get_custom_dimension"] + + @property + def create_custom_metric( + self, + ) -> Callable[ + [analytics_admin.CreateCustomMetricRequest], Awaitable[resources.CustomMetric] + ]: + r"""Return a callable for the create custom metric method over gRPC. + + Creates a CustomMetric. + + Returns: + Callable[[~.CreateCustomMetricRequest], + Awaitable[~.CustomMetric]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_custom_metric" not in self._stubs: + self._stubs["create_custom_metric"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomMetric", + request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs["create_custom_metric"] + + @property + def update_custom_metric( + self, + ) -> Callable[ + [analytics_admin.UpdateCustomMetricRequest], Awaitable[resources.CustomMetric] + ]: + r"""Return a callable for the update custom metric method over gRPC. + + Updates a CustomMetric on a property. + + Returns: + Callable[[~.UpdateCustomMetricRequest], + Awaitable[~.CustomMetric]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_custom_metric" not in self._stubs: + self._stubs["update_custom_metric"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomMetric", + request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs["update_custom_metric"] + + @property + def list_custom_metrics( + self, + ) -> Callable[ + [analytics_admin.ListCustomMetricsRequest], + Awaitable[analytics_admin.ListCustomMetricsResponse], + ]: + r"""Return a callable for the list custom metrics method over gRPC. + + Lists CustomMetrics on a property. + + Returns: + Callable[[~.ListCustomMetricsRequest], + Awaitable[~.ListCustomMetricsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_custom_metrics" not in self._stubs: + self._stubs["list_custom_metrics"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomMetrics", + request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, + response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, + ) + return self._stubs["list_custom_metrics"] + + @property + def archive_custom_metric( + self, + ) -> Callable[ + [analytics_admin.ArchiveCustomMetricRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the archive custom metric method over gRPC. + + Archives a CustomMetric on a property. + + Returns: + Callable[[~.ArchiveCustomMetricRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "archive_custom_metric" not in self._stubs: + self._stubs["archive_custom_metric"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomMetric", + request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["archive_custom_metric"] + + @property + def get_custom_metric( + self, + ) -> Callable[ + [analytics_admin.GetCustomMetricRequest], Awaitable[resources.CustomMetric] + ]: + r"""Return a callable for the get custom metric method over gRPC. + + Lookup for a single CustomMetric. + + Returns: + Callable[[~.GetCustomMetricRequest], + Awaitable[~.CustomMetric]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_custom_metric" not in self._stubs: + self._stubs["get_custom_metric"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomMetric", + request_serializer=analytics_admin.GetCustomMetricRequest.serialize, + response_deserializer=resources.CustomMetric.deserialize, + ) + return self._stubs["get_custom_metric"] + __all__ = ("AnalyticsAdminServiceGrpcAsyncIOTransport",) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/__init__.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/__init__.py index c265fb038f64..11c0bcf0e342 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/__init__.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,8 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .analytics_admin import ( + ArchiveCustomDimensionRequest, + ArchiveCustomMetricRequest, AuditUserLinksRequest, AuditUserLinksResponse, BatchCreateUserLinksRequest, @@ -25,27 +25,36 @@ BatchGetUserLinksResponse, BatchUpdateUserLinksRequest, BatchUpdateUserLinksResponse, - CreateAndroidAppDataStreamRequest, + CreateConversionEventRequest, + CreateCustomDimensionRequest, + CreateCustomMetricRequest, CreateFirebaseLinkRequest, CreateGoogleAdsLinkRequest, - CreateIosAppDataStreamRequest, + CreateMeasurementProtocolSecretRequest, CreatePropertyRequest, CreateUserLinkRequest, CreateWebDataStreamRequest, DeleteAccountRequest, DeleteAndroidAppDataStreamRequest, + DeleteConversionEventRequest, DeleteFirebaseLinkRequest, DeleteGoogleAdsLinkRequest, DeleteIosAppDataStreamRequest, + DeleteMeasurementProtocolSecretRequest, DeletePropertyRequest, DeleteUserLinkRequest, DeleteWebDataStreamRequest, GetAccountRequest, GetAndroidAppDataStreamRequest, + GetConversionEventRequest, + GetCustomDimensionRequest, + GetCustomMetricRequest, GetDataSharingSettingsRequest, GetEnhancedMeasurementSettingsRequest, GetGlobalSiteTagRequest, + GetGoogleSignalsSettingsRequest, GetIosAppDataStreamRequest, + GetMeasurementProtocolSecretRequest, GetPropertyRequest, GetUserLinkRequest, GetWebDataStreamRequest, @@ -55,12 +64,20 @@ ListAccountSummariesResponse, ListAndroidAppDataStreamsRequest, ListAndroidAppDataStreamsResponse, + ListConversionEventsRequest, + ListConversionEventsResponse, + ListCustomDimensionsRequest, + ListCustomDimensionsResponse, + ListCustomMetricsRequest, + ListCustomMetricsResponse, ListFirebaseLinksRequest, ListFirebaseLinksResponse, ListGoogleAdsLinksRequest, ListGoogleAdsLinksResponse, ListIosAppDataStreamsRequest, ListIosAppDataStreamsResponse, + ListMeasurementProtocolSecretsRequest, + ListMeasurementProtocolSecretsResponse, ListPropertiesRequest, ListPropertiesResponse, ListUserLinksRequest, @@ -69,12 +86,18 @@ ListWebDataStreamsResponse, ProvisionAccountTicketRequest, ProvisionAccountTicketResponse, + SearchChangeHistoryEventsRequest, + SearchChangeHistoryEventsResponse, UpdateAccountRequest, UpdateAndroidAppDataStreamRequest, + UpdateCustomDimensionRequest, + UpdateCustomMetricRequest, UpdateEnhancedMeasurementSettingsRequest, UpdateFirebaseLinkRequest, UpdateGoogleAdsLinkRequest, + UpdateGoogleSignalsSettingsRequest, UpdateIosAppDataStreamRequest, + UpdateMeasurementProtocolSecretRequest, UpdatePropertyRequest, UpdateUserLinkRequest, UpdateWebDataStreamRequest, @@ -84,21 +107,35 @@ AccountSummary, AndroidAppDataStream, AuditUserLink, + ChangeHistoryChange, + ChangeHistoryEvent, + ConversionEvent, + CustomDimension, + CustomMetric, DataSharingSettings, EnhancedMeasurementSettings, FirebaseLink, GlobalSiteTag, GoogleAdsLink, + GoogleSignalsSettings, IosAppDataStream, + MeasurementProtocolSecret, Property, PropertySummary, UserLink, WebDataStream, + ActionType, + ActorType, + ChangeHistoryResourceType, + GoogleSignalsConsent, + GoogleSignalsState, IndustryCategory, MaximumUserAccess, ) __all__ = ( + "ArchiveCustomDimensionRequest", + "ArchiveCustomMetricRequest", "AuditUserLinksRequest", "AuditUserLinksResponse", "BatchCreateUserLinksRequest", @@ -108,27 +145,36 @@ "BatchGetUserLinksResponse", "BatchUpdateUserLinksRequest", "BatchUpdateUserLinksResponse", - "CreateAndroidAppDataStreamRequest", + "CreateConversionEventRequest", + "CreateCustomDimensionRequest", + "CreateCustomMetricRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", - "CreateIosAppDataStreamRequest", + "CreateMeasurementProtocolSecretRequest", "CreatePropertyRequest", "CreateUserLinkRequest", "CreateWebDataStreamRequest", "DeleteAccountRequest", "DeleteAndroidAppDataStreamRequest", + "DeleteConversionEventRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", "DeleteIosAppDataStreamRequest", + "DeleteMeasurementProtocolSecretRequest", "DeletePropertyRequest", "DeleteUserLinkRequest", "DeleteWebDataStreamRequest", "GetAccountRequest", "GetAndroidAppDataStreamRequest", + "GetConversionEventRequest", + "GetCustomDimensionRequest", + "GetCustomMetricRequest", "GetDataSharingSettingsRequest", "GetEnhancedMeasurementSettingsRequest", "GetGlobalSiteTagRequest", + "GetGoogleSignalsSettingsRequest", "GetIosAppDataStreamRequest", + "GetMeasurementProtocolSecretRequest", "GetPropertyRequest", "GetUserLinkRequest", "GetWebDataStreamRequest", @@ -138,12 +184,20 @@ "ListAccountSummariesResponse", "ListAndroidAppDataStreamsRequest", "ListAndroidAppDataStreamsResponse", + "ListConversionEventsRequest", + "ListConversionEventsResponse", + "ListCustomDimensionsRequest", + "ListCustomDimensionsResponse", + "ListCustomMetricsRequest", + "ListCustomMetricsResponse", "ListFirebaseLinksRequest", "ListFirebaseLinksResponse", "ListGoogleAdsLinksRequest", "ListGoogleAdsLinksResponse", "ListIosAppDataStreamsRequest", "ListIosAppDataStreamsResponse", + "ListMeasurementProtocolSecretsRequest", + "ListMeasurementProtocolSecretsResponse", "ListPropertiesRequest", "ListPropertiesResponse", "ListUserLinksRequest", @@ -152,12 +206,18 @@ "ListWebDataStreamsResponse", "ProvisionAccountTicketRequest", "ProvisionAccountTicketResponse", + "SearchChangeHistoryEventsRequest", + "SearchChangeHistoryEventsResponse", "UpdateAccountRequest", "UpdateAndroidAppDataStreamRequest", + "UpdateCustomDimensionRequest", + "UpdateCustomMetricRequest", "UpdateEnhancedMeasurementSettingsRequest", "UpdateFirebaseLinkRequest", "UpdateGoogleAdsLinkRequest", + "UpdateGoogleSignalsSettingsRequest", "UpdateIosAppDataStreamRequest", + "UpdateMeasurementProtocolSecretRequest", "UpdatePropertyRequest", "UpdateUserLinkRequest", "UpdateWebDataStreamRequest", @@ -165,16 +225,28 @@ "AccountSummary", "AndroidAppDataStream", "AuditUserLink", + "ChangeHistoryChange", + "ChangeHistoryEvent", + "ConversionEvent", + "CustomDimension", + "CustomMetric", "DataSharingSettings", "EnhancedMeasurementSettings", "FirebaseLink", "GlobalSiteTag", "GoogleAdsLink", + "GoogleSignalsSettings", "IosAppDataStream", + "MeasurementProtocolSecret", "Property", "PropertySummary", "UserLink", "WebDataStream", + "ActionType", + "ActorType", + "ChangeHistoryResourceType", + "GoogleSignalsConsent", + "GoogleSignalsState", "IndustryCategory", "MaximumUserAccess", ) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/analytics_admin.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/analytics_admin.py index c929b13d7f5d..de15ce1e2afd 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/analytics_admin.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/analytics_admin.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.analytics.admin_v1alpha.types import resources -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -62,13 +60,11 @@ "GetIosAppDataStreamRequest", "DeleteIosAppDataStreamRequest", "UpdateIosAppDataStreamRequest", - "CreateIosAppDataStreamRequest", "ListIosAppDataStreamsRequest", "ListIosAppDataStreamsResponse", "GetAndroidAppDataStreamRequest", "DeleteAndroidAppDataStreamRequest", "UpdateAndroidAppDataStreamRequest", - "CreateAndroidAppDataStreamRequest", "ListAndroidAppDataStreamsRequest", "ListAndroidAppDataStreamsResponse", "GetEnhancedMeasurementSettingsRequest", @@ -87,13 +83,39 @@ "GetDataSharingSettingsRequest", "ListAccountSummariesRequest", "ListAccountSummariesResponse", + "SearchChangeHistoryEventsRequest", + "SearchChangeHistoryEventsResponse", + "GetMeasurementProtocolSecretRequest", + "CreateMeasurementProtocolSecretRequest", + "DeleteMeasurementProtocolSecretRequest", + "UpdateMeasurementProtocolSecretRequest", + "ListMeasurementProtocolSecretsRequest", + "ListMeasurementProtocolSecretsResponse", + "GetGoogleSignalsSettingsRequest", + "UpdateGoogleSignalsSettingsRequest", + "CreateConversionEventRequest", + "GetConversionEventRequest", + "DeleteConversionEventRequest", + "ListConversionEventsRequest", + "ListConversionEventsResponse", + "CreateCustomDimensionRequest", + "UpdateCustomDimensionRequest", + "ListCustomDimensionsRequest", + "ListCustomDimensionsResponse", + "ArchiveCustomDimensionRequest", + "GetCustomDimensionRequest", + "CreateCustomMetricRequest", + "UpdateCustomMetricRequest", + "ListCustomMetricsRequest", + "ListCustomMetricsResponse", + "ArchiveCustomMetricRequest", + "GetCustomMetricRequest", }, ) class GetAccountRequest(proto.Message): r"""Request message for GetAccount RPC. - Attributes: name (str): Required. The name of the account to lookup. @@ -101,12 +123,11 @@ class GetAccountRequest(proto.Message): Example: "accounts/100". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListAccountsRequest(proto.Message): r"""Request message for ListAccounts RPC. - Attributes: page_size (int): The maximum number of resources to return. @@ -128,16 +149,13 @@ class ListAccountsRequest(proto.Message): deleted or not. """ - page_size = proto.Field(proto.INT32, number=1) - - page_token = proto.Field(proto.STRING, number=2) - - show_deleted = proto.Field(proto.BOOL, number=3) + page_size = proto.Field(proto.INT32, number=1,) + page_token = proto.Field(proto.STRING, number=2,) + show_deleted = proto.Field(proto.BOOL, number=3,) class ListAccountsResponse(proto.Message): r"""Request message for ListAccounts RPC. - Attributes: accounts (Sequence[google.analytics.admin_v1alpha.types.Account]): Results that were accessible to the caller. @@ -152,13 +170,11 @@ def raw_page(self): return self accounts = proto.RepeatedField(proto.MESSAGE, number=1, message=resources.Account,) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteAccountRequest(proto.Message): r"""Request message for DeleteAccount RPC. - Attributes: name (str): Required. The name of the Account to soft- @@ -166,12 +182,11 @@ class DeleteAccountRequest(proto.Message): Example: "accounts/100". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateAccountRequest(proto.Message): r"""Request message for UpdateAccount RPC. - Attributes: account (google.analytics.admin_v1alpha.types.Account): Required. The account to update. The account's ``name`` @@ -184,13 +199,13 @@ class UpdateAccountRequest(proto.Message): """ account = proto.Field(proto.MESSAGE, number=1, message=resources.Account,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class ProvisionAccountTicketRequest(proto.Message): r"""Request message for ProvisionAccountTicket RPC. - Attributes: account (google.analytics.admin_v1alpha.types.Account): The account to create. @@ -202,36 +217,32 @@ class ProvisionAccountTicketRequest(proto.Message): """ account = proto.Field(proto.MESSAGE, number=1, message=resources.Account,) - - redirect_uri = proto.Field(proto.STRING, number=2) + redirect_uri = proto.Field(proto.STRING, number=2,) class ProvisionAccountTicketResponse(proto.Message): r"""Response message for ProvisionAccountTicket RPC. - Attributes: account_ticket_id (str): The param to be passed in the ToS link. """ - account_ticket_id = proto.Field(proto.STRING, number=1) + account_ticket_id = proto.Field(proto.STRING, number=1,) class GetPropertyRequest(proto.Message): r"""Request message for GetProperty RPC. - Attributes: name (str): Required. The name of the property to lookup. Format: properties/{property_id} Example: "properties/1000". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListPropertiesRequest(proto.Message): r"""Request message for ListProperties RPC. - Attributes: filter (str): Required. An expression for filtering the results of the @@ -267,18 +278,14 @@ class ListPropertiesRequest(proto.Message): deleted or not. """ - filter = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - show_deleted = proto.Field(proto.BOOL, number=4) + filter = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + show_deleted = proto.Field(proto.BOOL, number=4,) class ListPropertiesResponse(proto.Message): r"""Response message for ListProperties RPC. - Attributes: properties (Sequence[google.analytics.admin_v1alpha.types.Property]): Results that matched the filter criteria and @@ -296,13 +303,11 @@ def raw_page(self): properties = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.Property, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdatePropertyRequest(proto.Message): r"""Request message for UpdateProperty RPC. - Attributes: property (google.analytics.admin_v1alpha.types.Property): Required. The property to update. The property's ``name`` @@ -315,13 +320,13 @@ class UpdatePropertyRequest(proto.Message): """ property = proto.Field(proto.MESSAGE, number=1, message=resources.Property,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class CreatePropertyRequest(proto.Message): r"""Request message for CreateProperty RPC. - Attributes: property (google.analytics.admin_v1alpha.types.Property): Required. The property to create. @@ -334,31 +339,28 @@ class CreatePropertyRequest(proto.Message): class DeletePropertyRequest(proto.Message): r"""Request message for DeleteProperty RPC. - Attributes: name (str): Required. The name of the Property to soft-delete. Format: properties/{property_id} Example: "properties/1000". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class GetUserLinkRequest(proto.Message): r"""Request message for GetUserLink RPC. - Attributes: name (str): Required. Example format: accounts/1234/userLinks/5678 """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class BatchGetUserLinksRequest(proto.Message): r"""Request message for BatchGetUserLinks RPC. - Attributes: parent (str): Required. The account or property that all @@ -373,14 +375,12 @@ class BatchGetUserLinksRequest(proto.Message): accounts/{accountId}/userLinks/{userLinkId} """ - parent = proto.Field(proto.STRING, number=1) - - names = proto.RepeatedField(proto.STRING, number=2) + parent = proto.Field(proto.STRING, number=1,) + names = proto.RepeatedField(proto.STRING, number=2,) class BatchGetUserLinksResponse(proto.Message): r"""Response message for BatchGetUserLinks RPC. - Attributes: user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): The requested user links. @@ -393,7 +393,6 @@ class BatchGetUserLinksResponse(proto.Message): class ListUserLinksRequest(proto.Message): r"""Request message for ListUserLinks RPC. - Attributes: parent (str): Required. Example format: accounts/1234 @@ -411,16 +410,13 @@ class ListUserLinksRequest(proto.Message): token. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListUserLinksResponse(proto.Message): r"""Response message for ListUserLinks RPC. - Attributes: user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): List of UserLinks. These will be ordered @@ -438,13 +434,11 @@ def raw_page(self): user_links = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.UserLink, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class AuditUserLinksRequest(proto.Message): r"""Request message for AuditUserLinks RPC. - Attributes: parent (str): Required. Example format: accounts/1234 @@ -462,16 +456,13 @@ class AuditUserLinksRequest(proto.Message): 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) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class AuditUserLinksResponse(proto.Message): r"""Response message for AuditUserLinks RPC. - Attributes: user_links (Sequence[google.analytics.admin_v1alpha.types.AuditUserLink]): List of AuditUserLinks. These will be ordered @@ -489,8 +480,7 @@ def raw_page(self): user_links = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.AuditUserLink, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class CreateUserLinkRequest(proto.Message): @@ -514,16 +504,13 @@ class CreateUserLinkRequest(proto.Message): Required. The user link to create. """ - parent = proto.Field(proto.STRING, number=1) - - notify_new_user = proto.Field(proto.BOOL, number=2) - + parent = proto.Field(proto.STRING, number=1,) + notify_new_user = proto.Field(proto.BOOL, number=2,) user_link = proto.Field(proto.MESSAGE, number=3, message=resources.UserLink,) class BatchCreateUserLinksRequest(proto.Message): r"""Request message for BatchCreateUserLinks RPC. - Attributes: parent (str): Required. The account or property that all @@ -543,10 +530,8 @@ class BatchCreateUserLinksRequest(proto.Message): can be created in a batch. """ - parent = proto.Field(proto.STRING, number=1) - - notify_new_users = proto.Field(proto.BOOL, number=2) - + parent = proto.Field(proto.STRING, number=1,) + notify_new_users = proto.Field(proto.BOOL, number=2,) requests = proto.RepeatedField( proto.MESSAGE, number=3, message="CreateUserLinkRequest", ) @@ -554,7 +539,6 @@ class BatchCreateUserLinksRequest(proto.Message): class BatchCreateUserLinksResponse(proto.Message): r"""Response message for BatchCreateUserLinks RPC. - Attributes: user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): The user links created. @@ -567,7 +551,6 @@ class BatchCreateUserLinksResponse(proto.Message): class UpdateUserLinkRequest(proto.Message): r"""Request message for UpdateUserLink RPC. - Attributes: user_link (google.analytics.admin_v1alpha.types.UserLink): Required. The user link to update. @@ -578,7 +561,6 @@ class UpdateUserLinkRequest(proto.Message): class BatchUpdateUserLinksRequest(proto.Message): r"""Request message for BatchUpdateUserLinks RPC. - Attributes: parent (str): Required. The account or property that all @@ -592,8 +574,7 @@ class BatchUpdateUserLinksRequest(proto.Message): can be updated in a batch. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) requests = proto.RepeatedField( proto.MESSAGE, number=2, message="UpdateUserLinkRequest", ) @@ -601,7 +582,6 @@ class BatchUpdateUserLinksRequest(proto.Message): class BatchUpdateUserLinksResponse(proto.Message): r"""Response message for BatchUpdateUserLinks RPC. - Attributes: user_links (Sequence[google.analytics.admin_v1alpha.types.UserLink]): The user links updated. @@ -614,19 +594,17 @@ class BatchUpdateUserLinksResponse(proto.Message): class DeleteUserLinkRequest(proto.Message): r"""Request message for DeleteUserLink RPC. - Attributes: name (str): Required. Example format: accounts/1234/userLinks/5678 """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class BatchDeleteUserLinksRequest(proto.Message): r"""Request message for BatchDeleteUserLinks RPC. - Attributes: parent (str): Required. The account or property that all @@ -640,8 +618,7 @@ class BatchDeleteUserLinksRequest(proto.Message): can be updated in a batch. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) requests = proto.RepeatedField( proto.MESSAGE, number=2, message="DeleteUserLinkRequest", ) @@ -649,7 +626,6 @@ class BatchDeleteUserLinksRequest(proto.Message): class GetWebDataStreamRequest(proto.Message): r"""Request message for GetWebDataStream RPC. - Attributes: name (str): Required. The name of the web data stream to lookup. Format: @@ -657,12 +633,11 @@ class GetWebDataStreamRequest(proto.Message): "properties/123/webDataStreams/456". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeleteWebDataStreamRequest(proto.Message): r"""Request message for DeleteWebDataStream RPC. - Attributes: name (str): Required. The name of the web data stream to delete. Format: @@ -670,12 +645,11 @@ class DeleteWebDataStreamRequest(proto.Message): "properties/123/webDataStreams/456". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateWebDataStreamRequest(proto.Message): r"""Request message for UpdateWebDataStream RPC. - Attributes: web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): Required. The web stream to update. The ``name`` field is @@ -690,13 +664,13 @@ class UpdateWebDataStreamRequest(proto.Message): web_data_stream = proto.Field( proto.MESSAGE, number=1, message=resources.WebDataStream, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class CreateWebDataStreamRequest(proto.Message): r"""Request message for CreateWebDataStream RPC. - Attributes: web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): Required. The web stream to create. @@ -709,13 +683,11 @@ class CreateWebDataStreamRequest(proto.Message): web_data_stream = proto.Field( proto.MESSAGE, number=1, message=resources.WebDataStream, ) - - parent = proto.Field(proto.STRING, number=2) + parent = proto.Field(proto.STRING, number=2,) class ListWebDataStreamsRequest(proto.Message): r"""Request message for ListWebDataStreams RPC. - Attributes: parent (str): Required. The name of the parent property. @@ -734,16 +706,13 @@ class ListWebDataStreamsRequest(proto.Message): 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) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListWebDataStreamsResponse(proto.Message): r"""Request message for ListWebDataStreams RPC. - Attributes: web_data_streams (Sequence[google.analytics.admin_v1alpha.types.WebDataStream]): Results that matched the filter criteria and @@ -761,13 +730,11 @@ def raw_page(self): web_data_streams = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.WebDataStream, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetIosAppDataStreamRequest(proto.Message): r"""Request message for GetIosAppDataStream RPC. - Attributes: name (str): Required. The name of the iOS app data stream to lookup. @@ -776,12 +743,11 @@ class GetIosAppDataStreamRequest(proto.Message): Example: "properties/123/iosAppDataStreams/456". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeleteIosAppDataStreamRequest(proto.Message): r"""Request message for DeleteIosAppDataStream RPC. - Attributes: name (str): Required. The name of the iOS app data stream to delete. @@ -790,12 +756,11 @@ class DeleteIosAppDataStreamRequest(proto.Message): Example: "properties/123/iosAppDataStreams/456". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateIosAppDataStreamRequest(proto.Message): r"""Request message for UpdateIosAppDataStream RPC. - Attributes: ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): Required. The iOS app stream to update. The ``name`` field @@ -810,32 +775,13 @@ class UpdateIosAppDataStreamRequest(proto.Message): ios_app_data_stream = proto.Field( proto.MESSAGE, number=1, message=resources.IosAppDataStream, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - -class CreateIosAppDataStreamRequest(proto.Message): - r"""Request message for CreateIosAppDataStream RPC. - - Attributes: - ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): - Required. The iOS app data stream to create. - parent (str): - Required. The parent resource where this ios - app data stream will be created. Format: - properties/123 - """ - - ios_app_data_stream = proto.Field( - proto.MESSAGE, number=1, message=resources.IosAppDataStream, + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) - parent = proto.Field(proto.STRING, number=2) - class ListIosAppDataStreamsRequest(proto.Message): r"""Request message for ListIosAppDataStreams RPC. - Attributes: parent (str): Required. The name of the parent property. @@ -854,16 +800,13 @@ class ListIosAppDataStreamsRequest(proto.Message): 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) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListIosAppDataStreamsResponse(proto.Message): r"""Request message for ListIosAppDataStreams RPC. - Attributes: ios_app_data_streams (Sequence[google.analytics.admin_v1alpha.types.IosAppDataStream]): Results that matched the filter criteria and @@ -881,13 +824,11 @@ def raw_page(self): ios_app_data_streams = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.IosAppDataStream, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetAndroidAppDataStreamRequest(proto.Message): r"""Request message for GetAndroidAppDataStream RPC. - Attributes: name (str): Required. The name of the android app data stream to lookup. @@ -896,12 +837,11 @@ class GetAndroidAppDataStreamRequest(proto.Message): Example: "properties/123/androidAppDataStreams/456". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeleteAndroidAppDataStreamRequest(proto.Message): r"""Request message for DeleteAndroidAppDataStream RPC. - Attributes: name (str): Required. The name of the android app data stream to delete. @@ -910,12 +850,11 @@ class DeleteAndroidAppDataStreamRequest(proto.Message): Example: "properties/123/androidAppDataStreams/456". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateAndroidAppDataStreamRequest(proto.Message): r"""Request message for UpdateAndroidAppDataStream RPC. - Attributes: android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): Required. The android app stream to update. The ``name`` @@ -931,32 +870,13 @@ class UpdateAndroidAppDataStreamRequest(proto.Message): android_app_data_stream = proto.Field( proto.MESSAGE, number=1, message=resources.AndroidAppDataStream, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - -class CreateAndroidAppDataStreamRequest(proto.Message): - r"""Request message for CreateAndroidAppDataStream RPC. - - Attributes: - android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): - Required. The android app stream to create. - parent (str): - Required. The parent resource where this - android app data stream will be created. Format: - properties/123 - """ - - android_app_data_stream = proto.Field( - proto.MESSAGE, number=1, message=resources.AndroidAppDataStream, + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) - parent = proto.Field(proto.STRING, number=2) - class ListAndroidAppDataStreamsRequest(proto.Message): r"""Request message for ListAndroidAppDataStreams RPC. - Attributes: parent (str): Required. The name of the parent property. @@ -974,16 +894,13 @@ class ListAndroidAppDataStreamsRequest(proto.Message): 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) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListAndroidAppDataStreamsResponse(proto.Message): r"""Request message for ListAndroidDataStreams RPC. - Attributes: android_app_data_streams (Sequence[google.analytics.admin_v1alpha.types.AndroidAppDataStream]): Results that matched the filter criteria and @@ -1001,13 +918,11 @@ def raw_page(self): android_app_data_streams = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.AndroidAppDataStream, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetEnhancedMeasurementSettingsRequest(proto.Message): r"""Request message for GetEnhancedMeasurementSettings RPC. - Attributes: name (str): Required. The name of the settings to lookup. Format: @@ -1016,12 +931,11 @@ class GetEnhancedMeasurementSettingsRequest(proto.Message): "properties/1000/webDataStreams/2000/enhancedMeasurementSettings". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateEnhancedMeasurementSettingsRequest(proto.Message): r"""Request message for UpdateEnhancedMeasurementSettings RPC. - Attributes: enhanced_measurement_settings (google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings): Required. The settings to update. The ``name`` field is used @@ -1036,13 +950,13 @@ class UpdateEnhancedMeasurementSettingsRequest(proto.Message): enhanced_measurement_settings = proto.Field( proto.MESSAGE, number=1, message=resources.EnhancedMeasurementSettings, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class CreateFirebaseLinkRequest(proto.Message): r"""Request message for CreateFirebaseLink RPC - Attributes: parent (str): Required. Format: properties/{property_id} Example: @@ -1051,8 +965,7 @@ class CreateFirebaseLinkRequest(proto.Message): Required. The Firebase link to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) firebase_link = proto.Field( proto.MESSAGE, number=2, message=resources.FirebaseLink, ) @@ -1060,7 +973,6 @@ class CreateFirebaseLinkRequest(proto.Message): class UpdateFirebaseLinkRequest(proto.Message): r"""Request message for UpdateFirebaseLink RPC - Attributes: firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): Required. The Firebase link to update. @@ -1074,13 +986,13 @@ class UpdateFirebaseLinkRequest(proto.Message): firebase_link = proto.Field( proto.MESSAGE, number=1, message=resources.FirebaseLink, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteFirebaseLinkRequest(proto.Message): r"""Request message for DeleteFirebaseLink RPC - Attributes: name (str): Required. Format: @@ -1088,12 +1000,11 @@ class DeleteFirebaseLinkRequest(proto.Message): Example: properties/1234/firebaseLinks/5678 """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListFirebaseLinksRequest(proto.Message): r"""Request message for ListFirebaseLinks RPC - Attributes: parent (str): Required. Format: properties/{property_id} Example: @@ -1113,16 +1024,13 @@ class ListFirebaseLinksRequest(proto.Message): 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) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListFirebaseLinksResponse(proto.Message): r"""Response message for ListFirebaseLinks RPC - Attributes: firebase_links (Sequence[google.analytics.admin_v1alpha.types.FirebaseLink]): List of FirebaseLinks. This will have at most @@ -1141,13 +1049,11 @@ def raw_page(self): firebase_links = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.FirebaseLink, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetGlobalSiteTagRequest(proto.Message): r"""Request message for GetGlobalSiteTag RPC. - Attributes: name (str): Required. The name of the site tag to lookup. Note that site @@ -1156,12 +1062,11 @@ class GetGlobalSiteTagRequest(proto.Message): Example: "properties/123/webDataStreams/456/globalSiteTag". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateGoogleAdsLinkRequest(proto.Message): r"""Request message for CreateGoogleAdsLink RPC - Attributes: parent (str): Required. Example format: properties/1234 @@ -1169,8 +1074,7 @@ class CreateGoogleAdsLinkRequest(proto.Message): Required. The GoogleAdsLink to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) google_ads_link = proto.Field( proto.MESSAGE, number=2, message=resources.GoogleAdsLink, ) @@ -1178,7 +1082,6 @@ class CreateGoogleAdsLinkRequest(proto.Message): class UpdateGoogleAdsLinkRequest(proto.Message): r"""Request message for UpdateGoogleAdsLink RPC - Attributes: google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): The GoogleAdsLink to update @@ -1192,25 +1095,24 @@ class UpdateGoogleAdsLinkRequest(proto.Message): google_ads_link = proto.Field( proto.MESSAGE, number=1, message=resources.GoogleAdsLink, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteGoogleAdsLinkRequest(proto.Message): r"""Request message for DeleteGoogleAdsLink RPC. - Attributes: name (str): Required. Example format: properties/1234/googleAdsLinks/5678 """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListGoogleAdsLinksRequest(proto.Message): r"""Request message for ListGoogleAdsLinks RPC. - Attributes: parent (str): Required. Example format: properties/1234 @@ -1229,16 +1131,13 @@ class ListGoogleAdsLinksRequest(proto.Message): 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) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListGoogleAdsLinksResponse(proto.Message): r"""Response message for ListGoogleAdsLinks RPC. - Attributes: google_ads_links (Sequence[google.analytics.admin_v1alpha.types.GoogleAdsLink]): List of GoogleAdsLinks. @@ -1255,13 +1154,11 @@ def raw_page(self): google_ads_links = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.GoogleAdsLink, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetDataSharingSettingsRequest(proto.Message): r"""Request message for GetDataSharingSettings RPC. - Attributes: name (str): Required. The name of the settings to lookup. @@ -1269,12 +1166,11 @@ class GetDataSharingSettingsRequest(proto.Message): Example: "accounts/1000/dataSharingSettings". """ - name = proto.Field(proto.STRING, number=1) + 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 @@ -1292,14 +1188,12 @@ class ListAccountSummariesRequest(proto.Message): that provided the page token. """ - page_size = proto.Field(proto.INT32, number=1) - - page_token = proto.Field(proto.STRING, number=2) + 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 @@ -1317,8 +1211,534 @@ def raw_page(self): account_summaries = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.AccountSummary, ) + next_page_token = proto.Field(proto.STRING, number=2,) + + +class SearchChangeHistoryEventsRequest(proto.Message): + r"""Request message for SearchChangeHistoryEvents RPC. + Attributes: + account (str): + Required. The account resource for which to + return change history resources. + property (str): + Optional. Resource name for a child property. + If set, only return changes made to this + property or its child resources. + resource_type (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryResourceType]): + Optional. If set, only return changes if they + are for a resource that matches at least one of + these types. + action (Sequence[google.analytics.admin_v1alpha.types.ActionType]): + Optional. If set, only return changes that + match one or more of these types of actions. + actor_email (Sequence[str]): + Optional. If set, only return changes if they + are made by a user in this list. + earliest_change_time (google.protobuf.timestamp_pb2.Timestamp): + Optional. If set, only return changes made + after this time (inclusive). + latest_change_time (google.protobuf.timestamp_pb2.Timestamp): + Optional. If set, only return changes made + before this time (inclusive). + page_size (int): + Optional. The maximum number of + ChangeHistoryEvent items to return. The service + may return fewer than this value, even if there + are additional pages. If unspecified, at most 50 + items will be returned. The maximum value is 200 + (higher values will be coerced to the maximum). + page_token (str): + Optional. A page token, received from a previous + ``SearchChangeHistoryEvents`` call. Provide this to retrieve + the subsequent page. When paginating, all other parameters + provided to ``SearchChangeHistoryEvents`` must match the + call that provided the page token. + """ + + account = proto.Field(proto.STRING, number=1,) + property = proto.Field(proto.STRING, number=2,) + resource_type = proto.RepeatedField( + proto.ENUM, number=3, enum=resources.ChangeHistoryResourceType, + ) + action = proto.RepeatedField(proto.ENUM, number=4, enum=resources.ActionType,) + actor_email = proto.RepeatedField(proto.STRING, number=5,) + earliest_change_time = proto.Field( + proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp, + ) + latest_change_time = proto.Field( + proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, + ) + page_size = proto.Field(proto.INT32, number=8,) + page_token = proto.Field(proto.STRING, number=9,) + + +class SearchChangeHistoryEventsResponse(proto.Message): + r"""Response message for SearchAccounts RPC. + Attributes: + change_history_events (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryEvent]): + Results that were accessible to the caller. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + change_history_events = proto.RepeatedField( + proto.MESSAGE, number=1, message=resources.ChangeHistoryEvent, + ) + next_page_token = proto.Field(proto.STRING, number=2,) + + +class GetMeasurementProtocolSecretRequest(proto.Message): + r"""Request message for GetMeasurementProtocolSecret RPC. + Attributes: + name (str): + Required. The name of the measurement + protocol secret to lookup. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) may be a + parent. + """ + + name = proto.Field(proto.STRING, number=1,) + + +class CreateMeasurementProtocolSecretRequest(proto.Message): + r"""Request message for CreateMeasurementProtocolSecret RPC + Attributes: + parent (str): + Required. The parent resource where this + secret will be created. Any type of stream + (WebDataStream, IosAppDataStream, + AndroidAppDataStream) may be a parent. + Format: + properties/{property}/webDataStreams/{webDataStream} + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + Required. The measurement protocol secret to + create. + """ + + parent = proto.Field(proto.STRING, number=1,) + measurement_protocol_secret = proto.Field( + proto.MESSAGE, number=2, message=resources.MeasurementProtocolSecret, + ) + + +class DeleteMeasurementProtocolSecretRequest(proto.Message): + r"""Request message for DeleteMeasurementProtocolSecret RPC + Attributes: + name (str): + Required. The name of the + MeasurementProtocolSecret to delete. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + Note: Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) may be a + parent. + """ + + name = proto.Field(proto.STRING, number=1,) + + +class UpdateMeasurementProtocolSecretRequest(proto.Message): + r"""Request message for UpdateMeasurementProtocolSecret RPC + Attributes: + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + Required. The measurement protocol secret to + update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. Omitted + fields will not be updated. + """ + + measurement_protocol_secret = proto.Field( + proto.MESSAGE, number=1, message=resources.MeasurementProtocolSecret, + ) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + + +class ListMeasurementProtocolSecretsRequest(proto.Message): + r"""Request message for ListMeasurementProtocolSecret RPC + Attributes: + parent (str): + Required. The resource name of the parent + stream. Any type of stream (WebDataStream, + IosAppDataStream, AndroidAppDataStream) may be a + parent. + Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets + page_size (int): + The maximum number of resources to return. + If unspecified, at most 10 resources will be + returned. The maximum value is 10. Higher values + will be coerced to the maximum. + page_token (str): + A page token, received from a previous + ``ListMeasurementProtocolSecrets`` call. Provide this to + retrieve the subsequent page. When paginating, all other + parameters provided to ``ListMeasurementProtocolSecrets`` + must match the call that provided the page token. + """ + + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + + +class ListMeasurementProtocolSecretsResponse(proto.Message): + r"""Response message for ListMeasurementProtocolSecret RPC + Attributes: + measurement_protocol_secrets (Sequence[google.analytics.admin_v1alpha.types.MeasurementProtocolSecret]): + A list of secrets for the parent stream + specified in the request. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + measurement_protocol_secrets = proto.RepeatedField( + proto.MESSAGE, number=1, message=resources.MeasurementProtocolSecret, + ) + next_page_token = proto.Field(proto.STRING, number=2,) + + +class GetGoogleSignalsSettingsRequest(proto.Message): + r"""Request message for GetGoogleSignalsSettings RPC + Attributes: + name (str): + Required. The name of the google signals + settings to retrieve. Format: + properties/{property}/googleSignalsSettings + """ + + name = proto.Field(proto.STRING, number=1,) + + +class UpdateGoogleSignalsSettingsRequest(proto.Message): + r"""Request message for UpdateGoogleSignalsSettings RPC + Attributes: + google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): + Required. The settings to update. The ``name`` field is used + to identify the settings to be updated. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Field names must + be in snake case (e.g., "field_to_update"). Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + google_signals_settings = proto.Field( + proto.MESSAGE, number=1, message=resources.GoogleSignalsSettings, + ) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + + +class CreateConversionEventRequest(proto.Message): + r"""Request message for CreateConversionEvent RPC + Attributes: + conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): + Required. The conversion event to create. + parent (str): + Required. The resource name of the parent + property where this conversion event will be + created. Format: properties/123 + """ + + conversion_event = proto.Field( + proto.MESSAGE, number=1, message=resources.ConversionEvent, + ) + parent = proto.Field(proto.STRING, number=2,) + + +class GetConversionEventRequest(proto.Message): + r"""Request message for GetConversionEvent RPC + Attributes: + name (str): + Required. The resource name of the conversion event to + retrieve. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/456". + """ + + name = proto.Field(proto.STRING, number=1,) + + +class DeleteConversionEventRequest(proto.Message): + r"""Request message for DeleteConversionEvent RPC + Attributes: + name (str): + Required. The resource name of the conversion event to + delete. Format: + properties/{property}/conversionEvents/{conversion_event} + Example: "properties/123/conversionEvents/456". + """ + + name = proto.Field(proto.STRING, number=1,) + + +class ListConversionEventsRequest(proto.Message): + r"""Request message for ListConversionEvents RPC + Attributes: + parent (str): + Required. The resource name of the parent + property. Example: 'properties/123' + page_size (int): + The maximum number of resources to return. + If unspecified, at most 50 resources will be + returned. The maximum value is 200; (higher + values will be coerced to the maximum) + page_token (str): + A page token, received from a previous + ``ListConversionEvents`` call. Provide this to retrieve the + subsequent page. When paginating, all other parameters + provided to ``ListConversionEvents`` must match the call + that provided the page token. + """ + + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + + +class ListConversionEventsResponse(proto.Message): + r"""Response message for ListConversionEvents RPC. + Attributes: + conversion_events (Sequence[google.analytics.admin_v1alpha.types.ConversionEvent]): + The requested conversion events + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + conversion_events = proto.RepeatedField( + proto.MESSAGE, number=1, message=resources.ConversionEvent, + ) + next_page_token = proto.Field(proto.STRING, number=2,) + + +class CreateCustomDimensionRequest(proto.Message): + r"""Request message for CreateCustomDimension RPC. + Attributes: + parent (str): + Required. Example format: properties/1234 + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + Required. The CustomDimension to create. + """ + + parent = proto.Field(proto.STRING, number=1,) + custom_dimension = proto.Field( + proto.MESSAGE, number=2, message=resources.CustomDimension, + ) + + +class UpdateCustomDimensionRequest(proto.Message): + r"""Request message for UpdateCustomDimension RPC. + Attributes: + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + The CustomDimension to update + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + custom_dimension = proto.Field( + proto.MESSAGE, number=1, message=resources.CustomDimension, + ) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + + +class ListCustomDimensionsRequest(proto.Message): + r"""Request message for ListCustomDimensions RPC. + Attributes: + parent (str): + Required. Example format: properties/1234 + page_size (int): + The maximum number of resources to return. + If unspecified, at most 50 resources will be + returned. The maximum value is 200 (higher + values will be coerced to the maximum). + page_token (str): + A page token, received from a previous + ``ListCustomDimensions`` call. Provide this to retrieve the + subsequent page. + + When paginating, all other parameters provided to + ``ListCustomDimensions`` must match the call that provided + the page token. + """ + + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + + +class ListCustomDimensionsResponse(proto.Message): + r"""Response message for ListCustomDimensions RPC. + Attributes: + custom_dimensions (Sequence[google.analytics.admin_v1alpha.types.CustomDimension]): + List of CustomDimensions. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + custom_dimensions = proto.RepeatedField( + proto.MESSAGE, number=1, message=resources.CustomDimension, + ) + next_page_token = proto.Field(proto.STRING, number=2,) + + +class ArchiveCustomDimensionRequest(proto.Message): + r"""Request message for ArchiveCustomDimension RPC. + Attributes: + name (str): + Required. The name of the CustomDimension to + archive. Example format: + properties/1234/customDimensions/5678 + """ + + name = proto.Field(proto.STRING, number=1,) + + +class GetCustomDimensionRequest(proto.Message): + r"""Request message for GetCustomDimension RPC. + Attributes: + name (str): + Required. The name of the CustomDimension to + get. Example format: + properties/1234/customDimensions/5678 + """ + + name = proto.Field(proto.STRING, number=1,) + + +class CreateCustomMetricRequest(proto.Message): + r"""Request message for CreateCustomMetric RPC. + Attributes: + parent (str): + Required. Example format: properties/1234 + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + Required. The CustomMetric to create. + """ + + parent = proto.Field(proto.STRING, number=1,) + custom_metric = proto.Field( + proto.MESSAGE, number=2, message=resources.CustomMetric, + ) + + +class UpdateCustomMetricRequest(proto.Message): + r"""Request message for UpdateCustomMetric RPC. + Attributes: + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + The CustomMetric to update + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. Omitted fields + will not be updated. To replace the entire entity, use one + path with the string "*" to match all fields. + """ + + custom_metric = proto.Field( + proto.MESSAGE, number=1, message=resources.CustomMetric, + ) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + + +class ListCustomMetricsRequest(proto.Message): + r"""Request message for ListCustomMetrics RPC. + Attributes: + parent (str): + Required. Example format: properties/1234 + page_size (int): + The maximum number of resources to return. + If unspecified, at most 50 resources will be + returned. The maximum value is 200 (higher + values will be coerced to the maximum). + page_token (str): + A page token, received from a previous ``ListCustomMetrics`` + call. Provide this to retrieve the subsequent page. + + When paginating, all other parameters provided to + ``ListCustomMetrics`` must match the call that provided the + page token. + """ + + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + + +class ListCustomMetricsResponse(proto.Message): + r"""Response message for ListCustomMetrics RPC. + Attributes: + custom_metrics (Sequence[google.analytics.admin_v1alpha.types.CustomMetric]): + List of CustomMetrics. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + custom_metrics = proto.RepeatedField( + proto.MESSAGE, number=1, message=resources.CustomMetric, + ) + next_page_token = proto.Field(proto.STRING, number=2,) + + +class ArchiveCustomMetricRequest(proto.Message): + r"""Request message for ArchiveCustomMetric RPC. + Attributes: + name (str): + Required. The name of the CustomMetric to + archive. Example format: + properties/1234/customMetrics/5678 + """ + + name = proto.Field(proto.STRING, number=1,) + + +class GetCustomMetricRequest(proto.Message): + r"""Request message for GetCustomMetric RPC. + Attributes: + name (str): + Required. The name of the CustomMetric to + get. Example format: + properties/1234/customMetrics/5678 + """ - next_page_token = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/resources.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/resources.py index 9290e7cd8501..1af1d10838eb 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/resources.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/types/resources.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore __protobuf__ = proto.module( @@ -27,6 +24,11 @@ manifest={ "MaximumUserAccess", "IndustryCategory", + "ActorType", + "ActionType", + "ChangeHistoryResourceType", + "GoogleSignalsState", + "GoogleSignalsConsent", "Account", "Property", "AndroidAppDataStream", @@ -41,6 +43,13 @@ "DataSharingSettings", "AccountSummary", "PropertySummary", + "MeasurementProtocolSecret", + "ChangeHistoryEvent", + "ChangeHistoryChange", + "ConversionEvent", + "GoogleSignalsSettings", + "CustomDimension", + "CustomMetric", }, ) @@ -89,9 +98,63 @@ class IndustryCategory(proto.Enum): SHOPPING = 26 +class ActorType(proto.Enum): + r"""Different kinds of actors that can make changes to Google + Analytics resources. + """ + ACTOR_TYPE_UNSPECIFIED = 0 + USER = 1 + SYSTEM = 2 + SUPPORT = 3 + + +class ActionType(proto.Enum): + r"""Types of actions that may change a resource.""" + ACTION_TYPE_UNSPECIFIED = 0 + CREATED = 1 + UPDATED = 2 + DELETED = 3 + + +class ChangeHistoryResourceType(proto.Enum): + r"""Types of resources whose changes may be returned from change + history. + """ + CHANGE_HISTORY_RESOURCE_TYPE_UNSPECIFIED = 0 + ACCOUNT = 1 + PROPERTY = 2 + WEB_DATA_STREAM = 3 + ANDROID_APP_DATA_STREAM = 4 + IOS_APP_DATA_STREAM = 5 + FIREBASE_LINK = 6 + GOOGLE_ADS_LINK = 7 + GOOGLE_SIGNALS_SETTINGS = 8 + CONVERSION_EVENT = 9 + MEASUREMENT_PROTOCOL_SECRET = 10 + CUSTOM_DIMENSION = 11 + CUSTOM_METRIC = 12 + + +class GoogleSignalsState(proto.Enum): + r"""Status of the Google Signals settings (i.e., whether this + feature has been enabled for the property). + """ + GOOGLE_SIGNALS_STATE_UNSPECIFIED = 0 + GOOGLE_SIGNALS_ENABLED = 1 + GOOGLE_SIGNALS_DISABLED = 2 + + +class GoogleSignalsConsent(proto.Enum): + r"""Consent field of the Google Signals settings (i.e., whether + the user has consented to the Google Signals terms of service.) + """ + GOOGLE_SIGNALS_CONSENT_UNSPECIFIED = 0 + GOOGLE_SIGNALS_CONSENT_CONSENTED = 2 + GOOGLE_SIGNALS_CONSENT_NOT_CONSENTED = 1 + + class Account(proto.Message): r"""A resource message representing a Google Analytics account. - Attributes: name (str): Output only. Resource name of this account. @@ -116,17 +179,12 @@ class Account(proto.Message): requested. """ - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - display_name = proto.Field(proto.STRING, number=4) - - region_code = proto.Field(proto.STRING, number=5) - - deleted = proto.Field(proto.BOOL, number=6) + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + display_name = proto.Field(proto.STRING, number=4,) + region_code = proto.Field(proto.STRING, number=5,) + deleted = proto.Field(proto.BOOL, number=6,) class Property(proto.Message): @@ -158,10 +216,10 @@ class Property(proto.Message): Industry associated with this property Example: AUTOMOTIVE, FOOD_AND_DRINK time_zone (str): - Reporting Time Zone, used as the day boundary for reports, - regardless of where the data originates. If the time zone - honors DST, Analytics will automatically adjust for the - changes. + Required. Reporting Time Zone, used as the day boundary for + reports, regardless of where the data originates. If the + time zone honors DST, Analytics will automatically adjust + for the changes. NOTE: Changing the time zone only affects data going forward, and is not applied retroactively. @@ -173,30 +231,31 @@ class Property(proto.Message): Format: https://en.wikipedia.org/wiki/ISO_4217 Examples: "USD", "EUR", "JPY". - deleted (bool): - Output only. Indicates whether this Property - is soft-deleted or not. Deleted properties are - excluded from List results unless specifically - requested. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. If set, the time at which this + property was trashed. If not set, then this + property is not currently in the trash can. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. If set, the time at which this + trashed property will be permanently deleted. If + not set, then this property is not currently in + the trash can and is not slated to be deleted. """ - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - parent = proto.Field(proto.STRING, number=2) - - display_name = proto.Field(proto.STRING, number=5) - + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + parent = proto.Field(proto.STRING, number=2,) + display_name = proto.Field(proto.STRING, number=5,) industry_category = proto.Field(proto.ENUM, number=6, enum="IndustryCategory",) - - time_zone = proto.Field(proto.STRING, number=7) - - currency_code = proto.Field(proto.STRING, number=8) - - deleted = proto.Field(proto.BOOL, number=9) + time_zone = proto.Field(proto.STRING, number=7,) + currency_code = proto.Field(proto.STRING, number=8,) + delete_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + expire_time = proto.Field( + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + ) class AndroidAppDataStream(proto.Message): @@ -228,17 +287,12 @@ class AndroidAppDataStream(proto.Message): UTF-16 code units. """ - name = proto.Field(proto.STRING, number=1) - - firebase_app_id = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - package_name = proto.Field(proto.STRING, number=5) - - display_name = proto.Field(proto.STRING, number=6) + name = proto.Field(proto.STRING, number=1,) + firebase_app_id = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + package_name = proto.Field(proto.STRING, number=5,) + display_name = proto.Field(proto.STRING, number=6,) class IosAppDataStream(proto.Message): @@ -271,17 +325,12 @@ class IosAppDataStream(proto.Message): UTF-16 code units. """ - name = proto.Field(proto.STRING, number=1) - - firebase_app_id = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - bundle_id = proto.Field(proto.STRING, number=5) - - display_name = proto.Field(proto.STRING, number=6) + name = proto.Field(proto.STRING, number=1,) + firebase_app_id = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + bundle_id = proto.Field(proto.STRING, number=5,) + display_name = proto.Field(proto.STRING, number=6,) class WebDataStream(proto.Message): @@ -319,19 +368,13 @@ class WebDataStream(proto.Message): UTF-16 code units. """ - name = proto.Field(proto.STRING, number=1) - - measurement_id = proto.Field(proto.STRING, number=2) - - firebase_app_id = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - default_uri = proto.Field(proto.STRING, number=6) - - display_name = proto.Field(proto.STRING, number=7) + name = proto.Field(proto.STRING, number=1,) + measurement_id = proto.Field(proto.STRING, number=2,) + firebase_app_id = proto.Field(proto.STRING, number=3,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + default_uri = proto.Field(proto.STRING, number=6,) + display_name = proto.Field(proto.STRING, number=7,) class UserLink(proto.Message): @@ -340,10 +383,10 @@ class UserLink(proto.Message): Attributes: name (str): - Example format: + Output only. Example format: properties/1234/userLinks/5678 email_address (str): - Email address of the user to link + Immutable. Email address of the user to link direct_roles (Sequence[str]): Roles directly assigned to this user for this account or property. @@ -359,11 +402,9 @@ class UserLink(proto.Message): direct_roles will be deleted. """ - name = proto.Field(proto.STRING, number=1) - - email_address = proto.Field(proto.STRING, number=2) - - direct_roles = proto.RepeatedField(proto.STRING, number=3) + name = proto.Field(proto.STRING, number=1,) + email_address = proto.Field(proto.STRING, number=2,) + direct_roles = proto.RepeatedField(proto.STRING, number=3,) class AuditUserLink(proto.Message): @@ -391,13 +432,10 @@ class AuditUserLink(proto.Message): Format: predefinedRoles/read """ - name = proto.Field(proto.STRING, number=1) - - email_address = proto.Field(proto.STRING, number=2) - - direct_roles = proto.RepeatedField(proto.STRING, number=3) - - effective_roles = proto.RepeatedField(proto.STRING, number=4) + name = proto.Field(proto.STRING, number=1,) + email_address = proto.Field(proto.STRING, number=2,) + direct_roles = proto.RepeatedField(proto.STRING, number=3,) + effective_roles = proto.RepeatedField(proto.STRING, number=4,) class EnhancedMeasurementSettings(proto.Message): @@ -457,34 +495,22 @@ class EnhancedMeasurementSettings(proto.Message): Max length is 1024 characters. """ - name = proto.Field(proto.STRING, number=1) - - stream_enabled = proto.Field(proto.BOOL, number=2) - - page_views_enabled = proto.Field(proto.BOOL, number=3) - - scrolls_enabled = proto.Field(proto.BOOL, number=4) - - outbound_clicks_enabled = proto.Field(proto.BOOL, number=5) - - site_search_enabled = proto.Field(proto.BOOL, number=7) - - video_engagement_enabled = proto.Field(proto.BOOL, number=9) - - file_downloads_enabled = proto.Field(proto.BOOL, number=10) - - page_loads_enabled = proto.Field(proto.BOOL, number=12) - - page_changes_enabled = proto.Field(proto.BOOL, number=13) - - search_query_parameter = proto.Field(proto.STRING, number=16) - - uri_query_parameter = proto.Field(proto.STRING, number=17) + name = proto.Field(proto.STRING, number=1,) + stream_enabled = proto.Field(proto.BOOL, number=2,) + page_views_enabled = proto.Field(proto.BOOL, number=3,) + scrolls_enabled = proto.Field(proto.BOOL, number=4,) + outbound_clicks_enabled = proto.Field(proto.BOOL, number=5,) + site_search_enabled = proto.Field(proto.BOOL, number=7,) + video_engagement_enabled = proto.Field(proto.BOOL, number=9,) + file_downloads_enabled = proto.Field(proto.BOOL, number=10,) + page_loads_enabled = proto.Field(proto.BOOL, number=12,) + page_changes_enabled = proto.Field(proto.BOOL, number=13,) + search_query_parameter = proto.Field(proto.STRING, number=16,) + uri_query_parameter = proto.Field(proto.STRING, number=17,) class FirebaseLink(proto.Message): r"""A link between an GA4 property and a Firebase project. - Attributes: name (str): Output only. Example format: @@ -506,12 +532,9 @@ class FirebaseLink(proto.Message): project. """ - name = proto.Field(proto.STRING, number=1) - - project = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - + name = proto.Field(proto.STRING, number=1,) + project = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) maximum_user_access = proto.Field(proto.ENUM, number=4, enum="MaximumUserAccess",) @@ -530,14 +553,12 @@ class GlobalSiteTag(proto.Message): every webpage to measure. """ - name = proto.Field(proto.STRING, number=1) - - snippet = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + snippet = proto.Field(proto.STRING, number=2,) class GoogleAdsLink(proto.Message): r"""A link between an GA4 property and a Google Ads account. - Attributes: name (str): Output only. Format: @@ -555,7 +576,7 @@ class GoogleAdsLink(proto.Message): Google Analytics audience lists and Google Analytics remarketing events/parameters to the linked Google Ads account. If this field is not - set on create/update it will be defaulted to + set on create/update, it will be defaulted to true. email_address (str): Output only. Email address of the user that @@ -570,21 +591,15 @@ class GoogleAdsLink(proto.Message): updated. """ - name = proto.Field(proto.STRING, number=1) - - customer_id = proto.Field(proto.STRING, number=3) - - can_manage_clients = proto.Field(proto.BOOL, number=4) - + name = proto.Field(proto.STRING, number=1,) + customer_id = proto.Field(proto.STRING, number=3,) + can_manage_clients = proto.Field(proto.BOOL, number=4,) ads_personalization_enabled = proto.Field( - proto.MESSAGE, number=5, message=wrappers.BoolValue, + proto.MESSAGE, number=5, message=wrappers_pb2.BoolValue, ) - - email_address = proto.Field(proto.STRING, number=6) - - create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) + email_address = proto.Field(proto.STRING, number=6,) + create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) class DataSharingSettings(proto.Message): @@ -617,17 +632,12 @@ class DataSharingSettings(proto.Message): in aggregate form with others. """ - name = proto.Field(proto.STRING, number=1) - - sharing_with_google_support_enabled = proto.Field(proto.BOOL, number=2) - - sharing_with_google_assigned_sales_enabled = proto.Field(proto.BOOL, number=3) - - sharing_with_google_any_sales_enabled = proto.Field(proto.BOOL, number=4) - - sharing_with_google_products_enabled = proto.Field(proto.BOOL, number=5) - - sharing_with_others_enabled = proto.Field(proto.BOOL, number=6) + name = proto.Field(proto.STRING, number=1,) + sharing_with_google_support_enabled = proto.Field(proto.BOOL, number=2,) + sharing_with_google_assigned_sales_enabled = proto.Field(proto.BOOL, number=3,) + sharing_with_google_any_sales_enabled = proto.Field(proto.BOOL, number=4,) + sharing_with_google_products_enabled = proto.Field(proto.BOOL, number=5,) + sharing_with_others_enabled = proto.Field(proto.BOOL, number=6,) class AccountSummary(proto.Message): @@ -650,12 +660,9 @@ class AccountSummary(proto.Message): account. """ - name = proto.Field(proto.STRING, number=1) - - account = proto.Field(proto.STRING, number=2) - - display_name = proto.Field(proto.STRING, number=3) - + 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", ) @@ -663,7 +670,6 @@ class AccountSummary(proto.Message): 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 @@ -674,9 +680,348 @@ class PropertySummary(proto.Message): this account summary. """ - property = proto.Field(proto.STRING, number=1) + property = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + + +class MeasurementProtocolSecret(proto.Message): + r"""A secret value used for sending hits to Measurement Protocol. + Attributes: + name (str): + Output only. Resource name of this secret. + This secret may be a child of any type of + stream. Format: + properties/{property}/webDataStreams/{webDataStream}/measurementProtocolSecrets/{measurementProtocolSecret} + display_name (str): + Required. Human-readable display name for + this secret. + secret_value (str): + Output only. The measurement protocol secret value. Pass + this value to the api_secret field of the Measurement + Protocol API when sending hits to this secret's parent + property. + """ + + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + secret_value = proto.Field(proto.STRING, number=3,) + + +class ChangeHistoryEvent(proto.Message): + r"""A set of changes within a Google Analytics account or its + child properties that resulted from the same cause. Common + causes would be updates made in the Google Analytics UI, changes + from customer support, or automatic Google Analytics system + changes. + + Attributes: + id (str): + ID of this change history event. This ID is + unique across Google Analytics. + change_time (google.protobuf.timestamp_pb2.Timestamp): + Time when change was made. + actor_type (google.analytics.admin_v1alpha.types.ActorType): + The type of actor that made this change. + user_actor_email (str): + Email address of the Google account that made + the change. This will be a valid email address + if the actor field is set to USER, and empty + otherwise. Google accounts that have been + deleted will cause an error. + changes_filtered (bool): + If true, then the list of changes returned + was filtered, and does not represent all changes + that occurred in this event. + changes (Sequence[google.analytics.admin_v1alpha.types.ChangeHistoryChange]): + A list of changes made in this change history + event that fit the filters specified in + SearchChangeHistoryEventsRequest. + """ + + id = proto.Field(proto.STRING, number=1,) + change_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + actor_type = proto.Field(proto.ENUM, number=3, enum="ActorType",) + user_actor_email = proto.Field(proto.STRING, number=4,) + changes_filtered = proto.Field(proto.BOOL, number=5,) + changes = proto.RepeatedField( + proto.MESSAGE, number=6, message="ChangeHistoryChange", + ) + + +class ChangeHistoryChange(proto.Message): + r"""A description of a change to a single Google Analytics + resource. + + Attributes: + resource (str): + Resource name of the resource whose changes + are described by this entry. + action (google.analytics.admin_v1alpha.types.ActionType): + The type of action that changed this + resource. + resource_before_change (google.analytics.admin_v1alpha.types.ChangeHistoryChange.ChangeHistoryResource): + Resource contents from before the change was + made. If this resource was created in this + change, this field will be missing. + resource_after_change (google.analytics.admin_v1alpha.types.ChangeHistoryChange.ChangeHistoryResource): + Resource contents from after the change was + made. If this resource was deleted in this + change, this field will be missing. + """ + + class ChangeHistoryResource(proto.Message): + r"""A snapshot of a resource as before or after the result of a + change in change history. + + Attributes: + account (google.analytics.admin_v1alpha.types.Account): + A snapshot of an Account resource in change + history. + property (google.analytics.admin_v1alpha.types.Property): + A snapshot of a Property resource in change + history. + web_data_stream (google.analytics.admin_v1alpha.types.WebDataStream): + A snapshot of a WebDataStream resource in + change history. + android_app_data_stream (google.analytics.admin_v1alpha.types.AndroidAppDataStream): + A snapshot of an AndroidAppDataStream + resource in change history. + ios_app_data_stream (google.analytics.admin_v1alpha.types.IosAppDataStream): + A snapshot of an IosAppDataStream resource in + change history. + firebase_link (google.analytics.admin_v1alpha.types.FirebaseLink): + A snapshot of a FirebaseLink resource in + change history. + google_ads_link (google.analytics.admin_v1alpha.types.GoogleAdsLink): + A snapshot of a GoogleAdsLink resource in + change history. + google_signals_settings (google.analytics.admin_v1alpha.types.GoogleSignalsSettings): + A snapshot of a GoogleSignalsSettings + resource in change history. + conversion_event (google.analytics.admin_v1alpha.types.ConversionEvent): + A snapshot of a ConversionEvent resource in + change history. + measurement_protocol_secret (google.analytics.admin_v1alpha.types.MeasurementProtocolSecret): + A snapshot of a MeasurementProtocolSecret + resource in change history. + custom_dimension (google.analytics.admin_v1alpha.types.CustomDimension): + A snapshot of a CustomDimension resource in + change history. + custom_metric (google.analytics.admin_v1alpha.types.CustomMetric): + A snapshot of a CustomMetric resource in + change history. + """ + + account = proto.Field( + proto.MESSAGE, number=1, oneof="resource", message="Account", + ) + property = proto.Field( + proto.MESSAGE, number=2, oneof="resource", message="Property", + ) + web_data_stream = proto.Field( + proto.MESSAGE, number=3, oneof="resource", message="WebDataStream", + ) + android_app_data_stream = proto.Field( + proto.MESSAGE, number=4, oneof="resource", message="AndroidAppDataStream", + ) + ios_app_data_stream = proto.Field( + proto.MESSAGE, number=5, oneof="resource", message="IosAppDataStream", + ) + firebase_link = proto.Field( + proto.MESSAGE, number=6, oneof="resource", message="FirebaseLink", + ) + google_ads_link = proto.Field( + proto.MESSAGE, number=7, oneof="resource", message="GoogleAdsLink", + ) + google_signals_settings = proto.Field( + proto.MESSAGE, number=8, oneof="resource", message="GoogleSignalsSettings", + ) + conversion_event = proto.Field( + proto.MESSAGE, number=11, oneof="resource", message="ConversionEvent", + ) + measurement_protocol_secret = proto.Field( + proto.MESSAGE, + number=12, + oneof="resource", + message="MeasurementProtocolSecret", + ) + custom_dimension = proto.Field( + proto.MESSAGE, number=13, oneof="resource", message="CustomDimension", + ) + custom_metric = proto.Field( + proto.MESSAGE, number=14, oneof="resource", message="CustomMetric", + ) + + resource = proto.Field(proto.STRING, number=1,) + action = proto.Field(proto.ENUM, number=2, enum="ActionType",) + resource_before_change = proto.Field( + proto.MESSAGE, number=3, message=ChangeHistoryResource, + ) + resource_after_change = proto.Field( + proto.MESSAGE, number=4, message=ChangeHistoryResource, + ) + + +class ConversionEvent(proto.Message): + r"""A conversion event in a Google Analytics property. + Attributes: + name (str): + Output only. Resource name of this conversion event. Format: + properties/{property}/conversionEvents/{conversion_event} + event_name (str): + Immutable. The event name for this conversion + event. Examples: 'click', 'purchase' + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when this conversion event + was created in the property. + is_deletable (bool): + Output only. If set, this event can currently + be deleted via DeleteConversionEvent. + """ + + name = proto.Field(proto.STRING, number=1,) + event_name = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + is_deletable = proto.Field(proto.BOOL, number=4,) + + +class GoogleSignalsSettings(proto.Message): + r"""Settings values for Google Signals. This is a singleton + resource. + + Attributes: + name (str): + Output only. Resource name of this setting. Format: + properties/{property_id}/googleSignalsSettings Example: + "properties/1000/googleSignalsSettings". + state (google.analytics.admin_v1alpha.types.GoogleSignalsState): + Status of this setting. + consent (google.analytics.admin_v1alpha.types.GoogleSignalsConsent): + Output only. Terms of Service acceptance. + """ + + name = proto.Field(proto.STRING, number=1,) + state = proto.Field(proto.ENUM, number=3, enum="GoogleSignalsState",) + consent = proto.Field(proto.ENUM, number=4, enum="GoogleSignalsConsent",) + + +class CustomDimension(proto.Message): + r"""A definition for a CustomDimension. + Attributes: + name (str): + Output only. Resource name for this + CustomDimension resource. Format: + properties/{property}/customDimensions/{customDimension} + parameter_name (str): + Required. Immutable. Tagging parameter name + for this custom dimension. + If this is a user-scoped dimension, then this is + the user property name. If this is an event- + scoped dimension, then this is the event + parameter name. + + May only contain alphanumeric and underscore + characters, starting with a letter. Max length + of 24 characters for user-scoped dimensions, 40 + characters for event-scoped dimensions. + display_name (str): + Required. Display name for this custom + dimension as shown in the Analytics UI. Max + length of 82 characters, alphanumeric plus space + and underscore starting with a letter. Legacy + system-generated display names may contain + square brackets, but updates to this field will + never permit square brackets. + description (str): + Optional. Description for this custom + dimension. Max length of 150 characters. + scope (google.analytics.admin_v1alpha.types.CustomDimension.DimensionScope): + Required. Immutable. The scope of this + dimension. + disallow_ads_personalization (bool): + Optional. If set to true, sets this dimension + as NPA and excludes it from ads personalization. + This is currently only supported by user-scoped + custom dimensions. + """ + + class DimensionScope(proto.Enum): + r"""Valid values for the scope of this dimension.""" + DIMENSION_SCOPE_UNSPECIFIED = 0 + EVENT = 1 + USER = 2 + + name = proto.Field(proto.STRING, number=1,) + parameter_name = proto.Field(proto.STRING, number=2,) + display_name = proto.Field(proto.STRING, number=3,) + description = proto.Field(proto.STRING, number=4,) + scope = proto.Field(proto.ENUM, number=5, enum=DimensionScope,) + disallow_ads_personalization = proto.Field(proto.BOOL, number=6,) + + +class CustomMetric(proto.Message): + r"""A definition for a custom metric. + Attributes: + name (str): + Output only. Resource name for this + CustomMetric resource. Format: + properties/{property}/customMetrics/{customMetric} + parameter_name (str): + Required. Immutable. Tagging name for this + custom metric. + If this is an event-scoped metric, then this is + the event parameter name. + + May only contain alphanumeric and underscore + charactes, starting with a letter. Max length of + 40 characters for event-scoped metrics. + display_name (str): + Required. Display name for this custom metric + as shown in the Analytics UI. Max length of 82 + characters, alphanumeric plus space and + underscore starting with a letter. Legacy + system-generated display names may contain + square brackets, but updates to this field will + never permit square brackets. + description (str): + Optional. Description for this custom + dimension. Max length of 150 characters. + measurement_unit (google.analytics.admin_v1alpha.types.CustomMetric.MeasurementUnit): + Required. Immutable. The type for the custom + metric's value. + scope (google.analytics.admin_v1alpha.types.CustomMetric.MetricScope): + Required. Immutable. The scope of this custom + metric. + """ - display_name = proto.Field(proto.STRING, number=2) + class MeasurementUnit(proto.Enum): + r"""Possible types of representing the custom metric's value. + Currency representation may change in the future, requiring a + breaking API change. + """ + MEASUREMENT_UNIT_UNSPECIFIED = 0 + STANDARD = 1 + CURRENCY = 2 + FEET = 3 + METERS = 4 + KILOMETERS = 5 + MILES = 6 + MILLISECONDS = 7 + SECONDS = 8 + MINUTES = 9 + HOURS = 10 + + class MetricScope(proto.Enum): + r"""The scope of this metric.""" + METRIC_SCOPE_UNSPECIFIED = 0 + EVENT = 1 + + name = proto.Field(proto.STRING, number=1,) + parameter_name = proto.Field(proto.STRING, number=2,) + display_name = proto.Field(proto.STRING, number=3,) + description = proto.Field(proto.STRING, number=4,) + measurement_unit = proto.Field(proto.ENUM, number=5, enum=MeasurementUnit,) + scope = proto.Field(proto.ENUM, number=6, enum=MetricScope,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-analytics-admin/scripts/fixup_admin_v1alpha_keywords.py b/packages/google-analytics-admin/scripts/fixup_admin_v1alpha_keywords.py index 4aaee8325d80..24c3b61f8424 100644 --- a/packages/google-analytics-admin/scripts/fixup_admin_v1alpha_keywords.py +++ b/packages/google-analytics-admin/scripts/fixup_admin_v1alpha_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,55 +39,74 @@ def partition( class adminCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'audit_user_links': ('parent', 'page_size', 'page_token', ), - 'batch_create_user_links': ('parent', 'requests', 'notify_new_users', ), - 'batch_delete_user_links': ('parent', 'requests', ), - 'batch_get_user_links': ('parent', 'names', ), - 'batch_update_user_links': ('parent', 'requests', ), - 'create_android_app_data_stream': ('android_app_data_stream', 'parent', ), - 'create_firebase_link': ('parent', 'firebase_link', ), - 'create_google_ads_link': ('parent', 'google_ads_link', ), - 'create_ios_app_data_stream': ('ios_app_data_stream', 'parent', ), - 'create_property': ('property', ), - 'create_user_link': ('parent', 'user_link', 'notify_new_user', ), - 'create_web_data_stream': ('web_data_stream', 'parent', ), - 'delete_account': ('name', ), - 'delete_android_app_data_stream': ('name', ), - 'delete_firebase_link': ('name', ), - 'delete_google_ads_link': ('name', ), - 'delete_ios_app_data_stream': ('name', ), - 'delete_property': ('name', ), - 'delete_user_link': ('name', ), - 'delete_web_data_stream': ('name', ), - 'get_account': ('name', ), - 'get_android_app_data_stream': ('name', ), - 'get_data_sharing_settings': ('name', ), - 'get_enhanced_measurement_settings': ('name', ), - 'get_global_site_tag': ('name', ), - 'get_ios_app_data_stream': ('name', ), - 'get_property': ('name', ), - 'get_user_link': ('name', ), - 'get_web_data_stream': ('name', ), - 'list_accounts': ('page_size', 'page_token', 'show_deleted', ), - 'list_account_summaries': ('page_size', 'page_token', ), - 'list_android_app_data_streams': ('parent', 'page_size', 'page_token', ), - 'list_firebase_links': ('parent', 'page_size', 'page_token', ), - 'list_google_ads_links': ('parent', 'page_size', 'page_token', ), - 'list_ios_app_data_streams': ('parent', 'page_size', 'page_token', ), - 'list_properties': ('filter', 'page_size', 'page_token', 'show_deleted', ), - 'list_user_links': ('parent', 'page_size', 'page_token', ), - 'list_web_data_streams': ('parent', 'page_size', 'page_token', ), - 'provision_account_ticket': ('account', 'redirect_uri', ), - 'update_account': ('account', 'update_mask', ), - 'update_android_app_data_stream': ('android_app_data_stream', 'update_mask', ), - 'update_enhanced_measurement_settings': ('enhanced_measurement_settings', 'update_mask', ), - 'update_firebase_link': ('firebase_link', 'update_mask', ), - 'update_google_ads_link': ('update_mask', 'google_ads_link', ), - 'update_ios_app_data_stream': ('ios_app_data_stream', 'update_mask', ), - 'update_property': ('property', 'update_mask', ), - 'update_user_link': ('user_link', ), - 'update_web_data_stream': ('web_data_stream', 'update_mask', ), - + 'archive_custom_dimension': ('name', ), + 'archive_custom_metric': ('name', ), + 'audit_user_links': ('parent', 'page_size', 'page_token', ), + 'batch_create_user_links': ('parent', 'requests', 'notify_new_users', ), + 'batch_delete_user_links': ('parent', 'requests', ), + 'batch_get_user_links': ('parent', 'names', ), + 'batch_update_user_links': ('parent', 'requests', ), + 'create_conversion_event': ('conversion_event', 'parent', ), + 'create_custom_dimension': ('parent', 'custom_dimension', ), + 'create_custom_metric': ('parent', 'custom_metric', ), + 'create_firebase_link': ('parent', 'firebase_link', ), + 'create_google_ads_link': ('parent', 'google_ads_link', ), + 'create_measurement_protocol_secret': ('parent', 'measurement_protocol_secret', ), + 'create_property': ('property', ), + 'create_user_link': ('parent', 'user_link', 'notify_new_user', ), + 'create_web_data_stream': ('web_data_stream', 'parent', ), + 'delete_account': ('name', ), + 'delete_android_app_data_stream': ('name', ), + 'delete_conversion_event': ('name', ), + 'delete_firebase_link': ('name', ), + 'delete_google_ads_link': ('name', ), + 'delete_ios_app_data_stream': ('name', ), + 'delete_measurement_protocol_secret': ('name', ), + 'delete_property': ('name', ), + 'delete_user_link': ('name', ), + 'delete_web_data_stream': ('name', ), + 'get_account': ('name', ), + 'get_android_app_data_stream': ('name', ), + 'get_conversion_event': ('name', ), + 'get_custom_dimension': ('name', ), + 'get_custom_metric': ('name', ), + 'get_data_sharing_settings': ('name', ), + 'get_enhanced_measurement_settings': ('name', ), + 'get_global_site_tag': ('name', ), + 'get_google_signals_settings': ('name', ), + 'get_ios_app_data_stream': ('name', ), + 'get_measurement_protocol_secret': ('name', ), + 'get_property': ('name', ), + 'get_user_link': ('name', ), + 'get_web_data_stream': ('name', ), + 'list_accounts': ('page_size', 'page_token', 'show_deleted', ), + 'list_account_summaries': ('page_size', 'page_token', ), + 'list_android_app_data_streams': ('parent', 'page_size', 'page_token', ), + 'list_conversion_events': ('parent', 'page_size', 'page_token', ), + 'list_custom_dimensions': ('parent', 'page_size', 'page_token', ), + 'list_custom_metrics': ('parent', 'page_size', 'page_token', ), + 'list_firebase_links': ('parent', 'page_size', 'page_token', ), + 'list_google_ads_links': ('parent', 'page_size', 'page_token', ), + 'list_ios_app_data_streams': ('parent', 'page_size', 'page_token', ), + 'list_measurement_protocol_secrets': ('parent', 'page_size', 'page_token', ), + 'list_properties': ('filter', 'page_size', 'page_token', 'show_deleted', ), + 'list_user_links': ('parent', 'page_size', 'page_token', ), + 'list_web_data_streams': ('parent', 'page_size', 'page_token', ), + 'provision_account_ticket': ('account', 'redirect_uri', ), + 'search_change_history_events': ('account', 'property', 'resource_type', 'action', 'actor_email', 'earliest_change_time', 'latest_change_time', 'page_size', 'page_token', ), + 'update_account': ('account', 'update_mask', ), + 'update_android_app_data_stream': ('android_app_data_stream', 'update_mask', ), + 'update_custom_dimension': ('update_mask', 'custom_dimension', ), + 'update_custom_metric': ('update_mask', 'custom_metric', ), + 'update_enhanced_measurement_settings': ('enhanced_measurement_settings', 'update_mask', ), + 'update_firebase_link': ('firebase_link', 'update_mask', ), + 'update_google_ads_link': ('update_mask', 'google_ads_link', ), + 'update_google_signals_settings': ('google_signals_settings', 'update_mask', ), + 'update_ios_app_data_stream': ('ios_app_data_stream', 'update_mask', ), + 'update_measurement_protocol_secret': ('measurement_protocol_secret', 'update_mask', ), + 'update_property': ('property', 'update_mask', ), + 'update_user_link': ('user_link', ), + 'update_web_data_stream': ('web_data_stream', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -120,7 +137,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +cst.Element(value=arg.value) ) # Note: the args + kwargs looks silly, but keep in mind that # the control parameters had to be stripped out, and that diff --git a/packages/google-analytics-admin/tests/__init__.py b/packages/google-analytics-admin/tests/__init__.py new file mode 100644 index 000000000000..4de65971c238 --- /dev/null +++ b/packages/google-analytics-admin/tests/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/packages/google-analytics-admin/tests/unit/__init__.py b/packages/google-analytics-admin/tests/unit/__init__.py new file mode 100644 index 000000000000..4de65971c238 --- /dev/null +++ b/packages/google-analytics-admin/tests/unit/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/packages/google-analytics-admin/tests/unit/gapic/__init__.py b/packages/google-analytics-admin/tests/unit/gapic/__init__.py new file mode 100644 index 000000000000..4de65971c238 --- /dev/null +++ b/packages/google-analytics-admin/tests/unit/gapic/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/__init__.py b/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/__init__.py index 42ffdf2bc43d..4de65971c238 100644 --- a/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/__init__.py +++ b/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py b/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py index 3deec14a23da..f83a2ed734a7 100644 --- a/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +++ b/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,7 +23,7 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.analytics.admin_v1alpha.services.analytics_admin_service import ( AnalyticsAdminServiceAsyncClient, ) @@ -33,19 +32,49 @@ ) from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers from google.analytics.admin_v1alpha.services.analytics_admin_service import transports +from google.analytics.admin_v1alpha.services.analytics_admin_service.transports.base import ( + _API_CORE_VERSION, +) +from google.analytics.admin_v1alpha.services.analytics_admin_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import resources from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -97,7 +126,7 @@ def test__get_default_mtls_endpoint(): "client_class", [AnalyticsAdminServiceClient, AnalyticsAdminServiceAsyncClient,] ) def test_analytics_admin_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -114,7 +143,7 @@ def test_analytics_admin_service_client_from_service_account_info(client_class): "client_class", [AnalyticsAdminServiceClient, AnalyticsAdminServiceAsyncClient,] ) def test_analytics_admin_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -171,7 +200,7 @@ def test_analytics_admin_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(AnalyticsAdminServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -477,7 +506,7 @@ def test_get_account( transport: str = "grpc", request_type=analytics_admin.GetAccountRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -493,25 +522,18 @@ def test_get_account( region_code="region_code_value", deleted=True, ) - response = client.get_account(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetAccountRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Account) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.region_code == "region_code_value" - assert response.deleted is True @@ -523,7 +545,7 @@ def test_get_account_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -531,7 +553,6 @@ def test_get_account_empty_call(): client.get_account() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetAccountRequest() @@ -540,7 +561,7 @@ async def test_get_account_async( transport: str = "grpc_asyncio", request_type=analytics_admin.GetAccountRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -558,24 +579,18 @@ async def test_get_account_async( deleted=True, ) ) - response = await client.get_account(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetAccountRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Account) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.region_code == "region_code_value" - assert response.deleted is True @@ -586,18 +601,18 @@ async def test_get_account_async_from_dict(): def test_get_account_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetAccountRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_account), "__call__") as call: call.return_value = resources.Account() - client.get_account(request) # Establish that the underlying gRPC stub method was called. @@ -613,18 +628,18 @@ def test_get_account_field_headers(): @pytest.mark.asyncio async def test_get_account_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetAccountRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_account), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) - await client.get_account(request) # Establish that the underlying gRPC stub method was called. @@ -639,14 +654,13 @@ async def test_get_account_field_headers_async(): def test_get_account_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_account), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Account() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_account(name="name_value",) @@ -655,13 +669,12 @@ def test_get_account_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_account_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -675,7 +688,7 @@ def test_get_account_flattened_error(): @pytest.mark.asyncio async def test_get_account_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -692,14 +705,13 @@ async def test_get_account_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_account_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -714,7 +726,7 @@ def test_list_accounts( transport: str = "grpc", request_type=analytics_admin.ListAccountsRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -727,19 +739,15 @@ def test_list_accounts( call.return_value = analytics_admin.ListAccountsResponse( next_page_token="next_page_token_value", ) - response = client.list_accounts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAccountsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAccountsPager) - assert response.next_page_token == "next_page_token_value" @@ -751,7 +759,7 @@ def test_list_accounts_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -759,7 +767,6 @@ def test_list_accounts_empty_call(): client.list_accounts() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAccountsRequest() @@ -768,7 +775,7 @@ async def test_list_accounts_async( transport: str = "grpc_asyncio", request_type=analytics_admin.ListAccountsRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -783,18 +790,15 @@ async def test_list_accounts_async( next_page_token="next_page_token_value", ) ) - response = await client.list_accounts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAccountsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAccountsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -804,7 +808,9 @@ async def test_list_accounts_async_from_dict(): def test_list_accounts_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_accounts), "__call__") as call: @@ -839,7 +845,9 @@ def test_list_accounts_pager(): def test_list_accounts_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_accounts), "__call__") as call: @@ -870,7 +878,7 @@ def test_list_accounts_pages(): @pytest.mark.asyncio async def test_list_accounts_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -909,7 +917,7 @@ async def test_list_accounts_async_pager(): @pytest.mark.asyncio async def test_list_accounts_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -946,7 +954,7 @@ def test_delete_account( transport: str = "grpc", request_type=analytics_admin.DeleteAccountRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -957,13 +965,11 @@ def test_delete_account( with mock.patch.object(type(client.transport.delete_account), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_account(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteAccountRequest() # Establish that the response is the type that we expect. @@ -978,7 +984,7 @@ def test_delete_account_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -986,7 +992,6 @@ def test_delete_account_empty_call(): client.delete_account() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteAccountRequest() @@ -995,7 +1000,7 @@ async def test_delete_account_async( transport: str = "grpc_asyncio", request_type=analytics_admin.DeleteAccountRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1006,13 +1011,11 @@ async def test_delete_account_async( with mock.patch.object(type(client.transport.delete_account), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_account(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteAccountRequest() # Establish that the response is the type that we expect. @@ -1026,18 +1029,18 @@ async def test_delete_account_async_from_dict(): def test_delete_account_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteAccountRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_account), "__call__") as call: call.return_value = None - client.delete_account(request) # Establish that the underlying gRPC stub method was called. @@ -1053,18 +1056,18 @@ def test_delete_account_field_headers(): @pytest.mark.asyncio async def test_delete_account_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteAccountRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_account), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_account(request) # Establish that the underlying gRPC stub method was called. @@ -1079,14 +1082,13 @@ async def test_delete_account_field_headers_async(): def test_delete_account_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_account), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_account(name="name_value",) @@ -1095,13 +1097,12 @@ def test_delete_account_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_account_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1115,7 +1116,7 @@ def test_delete_account_flattened_error(): @pytest.mark.asyncio async def test_delete_account_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1132,14 +1133,13 @@ async def test_delete_account_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_account_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1154,7 +1154,7 @@ def test_update_account( transport: str = "grpc", request_type=analytics_admin.UpdateAccountRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1170,25 +1170,18 @@ def test_update_account( region_code="region_code_value", deleted=True, ) - response = client.update_account(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateAccountRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Account) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.region_code == "region_code_value" - assert response.deleted is True @@ -1200,7 +1193,7 @@ def test_update_account_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1208,7 +1201,6 @@ def test_update_account_empty_call(): client.update_account() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateAccountRequest() @@ -1217,7 +1209,7 @@ async def test_update_account_async( transport: str = "grpc_asyncio", request_type=analytics_admin.UpdateAccountRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1235,24 +1227,18 @@ async def test_update_account_async( deleted=True, ) ) - response = await client.update_account(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateAccountRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Account) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.region_code == "region_code_value" - assert response.deleted is True @@ -1263,18 +1249,18 @@ async def test_update_account_async_from_dict(): def test_update_account_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateAccountRequest() + request.account.name = "account.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_account), "__call__") as call: call.return_value = resources.Account() - client.update_account(request) # Establish that the underlying gRPC stub method was called. @@ -1292,18 +1278,18 @@ def test_update_account_field_headers(): @pytest.mark.asyncio async def test_update_account_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateAccountRequest() + request.account.name = "account.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_account), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Account()) - await client.update_account(request) # Establish that the underlying gRPC stub method was called. @@ -1320,34 +1306,31 @@ async def test_update_account_field_headers_async(): def test_update_account_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_account), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Account() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_account( account=resources.Account(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].account == resources.Account(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_account_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1356,14 +1339,14 @@ def test_update_account_flattened_error(): client.update_account( analytics_admin.UpdateAccountRequest(), account=resources.Account(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_account_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1376,23 +1359,21 @@ async def test_update_account_flattened_async(): # using the keyword arguments to the method. response = await client.update_account( account=resources.Account(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].account == resources.Account(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_account_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1401,7 +1382,7 @@ async def test_update_account_flattened_error_async(): await client.update_account( analytics_admin.UpdateAccountRequest(), account=resources.Account(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1409,7 +1390,7 @@ def test_provision_account_ticket( transport: str = "grpc", request_type=analytics_admin.ProvisionAccountTicketRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1424,19 +1405,15 @@ def test_provision_account_ticket( call.return_value = analytics_admin.ProvisionAccountTicketResponse( account_ticket_id="account_ticket_id_value", ) - response = client.provision_account_ticket(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ProvisionAccountTicketRequest() # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.ProvisionAccountTicketResponse) - assert response.account_ticket_id == "account_ticket_id_value" @@ -1448,7 +1425,7 @@ def test_provision_account_ticket_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1458,7 +1435,6 @@ def test_provision_account_ticket_empty_call(): client.provision_account_ticket() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ProvisionAccountTicketRequest() @@ -1468,7 +1444,7 @@ async def test_provision_account_ticket_async( request_type=analytics_admin.ProvisionAccountTicketRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1485,18 +1461,15 @@ async def test_provision_account_ticket_async( account_ticket_id="account_ticket_id_value", ) ) - response = await client.provision_account_ticket(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ProvisionAccountTicketRequest() # Establish that the response is the type that we expect. assert isinstance(response, analytics_admin.ProvisionAccountTicketResponse) - assert response.account_ticket_id == "account_ticket_id_value" @@ -1509,7 +1482,7 @@ def test_list_account_summaries( transport: str = "grpc", request_type=analytics_admin.ListAccountSummariesRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1524,19 +1497,15 @@ def test_list_account_summaries( call.return_value = analytics_admin.ListAccountSummariesResponse( next_page_token="next_page_token_value", ) - response = client.list_account_summaries(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAccountSummariesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAccountSummariesPager) - assert response.next_page_token == "next_page_token_value" @@ -1548,7 +1517,7 @@ def test_list_account_summaries_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1558,7 +1527,6 @@ def test_list_account_summaries_empty_call(): client.list_account_summaries() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAccountSummariesRequest() @@ -1568,7 +1536,7 @@ async def test_list_account_summaries_async( request_type=analytics_admin.ListAccountSummariesRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1585,18 +1553,15 @@ async def test_list_account_summaries_async( next_page_token="next_page_token_value", ) ) - response = await client.list_account_summaries(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAccountSummariesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAccountSummariesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1606,7 +1571,9 @@ async def test_list_account_summaries_async_from_dict(): def test_list_account_summaries_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1648,7 +1615,9 @@ def test_list_account_summaries_pager(): def test_list_account_summaries_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1686,7 +1655,7 @@ def test_list_account_summaries_pages(): @pytest.mark.asyncio async def test_list_account_summaries_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1732,7 +1701,7 @@ async def test_list_account_summaries_async_pager(): @pytest.mark.asyncio async def test_list_account_summaries_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1776,7 +1745,7 @@ def test_get_property( transport: str = "grpc", request_type=analytics_admin.GetPropertyRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1793,35 +1762,23 @@ def test_get_property( 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) @@ -1831,7 +1788,7 @@ def test_get_property_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1839,7 +1796,6 @@ def test_get_property_empty_call(): client.get_property() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetPropertyRequest() @@ -1848,7 +1804,7 @@ async def test_get_property_async( transport: str = "grpc_asyncio", request_type=analytics_admin.GetPropertyRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1866,35 +1822,24 @@ async def test_get_property_async( 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(): @@ -1903,18 +1848,18 @@ async def test_get_property_async_from_dict(): def test_get_property_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetPropertyRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_property), "__call__") as call: call.return_value = resources.Property() - client.get_property(request) # Establish that the underlying gRPC stub method was called. @@ -1930,18 +1875,18 @@ def test_get_property_field_headers(): @pytest.mark.asyncio async def test_get_property_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetPropertyRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_property), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) - await client.get_property(request) # Establish that the underlying gRPC stub method was called. @@ -1956,14 +1901,13 @@ async def test_get_property_field_headers_async(): def test_get_property_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_property), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Property() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_property(name="name_value",) @@ -1972,13 +1916,12 @@ def test_get_property_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_property_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1992,7 +1935,7 @@ def test_get_property_flattened_error(): @pytest.mark.asyncio async def test_get_property_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2009,14 +1952,13 @@ async def test_get_property_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_property_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2031,7 +1973,7 @@ def test_list_properties( transport: str = "grpc", request_type=analytics_admin.ListPropertiesRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2044,19 +1986,15 @@ def test_list_properties( call.return_value = analytics_admin.ListPropertiesResponse( next_page_token="next_page_token_value", ) - response = client.list_properties(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListPropertiesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPropertiesPager) - assert response.next_page_token == "next_page_token_value" @@ -2068,7 +2006,7 @@ def test_list_properties_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2076,7 +2014,6 @@ def test_list_properties_empty_call(): client.list_properties() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListPropertiesRequest() @@ -2085,7 +2022,7 @@ async def test_list_properties_async( transport: str = "grpc_asyncio", request_type=analytics_admin.ListPropertiesRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2100,18 +2037,15 @@ async def test_list_properties_async( next_page_token="next_page_token_value", ) ) - response = await client.list_properties(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListPropertiesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListPropertiesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2121,7 +2055,9 @@ async def test_list_properties_async_from_dict(): def test_list_properties_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_properties), "__call__") as call: @@ -2158,7 +2094,9 @@ def test_list_properties_pager(): def test_list_properties_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_properties), "__call__") as call: @@ -2191,7 +2129,7 @@ def test_list_properties_pages(): @pytest.mark.asyncio async def test_list_properties_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2232,7 +2170,7 @@ async def test_list_properties_async_pager(): @pytest.mark.asyncio async def test_list_properties_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2271,7 +2209,7 @@ def test_create_property( transport: str = "grpc", request_type=analytics_admin.CreatePropertyRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2288,35 +2226,23 @@ def test_create_property( industry_category=resources.IndustryCategory.AUTOMOTIVE, time_zone="time_zone_value", currency_code="currency_code_value", - deleted=True, ) - response = client.create_property(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreatePropertyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) - assert response.name == "name_value" - assert response.parent == "parent_value" - assert response.display_name == "display_name_value" - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - assert response.time_zone == "time_zone_value" - assert response.currency_code == "currency_code_value" - assert response.deleted is True - def test_create_property_from_dict(): test_create_property(request_type=dict) @@ -2326,7 +2252,7 @@ def test_create_property_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2334,7 +2260,6 @@ def test_create_property_empty_call(): client.create_property() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreatePropertyRequest() @@ -2343,7 +2268,7 @@ async def test_create_property_async( transport: str = "grpc_asyncio", request_type=analytics_admin.CreatePropertyRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2361,35 +2286,24 @@ async def test_create_property_async( industry_category=resources.IndustryCategory.AUTOMOTIVE, time_zone="time_zone_value", currency_code="currency_code_value", - deleted=True, ) ) - response = await client.create_property(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreatePropertyRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Property) - assert response.name == "name_value" - assert response.parent == "parent_value" - assert response.display_name == "display_name_value" - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - assert response.time_zone == "time_zone_value" - assert response.currency_code == "currency_code_value" - assert response.deleted is True - @pytest.mark.asyncio async def test_create_property_async_from_dict(): @@ -2398,14 +2312,13 @@ async def test_create_property_async_from_dict(): def test_create_property_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_property), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Property() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_property(property=resources.Property(name="name_value"),) @@ -2414,13 +2327,12 @@ def test_create_property_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].property == resources.Property(name="name_value") def test_create_property_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2435,7 +2347,7 @@ def test_create_property_flattened_error(): @pytest.mark.asyncio async def test_create_property_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2454,14 +2366,13 @@ async def test_create_property_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].property == resources.Property(name="name_value") @pytest.mark.asyncio async def test_create_property_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2477,7 +2388,7 @@ def test_delete_property( transport: str = "grpc", request_type=analytics_admin.DeletePropertyRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2487,18 +2398,29 @@ def test_delete_property( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_property), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = None - + call.return_value = resources.Property( + name="name_value", + parent="parent_value", + display_name="display_name_value", + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone="time_zone_value", + currency_code="currency_code_value", + ) response = client.delete_property(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeletePropertyRequest() # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.Property) + assert response.name == "name_value" + assert response.parent == "parent_value" + assert response.display_name == "display_name_value" + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + assert response.time_zone == "time_zone_value" + assert response.currency_code == "currency_code_value" def test_delete_property_from_dict(): @@ -2509,7 +2431,7 @@ def test_delete_property_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2517,7 +2439,6 @@ def test_delete_property_empty_call(): client.delete_property() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeletePropertyRequest() @@ -2526,7 +2447,7 @@ async def test_delete_property_async( transport: str = "grpc_asyncio", request_type=analytics_admin.DeletePropertyRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2536,18 +2457,31 @@ async def test_delete_property_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_property), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Property( + name="name_value", + parent="parent_value", + display_name="display_name_value", + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone="time_zone_value", + currency_code="currency_code_value", + ) + ) response = await client.delete_property(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeletePropertyRequest() # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.Property) + assert response.name == "name_value" + assert response.parent == "parent_value" + assert response.display_name == "display_name_value" + assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE + assert response.time_zone == "time_zone_value" + assert response.currency_code == "currency_code_value" @pytest.mark.asyncio @@ -2557,18 +2491,18 @@ async def test_delete_property_async_from_dict(): def test_delete_property_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeletePropertyRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_property), "__call__") as call: - call.return_value = None - + call.return_value = resources.Property() client.delete_property(request) # Establish that the underlying gRPC stub method was called. @@ -2584,18 +2518,18 @@ def test_delete_property_field_headers(): @pytest.mark.asyncio async def test_delete_property_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeletePropertyRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_property), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) await client.delete_property(request) # Establish that the underlying gRPC stub method was called. @@ -2610,14 +2544,13 @@ async def test_delete_property_field_headers_async(): def test_delete_property_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_property), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = None - + call.return_value = resources.Property() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_property(name="name_value",) @@ -2626,13 +2559,12 @@ def test_delete_property_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_property_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2646,15 +2578,15 @@ def test_delete_property_flattened_error(): @pytest.mark.asyncio async def test_delete_property_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_property), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = None + call.return_value = resources.Property() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.delete_property(name="name_value",) @@ -2663,14 +2595,13 @@ async def test_delete_property_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_property_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2685,7 +2616,7 @@ def test_update_property( transport: str = "grpc", request_type=analytics_admin.UpdatePropertyRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2702,35 +2633,23 @@ def test_update_property( industry_category=resources.IndustryCategory.AUTOMOTIVE, time_zone="time_zone_value", currency_code="currency_code_value", - deleted=True, ) - response = client.update_property(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdatePropertyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) - assert response.name == "name_value" - assert response.parent == "parent_value" - assert response.display_name == "display_name_value" - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - assert response.time_zone == "time_zone_value" - assert response.currency_code == "currency_code_value" - assert response.deleted is True - def test_update_property_from_dict(): test_update_property(request_type=dict) @@ -2740,7 +2659,7 @@ def test_update_property_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2748,7 +2667,6 @@ def test_update_property_empty_call(): client.update_property() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdatePropertyRequest() @@ -2757,7 +2675,7 @@ async def test_update_property_async( transport: str = "grpc_asyncio", request_type=analytics_admin.UpdatePropertyRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2775,35 +2693,24 @@ async def test_update_property_async( industry_category=resources.IndustryCategory.AUTOMOTIVE, time_zone="time_zone_value", currency_code="currency_code_value", - deleted=True, ) ) - response = await client.update_property(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdatePropertyRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Property) - assert response.name == "name_value" - assert response.parent == "parent_value" - assert response.display_name == "display_name_value" - assert response.industry_category == resources.IndustryCategory.AUTOMOTIVE - assert response.time_zone == "time_zone_value" - assert response.currency_code == "currency_code_value" - assert response.deleted is True - @pytest.mark.asyncio async def test_update_property_async_from_dict(): @@ -2812,18 +2719,18 @@ async def test_update_property_async_from_dict(): def test_update_property_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdatePropertyRequest() + request.property.name = "property.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_property), "__call__") as call: call.return_value = resources.Property() - client.update_property(request) # Establish that the underlying gRPC stub method was called. @@ -2841,18 +2748,18 @@ def test_update_property_field_headers(): @pytest.mark.asyncio async def test_update_property_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdatePropertyRequest() + request.property.name = "property.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_property), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Property()) - await client.update_property(request) # Establish that the underlying gRPC stub method was called. @@ -2869,34 +2776,31 @@ async def test_update_property_field_headers_async(): def test_update_property_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_property), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Property() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_property( property=resources.Property(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].property == resources.Property(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_property_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2905,14 +2809,14 @@ def test_update_property_flattened_error(): client.update_property( analytics_admin.UpdatePropertyRequest(), property=resources.Property(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_property_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2925,23 +2829,21 @@ async def test_update_property_flattened_async(): # using the keyword arguments to the method. response = await client.update_property( property=resources.Property(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].property == resources.Property(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_property_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2950,7 +2852,7 @@ async def test_update_property_flattened_error_async(): await client.update_property( analytics_admin.UpdatePropertyRequest(), property=resources.Property(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2958,7 +2860,7 @@ def test_get_user_link( transport: str = "grpc", request_type=analytics_admin.GetUserLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2973,23 +2875,17 @@ def test_get_user_link( email_address="email_address_value", direct_roles=["direct_roles_value"], ) - response = client.get_user_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetUserLinkRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.UserLink) - assert response.name == "name_value" - assert response.email_address == "email_address_value" - assert response.direct_roles == ["direct_roles_value"] @@ -3001,7 +2897,7 @@ def test_get_user_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3009,7 +2905,6 @@ def test_get_user_link_empty_call(): client.get_user_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetUserLinkRequest() @@ -3018,7 +2913,7 @@ async def test_get_user_link_async( transport: str = "grpc_asyncio", request_type=analytics_admin.GetUserLinkRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3035,22 +2930,17 @@ async def test_get_user_link_async( direct_roles=["direct_roles_value"], ) ) - response = await client.get_user_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetUserLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.UserLink) - assert response.name == "name_value" - assert response.email_address == "email_address_value" - assert response.direct_roles == ["direct_roles_value"] @@ -3061,18 +2951,18 @@ async def test_get_user_link_async_from_dict(): def test_get_user_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetUserLinkRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_user_link), "__call__") as call: call.return_value = resources.UserLink() - client.get_user_link(request) # Establish that the underlying gRPC stub method was called. @@ -3088,18 +2978,18 @@ def test_get_user_link_field_headers(): @pytest.mark.asyncio async def test_get_user_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetUserLinkRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_user_link), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - await client.get_user_link(request) # Establish that the underlying gRPC stub method was called. @@ -3114,14 +3004,13 @@ async def test_get_user_link_field_headers_async(): def test_get_user_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_user_link), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.UserLink() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_user_link(name="name_value",) @@ -3130,13 +3019,12 @@ def test_get_user_link_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_user_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3150,7 +3038,7 @@ def test_get_user_link_flattened_error(): @pytest.mark.asyncio async def test_get_user_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3167,14 +3055,13 @@ async def test_get_user_link_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_user_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3189,7 +3076,7 @@ def test_batch_get_user_links( transport: str = "grpc", request_type=analytics_admin.BatchGetUserLinksRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3202,17 +3089,14 @@ def test_batch_get_user_links( ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.BatchGetUserLinksResponse() - response = client.batch_get_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchGetUserLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) @@ -3224,7 +3108,7 @@ def test_batch_get_user_links_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3234,7 +3118,6 @@ def test_batch_get_user_links_empty_call(): client.batch_get_user_links() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchGetUserLinksRequest() @@ -3244,7 +3127,7 @@ async def test_batch_get_user_links_async( request_type=analytics_admin.BatchGetUserLinksRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3259,13 +3142,11 @@ async def test_batch_get_user_links_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchGetUserLinksResponse() ) - response = await client.batch_get_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchGetUserLinksRequest() # Establish that the response is the type that we expect. @@ -3279,12 +3160,13 @@ async def test_batch_get_user_links_async_from_dict(): def test_batch_get_user_links_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.BatchGetUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3292,7 +3174,6 @@ def test_batch_get_user_links_field_headers(): type(client.transport.batch_get_user_links), "__call__" ) as call: call.return_value = analytics_admin.BatchGetUserLinksResponse() - client.batch_get_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -3308,12 +3189,13 @@ def test_batch_get_user_links_field_headers(): @pytest.mark.asyncio async def test_batch_get_user_links_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.BatchGetUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3323,7 +3205,6 @@ async def test_batch_get_user_links_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchGetUserLinksResponse() ) - await client.batch_get_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -3340,7 +3221,7 @@ def test_list_user_links( transport: str = "grpc", request_type=analytics_admin.ListUserLinksRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3353,19 +3234,15 @@ def test_list_user_links( call.return_value = analytics_admin.ListUserLinksResponse( next_page_token="next_page_token_value", ) - response = client.list_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListUserLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListUserLinksPager) - assert response.next_page_token == "next_page_token_value" @@ -3377,7 +3254,7 @@ def test_list_user_links_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3385,7 +3262,6 @@ def test_list_user_links_empty_call(): client.list_user_links() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListUserLinksRequest() @@ -3394,7 +3270,7 @@ async def test_list_user_links_async( transport: str = "grpc_asyncio", request_type=analytics_admin.ListUserLinksRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3409,18 +3285,15 @@ async def test_list_user_links_async( next_page_token="next_page_token_value", ) ) - response = await client.list_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListUserLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListUserLinksAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -3431,18 +3304,18 @@ async def test_list_user_links_async_from_dict(): def test_list_user_links_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_user_links), "__call__") as call: call.return_value = analytics_admin.ListUserLinksResponse() - client.list_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -3458,12 +3331,13 @@ def test_list_user_links_field_headers(): @pytest.mark.asyncio async def test_list_user_links_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3471,7 +3345,6 @@ async def test_list_user_links_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListUserLinksResponse() ) - await client.list_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -3486,14 +3359,13 @@ async def test_list_user_links_field_headers_async(): def test_list_user_links_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_user_links), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListUserLinksResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_user_links(parent="parent_value",) @@ -3502,13 +3374,12 @@ def test_list_user_links_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_user_links_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3522,7 +3393,7 @@ def test_list_user_links_flattened_error(): @pytest.mark.asyncio async def test_list_user_links_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3541,14 +3412,13 @@ async def test_list_user_links_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_user_links_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3560,7 +3430,9 @@ async def test_list_user_links_flattened_error_async(): def test_list_user_links_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_user_links), "__call__") as call: @@ -3600,7 +3472,9 @@ def test_list_user_links_pager(): def test_list_user_links_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_user_links), "__call__") as call: @@ -3633,7 +3507,7 @@ def test_list_user_links_pages(): @pytest.mark.asyncio async def test_list_user_links_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3674,7 +3548,7 @@ async def test_list_user_links_async_pager(): @pytest.mark.asyncio async def test_list_user_links_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3713,7 +3587,7 @@ def test_audit_user_links( transport: str = "grpc", request_type=analytics_admin.AuditUserLinksRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3726,19 +3600,15 @@ def test_audit_user_links( call.return_value = analytics_admin.AuditUserLinksResponse( next_page_token="next_page_token_value", ) - response = client.audit_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.AuditUserLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.AuditUserLinksPager) - assert response.next_page_token == "next_page_token_value" @@ -3750,7 +3620,7 @@ def test_audit_user_links_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3758,7 +3628,6 @@ def test_audit_user_links_empty_call(): client.audit_user_links() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.AuditUserLinksRequest() @@ -3767,7 +3636,7 @@ async def test_audit_user_links_async( transport: str = "grpc_asyncio", request_type=analytics_admin.AuditUserLinksRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3782,18 +3651,15 @@ async def test_audit_user_links_async( next_page_token="next_page_token_value", ) ) - response = await client.audit_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.AuditUserLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.AuditUserLinksAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -3804,18 +3670,18 @@ async def test_audit_user_links_async_from_dict(): def test_audit_user_links_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.AuditUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.audit_user_links), "__call__") as call: call.return_value = analytics_admin.AuditUserLinksResponse() - client.audit_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -3831,12 +3697,13 @@ def test_audit_user_links_field_headers(): @pytest.mark.asyncio async def test_audit_user_links_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.AuditUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3844,7 +3711,6 @@ async def test_audit_user_links_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.AuditUserLinksResponse() ) - await client.audit_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -3858,7 +3724,9 @@ async def test_audit_user_links_field_headers_async(): def test_audit_user_links_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.audit_user_links), "__call__") as call: @@ -3898,7 +3766,9 @@ def test_audit_user_links_pager(): def test_audit_user_links_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.audit_user_links), "__call__") as call: @@ -3931,7 +3801,7 @@ def test_audit_user_links_pages(): @pytest.mark.asyncio async def test_audit_user_links_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3972,7 +3842,7 @@ async def test_audit_user_links_async_pager(): @pytest.mark.asyncio async def test_audit_user_links_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4011,7 +3881,7 @@ def test_create_user_link( transport: str = "grpc", request_type=analytics_admin.CreateUserLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4026,23 +3896,17 @@ def test_create_user_link( email_address="email_address_value", direct_roles=["direct_roles_value"], ) - response = client.create_user_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateUserLinkRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.UserLink) - assert response.name == "name_value" - assert response.email_address == "email_address_value" - assert response.direct_roles == ["direct_roles_value"] @@ -4054,7 +3918,7 @@ def test_create_user_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4062,7 +3926,6 @@ def test_create_user_link_empty_call(): client.create_user_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateUserLinkRequest() @@ -4071,7 +3934,7 @@ async def test_create_user_link_async( transport: str = "grpc_asyncio", request_type=analytics_admin.CreateUserLinkRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4088,22 +3951,17 @@ async def test_create_user_link_async( direct_roles=["direct_roles_value"], ) ) - response = await client.create_user_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateUserLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.UserLink) - assert response.name == "name_value" - assert response.email_address == "email_address_value" - assert response.direct_roles == ["direct_roles_value"] @@ -4114,18 +3972,18 @@ async def test_create_user_link_async_from_dict(): def test_create_user_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.CreateUserLinkRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_user_link), "__call__") as call: call.return_value = resources.UserLink() - client.create_user_link(request) # Establish that the underlying gRPC stub method was called. @@ -4141,18 +3999,18 @@ def test_create_user_link_field_headers(): @pytest.mark.asyncio async def test_create_user_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.CreateUserLinkRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_user_link), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - await client.create_user_link(request) # Establish that the underlying gRPC stub method was called. @@ -4167,14 +4025,13 @@ async def test_create_user_link_field_headers_async(): def test_create_user_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_user_link), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.UserLink() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_user_link( @@ -4185,15 +4042,13 @@ def test_create_user_link_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].user_link == resources.UserLink(name="name_value") def test_create_user_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4209,7 +4064,7 @@ def test_create_user_link_flattened_error(): @pytest.mark.asyncio async def test_create_user_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4228,16 +4083,14 @@ async def test_create_user_link_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].user_link == resources.UserLink(name="name_value") @pytest.mark.asyncio async def test_create_user_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4254,7 +4107,7 @@ def test_batch_create_user_links( transport: str = "grpc", request_type=analytics_admin.BatchCreateUserLinksRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4267,17 +4120,14 @@ def test_batch_create_user_links( ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.BatchCreateUserLinksResponse() - response = client.batch_create_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchCreateUserLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) @@ -4289,7 +4139,7 @@ def test_batch_create_user_links_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4299,7 +4149,6 @@ def test_batch_create_user_links_empty_call(): client.batch_create_user_links() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchCreateUserLinksRequest() @@ -4309,7 +4158,7 @@ async def test_batch_create_user_links_async( request_type=analytics_admin.BatchCreateUserLinksRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4324,13 +4173,11 @@ async def test_batch_create_user_links_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchCreateUserLinksResponse() ) - response = await client.batch_create_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchCreateUserLinksRequest() # Establish that the response is the type that we expect. @@ -4344,12 +4191,13 @@ async def test_batch_create_user_links_async_from_dict(): def test_batch_create_user_links_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.BatchCreateUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4357,7 +4205,6 @@ def test_batch_create_user_links_field_headers(): type(client.transport.batch_create_user_links), "__call__" ) as call: call.return_value = analytics_admin.BatchCreateUserLinksResponse() - client.batch_create_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -4373,12 +4220,13 @@ def test_batch_create_user_links_field_headers(): @pytest.mark.asyncio async def test_batch_create_user_links_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.BatchCreateUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4388,7 +4236,6 @@ async def test_batch_create_user_links_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchCreateUserLinksResponse() ) - await client.batch_create_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -4405,7 +4252,7 @@ def test_update_user_link( transport: str = "grpc", request_type=analytics_admin.UpdateUserLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4420,23 +4267,17 @@ def test_update_user_link( email_address="email_address_value", direct_roles=["direct_roles_value"], ) - response = client.update_user_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateUserLinkRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.UserLink) - assert response.name == "name_value" - assert response.email_address == "email_address_value" - assert response.direct_roles == ["direct_roles_value"] @@ -4448,7 +4289,7 @@ def test_update_user_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4456,7 +4297,6 @@ def test_update_user_link_empty_call(): client.update_user_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateUserLinkRequest() @@ -4465,7 +4305,7 @@ async def test_update_user_link_async( transport: str = "grpc_asyncio", request_type=analytics_admin.UpdateUserLinkRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4482,22 +4322,17 @@ async def test_update_user_link_async( direct_roles=["direct_roles_value"], ) ) - response = await client.update_user_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateUserLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.UserLink) - assert response.name == "name_value" - assert response.email_address == "email_address_value" - assert response.direct_roles == ["direct_roles_value"] @@ -4508,18 +4343,18 @@ async def test_update_user_link_async_from_dict(): def test_update_user_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateUserLinkRequest() + request.user_link.name = "user_link.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_user_link), "__call__") as call: call.return_value = resources.UserLink() - client.update_user_link(request) # Establish that the underlying gRPC stub method was called. @@ -4537,18 +4372,18 @@ def test_update_user_link_field_headers(): @pytest.mark.asyncio async def test_update_user_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateUserLinkRequest() + request.user_link.name = "user_link.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_user_link), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.UserLink()) - await client.update_user_link(request) # Establish that the underlying gRPC stub method was called. @@ -4565,14 +4400,13 @@ async def test_update_user_link_field_headers_async(): def test_update_user_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_user_link), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.UserLink() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_user_link(user_link=resources.UserLink(name="name_value"),) @@ -4581,13 +4415,12 @@ def test_update_user_link_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].user_link == resources.UserLink(name="name_value") def test_update_user_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4602,7 +4435,7 @@ def test_update_user_link_flattened_error(): @pytest.mark.asyncio async def test_update_user_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4621,14 +4454,13 @@ async def test_update_user_link_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].user_link == resources.UserLink(name="name_value") @pytest.mark.asyncio async def test_update_user_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4644,7 +4476,7 @@ def test_batch_update_user_links( transport: str = "grpc", request_type=analytics_admin.BatchUpdateUserLinksRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4657,17 +4489,14 @@ def test_batch_update_user_links( ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.BatchUpdateUserLinksResponse() - response = client.batch_update_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) @@ -4679,7 +4508,7 @@ def test_batch_update_user_links_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4689,7 +4518,6 @@ def test_batch_update_user_links_empty_call(): client.batch_update_user_links() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() @@ -4699,7 +4527,7 @@ async def test_batch_update_user_links_async( request_type=analytics_admin.BatchUpdateUserLinksRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4714,13 +4542,11 @@ async def test_batch_update_user_links_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchUpdateUserLinksResponse() ) - response = await client.batch_update_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchUpdateUserLinksRequest() # Establish that the response is the type that we expect. @@ -4734,12 +4560,13 @@ async def test_batch_update_user_links_async_from_dict(): def test_batch_update_user_links_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.BatchUpdateUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4747,7 +4574,6 @@ def test_batch_update_user_links_field_headers(): type(client.transport.batch_update_user_links), "__call__" ) as call: call.return_value = analytics_admin.BatchUpdateUserLinksResponse() - client.batch_update_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -4763,12 +4589,13 @@ def test_batch_update_user_links_field_headers(): @pytest.mark.asyncio async def test_batch_update_user_links_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.BatchUpdateUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4778,7 +4605,6 @@ async def test_batch_update_user_links_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.BatchUpdateUserLinksResponse() ) - await client.batch_update_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -4795,7 +4621,7 @@ def test_delete_user_link( transport: str = "grpc", request_type=analytics_admin.DeleteUserLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4806,13 +4632,11 @@ def test_delete_user_link( with mock.patch.object(type(client.transport.delete_user_link), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_user_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteUserLinkRequest() # Establish that the response is the type that we expect. @@ -4827,7 +4651,7 @@ def test_delete_user_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4835,7 +4659,6 @@ def test_delete_user_link_empty_call(): client.delete_user_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteUserLinkRequest() @@ -4844,7 +4667,7 @@ async def test_delete_user_link_async( transport: str = "grpc_asyncio", request_type=analytics_admin.DeleteUserLinkRequest ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4855,13 +4678,11 @@ async def test_delete_user_link_async( with mock.patch.object(type(client.transport.delete_user_link), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_user_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteUserLinkRequest() # Establish that the response is the type that we expect. @@ -4875,18 +4696,18 @@ async def test_delete_user_link_async_from_dict(): def test_delete_user_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteUserLinkRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_user_link), "__call__") as call: call.return_value = None - client.delete_user_link(request) # Establish that the underlying gRPC stub method was called. @@ -4902,18 +4723,18 @@ def test_delete_user_link_field_headers(): @pytest.mark.asyncio async def test_delete_user_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteUserLinkRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_user_link), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_user_link(request) # Establish that the underlying gRPC stub method was called. @@ -4928,14 +4749,13 @@ async def test_delete_user_link_field_headers_async(): def test_delete_user_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_user_link), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_user_link(name="name_value",) @@ -4944,13 +4764,12 @@ def test_delete_user_link_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_user_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4964,7 +4783,7 @@ def test_delete_user_link_flattened_error(): @pytest.mark.asyncio async def test_delete_user_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4981,14 +4800,13 @@ async def test_delete_user_link_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_user_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5003,7 +4821,7 @@ def test_batch_delete_user_links( transport: str = "grpc", request_type=analytics_admin.BatchDeleteUserLinksRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5016,13 +4834,11 @@ def test_batch_delete_user_links( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.batch_delete_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() # Establish that the response is the type that we expect. @@ -5037,7 +4853,7 @@ def test_batch_delete_user_links_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5047,7 +4863,6 @@ def test_batch_delete_user_links_empty_call(): client.batch_delete_user_links() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() @@ -5057,7 +4872,7 @@ async def test_batch_delete_user_links_async( request_type=analytics_admin.BatchDeleteUserLinksRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5070,13 +4885,11 @@ async def test_batch_delete_user_links_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.batch_delete_user_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.BatchDeleteUserLinksRequest() # Establish that the response is the type that we expect. @@ -5090,12 +4903,13 @@ async def test_batch_delete_user_links_async_from_dict(): def test_batch_delete_user_links_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.BatchDeleteUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5103,7 +4917,6 @@ def test_batch_delete_user_links_field_headers(): type(client.transport.batch_delete_user_links), "__call__" ) as call: call.return_value = None - client.batch_delete_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -5119,12 +4932,13 @@ def test_batch_delete_user_links_field_headers(): @pytest.mark.asyncio async def test_batch_delete_user_links_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.BatchDeleteUserLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5132,7 +4946,6 @@ async def test_batch_delete_user_links_field_headers_async(): type(client.transport.batch_delete_user_links), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.batch_delete_user_links(request) # Establish that the underlying gRPC stub method was called. @@ -5149,7 +4962,7 @@ def test_get_web_data_stream( transport: str = "grpc", request_type=analytics_admin.GetWebDataStreamRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5168,27 +4981,19 @@ def test_get_web_data_stream( default_uri="default_uri_value", display_name="display_name_value", ) - response = client.get_web_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetWebDataStreamRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.WebDataStream) - assert response.name == "name_value" - assert response.measurement_id == "measurement_id_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.default_uri == "default_uri_value" - assert response.display_name == "display_name_value" @@ -5200,7 +5005,7 @@ def test_get_web_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5210,7 +5015,6 @@ def test_get_web_data_stream_empty_call(): client.get_web_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetWebDataStreamRequest() @@ -5220,7 +5024,7 @@ async def test_get_web_data_stream_async( request_type=analytics_admin.GetWebDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5241,26 +5045,19 @@ async def test_get_web_data_stream_async( display_name="display_name_value", ) ) - response = await client.get_web_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetWebDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.WebDataStream) - assert response.name == "name_value" - assert response.measurement_id == "measurement_id_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.default_uri == "default_uri_value" - assert response.display_name == "display_name_value" @@ -5271,12 +5068,13 @@ async def test_get_web_data_stream_async_from_dict(): def test_get_web_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetWebDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5284,7 +5082,6 @@ def test_get_web_data_stream_field_headers(): type(client.transport.get_web_data_stream), "__call__" ) as call: call.return_value = resources.WebDataStream() - client.get_web_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -5300,12 +5097,13 @@ def test_get_web_data_stream_field_headers(): @pytest.mark.asyncio async def test_get_web_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetWebDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5315,7 +5113,6 @@ async def test_get_web_data_stream_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.WebDataStream() ) - await client.get_web_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -5330,7 +5127,7 @@ async def test_get_web_data_stream_field_headers_async(): def test_get_web_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5339,7 +5136,6 @@ def test_get_web_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_web_data_stream(name="name_value",) @@ -5348,13 +5144,12 @@ def test_get_web_data_stream_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_web_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5368,7 +5163,7 @@ def test_get_web_data_stream_flattened_error(): @pytest.mark.asyncio async def test_get_web_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5389,14 +5184,13 @@ async def test_get_web_data_stream_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_web_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5411,7 +5205,7 @@ def test_delete_web_data_stream( transport: str = "grpc", request_type=analytics_admin.DeleteWebDataStreamRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5424,13 +5218,11 @@ def test_delete_web_data_stream( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_web_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteWebDataStreamRequest() # Establish that the response is the type that we expect. @@ -5445,7 +5237,7 @@ def test_delete_web_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5455,7 +5247,6 @@ def test_delete_web_data_stream_empty_call(): client.delete_web_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteWebDataStreamRequest() @@ -5465,7 +5256,7 @@ async def test_delete_web_data_stream_async( request_type=analytics_admin.DeleteWebDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5478,13 +5269,11 @@ async def test_delete_web_data_stream_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_web_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteWebDataStreamRequest() # Establish that the response is the type that we expect. @@ -5498,12 +5287,13 @@ async def test_delete_web_data_stream_async_from_dict(): def test_delete_web_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteWebDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5511,7 +5301,6 @@ def test_delete_web_data_stream_field_headers(): type(client.transport.delete_web_data_stream), "__call__" ) as call: call.return_value = None - client.delete_web_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -5527,12 +5316,13 @@ def test_delete_web_data_stream_field_headers(): @pytest.mark.asyncio async def test_delete_web_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteWebDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5540,7 +5330,6 @@ async def test_delete_web_data_stream_field_headers_async(): type(client.transport.delete_web_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_web_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -5555,7 +5344,7 @@ async def test_delete_web_data_stream_field_headers_async(): def test_delete_web_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5564,7 +5353,6 @@ def test_delete_web_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_web_data_stream(name="name_value",) @@ -5573,13 +5361,12 @@ def test_delete_web_data_stream_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_web_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5593,7 +5380,7 @@ def test_delete_web_data_stream_flattened_error(): @pytest.mark.asyncio async def test_delete_web_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5612,14 +5399,13 @@ async def test_delete_web_data_stream_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_web_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5634,7 +5420,7 @@ def test_update_web_data_stream( transport: str = "grpc", request_type=analytics_admin.UpdateWebDataStreamRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5653,27 +5439,19 @@ def test_update_web_data_stream( default_uri="default_uri_value", display_name="display_name_value", ) - response = client.update_web_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateWebDataStreamRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.WebDataStream) - assert response.name == "name_value" - assert response.measurement_id == "measurement_id_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.default_uri == "default_uri_value" - assert response.display_name == "display_name_value" @@ -5685,7 +5463,7 @@ def test_update_web_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5695,7 +5473,6 @@ def test_update_web_data_stream_empty_call(): client.update_web_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateWebDataStreamRequest() @@ -5705,7 +5482,7 @@ async def test_update_web_data_stream_async( request_type=analytics_admin.UpdateWebDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5726,26 +5503,19 @@ async def test_update_web_data_stream_async( display_name="display_name_value", ) ) - response = await client.update_web_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateWebDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.WebDataStream) - assert response.name == "name_value" - assert response.measurement_id == "measurement_id_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.default_uri == "default_uri_value" - assert response.display_name == "display_name_value" @@ -5756,12 +5526,13 @@ async def test_update_web_data_stream_async_from_dict(): def test_update_web_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateWebDataStreamRequest() + request.web_data_stream.name = "web_data_stream.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5769,7 +5540,6 @@ def test_update_web_data_stream_field_headers(): type(client.transport.update_web_data_stream), "__call__" ) as call: call.return_value = resources.WebDataStream() - client.update_web_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -5788,12 +5558,13 @@ def test_update_web_data_stream_field_headers(): @pytest.mark.asyncio async def test_update_web_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateWebDataStreamRequest() + request.web_data_stream.name = "web_data_stream.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5803,7 +5574,6 @@ async def test_update_web_data_stream_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.WebDataStream() ) - await client.update_web_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -5821,7 +5591,7 @@ async def test_update_web_data_stream_field_headers_async(): def test_update_web_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5830,27 +5600,24 @@ def test_update_web_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_web_data_stream( web_data_stream=resources.WebDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].web_data_stream == resources.WebDataStream(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_web_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5859,14 +5626,14 @@ def test_update_web_data_stream_flattened_error(): client.update_web_data_stream( analytics_admin.UpdateWebDataStreamRequest(), web_data_stream=resources.WebDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_web_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5883,23 +5650,21 @@ async def test_update_web_data_stream_flattened_async(): # using the keyword arguments to the method. response = await client.update_web_data_stream( web_data_stream=resources.WebDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].web_data_stream == resources.WebDataStream(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_web_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5908,7 +5673,7 @@ async def test_update_web_data_stream_flattened_error_async(): await client.update_web_data_stream( analytics_admin.UpdateWebDataStreamRequest(), web_data_stream=resources.WebDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -5916,7 +5681,7 @@ def test_create_web_data_stream( transport: str = "grpc", request_type=analytics_admin.CreateWebDataStreamRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5935,27 +5700,19 @@ def test_create_web_data_stream( default_uri="default_uri_value", display_name="display_name_value", ) - response = client.create_web_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateWebDataStreamRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.WebDataStream) - assert response.name == "name_value" - assert response.measurement_id == "measurement_id_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.default_uri == "default_uri_value" - assert response.display_name == "display_name_value" @@ -5967,7 +5724,7 @@ def test_create_web_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5977,7 +5734,6 @@ def test_create_web_data_stream_empty_call(): client.create_web_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateWebDataStreamRequest() @@ -5987,7 +5743,7 @@ async def test_create_web_data_stream_async( request_type=analytics_admin.CreateWebDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6008,26 +5764,19 @@ async def test_create_web_data_stream_async( display_name="display_name_value", ) ) - response = await client.create_web_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateWebDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.WebDataStream) - assert response.name == "name_value" - assert response.measurement_id == "measurement_id_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.default_uri == "default_uri_value" - assert response.display_name == "display_name_value" @@ -6038,12 +5787,13 @@ async def test_create_web_data_stream_async_from_dict(): def test_create_web_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.CreateWebDataStreamRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6051,7 +5801,6 @@ def test_create_web_data_stream_field_headers(): type(client.transport.create_web_data_stream), "__call__" ) as call: call.return_value = resources.WebDataStream() - client.create_web_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -6067,12 +5816,13 @@ def test_create_web_data_stream_field_headers(): @pytest.mark.asyncio async def test_create_web_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.CreateWebDataStreamRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6082,7 +5832,6 @@ async def test_create_web_data_stream_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.WebDataStream() ) - await client.create_web_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -6097,7 +5846,7 @@ async def test_create_web_data_stream_field_headers_async(): def test_create_web_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6106,7 +5855,6 @@ def test_create_web_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.WebDataStream() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_web_data_stream( @@ -6118,15 +5866,13 @@ def test_create_web_data_stream_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].web_data_stream == resources.WebDataStream(name="name_value") def test_create_web_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6142,7 +5888,7 @@ def test_create_web_data_stream_flattened_error(): @pytest.mark.asyncio async def test_create_web_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6166,16 +5912,14 @@ async def test_create_web_data_stream_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].web_data_stream == resources.WebDataStream(name="name_value") @pytest.mark.asyncio async def test_create_web_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6192,7 +5936,7 @@ def test_list_web_data_streams( transport: str = "grpc", request_type=analytics_admin.ListWebDataStreamsRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6207,19 +5951,15 @@ def test_list_web_data_streams( call.return_value = analytics_admin.ListWebDataStreamsResponse( next_page_token="next_page_token_value", ) - response = client.list_web_data_streams(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListWebDataStreamsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListWebDataStreamsPager) - assert response.next_page_token == "next_page_token_value" @@ -6231,7 +5971,7 @@ def test_list_web_data_streams_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6241,7 +5981,6 @@ def test_list_web_data_streams_empty_call(): client.list_web_data_streams() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListWebDataStreamsRequest() @@ -6251,7 +5990,7 @@ async def test_list_web_data_streams_async( request_type=analytics_admin.ListWebDataStreamsRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6268,18 +6007,15 @@ async def test_list_web_data_streams_async( next_page_token="next_page_token_value", ) ) - response = await client.list_web_data_streams(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListWebDataStreamsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListWebDataStreamsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -6290,12 +6026,13 @@ async def test_list_web_data_streams_async_from_dict(): def test_list_web_data_streams_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListWebDataStreamsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6303,7 +6040,6 @@ def test_list_web_data_streams_field_headers(): type(client.transport.list_web_data_streams), "__call__" ) as call: call.return_value = analytics_admin.ListWebDataStreamsResponse() - client.list_web_data_streams(request) # Establish that the underlying gRPC stub method was called. @@ -6319,12 +6055,13 @@ def test_list_web_data_streams_field_headers(): @pytest.mark.asyncio async def test_list_web_data_streams_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListWebDataStreamsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6334,7 +6071,6 @@ async def test_list_web_data_streams_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListWebDataStreamsResponse() ) - await client.list_web_data_streams(request) # Establish that the underlying gRPC stub method was called. @@ -6349,7 +6085,7 @@ async def test_list_web_data_streams_field_headers_async(): def test_list_web_data_streams_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6358,7 +6094,6 @@ def test_list_web_data_streams_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListWebDataStreamsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_web_data_streams(parent="parent_value",) @@ -6367,13 +6102,12 @@ def test_list_web_data_streams_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_web_data_streams_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6387,7 +6121,7 @@ def test_list_web_data_streams_flattened_error(): @pytest.mark.asyncio async def test_list_web_data_streams_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6408,14 +6142,13 @@ async def test_list_web_data_streams_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_web_data_streams_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6427,7 +6160,9 @@ async def test_list_web_data_streams_flattened_error_async(): def test_list_web_data_streams_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6472,7 +6207,9 @@ def test_list_web_data_streams_pager(): def test_list_web_data_streams_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6510,7 +6247,7 @@ def test_list_web_data_streams_pages(): @pytest.mark.asyncio async def test_list_web_data_streams_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6556,7 +6293,7 @@ async def test_list_web_data_streams_async_pager(): @pytest.mark.asyncio async def test_list_web_data_streams_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6600,7 +6337,7 @@ def test_get_ios_app_data_stream( transport: str = "grpc", request_type=analytics_admin.GetIosAppDataStreamRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6618,25 +6355,18 @@ def test_get_ios_app_data_stream( bundle_id="bundle_id_value", display_name="display_name_value", ) - response = client.get_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetIosAppDataStreamRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.IosAppDataStream) - assert response.name == "name_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.bundle_id == "bundle_id_value" - assert response.display_name == "display_name_value" @@ -6648,7 +6378,7 @@ def test_get_ios_app_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6658,7 +6388,6 @@ def test_get_ios_app_data_stream_empty_call(): client.get_ios_app_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetIosAppDataStreamRequest() @@ -6668,7 +6397,7 @@ async def test_get_ios_app_data_stream_async( request_type=analytics_admin.GetIosAppDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6688,24 +6417,18 @@ async def test_get_ios_app_data_stream_async( display_name="display_name_value", ) ) - response = await client.get_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetIosAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.IosAppDataStream) - assert response.name == "name_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.bundle_id == "bundle_id_value" - assert response.display_name == "display_name_value" @@ -6716,12 +6439,13 @@ async def test_get_ios_app_data_stream_async_from_dict(): def test_get_ios_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetIosAppDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6729,7 +6453,6 @@ def test_get_ios_app_data_stream_field_headers(): type(client.transport.get_ios_app_data_stream), "__call__" ) as call: call.return_value = resources.IosAppDataStream() - client.get_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -6745,12 +6468,13 @@ def test_get_ios_app_data_stream_field_headers(): @pytest.mark.asyncio async def test_get_ios_app_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetIosAppDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6760,7 +6484,6 @@ async def test_get_ios_app_data_stream_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.IosAppDataStream() ) - await client.get_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -6775,7 +6498,7 @@ async def test_get_ios_app_data_stream_field_headers_async(): def test_get_ios_app_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6784,7 +6507,6 @@ def test_get_ios_app_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_ios_app_data_stream(name="name_value",) @@ -6793,13 +6515,12 @@ def test_get_ios_app_data_stream_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_ios_app_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6813,7 +6534,7 @@ def test_get_ios_app_data_stream_flattened_error(): @pytest.mark.asyncio async def test_get_ios_app_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6834,14 +6555,13 @@ async def test_get_ios_app_data_stream_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_ios_app_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6856,7 +6576,7 @@ def test_delete_ios_app_data_stream( transport: str = "grpc", request_type=analytics_admin.DeleteIosAppDataStreamRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6869,13 +6589,11 @@ def test_delete_ios_app_data_stream( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteIosAppDataStreamRequest() # Establish that the response is the type that we expect. @@ -6890,7 +6608,7 @@ def test_delete_ios_app_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6900,7 +6618,6 @@ def test_delete_ios_app_data_stream_empty_call(): client.delete_ios_app_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteIosAppDataStreamRequest() @@ -6910,7 +6627,7 @@ async def test_delete_ios_app_data_stream_async( request_type=analytics_admin.DeleteIosAppDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6923,13 +6640,11 @@ async def test_delete_ios_app_data_stream_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteIosAppDataStreamRequest() # Establish that the response is the type that we expect. @@ -6943,12 +6658,13 @@ async def test_delete_ios_app_data_stream_async_from_dict(): def test_delete_ios_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteIosAppDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6956,7 +6672,6 @@ def test_delete_ios_app_data_stream_field_headers(): type(client.transport.delete_ios_app_data_stream), "__call__" ) as call: call.return_value = None - client.delete_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -6972,12 +6687,13 @@ def test_delete_ios_app_data_stream_field_headers(): @pytest.mark.asyncio async def test_delete_ios_app_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteIosAppDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6985,7 +6701,6 @@ async def test_delete_ios_app_data_stream_field_headers_async(): type(client.transport.delete_ios_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -7000,7 +6715,7 @@ async def test_delete_ios_app_data_stream_field_headers_async(): def test_delete_ios_app_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7009,7 +6724,6 @@ def test_delete_ios_app_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_ios_app_data_stream(name="name_value",) @@ -7018,13 +6732,12 @@ def test_delete_ios_app_data_stream_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_ios_app_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7038,7 +6751,7 @@ def test_delete_ios_app_data_stream_flattened_error(): @pytest.mark.asyncio async def test_delete_ios_app_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7057,14 +6770,13 @@ async def test_delete_ios_app_data_stream_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_ios_app_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7079,7 +6791,7 @@ def test_update_ios_app_data_stream( transport: str = "grpc", request_type=analytics_admin.UpdateIosAppDataStreamRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7097,25 +6809,18 @@ def test_update_ios_app_data_stream( bundle_id="bundle_id_value", display_name="display_name_value", ) - response = client.update_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateIosAppDataStreamRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.IosAppDataStream) - assert response.name == "name_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.bundle_id == "bundle_id_value" - assert response.display_name == "display_name_value" @@ -7127,7 +6832,7 @@ def test_update_ios_app_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7137,7 +6842,6 @@ def test_update_ios_app_data_stream_empty_call(): client.update_ios_app_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateIosAppDataStreamRequest() @@ -7147,7 +6851,7 @@ async def test_update_ios_app_data_stream_async( request_type=analytics_admin.UpdateIosAppDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7167,24 +6871,18 @@ async def test_update_ios_app_data_stream_async( display_name="display_name_value", ) ) - response = await client.update_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateIosAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.IosAppDataStream) - assert response.name == "name_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.bundle_id == "bundle_id_value" - assert response.display_name == "display_name_value" @@ -7195,12 +6893,13 @@ async def test_update_ios_app_data_stream_async_from_dict(): def test_update_ios_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateIosAppDataStreamRequest() + request.ios_app_data_stream.name = "ios_app_data_stream.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7208,7 +6907,6 @@ def test_update_ios_app_data_stream_field_headers(): type(client.transport.update_ios_app_data_stream), "__call__" ) as call: call.return_value = resources.IosAppDataStream() - client.update_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -7227,12 +6925,13 @@ def test_update_ios_app_data_stream_field_headers(): @pytest.mark.asyncio async def test_update_ios_app_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateIosAppDataStreamRequest() + request.ios_app_data_stream.name = "ios_app_data_stream.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7242,7 +6941,6 @@ async def test_update_ios_app_data_stream_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.IosAppDataStream() ) - await client.update_ios_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -7260,7 +6958,7 @@ async def test_update_ios_app_data_stream_field_headers_async(): def test_update_ios_app_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7269,29 +6967,26 @@ def test_update_ios_app_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.IosAppDataStream() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_ios_app_data_stream( ios_app_data_stream=resources.IosAppDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].ios_app_data_stream == resources.IosAppDataStream( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_ios_app_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7300,14 +6995,14 @@ def test_update_ios_app_data_stream_flattened_error(): client.update_ios_app_data_stream( analytics_admin.UpdateIosAppDataStreamRequest(), ios_app_data_stream=resources.IosAppDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_ios_app_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7324,25 +7019,23 @@ async def test_update_ios_app_data_stream_flattened_async(): # using the keyword arguments to the method. response = await client.update_ios_app_data_stream( ios_app_data_stream=resources.IosAppDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].ios_app_data_stream == resources.IosAppDataStream( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_ios_app_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7351,15 +7044,15 @@ async def test_update_ios_app_data_stream_flattened_error_async(): await client.update_ios_app_data_stream( analytics_admin.UpdateIosAppDataStreamRequest(), ios_app_data_stream=resources.IosAppDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_create_ios_app_data_stream( - transport: str = "grpc", request_type=analytics_admin.CreateIosAppDataStreamRequest +def test_list_ios_app_data_streams( + transport: str = "grpc", request_type=analytics_admin.ListIosAppDataStreamsRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7368,66 +7061,52 @@ def test_create_ios_app_data_stream( # 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.list_ios_app_data_streams), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream( - name="name_value", - firebase_app_id="firebase_app_id_value", - bundle_id="bundle_id_value", - display_name="display_name_value", + call.return_value = analytics_admin.ListIosAppDataStreamsResponse( + next_page_token="next_page_token_value", ) - - response = client.create_ios_app_data_stream(request) + response = client.list_ios_app_data_streams(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() + assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, resources.IosAppDataStream) - - assert response.name == "name_value" - - assert response.firebase_app_id == "firebase_app_id_value" - - assert response.bundle_id == "bundle_id_value" - - assert response.display_name == "display_name_value" + assert isinstance(response, pagers.ListIosAppDataStreamsPager) + assert response.next_page_token == "next_page_token_value" -def test_create_ios_app_data_stream_from_dict(): - test_create_ios_app_data_stream(request_type=dict) +def test_list_ios_app_data_streams_from_dict(): + test_list_ios_app_data_streams(request_type=dict) -def test_create_ios_app_data_stream_empty_call(): +def test_list_ios_app_data_streams_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_ios_app_data_stream), "__call__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: - client.create_ios_app_data_stream() + client.list_ios_app_data_streams() call.assert_called() _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() + assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() @pytest.mark.asyncio -async def test_create_ios_app_data_stream_async( +async def test_list_ios_app_data_streams_async( transport: str = "grpc_asyncio", - request_type=analytics_admin.CreateIosAppDataStreamRequest, + request_type=analytics_admin.ListIosAppDataStreamsRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7436,60 +7115,48 @@ async def test_create_ios_app_data_stream_async( # 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.list_ios_app_data_streams), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.IosAppDataStream( - name="name_value", - firebase_app_id="firebase_app_id_value", - bundle_id="bundle_id_value", - display_name="display_name_value", + analytics_admin.ListIosAppDataStreamsResponse( + next_page_token="next_page_token_value", ) ) - - response = await client.create_ios_app_data_stream(request) + response = await client.list_ios_app_data_streams(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateIosAppDataStreamRequest() + assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.IosAppDataStream) - - assert response.name == "name_value" - - assert response.firebase_app_id == "firebase_app_id_value" - - assert response.bundle_id == "bundle_id_value" - - assert response.display_name == "display_name_value" + assert isinstance(response, pagers.ListIosAppDataStreamsAsyncPager) + assert response.next_page_token == "next_page_token_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) +async def test_list_ios_app_data_streams_async_from_dict(): + await test_list_ios_app_data_streams_async(request_type=dict) -def test_create_ios_app_data_stream_field_headers(): +def test_list_ios_app_data_streams_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = analytics_admin.CreateIosAppDataStreamRequest() + request = analytics_admin.ListIosAppDataStreamsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_ios_app_data_stream), "__call__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: - call.return_value = resources.IosAppDataStream() - - client.create_ios_app_data_stream(request) + call.return_value = analytics_admin.ListIosAppDataStreamsResponse() + client.list_ios_app_data_streams(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7502,25 +7169,25 @@ def test_create_ios_app_data_stream_field_headers(): @pytest.mark.asyncio -async def test_create_ios_app_data_stream_field_headers_async(): +async def test_list_ios_app_data_streams_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = analytics_admin.CreateIosAppDataStreamRequest() + request = analytics_admin.ListIosAppDataStreamsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_ios_app_data_stream), "__call__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.IosAppDataStream() + analytics_admin.ListIosAppDataStreamsResponse() ) - - await client.create_ios_app_data_stream(request) + await client.list_ios_app_data_streams(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7532,390 +7199,135 @@ async def test_create_ios_app_data_stream_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_create_ios_app_data_stream_flattened(): +def test_list_ios_app_data_streams_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_ios_app_data_stream), "__call__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream() - + call.return_value = analytics_admin.ListIosAppDataStreamsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_ios_app_data_stream( - parent="parent_value", - ios_app_data_stream=resources.IosAppDataStream(name="name_value"), - ) + client.list_ios_app_data_streams(parent="parent_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].ios_app_data_stream == resources.IosAppDataStream( - name="name_value" - ) - -def test_create_ios_app_data_stream_flattened_error(): +def test_list_ios_app_data_streams_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_ios_app_data_stream( - analytics_admin.CreateIosAppDataStreamRequest(), - parent="parent_value", - ios_app_data_stream=resources.IosAppDataStream(name="name_value"), + client.list_ios_app_data_streams( + analytics_admin.ListIosAppDataStreamsRequest(), parent="parent_value", ) @pytest.mark.asyncio -async def test_create_ios_app_data_stream_flattened_async(): +async def test_list_ios_app_data_streams_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.create_ios_app_data_stream), "__call__" + type(client.transport.list_ios_app_data_streams), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.IosAppDataStream() + call.return_value = analytics_admin.ListIosAppDataStreamsResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.IosAppDataStream() + analytics_admin.ListIosAppDataStreamsResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_ios_app_data_stream( - parent="parent_value", - ios_app_data_stream=resources.IosAppDataStream(name="name_value"), - ) + response = await client.list_ios_app_data_streams(parent="parent_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].ios_app_data_stream == resources.IosAppDataStream( - name="name_value" - ) - @pytest.mark.asyncio -async def test_create_ios_app_data_stream_flattened_error_async(): +async def test_list_ios_app_data_streams_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.create_ios_app_data_stream( - analytics_admin.CreateIosAppDataStreamRequest(), - parent="parent_value", - ios_app_data_stream=resources.IosAppDataStream(name="name_value"), + await client.list_ios_app_data_streams( + analytics_admin.ListIosAppDataStreamsRequest(), parent="parent_value", ) -def test_list_ios_app_data_streams( - transport: str = "grpc", request_type=analytics_admin.ListIosAppDataStreamsRequest -): +def test_list_ios_app_data_streams_pager(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.list_ios_app_data_streams), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListIosAppDataStreamsResponse( - next_page_token="next_page_token_value", + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + next_page_token="abc", + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[], next_page_token="def", + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[resources.IosAppDataStream(),], + next_page_token="ghi", + ), + analytics_admin.ListIosAppDataStreamsResponse( + ios_app_data_streams=[ + resources.IosAppDataStream(), + resources.IosAppDataStream(), + ], + ), + RuntimeError, ) - response = client.list_ios_app_data_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, pagers.ListIosAppDataStreamsPager) - - assert response.next_page_token == "next_page_token_value" + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_ios_app_data_streams(request={}) + assert pager._metadata == metadata -def test_list_ios_app_data_streams_from_dict(): - test_list_ios_app_data_streams(request_type=dict) + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.IosAppDataStream) for i in results) -def test_list_ios_app_data_streams_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. +def test_list_ios_app_data_streams_pages(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), "__call__" - ) as call: - client.list_ios_app_data_streams() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() - - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_async( - transport: str = "grpc_asyncio", - request_type=analytics_admin.ListIosAppDataStreamsRequest, -): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_admin.ListIosAppDataStreamsResponse( - next_page_token="next_page_token_value", - ) - ) - - response = await client.list_ios_app_data_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.ListIosAppDataStreamsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListIosAppDataStreamsAsyncPager) - - assert response.next_page_token == "next_page_token_value" - - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_async_from_dict(): - await test_list_ios_app_data_streams_async(request_type=dict) - - -def test_list_ios_app_data_streams_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListIosAppDataStreamsRequest() - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), "__call__" - ) as call: - call.return_value = analytics_admin.ListIosAppDataStreamsResponse() - - client.list_ios_app_data_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.ListIosAppDataStreamsRequest() - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_admin.ListIosAppDataStreamsResponse() - ) - - await client.list_ios_app_data_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] - - -def test_list_ios_app_data_streams_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListIosAppDataStreamsResponse() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_ios_app_data_streams(parent="parent_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" - - -def test_list_ios_app_data_streams_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_ios_app_data_streams( - analytics_admin.ListIosAppDataStreamsRequest(), parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListIosAppDataStreamsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_admin.ListIosAppDataStreamsResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_ios_app_data_streams(parent="parent_value",) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" - - -@pytest.mark.asyncio -async def test_list_ios_app_data_streams_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_ios_app_data_streams( - analytics_admin.ListIosAppDataStreamsRequest(), parent="parent_value", - ) - - -def test_list_ios_app_data_streams_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ios_app_data_streams), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - next_page_token="abc", - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[], next_page_token="def", - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[resources.IosAppDataStream(),], - next_page_token="ghi", - ), - analytics_admin.ListIosAppDataStreamsResponse( - ios_app_data_streams=[ - resources.IosAppDataStream(), - resources.IosAppDataStream(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_ios_app_data_streams(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.IosAppDataStream) for i in results) - - -def test_list_ios_app_data_streams_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) - # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.list_ios_app_data_streams), "__call__" @@ -7953,7 +7365,7 @@ def test_list_ios_app_data_streams_pages(): @pytest.mark.asyncio async def test_list_ios_app_data_streams_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8000,7 +7412,7 @@ async def test_list_ios_app_data_streams_async_pager(): @pytest.mark.asyncio async def test_list_ios_app_data_streams_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8045,7 +7457,7 @@ def test_get_android_app_data_stream( transport: str = "grpc", request_type=analytics_admin.GetAndroidAppDataStreamRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8063,25 +7475,18 @@ def test_get_android_app_data_stream( package_name="package_name_value", display_name="display_name_value", ) - response = client.get_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.AndroidAppDataStream) - assert response.name == "name_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.package_name == "package_name_value" - assert response.display_name == "display_name_value" @@ -8093,7 +7498,7 @@ def test_get_android_app_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8103,7 +7508,6 @@ def test_get_android_app_data_stream_empty_call(): client.get_android_app_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetAndroidAppDataStreamRequest() @@ -8113,7 +7517,7 @@ async def test_get_android_app_data_stream_async( request_type=analytics_admin.GetAndroidAppDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8133,24 +7537,18 @@ async def test_get_android_app_data_stream_async( display_name="display_name_value", ) ) - response = await client.get_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.AndroidAppDataStream) - assert response.name == "name_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.package_name == "package_name_value" - assert response.display_name == "display_name_value" @@ -8161,12 +7559,13 @@ async def test_get_android_app_data_stream_async_from_dict(): def test_get_android_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetAndroidAppDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8174,7 +7573,6 @@ def test_get_android_app_data_stream_field_headers(): type(client.transport.get_android_app_data_stream), "__call__" ) as call: call.return_value = resources.AndroidAppDataStream() - client.get_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -8190,12 +7588,13 @@ def test_get_android_app_data_stream_field_headers(): @pytest.mark.asyncio async def test_get_android_app_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetAndroidAppDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8205,7 +7604,6 @@ async def test_get_android_app_data_stream_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.AndroidAppDataStream() ) - await client.get_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -8220,7 +7618,7 @@ async def test_get_android_app_data_stream_field_headers_async(): def test_get_android_app_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8229,7 +7627,6 @@ def test_get_android_app_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_android_app_data_stream(name="name_value",) @@ -8238,13 +7635,12 @@ def test_get_android_app_data_stream_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_android_app_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -8258,7 +7654,7 @@ def test_get_android_app_data_stream_flattened_error(): @pytest.mark.asyncio async def test_get_android_app_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8279,14 +7675,13 @@ async def test_get_android_app_data_stream_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_android_app_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -8302,7 +7697,7 @@ def test_delete_android_app_data_stream( request_type=analytics_admin.DeleteAndroidAppDataStreamRequest, ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8315,13 +7710,11 @@ def test_delete_android_app_data_stream( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. @@ -8336,7 +7729,7 @@ def test_delete_android_app_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8346,7 +7739,6 @@ def test_delete_android_app_data_stream_empty_call(): client.delete_android_app_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteAndroidAppDataStreamRequest() @@ -8356,7 +7748,7 @@ async def test_delete_android_app_data_stream_async( request_type=analytics_admin.DeleteAndroidAppDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8369,13 +7761,11 @@ async def test_delete_android_app_data_stream_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. @@ -8389,12 +7779,13 @@ async def test_delete_android_app_data_stream_async_from_dict(): def test_delete_android_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteAndroidAppDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8402,7 +7793,6 @@ def test_delete_android_app_data_stream_field_headers(): type(client.transport.delete_android_app_data_stream), "__call__" ) as call: call.return_value = None - client.delete_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -8418,12 +7808,13 @@ def test_delete_android_app_data_stream_field_headers(): @pytest.mark.asyncio async def test_delete_android_app_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteAndroidAppDataStreamRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8431,7 +7822,6 @@ async def test_delete_android_app_data_stream_field_headers_async(): type(client.transport.delete_android_app_data_stream), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -8446,7 +7836,7 @@ async def test_delete_android_app_data_stream_field_headers_async(): def test_delete_android_app_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8455,7 +7845,6 @@ def test_delete_android_app_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_android_app_data_stream(name="name_value",) @@ -8464,13 +7853,12 @@ def test_delete_android_app_data_stream_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_android_app_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -8484,7 +7872,7 @@ def test_delete_android_app_data_stream_flattened_error(): @pytest.mark.asyncio async def test_delete_android_app_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8503,14 +7891,13 @@ async def test_delete_android_app_data_stream_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_android_app_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -8526,7 +7913,7 @@ def test_update_android_app_data_stream( request_type=analytics_admin.UpdateAndroidAppDataStreamRequest, ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8544,25 +7931,18 @@ def test_update_android_app_data_stream( package_name="package_name_value", display_name="display_name_value", ) - response = client.update_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.AndroidAppDataStream) - assert response.name == "name_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.package_name == "package_name_value" - assert response.display_name == "display_name_value" @@ -8574,7 +7954,7 @@ def test_update_android_app_data_stream_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8584,7 +7964,6 @@ def test_update_android_app_data_stream_empty_call(): client.update_android_app_data_stream() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateAndroidAppDataStreamRequest() @@ -8594,7 +7973,7 @@ async def test_update_android_app_data_stream_async( request_type=analytics_admin.UpdateAndroidAppDataStreamRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8614,24 +7993,18 @@ async def test_update_android_app_data_stream_async( display_name="display_name_value", ) ) - response = await client.update_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateAndroidAppDataStreamRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.AndroidAppDataStream) - assert response.name == "name_value" - assert response.firebase_app_id == "firebase_app_id_value" - assert response.package_name == "package_name_value" - assert response.display_name == "display_name_value" @@ -8642,12 +8015,13 @@ async def test_update_android_app_data_stream_async_from_dict(): def test_update_android_app_data_stream_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateAndroidAppDataStreamRequest() + request.android_app_data_stream.name = "android_app_data_stream.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8655,7 +8029,6 @@ def test_update_android_app_data_stream_field_headers(): type(client.transport.update_android_app_data_stream), "__call__" ) as call: call.return_value = resources.AndroidAppDataStream() - client.update_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -8674,12 +8047,13 @@ def test_update_android_app_data_stream_field_headers(): @pytest.mark.asyncio async def test_update_android_app_data_stream_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateAndroidAppDataStreamRequest() + request.android_app_data_stream.name = "android_app_data_stream.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8689,7 +8063,6 @@ async def test_update_android_app_data_stream_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.AndroidAppDataStream() ) - await client.update_android_app_data_stream(request) # Establish that the underlying gRPC stub method was called. @@ -8707,7 +8080,7 @@ async def test_update_android_app_data_stream_field_headers_async(): def test_update_android_app_data_stream_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8716,29 +8089,26 @@ def test_update_android_app_data_stream_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.AndroidAppDataStream() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_android_app_data_stream( android_app_data_stream=resources.AndroidAppDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].android_app_data_stream == resources.AndroidAppDataStream( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_android_app_data_stream_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -8747,14 +8117,14 @@ def test_update_android_app_data_stream_flattened_error(): client.update_android_app_data_stream( analytics_admin.UpdateAndroidAppDataStreamRequest(), android_app_data_stream=resources.AndroidAppDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_android_app_data_stream_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8771,25 +8141,23 @@ async def test_update_android_app_data_stream_flattened_async(): # using the keyword arguments to the method. response = await client.update_android_app_data_stream( android_app_data_stream=resources.AndroidAppDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].android_app_data_stream == resources.AndroidAppDataStream( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_android_app_data_stream_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -8798,282 +8166,7 @@ async def test_update_android_app_data_stream_flattened_error_async(): await client.update_android_app_data_stream( analytics_admin.UpdateAndroidAppDataStreamRequest(), android_app_data_stream=resources.AndroidAppDataStream(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), - ) - - -def test_create_android_app_data_stream( - transport: str = "grpc", - request_type=analytics_admin.CreateAndroidAppDataStreamRequest, -): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream( - name="name_value", - firebase_app_id="firebase_app_id_value", - package_name="package_name_value", - display_name="display_name_value", - ) - - response = client.create_android_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - - assert isinstance(response, resources.AndroidAppDataStream) - - assert response.name == "name_value" - - assert response.firebase_app_id == "firebase_app_id_value" - - assert response.package_name == "package_name_value" - - assert response.display_name == "display_name_value" - - -def test_create_android_app_data_stream_from_dict(): - test_create_android_app_data_stream(request_type=dict) - - -def test_create_android_app_data_stream_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), "__call__" - ) as call: - client.create_android_app_data_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() - - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_async( - transport: str = "grpc_asyncio", - request_type=analytics_admin.CreateAndroidAppDataStreamRequest, -): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.AndroidAppDataStream( - name="name_value", - firebase_app_id="firebase_app_id_value", - package_name="package_name_value", - display_name="display_name_value", - ) - ) - - response = await client.create_android_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0] == analytics_admin.CreateAndroidAppDataStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.AndroidAppDataStream) - - assert response.name == "name_value" - - assert response.firebase_app_id == "firebase_app_id_value" - - assert response.package_name == "package_name_value" - - assert response.display_name == "display_name_value" - - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_async_from_dict(): - await test_create_android_app_data_stream_async(request_type=dict) - - -def test_create_android_app_data_stream_field_headers(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateAndroidAppDataStreamRequest() - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), "__call__" - ) as call: - call.return_value = resources.AndroidAppDataStream() - - client.create_android_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_field_headers_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = analytics_admin.CreateAndroidAppDataStreamRequest() - request.parent = "parent/value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.AndroidAppDataStream() - ) - - await client.create_android_app_data_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] - - -def test_create_android_app_data_stream_flattened(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream() - - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_android_app_data_stream( - parent="parent_value", - android_app_data_stream=resources.AndroidAppDataStream(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" - - assert args[0].android_app_data_stream == resources.AndroidAppDataStream( - name="name_value" - ) - - -def test_create_android_app_data_stream_flattened_error(): - client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_android_app_data_stream( - analytics_admin.CreateAndroidAppDataStreamRequest(), - parent="parent_value", - android_app_data_stream=resources.AndroidAppDataStream(name="name_value"), - ) - - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_flattened_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_android_app_data_stream), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = resources.AndroidAppDataStream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.AndroidAppDataStream() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_android_app_data_stream( - parent="parent_value", - android_app_data_stream=resources.AndroidAppDataStream(name="name_value"), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - - assert args[0].parent == "parent_value" - - assert args[0].android_app_data_stream == resources.AndroidAppDataStream( - name="name_value" - ) - - -@pytest.mark.asyncio -async def test_create_android_app_data_stream_flattened_error_async(): - client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_android_app_data_stream( - analytics_admin.CreateAndroidAppDataStreamRequest(), - parent="parent_value", - android_app_data_stream=resources.AndroidAppDataStream(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -9082,7 +8175,7 @@ def test_list_android_app_data_streams( request_type=analytics_admin.ListAndroidAppDataStreamsRequest, ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -9097,19 +8190,15 @@ def test_list_android_app_data_streams( call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse( next_page_token="next_page_token_value", ) - response = client.list_android_app_data_streams(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAndroidAppDataStreamsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAndroidAppDataStreamsPager) - assert response.next_page_token == "next_page_token_value" @@ -9121,7 +8210,7 @@ def test_list_android_app_data_streams_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9131,7 +8220,6 @@ def test_list_android_app_data_streams_empty_call(): client.list_android_app_data_streams() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAndroidAppDataStreamsRequest() @@ -9141,7 +8229,7 @@ async def test_list_android_app_data_streams_async( request_type=analytics_admin.ListAndroidAppDataStreamsRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -9158,18 +8246,15 @@ async def test_list_android_app_data_streams_async( next_page_token="next_page_token_value", ) ) - response = await client.list_android_app_data_streams(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListAndroidAppDataStreamsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAndroidAppDataStreamsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -9180,12 +8265,13 @@ async def test_list_android_app_data_streams_async_from_dict(): def test_list_android_app_data_streams_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListAndroidAppDataStreamsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -9193,7 +8279,6 @@ def test_list_android_app_data_streams_field_headers(): type(client.transport.list_android_app_data_streams), "__call__" ) as call: call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() - client.list_android_app_data_streams(request) # Establish that the underlying gRPC stub method was called. @@ -9209,12 +8294,13 @@ def test_list_android_app_data_streams_field_headers(): @pytest.mark.asyncio async def test_list_android_app_data_streams_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListAndroidAppDataStreamsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -9224,7 +8310,6 @@ async def test_list_android_app_data_streams_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListAndroidAppDataStreamsResponse() ) - await client.list_android_app_data_streams(request) # Establish that the underlying gRPC stub method was called. @@ -9239,7 +8324,7 @@ async def test_list_android_app_data_streams_field_headers_async(): def test_list_android_app_data_streams_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9248,7 +8333,6 @@ def test_list_android_app_data_streams_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListAndroidAppDataStreamsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_android_app_data_streams(parent="parent_value",) @@ -9257,13 +8341,12 @@ def test_list_android_app_data_streams_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_android_app_data_streams_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -9277,7 +8360,7 @@ def test_list_android_app_data_streams_flattened_error(): @pytest.mark.asyncio async def test_list_android_app_data_streams_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9298,14 +8381,13 @@ async def test_list_android_app_data_streams_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_android_app_data_streams_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -9317,7 +8399,9 @@ async def test_list_android_app_data_streams_flattened_error_async(): def test_list_android_app_data_streams_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -9363,7 +8447,9 @@ def test_list_android_app_data_streams_pager(): def test_list_android_app_data_streams_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -9402,7 +8488,7 @@ def test_list_android_app_data_streams_pages(): @pytest.mark.asyncio async def test_list_android_app_data_streams_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9449,7 +8535,7 @@ async def test_list_android_app_data_streams_async_pager(): @pytest.mark.asyncio async def test_list_android_app_data_streams_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9497,7 +8583,7 @@ def test_get_enhanced_measurement_settings( request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest, ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -9523,41 +8609,26 @@ def test_get_enhanced_measurement_settings( search_query_parameter="search_query_parameter_value", uri_query_parameter="uri_query_parameter_value", ) - response = client.get_enhanced_measurement_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.EnhancedMeasurementSettings) - assert response.name == "name_value" - assert response.stream_enabled is True - assert response.page_views_enabled is True - assert response.scrolls_enabled is True - assert response.outbound_clicks_enabled is True - assert response.site_search_enabled is True - assert response.video_engagement_enabled is True - assert response.file_downloads_enabled is True - assert response.page_loads_enabled is True - assert response.page_changes_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.uri_query_parameter == "uri_query_parameter_value" @@ -9569,7 +8640,7 @@ def test_get_enhanced_measurement_settings_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9579,7 +8650,6 @@ def test_get_enhanced_measurement_settings_empty_call(): client.get_enhanced_measurement_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() @@ -9589,7 +8659,7 @@ async def test_get_enhanced_measurement_settings_async( request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -9617,40 +8687,26 @@ async def test_get_enhanced_measurement_settings_async( uri_query_parameter="uri_query_parameter_value", ) ) - response = await client.get_enhanced_measurement_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetEnhancedMeasurementSettingsRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.EnhancedMeasurementSettings) - assert response.name == "name_value" - assert response.stream_enabled is True - assert response.page_views_enabled is True - assert response.scrolls_enabled is True - assert response.outbound_clicks_enabled is True - assert response.site_search_enabled is True - assert response.video_engagement_enabled is True - assert response.file_downloads_enabled is True - assert response.page_loads_enabled is True - assert response.page_changes_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.uri_query_parameter == "uri_query_parameter_value" @@ -9661,12 +8717,13 @@ async def test_get_enhanced_measurement_settings_async_from_dict(): def test_get_enhanced_measurement_settings_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetEnhancedMeasurementSettingsRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -9674,7 +8731,6 @@ def test_get_enhanced_measurement_settings_field_headers(): type(client.transport.get_enhanced_measurement_settings), "__call__" ) as call: call.return_value = resources.EnhancedMeasurementSettings() - client.get_enhanced_measurement_settings(request) # Establish that the underlying gRPC stub method was called. @@ -9690,12 +8746,13 @@ def test_get_enhanced_measurement_settings_field_headers(): @pytest.mark.asyncio async def test_get_enhanced_measurement_settings_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetEnhancedMeasurementSettingsRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -9705,7 +8762,6 @@ async def test_get_enhanced_measurement_settings_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.EnhancedMeasurementSettings() ) - await client.get_enhanced_measurement_settings(request) # Establish that the underlying gRPC stub method was called. @@ -9720,7 +8776,7 @@ async def test_get_enhanced_measurement_settings_field_headers_async(): def test_get_enhanced_measurement_settings_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9729,7 +8785,6 @@ def test_get_enhanced_measurement_settings_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.EnhancedMeasurementSettings() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_enhanced_measurement_settings(name="name_value",) @@ -9738,13 +8793,12 @@ def test_get_enhanced_measurement_settings_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_enhanced_measurement_settings_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -9758,7 +8812,7 @@ def test_get_enhanced_measurement_settings_flattened_error(): @pytest.mark.asyncio async def test_get_enhanced_measurement_settings_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9779,14 +8833,13 @@ async def test_get_enhanced_measurement_settings_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_enhanced_measurement_settings_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -9802,7 +8855,7 @@ def test_update_enhanced_measurement_settings( request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest, ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -9828,41 +8881,26 @@ def test_update_enhanced_measurement_settings( search_query_parameter="search_query_parameter_value", uri_query_parameter="uri_query_parameter_value", ) - response = client.update_enhanced_measurement_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.EnhancedMeasurementSettings) - assert response.name == "name_value" - assert response.stream_enabled is True - assert response.page_views_enabled is True - assert response.scrolls_enabled is True - assert response.outbound_clicks_enabled is True - assert response.site_search_enabled is True - assert response.video_engagement_enabled is True - assert response.file_downloads_enabled is True - assert response.page_loads_enabled is True - assert response.page_changes_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.uri_query_parameter == "uri_query_parameter_value" @@ -9874,7 +8912,7 @@ def test_update_enhanced_measurement_settings_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -9884,7 +8922,6 @@ def test_update_enhanced_measurement_settings_empty_call(): client.update_enhanced_measurement_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() @@ -9894,7 +8931,7 @@ async def test_update_enhanced_measurement_settings_async( request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -9922,40 +8959,26 @@ async def test_update_enhanced_measurement_settings_async( uri_query_parameter="uri_query_parameter_value", ) ) - response = await client.update_enhanced_measurement_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateEnhancedMeasurementSettingsRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.EnhancedMeasurementSettings) - assert response.name == "name_value" - assert response.stream_enabled is True - assert response.page_views_enabled is True - assert response.scrolls_enabled is True - assert response.outbound_clicks_enabled is True - assert response.site_search_enabled is True - assert response.video_engagement_enabled is True - assert response.file_downloads_enabled is True - assert response.page_loads_enabled is True - assert response.page_changes_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.uri_query_parameter == "uri_query_parameter_value" @@ -9966,12 +8989,13 @@ async def test_update_enhanced_measurement_settings_async_from_dict(): def test_update_enhanced_measurement_settings_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + request.enhanced_measurement_settings.name = ( "enhanced_measurement_settings.name/value" ) @@ -9981,7 +9005,6 @@ def test_update_enhanced_measurement_settings_field_headers(): type(client.transport.update_enhanced_measurement_settings), "__call__" ) as call: call.return_value = resources.EnhancedMeasurementSettings() - client.update_enhanced_measurement_settings(request) # Establish that the underlying gRPC stub method was called. @@ -10000,12 +9023,13 @@ def test_update_enhanced_measurement_settings_field_headers(): @pytest.mark.asyncio async def test_update_enhanced_measurement_settings_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + request.enhanced_measurement_settings.name = ( "enhanced_measurement_settings.name/value" ) @@ -10017,7 +9041,6 @@ async def test_update_enhanced_measurement_settings_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.EnhancedMeasurementSettings() ) - await client.update_enhanced_measurement_settings(request) # Establish that the underlying gRPC stub method was called. @@ -10035,7 +9058,7 @@ async def test_update_enhanced_measurement_settings_field_headers_async(): def test_update_enhanced_measurement_settings_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10044,33 +9067,30 @@ def test_update_enhanced_measurement_settings_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.EnhancedMeasurementSettings() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_enhanced_measurement_settings( enhanced_measurement_settings=resources.EnhancedMeasurementSettings( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[ 0 ].enhanced_measurement_settings == resources.EnhancedMeasurementSettings( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_enhanced_measurement_settings_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -10081,14 +9101,14 @@ def test_update_enhanced_measurement_settings_flattened_error(): enhanced_measurement_settings=resources.EnhancedMeasurementSettings( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_enhanced_measurement_settings_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10107,27 +9127,25 @@ async def test_update_enhanced_measurement_settings_flattened_async(): enhanced_measurement_settings=resources.EnhancedMeasurementSettings( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[ 0 ].enhanced_measurement_settings == resources.EnhancedMeasurementSettings( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_enhanced_measurement_settings_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -10138,7 +9156,7 @@ async def test_update_enhanced_measurement_settings_flattened_error_async(): enhanced_measurement_settings=resources.EnhancedMeasurementSettings( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -10146,7 +9164,7 @@ def test_create_firebase_link( transport: str = "grpc", request_type=analytics_admin.CreateFirebaseLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -10163,23 +9181,17 @@ def test_create_firebase_link( project="project_value", maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, ) - response = client.create_firebase_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateFirebaseLinkRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.FirebaseLink) - assert response.name == "name_value" - assert response.project == "project_value" - assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS @@ -10191,7 +9203,7 @@ def test_create_firebase_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10201,7 +9213,6 @@ def test_create_firebase_link_empty_call(): client.create_firebase_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateFirebaseLinkRequest() @@ -10211,7 +9222,7 @@ async def test_create_firebase_link_async( request_type=analytics_admin.CreateFirebaseLinkRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -10230,22 +9241,17 @@ async def test_create_firebase_link_async( maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, ) ) - response = await client.create_firebase_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateFirebaseLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.FirebaseLink) - assert response.name == "name_value" - assert response.project == "project_value" - assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS @@ -10256,12 +9262,13 @@ async def test_create_firebase_link_async_from_dict(): def test_create_firebase_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.CreateFirebaseLinkRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -10269,7 +9276,6 @@ def test_create_firebase_link_field_headers(): type(client.transport.create_firebase_link), "__call__" ) as call: call.return_value = resources.FirebaseLink() - client.create_firebase_link(request) # Establish that the underlying gRPC stub method was called. @@ -10285,12 +9291,13 @@ def test_create_firebase_link_field_headers(): @pytest.mark.asyncio async def test_create_firebase_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.CreateFirebaseLinkRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -10300,7 +9307,6 @@ async def test_create_firebase_link_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.FirebaseLink() ) - await client.create_firebase_link(request) # Establish that the underlying gRPC stub method was called. @@ -10315,7 +9321,7 @@ async def test_create_firebase_link_field_headers_async(): def test_create_firebase_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10324,7 +9330,6 @@ def test_create_firebase_link_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.FirebaseLink() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_firebase_link( @@ -10336,15 +9341,13 @@ def test_create_firebase_link_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].firebase_link == resources.FirebaseLink(name="name_value") def test_create_firebase_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -10360,7 +9363,7 @@ def test_create_firebase_link_flattened_error(): @pytest.mark.asyncio async def test_create_firebase_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10384,16 +9387,14 @@ async def test_create_firebase_link_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].firebase_link == resources.FirebaseLink(name="name_value") @pytest.mark.asyncio async def test_create_firebase_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -10410,7 +9411,7 @@ def test_update_firebase_link( transport: str = "grpc", request_type=analytics_admin.UpdateFirebaseLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -10427,23 +9428,17 @@ def test_update_firebase_link( project="project_value", maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, ) - response = client.update_firebase_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.FirebaseLink) - assert response.name == "name_value" - assert response.project == "project_value" - assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS @@ -10455,7 +9450,7 @@ def test_update_firebase_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10465,7 +9460,6 @@ def test_update_firebase_link_empty_call(): client.update_firebase_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() @@ -10475,7 +9469,7 @@ async def test_update_firebase_link_async( request_type=analytics_admin.UpdateFirebaseLinkRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -10494,22 +9488,17 @@ async def test_update_firebase_link_async( maximum_user_access=resources.MaximumUserAccess.NO_ACCESS, ) ) - response = await client.update_firebase_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateFirebaseLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.FirebaseLink) - assert response.name == "name_value" - assert response.project == "project_value" - assert response.maximum_user_access == resources.MaximumUserAccess.NO_ACCESS @@ -10520,12 +9509,13 @@ async def test_update_firebase_link_async_from_dict(): def test_update_firebase_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateFirebaseLinkRequest() + request.firebase_link.name = "firebase_link.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -10533,7 +9523,6 @@ def test_update_firebase_link_field_headers(): type(client.transport.update_firebase_link), "__call__" ) as call: call.return_value = resources.FirebaseLink() - client.update_firebase_link(request) # Establish that the underlying gRPC stub method was called. @@ -10552,12 +9541,13 @@ def test_update_firebase_link_field_headers(): @pytest.mark.asyncio async def test_update_firebase_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateFirebaseLinkRequest() + request.firebase_link.name = "firebase_link.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -10567,7 +9557,6 @@ async def test_update_firebase_link_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.FirebaseLink() ) - await client.update_firebase_link(request) # Establish that the underlying gRPC stub method was called. @@ -10585,7 +9574,7 @@ async def test_update_firebase_link_field_headers_async(): def test_update_firebase_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10594,27 +9583,24 @@ def test_update_firebase_link_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.FirebaseLink() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_firebase_link( firebase_link=resources.FirebaseLink(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].firebase_link == resources.FirebaseLink(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_firebase_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -10623,14 +9609,14 @@ def test_update_firebase_link_flattened_error(): client.update_firebase_link( analytics_admin.UpdateFirebaseLinkRequest(), firebase_link=resources.FirebaseLink(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_firebase_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10647,23 +9633,21 @@ async def test_update_firebase_link_flattened_async(): # using the keyword arguments to the method. response = await client.update_firebase_link( firebase_link=resources.FirebaseLink(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].firebase_link == resources.FirebaseLink(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_firebase_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -10672,7 +9656,7 @@ async def test_update_firebase_link_flattened_error_async(): await client.update_firebase_link( analytics_admin.UpdateFirebaseLinkRequest(), firebase_link=resources.FirebaseLink(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -10680,7 +9664,7 @@ def test_delete_firebase_link( transport: str = "grpc", request_type=analytics_admin.DeleteFirebaseLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -10693,13 +9677,11 @@ def test_delete_firebase_link( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_firebase_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() # Establish that the response is the type that we expect. @@ -10714,7 +9696,7 @@ def test_delete_firebase_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10724,7 +9706,6 @@ def test_delete_firebase_link_empty_call(): client.delete_firebase_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() @@ -10734,7 +9715,7 @@ async def test_delete_firebase_link_async( request_type=analytics_admin.DeleteFirebaseLinkRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -10747,13 +9728,11 @@ async def test_delete_firebase_link_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_firebase_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteFirebaseLinkRequest() # Establish that the response is the type that we expect. @@ -10767,12 +9746,13 @@ async def test_delete_firebase_link_async_from_dict(): def test_delete_firebase_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteFirebaseLinkRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -10780,7 +9760,6 @@ def test_delete_firebase_link_field_headers(): type(client.transport.delete_firebase_link), "__call__" ) as call: call.return_value = None - client.delete_firebase_link(request) # Establish that the underlying gRPC stub method was called. @@ -10796,12 +9775,13 @@ def test_delete_firebase_link_field_headers(): @pytest.mark.asyncio async def test_delete_firebase_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteFirebaseLinkRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -10809,7 +9789,6 @@ async def test_delete_firebase_link_field_headers_async(): type(client.transport.delete_firebase_link), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_firebase_link(request) # Establish that the underlying gRPC stub method was called. @@ -10824,7 +9803,7 @@ async def test_delete_firebase_link_field_headers_async(): def test_delete_firebase_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10833,7 +9812,6 @@ def test_delete_firebase_link_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_firebase_link(name="name_value",) @@ -10842,13 +9820,12 @@ def test_delete_firebase_link_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_firebase_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -10862,7 +9839,7 @@ def test_delete_firebase_link_flattened_error(): @pytest.mark.asyncio async def test_delete_firebase_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10881,14 +9858,13 @@ async def test_delete_firebase_link_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_firebase_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -10903,7 +9879,7 @@ def test_list_firebase_links( transport: str = "grpc", request_type=analytics_admin.ListFirebaseLinksRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -10918,19 +9894,15 @@ def test_list_firebase_links( call.return_value = analytics_admin.ListFirebaseLinksResponse( next_page_token="next_page_token_value", ) - response = client.list_firebase_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListFirebaseLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFirebaseLinksPager) - assert response.next_page_token == "next_page_token_value" @@ -10942,7 +9914,7 @@ def test_list_firebase_links_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -10952,7 +9924,6 @@ def test_list_firebase_links_empty_call(): client.list_firebase_links() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListFirebaseLinksRequest() @@ -10962,7 +9933,7 @@ async def test_list_firebase_links_async( request_type=analytics_admin.ListFirebaseLinksRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -10979,18 +9950,15 @@ async def test_list_firebase_links_async( next_page_token="next_page_token_value", ) ) - response = await client.list_firebase_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListFirebaseLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFirebaseLinksAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -11001,12 +9969,13 @@ async def test_list_firebase_links_async_from_dict(): def test_list_firebase_links_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListFirebaseLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -11014,7 +9983,6 @@ def test_list_firebase_links_field_headers(): type(client.transport.list_firebase_links), "__call__" ) as call: call.return_value = analytics_admin.ListFirebaseLinksResponse() - client.list_firebase_links(request) # Establish that the underlying gRPC stub method was called. @@ -11030,12 +9998,13 @@ def test_list_firebase_links_field_headers(): @pytest.mark.asyncio async def test_list_firebase_links_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListFirebaseLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -11045,7 +10014,6 @@ async def test_list_firebase_links_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListFirebaseLinksResponse() ) - await client.list_firebase_links(request) # Establish that the underlying gRPC stub method was called. @@ -11060,7 +10028,7 @@ async def test_list_firebase_links_field_headers_async(): def test_list_firebase_links_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11069,7 +10037,6 @@ def test_list_firebase_links_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListFirebaseLinksResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_firebase_links(parent="parent_value",) @@ -11078,13 +10045,12 @@ def test_list_firebase_links_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_firebase_links_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -11098,7 +10064,7 @@ def test_list_firebase_links_flattened_error(): @pytest.mark.asyncio async def test_list_firebase_links_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11119,14 +10085,13 @@ async def test_list_firebase_links_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_firebase_links_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -11138,7 +10103,9 @@ async def test_list_firebase_links_flattened_error_async(): def test_list_firebase_links_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -11180,7 +10147,9 @@ def test_list_firebase_links_pager(): def test_list_firebase_links_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -11215,7 +10184,7 @@ def test_list_firebase_links_pages(): @pytest.mark.asyncio async def test_list_firebase_links_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11258,7 +10227,7 @@ async def test_list_firebase_links_async_pager(): @pytest.mark.asyncio async def test_list_firebase_links_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11299,7 +10268,7 @@ def test_get_global_site_tag( transport: str = "grpc", request_type=analytics_admin.GetGlobalSiteTagRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -11314,21 +10283,16 @@ def test_get_global_site_tag( call.return_value = resources.GlobalSiteTag( name="name_value", snippet="snippet_value", ) - response = client.get_global_site_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetGlobalSiteTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.GlobalSiteTag) - assert response.name == "name_value" - assert response.snippet == "snippet_value" @@ -11340,7 +10304,7 @@ def test_get_global_site_tag_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11350,7 +10314,6 @@ def test_get_global_site_tag_empty_call(): client.get_global_site_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetGlobalSiteTagRequest() @@ -11360,7 +10323,7 @@ async def test_get_global_site_tag_async( request_type=analytics_admin.GetGlobalSiteTagRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -11375,20 +10338,16 @@ async def test_get_global_site_tag_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.GlobalSiteTag(name="name_value", snippet="snippet_value",) ) - response = await client.get_global_site_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetGlobalSiteTagRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.GlobalSiteTag) - assert response.name == "name_value" - assert response.snippet == "snippet_value" @@ -11399,12 +10358,13 @@ async def test_get_global_site_tag_async_from_dict(): def test_get_global_site_tag_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetGlobalSiteTagRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -11412,7 +10372,6 @@ def test_get_global_site_tag_field_headers(): type(client.transport.get_global_site_tag), "__call__" ) as call: call.return_value = resources.GlobalSiteTag() - client.get_global_site_tag(request) # Establish that the underlying gRPC stub method was called. @@ -11428,12 +10387,13 @@ def test_get_global_site_tag_field_headers(): @pytest.mark.asyncio async def test_get_global_site_tag_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.GetGlobalSiteTagRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -11443,7 +10403,6 @@ async def test_get_global_site_tag_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.GlobalSiteTag() ) - await client.get_global_site_tag(request) # Establish that the underlying gRPC stub method was called. @@ -11458,7 +10417,7 @@ async def test_get_global_site_tag_field_headers_async(): def test_get_global_site_tag_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11467,7 +10426,6 @@ def test_get_global_site_tag_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GlobalSiteTag() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_global_site_tag(name="name_value",) @@ -11476,13 +10434,12 @@ def test_get_global_site_tag_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_global_site_tag_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -11496,7 +10453,7 @@ def test_get_global_site_tag_flattened_error(): @pytest.mark.asyncio async def test_get_global_site_tag_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11517,14 +10474,13 @@ async def test_get_global_site_tag_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_global_site_tag_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -11539,7 +10495,7 @@ def test_create_google_ads_link( transport: str = "grpc", request_type=analytics_admin.CreateGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -11557,25 +10513,18 @@ def test_create_google_ads_link( can_manage_clients=True, email_address="email_address_value", ) - response = client.create_google_ads_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleAdsLink) - assert response.name == "name_value" - assert response.customer_id == "customer_id_value" - assert response.can_manage_clients is True - assert response.email_address == "email_address_value" @@ -11587,7 +10536,7 @@ def test_create_google_ads_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11597,7 +10546,6 @@ def test_create_google_ads_link_empty_call(): client.create_google_ads_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() @@ -11607,7 +10555,7 @@ async def test_create_google_ads_link_async( request_type=analytics_admin.CreateGoogleAdsLinkRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -11627,24 +10575,18 @@ async def test_create_google_ads_link_async( email_address="email_address_value", ) ) - response = await client.create_google_ads_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.CreateGoogleAdsLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.GoogleAdsLink) - assert response.name == "name_value" - assert response.customer_id == "customer_id_value" - assert response.can_manage_clients is True - assert response.email_address == "email_address_value" @@ -11655,12 +10597,13 @@ async def test_create_google_ads_link_async_from_dict(): def test_create_google_ads_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.CreateGoogleAdsLinkRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -11668,7 +10611,6 @@ def test_create_google_ads_link_field_headers(): type(client.transport.create_google_ads_link), "__call__" ) as call: call.return_value = resources.GoogleAdsLink() - client.create_google_ads_link(request) # Establish that the underlying gRPC stub method was called. @@ -11684,12 +10626,13 @@ def test_create_google_ads_link_field_headers(): @pytest.mark.asyncio async def test_create_google_ads_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.CreateGoogleAdsLinkRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -11699,7 +10642,6 @@ async def test_create_google_ads_link_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.GoogleAdsLink() ) - await client.create_google_ads_link(request) # Establish that the underlying gRPC stub method was called. @@ -11714,7 +10656,7 @@ async def test_create_google_ads_link_field_headers_async(): def test_create_google_ads_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11723,7 +10665,6 @@ def test_create_google_ads_link_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GoogleAdsLink() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_google_ads_link( @@ -11735,15 +10676,13 @@ def test_create_google_ads_link_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].google_ads_link == resources.GoogleAdsLink(name="name_value") def test_create_google_ads_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -11759,7 +10698,7 @@ def test_create_google_ads_link_flattened_error(): @pytest.mark.asyncio async def test_create_google_ads_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11783,16 +10722,14 @@ async def test_create_google_ads_link_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].google_ads_link == resources.GoogleAdsLink(name="name_value") @pytest.mark.asyncio async def test_create_google_ads_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -11809,7 +10746,7 @@ def test_update_google_ads_link( transport: str = "grpc", request_type=analytics_admin.UpdateGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -11827,25 +10764,18 @@ def test_update_google_ads_link( can_manage_clients=True, email_address="email_address_value", ) - response = client.update_google_ads_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleAdsLink) - assert response.name == "name_value" - assert response.customer_id == "customer_id_value" - assert response.can_manage_clients is True - assert response.email_address == "email_address_value" @@ -11857,7 +10787,7 @@ def test_update_google_ads_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11867,7 +10797,6 @@ def test_update_google_ads_link_empty_call(): client.update_google_ads_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() @@ -11877,7 +10806,7 @@ async def test_update_google_ads_link_async( request_type=analytics_admin.UpdateGoogleAdsLinkRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -11897,24 +10826,18 @@ async def test_update_google_ads_link_async( email_address="email_address_value", ) ) - response = await client.update_google_ads_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.UpdateGoogleAdsLinkRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.GoogleAdsLink) - assert response.name == "name_value" - assert response.customer_id == "customer_id_value" - assert response.can_manage_clients is True - assert response.email_address == "email_address_value" @@ -11925,12 +10848,13 @@ async def test_update_google_ads_link_async_from_dict(): def test_update_google_ads_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateGoogleAdsLinkRequest() + request.google_ads_link.name = "google_ads_link.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -11938,7 +10862,6 @@ def test_update_google_ads_link_field_headers(): type(client.transport.update_google_ads_link), "__call__" ) as call: call.return_value = resources.GoogleAdsLink() - client.update_google_ads_link(request) # Establish that the underlying gRPC stub method was called. @@ -11957,12 +10880,13 @@ def test_update_google_ads_link_field_headers(): @pytest.mark.asyncio async def test_update_google_ads_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.UpdateGoogleAdsLinkRequest() + request.google_ads_link.name = "google_ads_link.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -11972,7 +10896,6 @@ async def test_update_google_ads_link_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.GoogleAdsLink() ) - await client.update_google_ads_link(request) # Establish that the underlying gRPC stub method was called. @@ -11990,7 +10913,7 @@ async def test_update_google_ads_link_field_headers_async(): def test_update_google_ads_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -11999,27 +10922,24 @@ def test_update_google_ads_link_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.GoogleAdsLink() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_google_ads_link( google_ads_link=resources.GoogleAdsLink(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].google_ads_link == resources.GoogleAdsLink(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_google_ads_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -12028,14 +10948,14 @@ def test_update_google_ads_link_flattened_error(): client.update_google_ads_link( analytics_admin.UpdateGoogleAdsLinkRequest(), google_ads_link=resources.GoogleAdsLink(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_google_ads_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12052,23 +10972,21 @@ async def test_update_google_ads_link_flattened_async(): # using the keyword arguments to the method. response = await client.update_google_ads_link( google_ads_link=resources.GoogleAdsLink(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].google_ads_link == resources.GoogleAdsLink(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_google_ads_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -12077,7 +10995,7 @@ async def test_update_google_ads_link_flattened_error_async(): await client.update_google_ads_link( analytics_admin.UpdateGoogleAdsLinkRequest(), google_ads_link=resources.GoogleAdsLink(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -12085,7 +11003,7 @@ def test_delete_google_ads_link( transport: str = "grpc", request_type=analytics_admin.DeleteGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -12098,13 +11016,11 @@ def test_delete_google_ads_link( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_google_ads_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() # Establish that the response is the type that we expect. @@ -12119,7 +11035,7 @@ def test_delete_google_ads_link_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12129,7 +11045,6 @@ def test_delete_google_ads_link_empty_call(): client.delete_google_ads_link() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() @@ -12139,7 +11054,7 @@ async def test_delete_google_ads_link_async( request_type=analytics_admin.DeleteGoogleAdsLinkRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -12152,13 +11067,11 @@ async def test_delete_google_ads_link_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_google_ads_link(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.DeleteGoogleAdsLinkRequest() # Establish that the response is the type that we expect. @@ -12172,12 +11085,13 @@ async def test_delete_google_ads_link_async_from_dict(): def test_delete_google_ads_link_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteGoogleAdsLinkRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -12185,7 +11099,6 @@ def test_delete_google_ads_link_field_headers(): type(client.transport.delete_google_ads_link), "__call__" ) as call: call.return_value = None - client.delete_google_ads_link(request) # Establish that the underlying gRPC stub method was called. @@ -12201,12 +11114,13 @@ def test_delete_google_ads_link_field_headers(): @pytest.mark.asyncio async def test_delete_google_ads_link_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.DeleteGoogleAdsLinkRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -12214,7 +11128,6 @@ async def test_delete_google_ads_link_field_headers_async(): type(client.transport.delete_google_ads_link), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_google_ads_link(request) # Establish that the underlying gRPC stub method was called. @@ -12229,7 +11142,7 @@ async def test_delete_google_ads_link_field_headers_async(): def test_delete_google_ads_link_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12238,7 +11151,6 @@ def test_delete_google_ads_link_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_google_ads_link(name="name_value",) @@ -12247,13 +11159,12 @@ def test_delete_google_ads_link_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_google_ads_link_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -12267,7 +11178,7 @@ def test_delete_google_ads_link_flattened_error(): @pytest.mark.asyncio async def test_delete_google_ads_link_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12286,14 +11197,13 @@ async def test_delete_google_ads_link_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_google_ads_link_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -12308,7 +11218,7 @@ def test_list_google_ads_links( transport: str = "grpc", request_type=analytics_admin.ListGoogleAdsLinksRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -12323,19 +11233,15 @@ def test_list_google_ads_links( call.return_value = analytics_admin.ListGoogleAdsLinksResponse( next_page_token="next_page_token_value", ) - response = client.list_google_ads_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListGoogleAdsLinksPager) - assert response.next_page_token == "next_page_token_value" @@ -12347,7 +11253,7 @@ def test_list_google_ads_links_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12357,7 +11263,6 @@ def test_list_google_ads_links_empty_call(): client.list_google_ads_links() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() @@ -12367,7 +11272,7 @@ async def test_list_google_ads_links_async( request_type=analytics_admin.ListGoogleAdsLinksRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -12384,18 +11289,15 @@ async def test_list_google_ads_links_async( next_page_token="next_page_token_value", ) ) - response = await client.list_google_ads_links(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListGoogleAdsLinksRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListGoogleAdsLinksAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -12406,12 +11308,13 @@ async def test_list_google_ads_links_async_from_dict(): def test_list_google_ads_links_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListGoogleAdsLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -12419,7 +11322,6 @@ def test_list_google_ads_links_field_headers(): type(client.transport.list_google_ads_links), "__call__" ) as call: call.return_value = analytics_admin.ListGoogleAdsLinksResponse() - client.list_google_ads_links(request) # Establish that the underlying gRPC stub method was called. @@ -12435,12 +11337,13 @@ def test_list_google_ads_links_field_headers(): @pytest.mark.asyncio async def test_list_google_ads_links_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = analytics_admin.ListGoogleAdsLinksRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -12450,7 +11353,6 @@ async def test_list_google_ads_links_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_admin.ListGoogleAdsLinksResponse() ) - await client.list_google_ads_links(request) # Establish that the underlying gRPC stub method was called. @@ -12465,7 +11367,7 @@ async def test_list_google_ads_links_field_headers_async(): def test_list_google_ads_links_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12474,7 +11376,6 @@ def test_list_google_ads_links_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = analytics_admin.ListGoogleAdsLinksResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_google_ads_links(parent="parent_value",) @@ -12483,13 +11384,12 @@ def test_list_google_ads_links_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_google_ads_links_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -12503,7 +11403,7 @@ def test_list_google_ads_links_flattened_error(): @pytest.mark.asyncio async def test_list_google_ads_links_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12524,14 +11424,13 @@ async def test_list_google_ads_links_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_google_ads_links_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -12543,7 +11442,9 @@ async def test_list_google_ads_links_flattened_error_async(): def test_list_google_ads_links_pager(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -12588,7 +11489,9 @@ def test_list_google_ads_links_pager(): def test_list_google_ads_links_pages(): - client = AnalyticsAdminServiceClient(credentials=credentials.AnonymousCredentials,) + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -12626,7 +11529,7 @@ def test_list_google_ads_links_pages(): @pytest.mark.asyncio async def test_list_google_ads_links_async_pager(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12672,7 +11575,7 @@ async def test_list_google_ads_links_async_pager(): @pytest.mark.asyncio async def test_list_google_ads_links_async_pages(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12716,7 +11619,7 @@ def test_get_data_sharing_settings( transport: str = "grpc", request_type=analytics_admin.GetDataSharingSettingsRequest ): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -12736,29 +11639,20 @@ def test_get_data_sharing_settings( sharing_with_google_products_enabled=True, sharing_with_others_enabled=True, ) - response = client.get_data_sharing_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetDataSharingSettingsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataSharingSettings) - assert response.name == "name_value" - assert response.sharing_with_google_support_enabled is True - assert response.sharing_with_google_assigned_sales_enabled is True - assert response.sharing_with_google_any_sales_enabled is True - assert response.sharing_with_google_products_enabled is True - assert response.sharing_with_others_enabled is True @@ -12770,7 +11664,7 @@ def test_get_data_sharing_settings_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -12780,7 +11674,6 @@ def test_get_data_sharing_settings_empty_call(): client.get_data_sharing_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetDataSharingSettingsRequest() @@ -12790,7 +11683,7 @@ async def test_get_data_sharing_settings_async( request_type=analytics_admin.GetDataSharingSettingsRequest, ): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -12812,28 +11705,20 @@ async def test_get_data_sharing_settings_async( sharing_with_others_enabled=True, ) ) - response = await client.get_data_sharing_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetDataSharingSettingsRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.DataSharingSettings) - assert response.name == "name_value" - assert response.sharing_with_google_support_enabled is True - assert response.sharing_with_google_assigned_sales_enabled is True - assert response.sharing_with_google_any_sales_enabled is True - assert response.sharing_with_google_products_enabled is True - assert response.sharing_with_others_enabled is True @@ -12844,21 +11729,6110 @@ async def test_get_data_sharing_settings_async_from_dict(): def test_get_data_sharing_settings_field_headers(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetDataSharingSettingsRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), "__call__" + ) as call: + call.return_value = resources.DataSharingSettings() + client.get_data_sharing_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetDataSharingSettingsRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.DataSharingSettings() + ) + await client.get_data_sharing_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_data_sharing_settings_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.DataSharingSettings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_data_sharing_settings(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_get_data_sharing_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_data_sharing_settings( + analytics_admin.GetDataSharingSettingsRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_data_sharing_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.DataSharingSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.DataSharingSettings() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_data_sharing_settings(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_data_sharing_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_data_sharing_settings( + analytics_admin.GetDataSharingSettingsRequest(), name="name_value", + ) + + +def test_get_measurement_protocol_secret( + transport: str = "grpc", + request_type=analytics_admin.GetMeasurementProtocolSecretRequest, +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) + response = client.get_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.secret_value == "secret_value_value" + + +def test_get_measurement_protocol_secret_from_dict(): + test_get_measurement_protocol_secret(request_type=dict) + + +def test_get_measurement_protocol_secret_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), "__call__" + ) as call: + client.get_measurement_protocol_secret() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetMeasurementProtocolSecretRequest() + + +@pytest.mark.asyncio +async def test_get_measurement_protocol_secret_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetMeasurementProtocolSecretRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) + ) + response = await client.get_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.secret_value == "secret_value_value" + + +@pytest.mark.asyncio +async def test_get_measurement_protocol_secret_async_from_dict(): + await test_get_measurement_protocol_secret_async(request_type=dict) + + +def test_get_measurement_protocol_secret_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetMeasurementProtocolSecretRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), "__call__" + ) as call: + call.return_value = resources.MeasurementProtocolSecret() + client.get_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_measurement_protocol_secret_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetMeasurementProtocolSecretRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret() + ) + await client.get_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_measurement_protocol_secret_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_measurement_protocol_secret(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_get_measurement_protocol_secret_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_measurement_protocol_secret( + analytics_admin.GetMeasurementProtocolSecretRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_measurement_protocol_secret_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_measurement_protocol_secret(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_measurement_protocol_secret_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_measurement_protocol_secret( + analytics_admin.GetMeasurementProtocolSecretRequest(), name="name_value", + ) + + +def test_list_measurement_protocol_secrets( + transport: str = "grpc", + request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_measurement_protocol_secrets(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListMeasurementProtocolSecretsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMeasurementProtocolSecretsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_measurement_protocol_secrets_from_dict(): + test_list_measurement_protocol_secrets(request_type=dict) + + +def test_list_measurement_protocol_secrets_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + client.list_measurement_protocol_secrets() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListMeasurementProtocolSecretsRequest() + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListMeasurementProtocolSecretsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_measurement_protocol_secrets(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListMeasurementProtocolSecretsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMeasurementProtocolSecretsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_async_from_dict(): + await test_list_measurement_protocol_secrets_async(request_type=dict) + + +def test_list_measurement_protocol_secrets_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListMeasurementProtocolSecretsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + client.list_measurement_protocol_secrets(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListMeasurementProtocolSecretsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListMeasurementProtocolSecretsResponse() + ) + await client.list_measurement_protocol_secrets(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_measurement_protocol_secrets_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_measurement_protocol_secrets(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_list_measurement_protocol_secrets_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_measurement_protocol_secrets( + analytics_admin.ListMeasurementProtocolSecretsRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListMeasurementProtocolSecretsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_measurement_protocol_secrets( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_measurement_protocol_secrets( + analytics_admin.ListMeasurementProtocolSecretsRequest(), + parent="parent_value", + ) + + +def test_list_measurement_protocol_secrets_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + next_page_token="abc", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], next_page_token="def", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[resources.MeasurementProtocolSecret(),], + next_page_token="ghi", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_measurement_protocol_secrets(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.MeasurementProtocolSecret) for i in results) + + +def test_list_measurement_protocol_secrets_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + next_page_token="abc", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], next_page_token="def", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[resources.MeasurementProtocolSecret(),], + next_page_token="ghi", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + ), + RuntimeError, + ) + pages = list(client.list_measurement_protocol_secrets(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + next_page_token="abc", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], next_page_token="def", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[resources.MeasurementProtocolSecret(),], + next_page_token="ghi", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_measurement_protocol_secrets(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all( + isinstance(i, resources.MeasurementProtocolSecret) for i in responses + ) + + +@pytest.mark.asyncio +async def test_list_measurement_protocol_secrets_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_measurement_protocol_secrets), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + next_page_token="abc", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], next_page_token="def", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[resources.MeasurementProtocolSecret(),], + next_page_token="ghi", + ), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_measurement_protocol_secrets(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_create_measurement_protocol_secret( + transport: str = "grpc", + request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) + response = client.create_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.secret_value == "secret_value_value" + + +def test_create_measurement_protocol_secret_from_dict(): + test_create_measurement_protocol_secret(request_type=dict) + + +def test_create_measurement_protocol_secret_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), "__call__" + ) as call: + client.create_measurement_protocol_secret() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateMeasurementProtocolSecretRequest() + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) + ) + response = await client.create_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.secret_value == "secret_value_value" + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_async_from_dict(): + await test_create_measurement_protocol_secret_async(request_type=dict) + + +def test_create_measurement_protocol_secret_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateMeasurementProtocolSecretRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), "__call__" + ) as call: + call.return_value = resources.MeasurementProtocolSecret() + client.create_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateMeasurementProtocolSecretRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret() + ) + await client.create_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_measurement_protocol_secret_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_measurement_protocol_secret( + parent="parent_value", + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[ + 0 + ].measurement_protocol_secret == resources.MeasurementProtocolSecret( + name="name_value" + ) + + +def test_create_measurement_protocol_secret_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_measurement_protocol_secret( + analytics_admin.CreateMeasurementProtocolSecretRequest(), + parent="parent_value", + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + ) + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_measurement_protocol_secret( + parent="parent_value", + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[ + 0 + ].measurement_protocol_secret == resources.MeasurementProtocolSecret( + name="name_value" + ) + + +@pytest.mark.asyncio +async def test_create_measurement_protocol_secret_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_measurement_protocol_secret( + analytics_admin.CreateMeasurementProtocolSecretRequest(), + parent="parent_value", + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + ) + + +def test_delete_measurement_protocol_secret( + transport: str = "grpc", + request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_measurement_protocol_secret_from_dict(): + test_delete_measurement_protocol_secret(request_type=dict) + + +def test_delete_measurement_protocol_secret_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), "__call__" + ) as call: + client.delete_measurement_protocol_secret() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteMeasurementProtocolSecretRequest() + + +@pytest.mark.asyncio +async def test_delete_measurement_protocol_secret_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_measurement_protocol_secret_async_from_dict(): + await test_delete_measurement_protocol_secret_async(request_type=dict) + + +def test_delete_measurement_protocol_secret_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteMeasurementProtocolSecretRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), "__call__" + ) as call: + call.return_value = None + client.delete_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_measurement_protocol_secret_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteMeasurementProtocolSecretRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_delete_measurement_protocol_secret_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_measurement_protocol_secret(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_delete_measurement_protocol_secret_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_measurement_protocol_secret( + analytics_admin.DeleteMeasurementProtocolSecretRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_measurement_protocol_secret_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_measurement_protocol_secret(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_delete_measurement_protocol_secret_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_measurement_protocol_secret( + analytics_admin.DeleteMeasurementProtocolSecretRequest(), name="name_value", + ) + + +def test_update_measurement_protocol_secret( + transport: str = "grpc", + request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) + response = client.update_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.secret_value == "secret_value_value" + + +def test_update_measurement_protocol_secret_from_dict(): + test_update_measurement_protocol_secret(request_type=dict) + + +def test_update_measurement_protocol_secret_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), "__call__" + ) as call: + client.update_measurement_protocol_secret() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateMeasurementProtocolSecretRequest() + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) + ) + response = await client.update_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateMeasurementProtocolSecretRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.MeasurementProtocolSecret) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.secret_value == "secret_value_value" + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_async_from_dict(): + await test_update_measurement_protocol_secret_async(request_type=dict) + + +def test_update_measurement_protocol_secret_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateMeasurementProtocolSecretRequest() + + request.measurement_protocol_secret.name = "measurement_protocol_secret.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), "__call__" + ) as call: + call.return_value = resources.MeasurementProtocolSecret() + client.update_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "measurement_protocol_secret.name=measurement_protocol_secret.name/value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateMeasurementProtocolSecretRequest() + + request.measurement_protocol_secret.name = "measurement_protocol_secret.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret() + ) + await client.update_measurement_protocol_secret(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "measurement_protocol_secret.name=measurement_protocol_secret.name/value", + ) in kw["metadata"] + + +def test_update_measurement_protocol_secret_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_measurement_protocol_secret( + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[ + 0 + ].measurement_protocol_secret == resources.MeasurementProtocolSecret( + name="name_value" + ) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +def test_update_measurement_protocol_secret_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_measurement_protocol_secret( + analytics_admin.UpdateMeasurementProtocolSecretRequest(), + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_measurement_protocol_secret), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.MeasurementProtocolSecret() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.MeasurementProtocolSecret() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_measurement_protocol_secret( + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[ + 0 + ].measurement_protocol_secret == resources.MeasurementProtocolSecret( + name="name_value" + ) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +@pytest.mark.asyncio +async def test_update_measurement_protocol_secret_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_measurement_protocol_secret( + analytics_admin.UpdateMeasurementProtocolSecretRequest(), + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_search_change_history_events( + transport: str = "grpc", + request_type=analytics_admin.SearchChangeHistoryEventsRequest, +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.SearchChangeHistoryEventsResponse( + next_page_token="next_page_token_value", + ) + response = client.search_change_history_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.SearchChangeHistoryEventsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchChangeHistoryEventsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_search_change_history_events_from_dict(): + test_search_change_history_events(request_type=dict) + + +def test_search_change_history_events_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), "__call__" + ) as call: + client.search_change_history_events() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.SearchChangeHistoryEventsRequest() + + +@pytest.mark.asyncio +async def test_search_change_history_events_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.SearchChangeHistoryEventsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.SearchChangeHistoryEventsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.search_change_history_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.SearchChangeHistoryEventsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchChangeHistoryEventsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_search_change_history_events_async_from_dict(): + await test_search_change_history_events_async(request_type=dict) + + +def test_search_change_history_events_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.SearchChangeHistoryEventsRequest() + + request.account = "account/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), "__call__" + ) as call: + call.return_value = analytics_admin.SearchChangeHistoryEventsResponse() + client.search_change_history_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "account=account/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_search_change_history_events_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.SearchChangeHistoryEventsRequest() + + request.account = "account/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.SearchChangeHistoryEventsResponse() + ) + await client.search_change_history_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "account=account/value",) in kw["metadata"] + + +def test_search_change_history_events_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + next_page_token="abc", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], next_page_token="def", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[resources.ChangeHistoryEvent(),], + next_page_token="ghi", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("account", ""),)), + ) + pager = client.search_change_history_events(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.ChangeHistoryEvent) for i in results) + + +def test_search_change_history_events_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + next_page_token="abc", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], next_page_token="def", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[resources.ChangeHistoryEvent(),], + next_page_token="ghi", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + ), + RuntimeError, + ) + pages = list(client.search_change_history_events(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_search_change_history_events_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + next_page_token="abc", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], next_page_token="def", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[resources.ChangeHistoryEvent(),], + next_page_token="ghi", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + ), + RuntimeError, + ) + async_pager = await client.search_change_history_events(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.ChangeHistoryEvent) for i in responses) + + +@pytest.mark.asyncio +async def test_search_change_history_events_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.search_change_history_events), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + next_page_token="abc", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], next_page_token="def", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[resources.ChangeHistoryEvent(),], + next_page_token="ghi", + ), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.search_change_history_events(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_google_signals_settings( + transport: str = "grpc", + request_type=analytics_admin.GetGoogleSignalsSettingsRequest, +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings( + name="name_value", + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + ) + response = client.get_google_signals_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetGoogleSignalsSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleSignalsSettings) + assert response.name == "name_value" + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert ( + response.consent + == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + ) + + +def test_get_google_signals_settings_from_dict(): + test_get_google_signals_settings(request_type=dict) + + +def test_get_google_signals_settings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), "__call__" + ) as call: + client.get_google_signals_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetGoogleSignalsSettingsRequest() + + +@pytest.mark.asyncio +async def test_get_google_signals_settings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetGoogleSignalsSettingsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.GoogleSignalsSettings( + name="name_value", + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + ) + ) + response = await client.get_google_signals_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetGoogleSignalsSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleSignalsSettings) + assert response.name == "name_value" + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert ( + response.consent + == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + ) + + +@pytest.mark.asyncio +async def test_get_google_signals_settings_async_from_dict(): + await test_get_google_signals_settings_async(request_type=dict) + + +def test_get_google_signals_settings_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetGoogleSignalsSettingsRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), "__call__" + ) as call: + call.return_value = resources.GoogleSignalsSettings() + client.get_google_signals_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_google_signals_settings_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetGoogleSignalsSettingsRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.GoogleSignalsSettings() + ) + await client.get_google_signals_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_google_signals_settings_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_google_signals_settings(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_get_google_signals_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_google_signals_settings( + analytics_admin.GetGoogleSignalsSettingsRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_google_signals_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_google_signals_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.GoogleSignalsSettings() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_google_signals_settings(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_google_signals_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_google_signals_settings( + analytics_admin.GetGoogleSignalsSettingsRequest(), name="name_value", + ) + + +def test_update_google_signals_settings( + transport: str = "grpc", + request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings( + name="name_value", + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + ) + response = client.update_google_signals_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateGoogleSignalsSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleSignalsSettings) + assert response.name == "name_value" + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert ( + response.consent + == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + ) + + +def test_update_google_signals_settings_from_dict(): + test_update_google_signals_settings(request_type=dict) + + +def test_update_google_signals_settings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), "__call__" + ) as call: + client.update_google_signals_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateGoogleSignalsSettingsRequest() + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.GoogleSignalsSettings( + name="name_value", + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + ) + ) + response = await client.update_google_signals_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateGoogleSignalsSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.GoogleSignalsSettings) + assert response.name == "name_value" + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert ( + response.consent + == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + ) + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_async_from_dict(): + await test_update_google_signals_settings_async(request_type=dict) + + +def test_update_google_signals_settings_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateGoogleSignalsSettingsRequest() + + request.google_signals_settings.name = "google_signals_settings.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), "__call__" + ) as call: + call.return_value = resources.GoogleSignalsSettings() + client.update_google_signals_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "google_signals_settings.name=google_signals_settings.name/value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateGoogleSignalsSettingsRequest() + + request.google_signals_settings.name = "google_signals_settings.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.GoogleSignalsSettings() + ) + await client.update_google_signals_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "google_signals_settings.name=google_signals_settings.name/value", + ) in kw["metadata"] + + +def test_update_google_signals_settings_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_google_signals_settings( + google_signals_settings=resources.GoogleSignalsSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].google_signals_settings == resources.GoogleSignalsSettings( + name="name_value" + ) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +def test_update_google_signals_settings_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_google_signals_settings( + analytics_admin.UpdateGoogleSignalsSettingsRequest(), + google_signals_settings=resources.GoogleSignalsSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_google_signals_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.GoogleSignalsSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.GoogleSignalsSettings() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_google_signals_settings( + google_signals_settings=resources.GoogleSignalsSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].google_signals_settings == resources.GoogleSignalsSettings( + name="name_value" + ) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +@pytest.mark.asyncio +async def test_update_google_signals_settings_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_google_signals_settings( + analytics_admin.UpdateGoogleSignalsSettingsRequest(), + google_signals_settings=resources.GoogleSignalsSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_create_conversion_event( + transport: str = "grpc", request_type=analytics_admin.CreateConversionEventRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent( + name="name_value", event_name="event_name_value", is_deletable=True, + ) + response = client.create_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateConversionEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ConversionEvent) + assert response.name == "name_value" + assert response.event_name == "event_name_value" + assert response.is_deletable is True + + +def test_create_conversion_event_from_dict(): + test_create_conversion_event(request_type=dict) + + +def test_create_conversion_event_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), "__call__" + ) as call: + client.create_conversion_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateConversionEventRequest() + + +@pytest.mark.asyncio +async def test_create_conversion_event_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateConversionEventRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.ConversionEvent( + name="name_value", event_name="event_name_value", is_deletable=True, + ) + ) + response = await client.create_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateConversionEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ConversionEvent) + assert response.name == "name_value" + assert response.event_name == "event_name_value" + assert response.is_deletable is True + + +@pytest.mark.asyncio +async def test_create_conversion_event_async_from_dict(): + await test_create_conversion_event_async(request_type=dict) + + +def test_create_conversion_event_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateConversionEventRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), "__call__" + ) as call: + call.return_value = resources.ConversionEvent() + client.create_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_conversion_event_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateConversionEventRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.ConversionEvent() + ) + await client.create_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_conversion_event_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_conversion_event( + parent="parent_value", + conversion_event=resources.ConversionEvent(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].conversion_event == resources.ConversionEvent(name="name_value") + + +def test_create_conversion_event_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_conversion_event( + analytics_admin.CreateConversionEventRequest(), + parent="parent_value", + conversion_event=resources.ConversionEvent(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_conversion_event_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.ConversionEvent() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_conversion_event( + parent="parent_value", + conversion_event=resources.ConversionEvent(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].conversion_event == resources.ConversionEvent(name="name_value") + + +@pytest.mark.asyncio +async def test_create_conversion_event_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_conversion_event( + analytics_admin.CreateConversionEventRequest(), + parent="parent_value", + conversion_event=resources.ConversionEvent(name="name_value"), + ) + + +def test_get_conversion_event( + transport: str = "grpc", request_type=analytics_admin.GetConversionEventRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent( + name="name_value", event_name="event_name_value", is_deletable=True, + ) + response = client.get_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetConversionEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ConversionEvent) + assert response.name == "name_value" + assert response.event_name == "event_name_value" + assert response.is_deletable is True + + +def test_get_conversion_event_from_dict(): + test_get_conversion_event(request_type=dict) + + +def test_get_conversion_event_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), "__call__" + ) as call: + client.get_conversion_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetConversionEventRequest() + + +@pytest.mark.asyncio +async def test_get_conversion_event_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetConversionEventRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.ConversionEvent( + name="name_value", event_name="event_name_value", is_deletable=True, + ) + ) + response = await client.get_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetConversionEventRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ConversionEvent) + assert response.name == "name_value" + assert response.event_name == "event_name_value" + assert response.is_deletable is True + + +@pytest.mark.asyncio +async def test_get_conversion_event_async_from_dict(): + await test_get_conversion_event_async(request_type=dict) + + +def test_get_conversion_event_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetConversionEventRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), "__call__" + ) as call: + call.return_value = resources.ConversionEvent() + client.get_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_conversion_event_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetConversionEventRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.ConversionEvent() + ) + await client.get_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_conversion_event_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_conversion_event(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_get_conversion_event_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_conversion_event( + analytics_admin.GetConversionEventRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_conversion_event_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ConversionEvent() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.ConversionEvent() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_conversion_event(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_conversion_event_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_conversion_event( + analytics_admin.GetConversionEventRequest(), name="name_value", + ) + + +def test_delete_conversion_event( + transport: str = "grpc", request_type=analytics_admin.DeleteConversionEventRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteConversionEventRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_conversion_event_from_dict(): + test_delete_conversion_event(request_type=dict) + + +def test_delete_conversion_event_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), "__call__" + ) as call: + client.delete_conversion_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteConversionEventRequest() + + +@pytest.mark.asyncio +async def test_delete_conversion_event_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteConversionEventRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteConversionEventRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_conversion_event_async_from_dict(): + await test_delete_conversion_event_async(request_type=dict) + + +def test_delete_conversion_event_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteConversionEventRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), "__call__" + ) as call: + call.return_value = None + client.delete_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_conversion_event_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.DeleteConversionEventRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_conversion_event(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_delete_conversion_event_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_conversion_event(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_delete_conversion_event_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_conversion_event( + analytics_admin.DeleteConversionEventRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_conversion_event_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversion_event), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_conversion_event(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_delete_conversion_event_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_conversion_event( + analytics_admin.DeleteConversionEventRequest(), name="name_value", + ) + + +def test_list_conversion_events( + transport: str = "grpc", request_type=analytics_admin.ListConversionEventsRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListConversionEventsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_conversion_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListConversionEventsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversionEventsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_conversion_events_from_dict(): + test_list_conversion_events(request_type=dict) + + +def test_list_conversion_events_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + client.list_conversion_events() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListConversionEventsRequest() + + +@pytest.mark.asyncio +async def test_list_conversion_events_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListConversionEventsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListConversionEventsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_conversion_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListConversionEventsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversionEventsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_conversion_events_async_from_dict(): + await test_list_conversion_events_async(request_type=dict) + + +def test_list_conversion_events_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListConversionEventsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + call.return_value = analytics_admin.ListConversionEventsResponse() + client.list_conversion_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_conversion_events_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListConversionEventsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListConversionEventsResponse() + ) + await client.list_conversion_events(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_conversion_events_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListConversionEventsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_conversion_events(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_list_conversion_events_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_conversion_events( + analytics_admin.ListConversionEventsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_conversion_events_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListConversionEventsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListConversionEventsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_conversion_events(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_conversion_events_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_conversion_events( + analytics_admin.ListConversionEventsRequest(), parent="parent_value", + ) + + +def test_list_conversion_events_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token="abc", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], next_page_token="def", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[resources.ConversionEvent(),], next_page_token="ghi", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_conversion_events(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.ConversionEvent) for i in results) + + +def test_list_conversion_events_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token="abc", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], next_page_token="def", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[resources.ConversionEvent(),], next_page_token="ghi", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + RuntimeError, + ) + pages = list(client.list_conversion_events(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_conversion_events_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token="abc", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], next_page_token="def", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[resources.ConversionEvent(),], next_page_token="ghi", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_conversion_events(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.ConversionEvent) for i in responses) + + +@pytest.mark.asyncio +async def test_list_conversion_events_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversion_events), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token="abc", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], next_page_token="def", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[resources.ConversionEvent(),], next_page_token="ghi", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_conversion_events(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_create_custom_dimension( + transport: str = "grpc", request_type=analytics_admin.CreateCustomDimensionRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + response = client.create_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +def test_create_custom_dimension_from_dict(): + test_create_custom_dimension(request_type=dict) + + +def test_create_custom_dimension_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), "__call__" + ) as call: + client.create_custom_dimension() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateCustomDimensionRequest() + + +@pytest.mark.asyncio +async def test_create_custom_dimension_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateCustomDimensionRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + ) + response = await client.create_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +@pytest.mark.asyncio +async def test_create_custom_dimension_async_from_dict(): + await test_create_custom_dimension_async(request_type=dict) + + +def test_create_custom_dimension_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateCustomDimensionRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), "__call__" + ) as call: + call.return_value = resources.CustomDimension() + client.create_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_custom_dimension_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateCustomDimensionRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension() + ) + await client.create_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_custom_dimension_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_custom_dimension( + parent="parent_value", + custom_dimension=resources.CustomDimension(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].custom_dimension == resources.CustomDimension(name="name_value") + + +def test_create_custom_dimension_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_custom_dimension( + analytics_admin.CreateCustomDimensionRequest(), + parent="parent_value", + custom_dimension=resources.CustomDimension(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_custom_dimension_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_custom_dimension( + parent="parent_value", + custom_dimension=resources.CustomDimension(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].custom_dimension == resources.CustomDimension(name="name_value") + + +@pytest.mark.asyncio +async def test_create_custom_dimension_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_custom_dimension( + analytics_admin.CreateCustomDimensionRequest(), + parent="parent_value", + custom_dimension=resources.CustomDimension(name="name_value"), + ) + + +def test_update_custom_dimension( + transport: str = "grpc", request_type=analytics_admin.UpdateCustomDimensionRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + response = client.update_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +def test_update_custom_dimension_from_dict(): + test_update_custom_dimension(request_type=dict) + + +def test_update_custom_dimension_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), "__call__" + ) as call: + client.update_custom_dimension() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateCustomDimensionRequest() + + +@pytest.mark.asyncio +async def test_update_custom_dimension_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateCustomDimensionRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + ) + response = await client.update_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +@pytest.mark.asyncio +async def test_update_custom_dimension_async_from_dict(): + await test_update_custom_dimension_async(request_type=dict) + + +def test_update_custom_dimension_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateCustomDimensionRequest() + + request.custom_dimension.name = "custom_dimension.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), "__call__" + ) as call: + call.return_value = resources.CustomDimension() + client.update_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "custom_dimension.name=custom_dimension.name/value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_custom_dimension_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateCustomDimensionRequest() + + request.custom_dimension.name = "custom_dimension.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension() + ) + await client.update_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "custom_dimension.name=custom_dimension.name/value", + ) in kw["metadata"] + + +def test_update_custom_dimension_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_custom_dimension( + custom_dimension=resources.CustomDimension(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].custom_dimension == resources.CustomDimension(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +def test_update_custom_dimension_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_custom_dimension( + analytics_admin.UpdateCustomDimensionRequest(), + custom_dimension=resources.CustomDimension(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_custom_dimension_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_custom_dimension( + custom_dimension=resources.CustomDimension(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].custom_dimension == resources.CustomDimension(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +@pytest.mark.asyncio +async def test_update_custom_dimension_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_custom_dimension( + analytics_admin.UpdateCustomDimensionRequest(), + custom_dimension=resources.CustomDimension(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_list_custom_dimensions( + transport: str = "grpc", request_type=analytics_admin.ListCustomDimensionsRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomDimensionsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_custom_dimensions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListCustomDimensionsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomDimensionsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_custom_dimensions_from_dict(): + test_list_custom_dimensions(request_type=dict) + + +def test_list_custom_dimensions_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + client.list_custom_dimensions() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListCustomDimensionsRequest() + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListCustomDimensionsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListCustomDimensionsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_custom_dimensions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListCustomDimensionsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomDimensionsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_async_from_dict(): + await test_list_custom_dimensions_async(request_type=dict) + + +def test_list_custom_dimensions_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListCustomDimensionsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + call.return_value = analytics_admin.ListCustomDimensionsResponse() + client.list_custom_dimensions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListCustomDimensionsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListCustomDimensionsResponse() + ) + await client.list_custom_dimensions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_custom_dimensions_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomDimensionsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_custom_dimensions(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_list_custom_dimensions_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_custom_dimensions( + analytics_admin.ListCustomDimensionsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomDimensionsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListCustomDimensionsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_custom_dimensions(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_custom_dimensions( + analytics_admin.ListCustomDimensionsRequest(), parent="parent_value", + ) + + +def test_list_custom_dimensions_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), + ], + next_page_token="abc", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], next_page_token="def", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[resources.CustomDimension(),], next_page_token="ghi", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_custom_dimensions(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CustomDimension) for i in results) + + +def test_list_custom_dimensions_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), + ], + next_page_token="abc", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], next_page_token="def", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[resources.CustomDimension(),], next_page_token="ghi", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + ], + ), + RuntimeError, + ) + pages = list(client.list_custom_dimensions(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), + ], + next_page_token="abc", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], next_page_token="def", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[resources.CustomDimension(),], next_page_token="ghi", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_custom_dimensions(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.CustomDimension) for i in responses) + + +@pytest.mark.asyncio +async def test_list_custom_dimensions_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_dimensions), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), + ], + next_page_token="abc", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], next_page_token="def", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[resources.CustomDimension(),], next_page_token="ghi", + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_custom_dimensions(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_archive_custom_dimension( + transport: str = "grpc", request_type=analytics_admin.ArchiveCustomDimensionRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.archive_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ArchiveCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_archive_custom_dimension_from_dict(): + test_archive_custom_dimension(request_type=dict) + + +def test_archive_custom_dimension_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), "__call__" + ) as call: + client.archive_custom_dimension() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ArchiveCustomDimensionRequest() + + +@pytest.mark.asyncio +async def test_archive_custom_dimension_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ArchiveCustomDimensionRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.archive_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ArchiveCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_archive_custom_dimension_async_from_dict(): + await test_archive_custom_dimension_async(request_type=dict) + + +def test_archive_custom_dimension_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ArchiveCustomDimensionRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), "__call__" + ) as call: + call.return_value = None + client.archive_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_archive_custom_dimension_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ArchiveCustomDimensionRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.archive_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_archive_custom_dimension_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.archive_custom_dimension(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_archive_custom_dimension_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.archive_custom_dimension( + analytics_admin.ArchiveCustomDimensionRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_archive_custom_dimension_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.archive_custom_dimension(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_archive_custom_dimension_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.archive_custom_dimension( + analytics_admin.ArchiveCustomDimensionRequest(), name="name_value", + ) + + +def test_get_custom_dimension( + transport: str = "grpc", request_type=analytics_admin.GetCustomDimensionRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + response = client.get_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +def test_get_custom_dimension_from_dict(): + test_get_custom_dimension(request_type=dict) + + +def test_get_custom_dimension_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), "__call__" + ) as call: + client.get_custom_dimension() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetCustomDimensionRequest() + + +@pytest.mark.asyncio +async def test_get_custom_dimension_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetCustomDimensionRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, + ) + ) + response = await client.get_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetCustomDimensionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomDimension) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True + + +@pytest.mark.asyncio +async def test_get_custom_dimension_async_from_dict(): + await test_get_custom_dimension_async(request_type=dict) + + +def test_get_custom_dimension_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetCustomDimensionRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), "__call__" + ) as call: + call.return_value = resources.CustomDimension() + client.get_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_custom_dimension_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetCustomDimensionRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension() + ) + await client.get_custom_dimension(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_custom_dimension_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_custom_dimension(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_get_custom_dimension_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_custom_dimension( + analytics_admin.GetCustomDimensionRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_custom_dimension_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_dimension), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomDimension() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomDimension() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_custom_dimension(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_custom_dimension_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_custom_dimension( + analytics_admin.GetCustomDimensionRequest(), name="name_value", + ) + + +def test_create_custom_metric( + transport: str = "grpc", request_type=analytics_admin.CreateCustomMetricRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + response = client.create_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +def test_create_custom_metric_from_dict(): + test_create_custom_metric(request_type=dict) + + +def test_create_custom_metric_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), "__call__" + ) as call: + client.create_custom_metric() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateCustomMetricRequest() + + +@pytest.mark.asyncio +async def test_create_custom_metric_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateCustomMetricRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomMetric( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + ) + response = await client.create_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +@pytest.mark.asyncio +async def test_create_custom_metric_async_from_dict(): + await test_create_custom_metric_async(request_type=dict) + + +def test_create_custom_metric_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateCustomMetricRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), "__call__" + ) as call: + call.return_value = resources.CustomMetric() + client.create_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_custom_metric_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateCustomMetricRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomMetric() + ) + await client.create_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_custom_metric_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_custom_metric( + parent="parent_value", + custom_metric=resources.CustomMetric(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].custom_metric == resources.CustomMetric(name="name_value") + + +def test_create_custom_metric_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_custom_metric( + analytics_admin.CreateCustomMetricRequest(), + parent="parent_value", + custom_metric=resources.CustomMetric(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_custom_metric_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomMetric() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_custom_metric( + parent="parent_value", + custom_metric=resources.CustomMetric(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].custom_metric == resources.CustomMetric(name="name_value") + + +@pytest.mark.asyncio +async def test_create_custom_metric_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_custom_metric( + analytics_admin.CreateCustomMetricRequest(), + parent="parent_value", + custom_metric=resources.CustomMetric(name="name_value"), + ) + + +def test_update_custom_metric( + transport: str = "grpc", request_type=analytics_admin.UpdateCustomMetricRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + response = client.update_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +def test_update_custom_metric_from_dict(): + test_update_custom_metric(request_type=dict) + + +def test_update_custom_metric_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), "__call__" + ) as call: + client.update_custom_metric() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateCustomMetricRequest() + + +@pytest.mark.asyncio +async def test_update_custom_metric_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateCustomMetricRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomMetric( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + ) + response = await client.update_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +@pytest.mark.asyncio +async def test_update_custom_metric_async_from_dict(): + await test_update_custom_metric_async(request_type=dict) + + +def test_update_custom_metric_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateCustomMetricRequest() + + request.custom_metric.name = "custom_metric.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), "__call__" + ) as call: + call.return_value = resources.CustomMetric() + client.update_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "custom_metric.name=custom_metric.name/value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_custom_metric_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.UpdateCustomMetricRequest() + + request.custom_metric.name = "custom_metric.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomMetric() + ) + await client.update_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "custom_metric.name=custom_metric.name/value", + ) in kw["metadata"] + + +def test_update_custom_metric_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_custom_metric( + custom_metric=resources.CustomMetric(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].custom_metric == resources.CustomMetric(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +def test_update_custom_metric_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_custom_metric( + analytics_admin.UpdateCustomMetricRequest(), + custom_metric=resources.CustomMetric(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_custom_metric_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomMetric() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_custom_metric( + custom_metric=resources.CustomMetric(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].custom_metric == resources.CustomMetric(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +@pytest.mark.asyncio +async def test_update_custom_metric_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_custom_metric( + analytics_admin.UpdateCustomMetricRequest(), + custom_metric=resources.CustomMetric(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_list_custom_metrics( + transport: str = "grpc", request_type=analytics_admin.ListCustomMetricsRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomMetricsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_custom_metrics(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListCustomMetricsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomMetricsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_custom_metrics_from_dict(): + test_list_custom_metrics(request_type=dict) + + +def test_list_custom_metrics_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + client.list_custom_metrics() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListCustomMetricsRequest() + + +@pytest.mark.asyncio +async def test_list_custom_metrics_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListCustomMetricsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListCustomMetricsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_custom_metrics(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListCustomMetricsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomMetricsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_custom_metrics_async_from_dict(): + await test_list_custom_metrics_async(request_type=dict) + + +def test_list_custom_metrics_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListCustomMetricsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + call.return_value = analytics_admin.ListCustomMetricsResponse() + client.list_custom_metrics(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_custom_metrics_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListCustomMetricsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListCustomMetricsResponse() + ) + await client.list_custom_metrics(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_custom_metrics_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomMetricsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_custom_metrics(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_list_custom_metrics_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_custom_metrics( + analytics_admin.ListCustomMetricsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_custom_metrics_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListCustomMetricsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListCustomMetricsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_custom_metrics(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_custom_metrics_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_custom_metrics( + analytics_admin.ListCustomMetricsRequest(), parent="parent_value", + ) + + +def test_list_custom_metrics_pager(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + resources.CustomMetric(), + ], + next_page_token="abc", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[], next_page_token="def", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[resources.CustomMetric(),], next_page_token="ghi", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[resources.CustomMetric(), resources.CustomMetric(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_custom_metrics(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CustomMetric) for i in results) + + +def test_list_custom_metrics_pages(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + resources.CustomMetric(), + ], + next_page_token="abc", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[], next_page_token="def", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[resources.CustomMetric(),], next_page_token="ghi", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[resources.CustomMetric(), resources.CustomMetric(),], + ), + RuntimeError, + ) + pages = list(client.list_custom_metrics(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_custom_metrics_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + resources.CustomMetric(), + ], + next_page_token="abc", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[], next_page_token="def", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[resources.CustomMetric(),], next_page_token="ghi", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[resources.CustomMetric(), resources.CustomMetric(),], + ), + RuntimeError, + ) + async_pager = await client.list_custom_metrics(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.CustomMetric) for i in responses) + + +@pytest.mark.asyncio +async def test_list_custom_metrics_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_custom_metrics), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[ + resources.CustomMetric(), + resources.CustomMetric(), + resources.CustomMetric(), + ], + next_page_token="abc", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[], next_page_token="def", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[resources.CustomMetric(),], next_page_token="ghi", + ), + analytics_admin.ListCustomMetricsResponse( + custom_metrics=[resources.CustomMetric(), resources.CustomMetric(),], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_custom_metrics(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_archive_custom_metric( + transport: str = "grpc", request_type=analytics_admin.ArchiveCustomMetricRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.archive_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ArchiveCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_archive_custom_metric_from_dict(): + test_archive_custom_metric(request_type=dict) + + +def test_archive_custom_metric_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), "__call__" + ) as call: + client.archive_custom_metric() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ArchiveCustomMetricRequest() + + +@pytest.mark.asyncio +async def test_archive_custom_metric_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ArchiveCustomMetricRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.archive_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ArchiveCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_archive_custom_metric_async_from_dict(): + await test_archive_custom_metric_async(request_type=dict) + + +def test_archive_custom_metric_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ArchiveCustomMetricRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), "__call__" + ) as call: + call.return_value = None + client.archive_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_archive_custom_metric_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ArchiveCustomMetricRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.archive_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_archive_custom_metric_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.archive_custom_metric(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_archive_custom_metric_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.archive_custom_metric( + analytics_admin.ArchiveCustomMetricRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_archive_custom_metric_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.archive_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.archive_custom_metric(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_archive_custom_metric_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.archive_custom_metric( + analytics_admin.ArchiveCustomMetricRequest(), name="name_value", + ) + + +def test_get_custom_metric( + transport: str = "grpc", request_type=analytics_admin.GetCustomMetricRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CustomMetric( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + response = client.get_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +def test_get_custom_metric_from_dict(): + test_get_custom_metric(request_type=dict) + + +def test_get_custom_metric_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_metric), "__call__" + ) as call: + client.get_custom_metric() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetCustomMetricRequest() + + +@pytest.mark.asyncio +async def test_get_custom_metric_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.GetCustomMetricRequest +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_custom_metric), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.CustomMetric( + name="name_value", + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, + scope=resources.CustomMetric.MetricScope.EVENT, + ) + ) + response = await client.get_custom_metric(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetCustomMetricRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CustomMetric) + assert response.name == "name_value" + assert response.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.measurement_unit == resources.CustomMetric.MeasurementUnit.STANDARD + assert response.scope == resources.CustomMetric.MetricScope.EVENT + + +@pytest.mark.asyncio +async def test_get_custom_metric_async_from_dict(): + await test_get_custom_metric_async(request_type=dict) + + +def test_get_custom_metric_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = analytics_admin.GetDataSharingSettingsRequest() + request = analytics_admin.GetCustomMetricRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_data_sharing_settings), "__call__" + type(client.transport.get_custom_metric), "__call__" ) as call: - call.return_value = resources.DataSharingSettings() - - client.get_data_sharing_settings(request) + call.return_value = resources.CustomMetric() + client.get_custom_metric(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -12871,25 +17845,25 @@ def test_get_data_sharing_settings_field_headers(): @pytest.mark.asyncio -async def test_get_data_sharing_settings_field_headers_async(): +async def test_get_custom_metric_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = analytics_admin.GetDataSharingSettingsRequest() + request = analytics_admin.GetCustomMetricRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_data_sharing_settings), "__call__" + type(client.transport.get_custom_metric), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.DataSharingSettings() + resources.CustomMetric() ) - - await client.get_data_sharing_settings(request) + await client.get_custom_metric(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -12901,98 +17875,95 @@ async def test_get_data_sharing_settings_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_get_data_sharing_settings_flattened(): +def test_get_custom_metric_flattened(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_data_sharing_settings), "__call__" + type(client.transport.get_custom_metric), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.DataSharingSettings() - + call.return_value = resources.CustomMetric() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_data_sharing_settings(name="name_value",) + client.get_custom_metric(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" -def test_get_data_sharing_settings_flattened_error(): +def test_get_custom_metric_flattened_error(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_data_sharing_settings( - analytics_admin.GetDataSharingSettingsRequest(), name="name_value", + client.get_custom_metric( + analytics_admin.GetCustomMetricRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_get_data_sharing_settings_flattened_async(): +async def test_get_custom_metric_flattened_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_data_sharing_settings), "__call__" + type(client.transport.get_custom_metric), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.DataSharingSettings() + call.return_value = resources.CustomMetric() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.DataSharingSettings() + resources.CustomMetric() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_data_sharing_settings(name="name_value",) + response = await client.get_custom_metric(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio -async def test_get_data_sharing_settings_flattened_error_async(): +async def test_get_custom_metric_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_data_sharing_settings( - analytics_admin.GetDataSharingSettingsRequest(), name="name_value", + await client.get_custom_metric( + analytics_admin.GetCustomMetricRequest(), name="name_value", ) def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = AnalyticsAdminServiceClient( @@ -13002,7 +17973,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = AnalyticsAdminServiceClient( @@ -13013,7 +17984,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = AnalyticsAdminServiceClient(transport=transport) assert client.transport is transport @@ -13022,13 +17993,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.AnalyticsAdminServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.AnalyticsAdminServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -13043,8 +18014,8 @@ def test_transport_get_channel(): ) 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) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() @@ -13052,16 +18023,16 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance(client.transport, transports.AnalyticsAdminServiceGrpcTransport,) def test_analytics_admin_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.AnalyticsAdminServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -13073,7 +18044,7 @@ def test_analytics_admin_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.AnalyticsAdminServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -13108,12 +18079,10 @@ def test_analytics_admin_service_base_transport(): "get_ios_app_data_stream", "delete_ios_app_data_stream", "update_ios_app_data_stream", - "create_ios_app_data_stream", "list_ios_app_data_streams", "get_android_app_data_stream", "delete_android_app_data_stream", "update_android_app_data_stream", - "create_android_app_data_stream", "list_android_app_data_streams", "get_enhanced_measurement_settings", "update_enhanced_measurement_settings", @@ -13127,21 +18096,70 @@ def test_analytics_admin_service_base_transport(): "delete_google_ads_link", "list_google_ads_links", "get_data_sharing_settings", + "get_measurement_protocol_secret", + "list_measurement_protocol_secrets", + "create_measurement_protocol_secret", + "delete_measurement_protocol_secret", + "update_measurement_protocol_secret", + "search_change_history_events", + "get_google_signals_settings", + "update_google_signals_settings", + "create_conversion_event", + "get_conversion_event", + "delete_conversion_event", + "list_conversion_events", + "create_custom_dimension", + "update_custom_dimension", + "list_custom_dimensions", + "archive_custom_dimension", + "get_custom_dimension", + "create_custom_metric", + "update_custom_metric", + "list_custom_metrics", + "archive_custom_metric", + "get_custom_metric", ) for method in methods: with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) +@requires_google_auth_gte_1_25_0 def test_analytics_admin_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.AnalyticsAdminServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=( + "https://www.googleapis.com/auth/analytics.edit", + "https://www.googleapis.com/auth/analytics.manage.users", + "https://www.googleapis.com/auth/analytics.manage.users.readonly", + "https://www.googleapis.com/auth/analytics.readonly", + ), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_analytics_admin_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AnalyticsAdminServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -13159,19 +18177,38 @@ 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( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.analytics.admin_v1alpha.services.analytics_admin_service.transports.AnalyticsAdminServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AnalyticsAdminServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_analytics_admin_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + AnalyticsAdminServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + "https://www.googleapis.com/auth/analytics.edit", + "https://www.googleapis.com/auth/analytics.manage.users", + "https://www.googleapis.com/auth/analytics.manage.users.readonly", + "https://www.googleapis.com/auth/analytics.readonly", + ), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_analytics_admin_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) AnalyticsAdminServiceClient() adc.assert_called_once_with( scopes=( @@ -13184,14 +18221,46 @@ def test_analytics_admin_service_auth_adc(): ) -def test_analytics_admin_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.AnalyticsAdminServiceGrpcTransport, + transports.AnalyticsAdminServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_analytics_admin_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.AnalyticsAdminServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( + "https://www.googleapis.com/auth/analytics.edit", + "https://www.googleapis.com/auth/analytics.manage.users", + "https://www.googleapis.com/auth/analytics.manage.users.readonly", + "https://www.googleapis.com/auth/analytics.readonly", + ), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.AnalyticsAdminServiceGrpcTransport, + transports.AnalyticsAdminServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_analytics_admin_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=( "https://www.googleapis.com/auth/analytics.edit", @@ -13203,6 +18272,127 @@ def test_analytics_admin_service_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.AnalyticsAdminServiceGrpcTransport, grpc_helpers), + (transports.AnalyticsAdminServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_analytics_admin_service_transport_create_channel( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "analyticsadmin.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + "https://www.googleapis.com/auth/analytics.edit", + "https://www.googleapis.com/auth/analytics.manage.users", + "https://www.googleapis.com/auth/analytics.manage.users.readonly", + "https://www.googleapis.com/auth/analytics.readonly", + ), + scopes=["1", "2"], + default_host="analyticsadmin.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.AnalyticsAdminServiceGrpcTransport, grpc_helpers), + (transports.AnalyticsAdminServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_analytics_admin_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "analyticsadmin.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + 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=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.AnalyticsAdminServiceGrpcTransport, grpc_helpers), + (transports.AnalyticsAdminServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_analytics_admin_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "analyticsadmin.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -13213,7 +18403,7 @@ def test_analytics_admin_service_transport_auth_adc(): def test_analytics_admin_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -13257,7 +18447,7 @@ def test_analytics_admin_service_grpc_transport_client_cert_source_for_mtls( def test_analytics_admin_service_host_no_port(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="analyticsadmin.googleapis.com" ), @@ -13267,7 +18457,7 @@ def test_analytics_admin_service_host_no_port(): def test_analytics_admin_service_host_with_port(): client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="analyticsadmin.googleapis.com:8000" ), @@ -13323,9 +18513,9 @@ def test_analytics_admin_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -13411,7 +18601,6 @@ def test_analytics_admin_service_transport_channel_mtls_with_adc(transport_class def test_account_path(): account = "squid" - expected = "accounts/{account}".format(account=account,) actual = AnalyticsAdminServiceClient.account_path(account) assert expected == actual @@ -13430,7 +18619,6 @@ def test_parse_account_path(): def test_account_summary_path(): account_summary = "whelk" - expected = "accountSummaries/{account_summary}".format( account_summary=account_summary, ) @@ -13452,7 +18640,6 @@ def test_parse_account_summary_path(): def test_android_app_data_stream_path(): property = "oyster" android_app_data_stream = "nudibranch" - expected = "properties/{property}/androidAppDataStreams/{android_app_data_stream}".format( property=property, android_app_data_stream=android_app_data_stream, ) @@ -13474,9 +18661,68 @@ def test_parse_android_app_data_stream_path(): assert expected == actual -def test_data_sharing_settings_path(): - account = "winkle" +def test_conversion_event_path(): + property = "winkle" + conversion_event = "nautilus" + expected = "properties/{property}/conversionEvents/{conversion_event}".format( + property=property, conversion_event=conversion_event, + ) + actual = AnalyticsAdminServiceClient.conversion_event_path( + property, conversion_event + ) + assert expected == actual + + +def test_parse_conversion_event_path(): + expected = { + "property": "scallop", + "conversion_event": "abalone", + } + path = AnalyticsAdminServiceClient.conversion_event_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_conversion_event_path(path) + assert expected == actual + + +def test_custom_dimension_path(): + property = "squid" + expected = "properties/{property}/customDimensions".format(property=property,) + actual = AnalyticsAdminServiceClient.custom_dimension_path(property) + assert expected == actual + + +def test_parse_custom_dimension_path(): + expected = { + "property": "clam", + } + path = AnalyticsAdminServiceClient.custom_dimension_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_custom_dimension_path(path) + assert expected == actual + + +def test_custom_metric_path(): + property = "whelk" + expected = "properties/{property}/customMetrics".format(property=property,) + actual = AnalyticsAdminServiceClient.custom_metric_path(property) + assert expected == actual + + +def test_parse_custom_metric_path(): + expected = { + "property": "octopus", + } + path = AnalyticsAdminServiceClient.custom_metric_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_custom_metric_path(path) + assert expected == actual + +def test_data_sharing_settings_path(): + account = "oyster" expected = "accounts/{account}/dataSharingSettings".format(account=account,) actual = AnalyticsAdminServiceClient.data_sharing_settings_path(account) assert expected == actual @@ -13484,7 +18730,7 @@ def test_data_sharing_settings_path(): def test_parse_data_sharing_settings_path(): expected = { - "account": "nautilus", + "account": "nudibranch", } path = AnalyticsAdminServiceClient.data_sharing_settings_path(**expected) @@ -13494,9 +18740,8 @@ def test_parse_data_sharing_settings_path(): def test_enhanced_measurement_settings_path(): - property = "scallop" - web_data_stream = "abalone" - + property = "cuttlefish" + web_data_stream = "mussel" expected = "properties/{property}/webDataStreams/{web_data_stream}/enhancedMeasurementSettings".format( property=property, web_data_stream=web_data_stream, ) @@ -13508,8 +18753,8 @@ def test_enhanced_measurement_settings_path(): def test_parse_enhanced_measurement_settings_path(): expected = { - "property": "squid", - "web_data_stream": "clam", + "property": "winkle", + "web_data_stream": "nautilus", } path = AnalyticsAdminServiceClient.enhanced_measurement_settings_path(**expected) @@ -13519,9 +18764,8 @@ def test_parse_enhanced_measurement_settings_path(): def test_firebase_link_path(): - property = "whelk" - firebase_link = "octopus" - + property = "scallop" + firebase_link = "abalone" expected = "properties/{property}/firebaseLinks/{firebase_link}".format( property=property, firebase_link=firebase_link, ) @@ -13531,8 +18775,8 @@ def test_firebase_link_path(): def test_parse_firebase_link_path(): expected = { - "property": "oyster", - "firebase_link": "nudibranch", + "property": "squid", + "firebase_link": "clam", } path = AnalyticsAdminServiceClient.firebase_link_path(**expected) @@ -13542,8 +18786,7 @@ def test_parse_firebase_link_path(): def test_global_site_tag_path(): - property = "cuttlefish" - + property = "whelk" expected = "properties/{property}/globalSiteTag".format(property=property,) actual = AnalyticsAdminServiceClient.global_site_tag_path(property) assert expected == actual @@ -13551,7 +18794,7 @@ def test_global_site_tag_path(): def test_parse_global_site_tag_path(): expected = { - "property": "mussel", + "property": "octopus", } path = AnalyticsAdminServiceClient.global_site_tag_path(**expected) @@ -13561,9 +18804,8 @@ def test_parse_global_site_tag_path(): def test_google_ads_link_path(): - property = "winkle" - google_ads_link = "nautilus" - + property = "oyster" + google_ads_link = "nudibranch" expected = "properties/{property}/googleAdsLinks/{google_ads_link}".format( property=property, google_ads_link=google_ads_link, ) @@ -13573,8 +18815,8 @@ def test_google_ads_link_path(): def test_parse_google_ads_link_path(): expected = { - "property": "scallop", - "google_ads_link": "abalone", + "property": "cuttlefish", + "google_ads_link": "mussel", } path = AnalyticsAdminServiceClient.google_ads_link_path(**expected) @@ -13583,10 +18825,27 @@ def test_parse_google_ads_link_path(): assert expected == actual -def test_ios_app_data_stream_path(): - property = "squid" - ios_app_data_stream = "clam" +def test_google_signals_settings_path(): + property = "winkle" + expected = "properties/{property}/googleSignalsSettings".format(property=property,) + actual = AnalyticsAdminServiceClient.google_signals_settings_path(property) + assert expected == actual + + +def test_parse_google_signals_settings_path(): + expected = { + "property": "nautilus", + } + path = AnalyticsAdminServiceClient.google_signals_settings_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_google_signals_settings_path(path) + assert expected == actual + +def test_ios_app_data_stream_path(): + property = "scallop" + ios_app_data_stream = "abalone" expected = "properties/{property}/iosAppDataStreams/{ios_app_data_stream}".format( property=property, ios_app_data_stream=ios_app_data_stream, ) @@ -13598,8 +18857,8 @@ def test_ios_app_data_stream_path(): def test_parse_ios_app_data_stream_path(): expected = { - "property": "whelk", - "ios_app_data_stream": "octopus", + "property": "squid", + "ios_app_data_stream": "clam", } path = AnalyticsAdminServiceClient.ios_app_data_stream_path(**expected) @@ -13608,9 +18867,36 @@ def test_parse_ios_app_data_stream_path(): assert expected == actual -def test_property_path(): - property = "oyster" +def test_measurement_protocol_secret_path(): + property = "whelk" + web_data_stream = "octopus" + measurement_protocol_secret = "oyster" + expected = "properties/{property}/webDataStreams/{web_data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}".format( + property=property, + web_data_stream=web_data_stream, + measurement_protocol_secret=measurement_protocol_secret, + ) + actual = AnalyticsAdminServiceClient.measurement_protocol_secret_path( + property, web_data_stream, measurement_protocol_secret + ) + assert expected == actual + + +def test_parse_measurement_protocol_secret_path(): + expected = { + "property": "nudibranch", + "web_data_stream": "cuttlefish", + "measurement_protocol_secret": "mussel", + } + path = AnalyticsAdminServiceClient.measurement_protocol_secret_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_measurement_protocol_secret_path(path) + assert expected == actual + +def test_property_path(): + property = "winkle" expected = "properties/{property}".format(property=property,) actual = AnalyticsAdminServiceClient.property_path(property) assert expected == actual @@ -13618,7 +18904,7 @@ def test_property_path(): def test_parse_property_path(): expected = { - "property": "nudibranch", + "property": "nautilus", } path = AnalyticsAdminServiceClient.property_path(**expected) @@ -13628,9 +18914,8 @@ def test_parse_property_path(): def test_user_link_path(): - account = "cuttlefish" - user_link = "mussel" - + account = "scallop" + user_link = "abalone" expected = "accounts/{account}/userLinks/{user_link}".format( account=account, user_link=user_link, ) @@ -13640,8 +18925,8 @@ def test_user_link_path(): def test_parse_user_link_path(): expected = { - "account": "winkle", - "user_link": "nautilus", + "account": "squid", + "user_link": "clam", } path = AnalyticsAdminServiceClient.user_link_path(**expected) @@ -13651,9 +18936,8 @@ def test_parse_user_link_path(): def test_web_data_stream_path(): - property = "scallop" - web_data_stream = "abalone" - + property = "whelk" + web_data_stream = "octopus" expected = "properties/{property}/webDataStreams/{web_data_stream}".format( property=property, web_data_stream=web_data_stream, ) @@ -13663,8 +18947,8 @@ def test_web_data_stream_path(): def test_parse_web_data_stream_path(): expected = { - "property": "squid", - "web_data_stream": "clam", + "property": "oyster", + "web_data_stream": "nudibranch", } path = AnalyticsAdminServiceClient.web_data_stream_path(**expected) @@ -13674,8 +18958,7 @@ def test_parse_web_data_stream_path(): def test_common_billing_account_path(): - billing_account = "whelk" - + billing_account = "cuttlefish" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -13685,7 +18968,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "octopus", + "billing_account": "mussel", } path = AnalyticsAdminServiceClient.common_billing_account_path(**expected) @@ -13695,8 +18978,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "oyster" - + folder = "winkle" expected = "folders/{folder}".format(folder=folder,) actual = AnalyticsAdminServiceClient.common_folder_path(folder) assert expected == actual @@ -13704,7 +18986,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nudibranch", + "folder": "nautilus", } path = AnalyticsAdminServiceClient.common_folder_path(**expected) @@ -13714,8 +18996,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "cuttlefish" - + organization = "scallop" expected = "organizations/{organization}".format(organization=organization,) actual = AnalyticsAdminServiceClient.common_organization_path(organization) assert expected == actual @@ -13723,7 +19004,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "mussel", + "organization": "abalone", } path = AnalyticsAdminServiceClient.common_organization_path(**expected) @@ -13733,8 +19014,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "winkle" - + project = "squid" expected = "projects/{project}".format(project=project,) actual = AnalyticsAdminServiceClient.common_project_path(project) assert expected == actual @@ -13742,7 +19022,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nautilus", + "project": "clam", } path = AnalyticsAdminServiceClient.common_project_path(**expected) @@ -13752,9 +19032,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "scallop" - location = "abalone" - + project = "whelk" + location = "octopus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -13764,8 +19043,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "squid", - "location": "clam", + "project": "oyster", + "location": "nudibranch", } path = AnalyticsAdminServiceClient.common_location_path(**expected) @@ -13781,7 +19060,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.AnalyticsAdminServiceTransport, "_prep_wrapped_messages" ) as prep: client = AnalyticsAdminServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -13790,6 +19069,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = AnalyticsAdminServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)