diff --git a/google/analytics/admin/__init__.py b/google/analytics/admin/__init__.py index 1f734a3a..bb50815f 100644 --- a/google/analytics/admin/__init__.py +++ b/google/analytics/admin/__init__.py @@ -55,14 +55,22 @@ ArchiveCustomMetricRequest, AuditUserLinksRequest, AuditUserLinksResponse, + BatchCreateAccessBindingsRequest, + BatchCreateAccessBindingsResponse, BatchCreateUserLinksRequest, BatchCreateUserLinksResponse, + BatchDeleteAccessBindingsRequest, BatchDeleteUserLinksRequest, + BatchGetAccessBindingsRequest, + BatchGetAccessBindingsResponse, BatchGetUserLinksRequest, BatchGetUserLinksResponse, + BatchUpdateAccessBindingsRequest, + BatchUpdateAccessBindingsResponse, BatchUpdateUserLinksRequest, BatchUpdateUserLinksResponse, CancelDisplayVideo360AdvertiserLinkProposalRequest, + CreateAccessBindingRequest, CreateAudienceRequest, CreateConversionEventRequest, CreateCustomDimensionRequest, @@ -70,17 +78,20 @@ CreateDataStreamRequest, CreateDisplayVideo360AdvertiserLinkProposalRequest, CreateDisplayVideo360AdvertiserLinkRequest, + CreateExpandedDataSetRequest, CreateFirebaseLinkRequest, CreateGoogleAdsLinkRequest, CreateMeasurementProtocolSecretRequest, CreatePropertyRequest, CreateSearchAds360LinkRequest, CreateUserLinkRequest, + DeleteAccessBindingRequest, DeleteAccountRequest, DeleteConversionEventRequest, DeleteDataStreamRequest, DeleteDisplayVideo360AdvertiserLinkProposalRequest, DeleteDisplayVideo360AdvertiserLinkRequest, + DeleteExpandedDataSetRequest, DeleteFirebaseLinkRequest, DeleteGoogleAdsLinkRequest, DeleteMeasurementProtocolSecretRequest, @@ -89,6 +100,7 @@ DeleteUserLinkRequest, FetchAutomatedGa4ConfigurationOptOutRequest, FetchAutomatedGa4ConfigurationOptOutResponse, + GetAccessBindingRequest, GetAccountRequest, GetAttributionSettingsRequest, GetAudienceRequest, @@ -101,12 +113,15 @@ GetDataStreamRequest, GetDisplayVideo360AdvertiserLinkProposalRequest, GetDisplayVideo360AdvertiserLinkRequest, + GetExpandedDataSetRequest, GetGlobalSiteTagRequest, GetGoogleSignalsSettingsRequest, GetMeasurementProtocolSecretRequest, GetPropertyRequest, GetSearchAds360LinkRequest, GetUserLinkRequest, + ListAccessBindingsRequest, + ListAccessBindingsResponse, ListAccountsRequest, ListAccountsResponse, ListAccountSummariesRequest, @@ -127,6 +142,8 @@ ListDisplayVideo360AdvertiserLinkProposalsResponse, ListDisplayVideo360AdvertiserLinksRequest, ListDisplayVideo360AdvertiserLinksResponse, + ListExpandedDataSetsRequest, + ListExpandedDataSetsResponse, ListFirebaseLinksRequest, ListFirebaseLinksResponse, ListGoogleAdsLinksRequest, @@ -147,6 +164,7 @@ SearchChangeHistoryEventsResponse, SetAutomatedGa4ConfigurationOptOutRequest, SetAutomatedGa4ConfigurationOptOutResponse, + UpdateAccessBindingRequest, UpdateAccountRequest, UpdateAttributionSettingsRequest, UpdateAudienceRequest, @@ -155,6 +173,7 @@ UpdateDataRetentionSettingsRequest, UpdateDataStreamRequest, UpdateDisplayVideo360AdvertiserLinkRequest, + UpdateExpandedDataSetRequest, UpdateGoogleAdsLinkRequest, UpdateGoogleSignalsSettingsRequest, UpdateMeasurementProtocolSecretRequest, @@ -181,6 +200,7 @@ ExpandedDataSetFilterExpressionList, ) from google.analytics.admin_v1alpha.types.resources import ( + AccessBinding, Account, AccountSummary, ActionType, @@ -249,14 +269,22 @@ "ArchiveCustomMetricRequest", "AuditUserLinksRequest", "AuditUserLinksResponse", + "BatchCreateAccessBindingsRequest", + "BatchCreateAccessBindingsResponse", "BatchCreateUserLinksRequest", "BatchCreateUserLinksResponse", + "BatchDeleteAccessBindingsRequest", "BatchDeleteUserLinksRequest", + "BatchGetAccessBindingsRequest", + "BatchGetAccessBindingsResponse", "BatchGetUserLinksRequest", "BatchGetUserLinksResponse", + "BatchUpdateAccessBindingsRequest", + "BatchUpdateAccessBindingsResponse", "BatchUpdateUserLinksRequest", "BatchUpdateUserLinksResponse", "CancelDisplayVideo360AdvertiserLinkProposalRequest", + "CreateAccessBindingRequest", "CreateAudienceRequest", "CreateConversionEventRequest", "CreateCustomDimensionRequest", @@ -264,17 +292,20 @@ "CreateDataStreamRequest", "CreateDisplayVideo360AdvertiserLinkProposalRequest", "CreateDisplayVideo360AdvertiserLinkRequest", + "CreateExpandedDataSetRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", "CreateMeasurementProtocolSecretRequest", "CreatePropertyRequest", "CreateSearchAds360LinkRequest", "CreateUserLinkRequest", + "DeleteAccessBindingRequest", "DeleteAccountRequest", "DeleteConversionEventRequest", "DeleteDataStreamRequest", "DeleteDisplayVideo360AdvertiserLinkProposalRequest", "DeleteDisplayVideo360AdvertiserLinkRequest", + "DeleteExpandedDataSetRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", "DeleteMeasurementProtocolSecretRequest", @@ -283,6 +314,7 @@ "DeleteUserLinkRequest", "FetchAutomatedGa4ConfigurationOptOutRequest", "FetchAutomatedGa4ConfigurationOptOutResponse", + "GetAccessBindingRequest", "GetAccountRequest", "GetAttributionSettingsRequest", "GetAudienceRequest", @@ -295,12 +327,15 @@ "GetDataStreamRequest", "GetDisplayVideo360AdvertiserLinkProposalRequest", "GetDisplayVideo360AdvertiserLinkRequest", + "GetExpandedDataSetRequest", "GetGlobalSiteTagRequest", "GetGoogleSignalsSettingsRequest", "GetMeasurementProtocolSecretRequest", "GetPropertyRequest", "GetSearchAds360LinkRequest", "GetUserLinkRequest", + "ListAccessBindingsRequest", + "ListAccessBindingsResponse", "ListAccountsRequest", "ListAccountsResponse", "ListAccountSummariesRequest", @@ -321,6 +356,8 @@ "ListDisplayVideo360AdvertiserLinkProposalsResponse", "ListDisplayVideo360AdvertiserLinksRequest", "ListDisplayVideo360AdvertiserLinksResponse", + "ListExpandedDataSetsRequest", + "ListExpandedDataSetsResponse", "ListFirebaseLinksRequest", "ListFirebaseLinksResponse", "ListGoogleAdsLinksRequest", @@ -341,6 +378,7 @@ "SearchChangeHistoryEventsResponse", "SetAutomatedGa4ConfigurationOptOutRequest", "SetAutomatedGa4ConfigurationOptOutResponse", + "UpdateAccessBindingRequest", "UpdateAccountRequest", "UpdateAttributionSettingsRequest", "UpdateAudienceRequest", @@ -349,6 +387,7 @@ "UpdateDataRetentionSettingsRequest", "UpdateDataStreamRequest", "UpdateDisplayVideo360AdvertiserLinkRequest", + "UpdateExpandedDataSetRequest", "UpdateGoogleAdsLinkRequest", "UpdateGoogleSignalsSettingsRequest", "UpdateMeasurementProtocolSecretRequest", @@ -369,6 +408,7 @@ "ExpandedDataSetFilter", "ExpandedDataSetFilterExpression", "ExpandedDataSetFilterExpressionList", + "AccessBinding", "Account", "AccountSummary", "AttributionSettings", diff --git a/google/analytics/admin_v1alpha/__init__.py b/google/analytics/admin_v1alpha/__init__.py index 2140cc60..cd669c07 100644 --- a/google/analytics/admin_v1alpha/__init__.py +++ b/google/analytics/admin_v1alpha/__init__.py @@ -53,14 +53,22 @@ ArchiveCustomMetricRequest, AuditUserLinksRequest, AuditUserLinksResponse, + BatchCreateAccessBindingsRequest, + BatchCreateAccessBindingsResponse, BatchCreateUserLinksRequest, BatchCreateUserLinksResponse, + BatchDeleteAccessBindingsRequest, BatchDeleteUserLinksRequest, + BatchGetAccessBindingsRequest, + BatchGetAccessBindingsResponse, BatchGetUserLinksRequest, BatchGetUserLinksResponse, + BatchUpdateAccessBindingsRequest, + BatchUpdateAccessBindingsResponse, BatchUpdateUserLinksRequest, BatchUpdateUserLinksResponse, CancelDisplayVideo360AdvertiserLinkProposalRequest, + CreateAccessBindingRequest, CreateAudienceRequest, CreateConversionEventRequest, CreateCustomDimensionRequest, @@ -68,17 +76,20 @@ CreateDataStreamRequest, CreateDisplayVideo360AdvertiserLinkProposalRequest, CreateDisplayVideo360AdvertiserLinkRequest, + CreateExpandedDataSetRequest, CreateFirebaseLinkRequest, CreateGoogleAdsLinkRequest, CreateMeasurementProtocolSecretRequest, CreatePropertyRequest, CreateSearchAds360LinkRequest, CreateUserLinkRequest, + DeleteAccessBindingRequest, DeleteAccountRequest, DeleteConversionEventRequest, DeleteDataStreamRequest, DeleteDisplayVideo360AdvertiserLinkProposalRequest, DeleteDisplayVideo360AdvertiserLinkRequest, + DeleteExpandedDataSetRequest, DeleteFirebaseLinkRequest, DeleteGoogleAdsLinkRequest, DeleteMeasurementProtocolSecretRequest, @@ -87,6 +98,7 @@ DeleteUserLinkRequest, FetchAutomatedGa4ConfigurationOptOutRequest, FetchAutomatedGa4ConfigurationOptOutResponse, + GetAccessBindingRequest, GetAccountRequest, GetAttributionSettingsRequest, GetAudienceRequest, @@ -99,12 +111,15 @@ GetDataStreamRequest, GetDisplayVideo360AdvertiserLinkProposalRequest, GetDisplayVideo360AdvertiserLinkRequest, + GetExpandedDataSetRequest, GetGlobalSiteTagRequest, GetGoogleSignalsSettingsRequest, GetMeasurementProtocolSecretRequest, GetPropertyRequest, GetSearchAds360LinkRequest, GetUserLinkRequest, + ListAccessBindingsRequest, + ListAccessBindingsResponse, ListAccountsRequest, ListAccountsResponse, ListAccountSummariesRequest, @@ -125,6 +140,8 @@ ListDisplayVideo360AdvertiserLinkProposalsResponse, ListDisplayVideo360AdvertiserLinksRequest, ListDisplayVideo360AdvertiserLinksResponse, + ListExpandedDataSetsRequest, + ListExpandedDataSetsResponse, ListFirebaseLinksRequest, ListFirebaseLinksResponse, ListGoogleAdsLinksRequest, @@ -145,6 +162,7 @@ SearchChangeHistoryEventsResponse, SetAutomatedGa4ConfigurationOptOutRequest, SetAutomatedGa4ConfigurationOptOutResponse, + UpdateAccessBindingRequest, UpdateAccountRequest, UpdateAttributionSettingsRequest, UpdateAudienceRequest, @@ -153,6 +171,7 @@ UpdateDataRetentionSettingsRequest, UpdateDataStreamRequest, UpdateDisplayVideo360AdvertiserLinkRequest, + UpdateExpandedDataSetRequest, UpdateGoogleAdsLinkRequest, UpdateGoogleSignalsSettingsRequest, UpdateMeasurementProtocolSecretRequest, @@ -179,6 +198,7 @@ ExpandedDataSetFilterExpressionList, ) from .types.resources import ( + AccessBinding, Account, AccountSummary, ActionType, @@ -219,6 +239,7 @@ __all__ = ( "AnalyticsAdminServiceAsyncClient", "AccessBetweenFilter", + "AccessBinding", "AccessDateRange", "AccessDimension", "AccessDimensionHeader", @@ -262,11 +283,18 @@ "AuditUserLink", "AuditUserLinksRequest", "AuditUserLinksResponse", + "BatchCreateAccessBindingsRequest", + "BatchCreateAccessBindingsResponse", "BatchCreateUserLinksRequest", "BatchCreateUserLinksResponse", + "BatchDeleteAccessBindingsRequest", "BatchDeleteUserLinksRequest", + "BatchGetAccessBindingsRequest", + "BatchGetAccessBindingsResponse", "BatchGetUserLinksRequest", "BatchGetUserLinksResponse", + "BatchUpdateAccessBindingsRequest", + "BatchUpdateAccessBindingsResponse", "BatchUpdateUserLinksRequest", "BatchUpdateUserLinksResponse", "BigQueryLink", @@ -275,6 +303,7 @@ "ChangeHistoryEvent", "ChangeHistoryResourceType", "ConversionEvent", + "CreateAccessBindingRequest", "CreateAudienceRequest", "CreateConversionEventRequest", "CreateCustomDimensionRequest", @@ -282,6 +311,7 @@ "CreateDataStreamRequest", "CreateDisplayVideo360AdvertiserLinkProposalRequest", "CreateDisplayVideo360AdvertiserLinkRequest", + "CreateExpandedDataSetRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", "CreateMeasurementProtocolSecretRequest", @@ -293,11 +323,13 @@ "DataRetentionSettings", "DataSharingSettings", "DataStream", + "DeleteAccessBindingRequest", "DeleteAccountRequest", "DeleteConversionEventRequest", "DeleteDataStreamRequest", "DeleteDisplayVideo360AdvertiserLinkProposalRequest", "DeleteDisplayVideo360AdvertiserLinkRequest", + "DeleteExpandedDataSetRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", "DeleteMeasurementProtocolSecretRequest", @@ -313,6 +345,7 @@ "FetchAutomatedGa4ConfigurationOptOutRequest", "FetchAutomatedGa4ConfigurationOptOutResponse", "FirebaseLink", + "GetAccessBindingRequest", "GetAccountRequest", "GetAttributionSettingsRequest", "GetAudienceRequest", @@ -325,6 +358,7 @@ "GetDataStreamRequest", "GetDisplayVideo360AdvertiserLinkProposalRequest", "GetDisplayVideo360AdvertiserLinkRequest", + "GetExpandedDataSetRequest", "GetGlobalSiteTagRequest", "GetGoogleSignalsSettingsRequest", "GetMeasurementProtocolSecretRequest", @@ -340,6 +374,8 @@ "LinkProposalInitiatingProduct", "LinkProposalState", "LinkProposalStatusDetails", + "ListAccessBindingsRequest", + "ListAccessBindingsResponse", "ListAccountSummariesRequest", "ListAccountSummariesResponse", "ListAccountsRequest", @@ -360,6 +396,8 @@ "ListDisplayVideo360AdvertiserLinkProposalsResponse", "ListDisplayVideo360AdvertiserLinksRequest", "ListDisplayVideo360AdvertiserLinksResponse", + "ListExpandedDataSetsRequest", + "ListExpandedDataSetsResponse", "ListFirebaseLinksRequest", "ListFirebaseLinksResponse", "ListGoogleAdsLinksRequest", @@ -387,6 +425,7 @@ "ServiceLevel", "SetAutomatedGa4ConfigurationOptOutRequest", "SetAutomatedGa4ConfigurationOptOutResponse", + "UpdateAccessBindingRequest", "UpdateAccountRequest", "UpdateAttributionSettingsRequest", "UpdateAudienceRequest", @@ -395,6 +434,7 @@ "UpdateDataRetentionSettingsRequest", "UpdateDataStreamRequest", "UpdateDisplayVideo360AdvertiserLinkRequest", + "UpdateExpandedDataSetRequest", "UpdateGoogleAdsLinkRequest", "UpdateGoogleSignalsSettingsRequest", "UpdateMeasurementProtocolSecretRequest", diff --git a/google/analytics/admin_v1alpha/gapic_metadata.json b/google/analytics/admin_v1alpha/gapic_metadata.json index 6b6cfc5c..684dc82c 100644 --- a/google/analytics/admin_v1alpha/gapic_metadata.json +++ b/google/analytics/admin_v1alpha/gapic_metadata.json @@ -40,21 +40,41 @@ "audit_user_links" ] }, + "BatchCreateAccessBindings": { + "methods": [ + "batch_create_access_bindings" + ] + }, "BatchCreateUserLinks": { "methods": [ "batch_create_user_links" ] }, + "BatchDeleteAccessBindings": { + "methods": [ + "batch_delete_access_bindings" + ] + }, "BatchDeleteUserLinks": { "methods": [ "batch_delete_user_links" ] }, + "BatchGetAccessBindings": { + "methods": [ + "batch_get_access_bindings" + ] + }, "BatchGetUserLinks": { "methods": [ "batch_get_user_links" ] }, + "BatchUpdateAccessBindings": { + "methods": [ + "batch_update_access_bindings" + ] + }, "BatchUpdateUserLinks": { "methods": [ "batch_update_user_links" @@ -65,6 +85,11 @@ "cancel_display_video360_advertiser_link_proposal" ] }, + "CreateAccessBinding": { + "methods": [ + "create_access_binding" + ] + }, "CreateAudience": { "methods": [ "create_audience" @@ -100,6 +125,11 @@ "create_display_video360_advertiser_link_proposal" ] }, + "CreateExpandedDataSet": { + "methods": [ + "create_expanded_data_set" + ] + }, "CreateFirebaseLink": { "methods": [ "create_firebase_link" @@ -130,6 +160,11 @@ "create_user_link" ] }, + "DeleteAccessBinding": { + "methods": [ + "delete_access_binding" + ] + }, "DeleteAccount": { "methods": [ "delete_account" @@ -155,6 +190,11 @@ "delete_display_video360_advertiser_link_proposal" ] }, + "DeleteExpandedDataSet": { + "methods": [ + "delete_expanded_data_set" + ] + }, "DeleteFirebaseLink": { "methods": [ "delete_firebase_link" @@ -190,6 +230,11 @@ "fetch_automated_ga4_configuration_opt_out" ] }, + "GetAccessBinding": { + "methods": [ + "get_access_binding" + ] + }, "GetAccount": { "methods": [ "get_account" @@ -250,6 +295,11 @@ "get_display_video360_advertiser_link_proposal" ] }, + "GetExpandedDataSet": { + "methods": [ + "get_expanded_data_set" + ] + }, "GetGlobalSiteTag": { "methods": [ "get_global_site_tag" @@ -280,6 +330,11 @@ "get_user_link" ] }, + "ListAccessBindings": { + "methods": [ + "list_access_bindings" + ] + }, "ListAccountSummaries": { "methods": [ "list_account_summaries" @@ -330,6 +385,11 @@ "list_display_video360_advertiser_links" ] }, + "ListExpandedDataSets": { + "methods": [ + "list_expanded_data_sets" + ] + }, "ListFirebaseLinks": { "methods": [ "list_firebase_links" @@ -380,6 +440,11 @@ "set_automated_ga4_configuration_opt_out" ] }, + "UpdateAccessBinding": { + "methods": [ + "update_access_binding" + ] + }, "UpdateAccount": { "methods": [ "update_account" @@ -420,6 +485,11 @@ "update_display_video360_advertiser_link" ] }, + "UpdateExpandedDataSet": { + "methods": [ + "update_expanded_data_set" + ] + }, "UpdateGoogleAdsLink": { "methods": [ "update_google_ads_link" @@ -485,21 +555,41 @@ "audit_user_links" ] }, + "BatchCreateAccessBindings": { + "methods": [ + "batch_create_access_bindings" + ] + }, "BatchCreateUserLinks": { "methods": [ "batch_create_user_links" ] }, + "BatchDeleteAccessBindings": { + "methods": [ + "batch_delete_access_bindings" + ] + }, "BatchDeleteUserLinks": { "methods": [ "batch_delete_user_links" ] }, + "BatchGetAccessBindings": { + "methods": [ + "batch_get_access_bindings" + ] + }, "BatchGetUserLinks": { "methods": [ "batch_get_user_links" ] }, + "BatchUpdateAccessBindings": { + "methods": [ + "batch_update_access_bindings" + ] + }, "BatchUpdateUserLinks": { "methods": [ "batch_update_user_links" @@ -510,6 +600,11 @@ "cancel_display_video360_advertiser_link_proposal" ] }, + "CreateAccessBinding": { + "methods": [ + "create_access_binding" + ] + }, "CreateAudience": { "methods": [ "create_audience" @@ -545,6 +640,11 @@ "create_display_video360_advertiser_link_proposal" ] }, + "CreateExpandedDataSet": { + "methods": [ + "create_expanded_data_set" + ] + }, "CreateFirebaseLink": { "methods": [ "create_firebase_link" @@ -575,6 +675,11 @@ "create_user_link" ] }, + "DeleteAccessBinding": { + "methods": [ + "delete_access_binding" + ] + }, "DeleteAccount": { "methods": [ "delete_account" @@ -600,6 +705,11 @@ "delete_display_video360_advertiser_link_proposal" ] }, + "DeleteExpandedDataSet": { + "methods": [ + "delete_expanded_data_set" + ] + }, "DeleteFirebaseLink": { "methods": [ "delete_firebase_link" @@ -635,6 +745,11 @@ "fetch_automated_ga4_configuration_opt_out" ] }, + "GetAccessBinding": { + "methods": [ + "get_access_binding" + ] + }, "GetAccount": { "methods": [ "get_account" @@ -695,6 +810,11 @@ "get_display_video360_advertiser_link_proposal" ] }, + "GetExpandedDataSet": { + "methods": [ + "get_expanded_data_set" + ] + }, "GetGlobalSiteTag": { "methods": [ "get_global_site_tag" @@ -725,6 +845,11 @@ "get_user_link" ] }, + "ListAccessBindings": { + "methods": [ + "list_access_bindings" + ] + }, "ListAccountSummaries": { "methods": [ "list_account_summaries" @@ -775,6 +900,11 @@ "list_display_video360_advertiser_links" ] }, + "ListExpandedDataSets": { + "methods": [ + "list_expanded_data_sets" + ] + }, "ListFirebaseLinks": { "methods": [ "list_firebase_links" @@ -825,6 +955,11 @@ "set_automated_ga4_configuration_opt_out" ] }, + "UpdateAccessBinding": { + "methods": [ + "update_access_binding" + ] + }, "UpdateAccount": { "methods": [ "update_account" @@ -865,6 +1000,11 @@ "update_display_video360_advertiser_link" ] }, + "UpdateExpandedDataSet": { + "methods": [ + "update_expanded_data_set" + ] + }, "UpdateGoogleAdsLink": { "methods": [ "update_google_ads_link" @@ -930,21 +1070,41 @@ "audit_user_links" ] }, + "BatchCreateAccessBindings": { + "methods": [ + "batch_create_access_bindings" + ] + }, "BatchCreateUserLinks": { "methods": [ "batch_create_user_links" ] }, + "BatchDeleteAccessBindings": { + "methods": [ + "batch_delete_access_bindings" + ] + }, "BatchDeleteUserLinks": { "methods": [ "batch_delete_user_links" ] }, + "BatchGetAccessBindings": { + "methods": [ + "batch_get_access_bindings" + ] + }, "BatchGetUserLinks": { "methods": [ "batch_get_user_links" ] }, + "BatchUpdateAccessBindings": { + "methods": [ + "batch_update_access_bindings" + ] + }, "BatchUpdateUserLinks": { "methods": [ "batch_update_user_links" @@ -955,6 +1115,11 @@ "cancel_display_video360_advertiser_link_proposal" ] }, + "CreateAccessBinding": { + "methods": [ + "create_access_binding" + ] + }, "CreateAudience": { "methods": [ "create_audience" @@ -990,6 +1155,11 @@ "create_display_video360_advertiser_link_proposal" ] }, + "CreateExpandedDataSet": { + "methods": [ + "create_expanded_data_set" + ] + }, "CreateFirebaseLink": { "methods": [ "create_firebase_link" @@ -1020,6 +1190,11 @@ "create_user_link" ] }, + "DeleteAccessBinding": { + "methods": [ + "delete_access_binding" + ] + }, "DeleteAccount": { "methods": [ "delete_account" @@ -1045,6 +1220,11 @@ "delete_display_video360_advertiser_link_proposal" ] }, + "DeleteExpandedDataSet": { + "methods": [ + "delete_expanded_data_set" + ] + }, "DeleteFirebaseLink": { "methods": [ "delete_firebase_link" @@ -1080,6 +1260,11 @@ "fetch_automated_ga4_configuration_opt_out" ] }, + "GetAccessBinding": { + "methods": [ + "get_access_binding" + ] + }, "GetAccount": { "methods": [ "get_account" @@ -1140,6 +1325,11 @@ "get_display_video360_advertiser_link_proposal" ] }, + "GetExpandedDataSet": { + "methods": [ + "get_expanded_data_set" + ] + }, "GetGlobalSiteTag": { "methods": [ "get_global_site_tag" @@ -1170,6 +1360,11 @@ "get_user_link" ] }, + "ListAccessBindings": { + "methods": [ + "list_access_bindings" + ] + }, "ListAccountSummaries": { "methods": [ "list_account_summaries" @@ -1220,6 +1415,11 @@ "list_display_video360_advertiser_links" ] }, + "ListExpandedDataSets": { + "methods": [ + "list_expanded_data_sets" + ] + }, "ListFirebaseLinks": { "methods": [ "list_firebase_links" @@ -1270,6 +1470,11 @@ "set_automated_ga4_configuration_opt_out" ] }, + "UpdateAccessBinding": { + "methods": [ + "update_access_binding" + ] + }, "UpdateAccount": { "methods": [ "update_account" @@ -1310,6 +1515,11 @@ "update_display_video360_advertiser_link" ] }, + "UpdateExpandedDataSet": { + "methods": [ + "update_expanded_data_set" + ] + }, "UpdateGoogleAdsLink": { "methods": [ "update_google_ads_link" diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py index 74d125e1..99498f00 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py @@ -47,9 +47,13 @@ from google.protobuf import wrappers_pb2 # type: ignore from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers +from google.analytics.admin_v1alpha.types import ( + expanded_data_set as gaa_expanded_data_set, +) from google.analytics.admin_v1alpha.types import access_report, analytics_admin from google.analytics.admin_v1alpha.types import audience from google.analytics.admin_v1alpha.types import audience as gaa_audience +from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources from .client import AnalyticsAdminServiceClient @@ -65,6 +69,10 @@ class AnalyticsAdminServiceAsyncClient: DEFAULT_ENDPOINT = AnalyticsAdminServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = AnalyticsAdminServiceClient.DEFAULT_MTLS_ENDPOINT + access_binding_path = staticmethod(AnalyticsAdminServiceClient.access_binding_path) + parse_access_binding_path = staticmethod( + AnalyticsAdminServiceClient.parse_access_binding_path + ) account_path = staticmethod(AnalyticsAdminServiceClient.account_path) parse_account_path = staticmethod(AnalyticsAdminServiceClient.parse_account_path) account_summary_path = staticmethod( @@ -678,10 +686,10 @@ async def sample_update_account(): 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. + must be in snake case (for example, "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 @@ -3963,7 +3971,7 @@ async def acknowledge_user_data_collection( r"""Acknowledges the terms of user data collection for the specified property. This acknowledgement must be completed (either in the - Google Analytics UI or via this API) before + Google Analytics UI or through this API) before MeasurementProtocolSecret resources may be created. .. code-block:: python @@ -9277,6 +9285,1446 @@ async def sample_run_access_report(): # Done; return the response. return response + async def create_access_binding( + self, + request: Optional[ + Union[analytics_admin.CreateAccessBindingRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + access_binding: Optional[resources.AccessBinding] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AccessBinding: + r"""Creates an access binding on an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_create_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + access_binding = admin_v1alpha.AccessBinding() + access_binding.user = "user_value" + + request = admin_v1alpha.CreateAccessBindingRequest( + parent="parent_value", + access_binding=access_binding, + ) + + # Make the request + response = await client.create_access_binding(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.CreateAccessBindingRequest, dict]]): + The request object. Request message for + CreateAccessBinding RPC. + parent (:class:`str`): + Required. Formats: + - accounts/{account} + - properties/{property} + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + access_binding (:class:`google.analytics.admin_v1alpha.types.AccessBinding`): + Required. The access binding to + create. + + This corresponds to the ``access_binding`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AccessBinding: + A binding of a user to a set of + roles. + + """ + # Create or coerce a protobuf request object. + # Quick 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, access_binding]) + if request is 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.CreateAccessBindingRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if access_binding is not None: + request.access_binding = access_binding + + # 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_access_binding, + 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_access_binding( + self, + request: Optional[Union[analytics_admin.GetAccessBindingRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AccessBinding: + r"""Gets information about an access binding. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_get_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetAccessBindingRequest( + name="name_value", + ) + + # Make the request + response = await client.get_access_binding(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.GetAccessBindingRequest, dict]]): + The request object. Request message for GetAccessBinding + RPC. + name (:class:`str`): + Required. The name of the access + binding to retrieve. Formats: + - + accounts/{account}/accessBindings/{accessBinding} + - + properties/{property}/accessBindings/{accessBinding} + + 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.AccessBinding: + A binding of a user to a set of + roles. + + """ + # Create or coerce a protobuf request object. + # Quick 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.GetAccessBindingRequest(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_access_binding, + 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_access_binding( + self, + request: Optional[ + Union[analytics_admin.UpdateAccessBindingRequest, dict] + ] = None, + *, + access_binding: Optional[resources.AccessBinding] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AccessBinding: + r"""Updates an access binding on an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_update_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + access_binding = admin_v1alpha.AccessBinding() + access_binding.user = "user_value" + + request = admin_v1alpha.UpdateAccessBindingRequest( + access_binding=access_binding, + ) + + # Make the request + response = await client.update_access_binding(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.UpdateAccessBindingRequest, dict]]): + The request object. Request message for + UpdateAccessBinding RPC. + access_binding (:class:`google.analytics.admin_v1alpha.types.AccessBinding`): + Required. The access binding to + update. + + This corresponds to the ``access_binding`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AccessBinding: + A binding of a user to a set of + roles. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([access_binding]) + if request is 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.UpdateAccessBindingRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if access_binding is not None: + request.access_binding = access_binding + + # 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_access_binding, + 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( + (("access_binding.name", request.access_binding.name),) + ), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_access_binding( + self, + request: Optional[ + Union[analytics_admin.DeleteAccessBindingRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an access binding on an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_delete_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteAccessBindingRequest( + name="name_value", + ) + + # Make the request + await client.delete_access_binding(request=request) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.DeleteAccessBindingRequest, dict]]): + The request object. Request message for + DeleteAccessBinding RPC. + name (:class:`str`): + Required. Formats: + - + accounts/{account}/accessBindings/{accessBinding} + - + properties/{property}/accessBindings/{accessBinding} + + 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. + # Quick 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.DeleteAccessBindingRequest(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_access_binding, + 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_access_bindings( + self, + request: Optional[ + Union[analytics_admin.ListAccessBindingsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAccessBindingsAsyncPager: + r"""Lists all access bindings on an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_list_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListAccessBindingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_access_bindings(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.ListAccessBindingsRequest, dict]]): + The request object. Request message for + ListAccessBindings RPC. + parent (:class:`str`): + Required. Formats: + - accounts/{account} + - properties/{property} + + 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.ListAccessBindingsAsyncPager: + Response message for + ListAccessBindings RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick 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.ListAccessBindingsRequest(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_access_bindings, + 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.ListAccessBindingsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def batch_create_access_bindings( + self, + request: Optional[ + Union[analytics_admin.BatchCreateAccessBindingsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchCreateAccessBindingsResponse: + r"""Creates information about multiple access bindings to + an account or property. + + This method is transactional. If any AccessBinding + cannot be created, none of the AccessBindings will be + created. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_batch_create_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + requests = admin_v1alpha.CreateAccessBindingRequest() + requests.parent = "parent_value" + requests.access_binding.user = "user_value" + + request = admin_v1alpha.BatchCreateAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = await client.batch_create_access_bindings(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.BatchCreateAccessBindingsRequest, dict]]): + The request object. Request message for + BatchCreateAccessBindings RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchCreateAccessBindingsResponse: + Response message for + BatchCreateAccessBindings RPC. + + """ + # Create or coerce a protobuf request object. + request = analytics_admin.BatchCreateAccessBindingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_create_access_bindings, + 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 batch_get_access_bindings( + self, + request: Optional[ + Union[analytics_admin.BatchGetAccessBindingsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchGetAccessBindingsResponse: + r"""Gets information about multiple access bindings to an + account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_batch_get_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.BatchGetAccessBindingsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + response = await client.batch_get_access_bindings(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.BatchGetAccessBindingsRequest, dict]]): + The request object. Request message for + BatchGetAccessBindings RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchGetAccessBindingsResponse: + Response message for + BatchGetAccessBindings RPC. + + """ + # Create or coerce a protobuf request object. + request = analytics_admin.BatchGetAccessBindingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_get_access_bindings, + 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 batch_update_access_bindings( + self, + request: Optional[ + Union[analytics_admin.BatchUpdateAccessBindingsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchUpdateAccessBindingsResponse: + r"""Updates information about multiple access bindings to + an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_batch_update_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + requests = admin_v1alpha.UpdateAccessBindingRequest() + requests.access_binding.user = "user_value" + + request = admin_v1alpha.BatchUpdateAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = await client.batch_update_access_bindings(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsRequest, dict]]): + The request object. Request message for + BatchUpdateAccessBindings RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsResponse: + Response message for + BatchUpdateAccessBindings RPC. + + """ + # Create or coerce a protobuf request object. + request = analytics_admin.BatchUpdateAccessBindingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_update_access_bindings, + 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 batch_delete_access_bindings( + self, + request: Optional[ + Union[analytics_admin.BatchDeleteAccessBindingsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes information about multiple users' links to an + account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_batch_delete_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + requests = admin_v1alpha.DeleteAccessBindingRequest() + requests.name = "name_value" + + request = admin_v1alpha.BatchDeleteAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + await client.batch_delete_access_bindings(request=request) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.BatchDeleteAccessBindingsRequest, dict]]): + The request object. Request message for + BatchDeleteAccessBindings RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + request = analytics_admin.BatchDeleteAccessBindingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.batch_delete_access_bindings, + 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. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def get_expanded_data_set( + self, + request: Optional[ + Union[analytics_admin.GetExpandedDataSetRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> expanded_data_set.ExpandedDataSet: + r"""Lookup for a single ExpandedDataSet. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_get_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetExpandedDataSetRequest( + name="name_value", + ) + + # Make the request + response = await client.get_expanded_data_set(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.GetExpandedDataSetRequest, dict]]): + The request object. Request message for + GetExpandedDataSet RPC. + name (:class:`str`): + Required. The name of the Audience to + get. Example format: + properties/1234/expandedDataSets/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.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + # Create or coerce a protobuf request object. + # Quick 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.GetExpandedDataSetRequest(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_expanded_data_set, + 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_expanded_data_sets( + self, + request: Optional[ + Union[analytics_admin.ListExpandedDataSetsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListExpandedDataSetsAsyncPager: + r"""Lists ExpandedDataSets on a property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_list_expanded_data_sets(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListExpandedDataSetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_expanded_data_sets(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.ListExpandedDataSetsRequest, dict]]): + The request object. Request message for + ListExpandedDataSets 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.ListExpandedDataSetsAsyncPager: + Response message for + ListExpandedDataSets RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick 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.ListExpandedDataSetsRequest(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_expanded_data_sets, + 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.ListExpandedDataSetsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_expanded_data_set( + self, + request: Optional[ + Union[analytics_admin.CreateExpandedDataSetRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + expanded_data_set: Optional[gaa_expanded_data_set.ExpandedDataSet] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gaa_expanded_data_set.ExpandedDataSet: + r"""Creates a ExpandedDataSet. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_create_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + expanded_data_set = admin_v1alpha.ExpandedDataSet() + expanded_data_set.display_name = "display_name_value" + + request = admin_v1alpha.CreateExpandedDataSetRequest( + parent="parent_value", + expanded_data_set=expanded_data_set, + ) + + # Make the request + response = await client.create_expanded_data_set(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.CreateExpandedDataSetRequest, dict]]): + The request object. Request message for + CreateExpandedDataSet 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. + expanded_data_set (:class:`google.analytics.admin_v1alpha.types.ExpandedDataSet`): + Required. The ExpandedDataSet to + create. + + This corresponds to the ``expanded_data_set`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + # Create or coerce a protobuf request object. + # Quick 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, expanded_data_set]) + if request is 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.CreateExpandedDataSetRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if expanded_data_set is not None: + request.expanded_data_set = expanded_data_set + + # 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_expanded_data_set, + 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_expanded_data_set( + self, + request: Optional[ + Union[analytics_admin.UpdateExpandedDataSetRequest, dict] + ] = None, + *, + expanded_data_set: Optional[gaa_expanded_data_set.ExpandedDataSet] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gaa_expanded_data_set.ExpandedDataSet: + r"""Updates a ExpandedDataSet on a property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_update_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + expanded_data_set = admin_v1alpha.ExpandedDataSet() + expanded_data_set.display_name = "display_name_value" + + request = admin_v1alpha.UpdateExpandedDataSetRequest( + expanded_data_set=expanded_data_set, + ) + + # Make the request + response = await client.update_expanded_data_set(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.UpdateExpandedDataSetRequest, dict]]): + The request object. Request message for + UpdateExpandedDataSet RPC. + expanded_data_set (:class:`google.analytics.admin_v1alpha.types.ExpandedDataSet`): + Required. The ExpandedDataSet to update. The resource's + ``name`` field is used to identify the ExpandedDataSet + to be updated. + + This corresponds to the ``expanded_data_set`` 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.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([expanded_data_set, 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.UpdateExpandedDataSetRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if expanded_data_set is not None: + request.expanded_data_set = expanded_data_set + 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_expanded_data_set, + 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( + (("expanded_data_set.name", request.expanded_data_set.name),) + ), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_expanded_data_set( + self, + request: Optional[ + Union[analytics_admin.DeleteExpandedDataSetRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a ExpandedDataSet on a property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + async def sample_delete_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteExpandedDataSetRequest( + name="name_value", + ) + + # Make the request + await client.delete_expanded_data_set(request=request) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.DeleteExpandedDataSetRequest, dict]]): + The request object. Request message for + DeleteExpandedDataSet RPC. + name (:class:`str`): + Required. Example format: + properties/1234/expandedDataSets/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. + # Quick 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.DeleteExpandedDataSetRequest(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_expanded_data_set, + 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 set_automated_ga4_configuration_opt_out( self, request: Optional[ diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py index 28d268de..6a008cce 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py @@ -51,9 +51,13 @@ from google.protobuf import wrappers_pb2 # type: ignore from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers +from google.analytics.admin_v1alpha.types import ( + expanded_data_set as gaa_expanded_data_set, +) from google.analytics.admin_v1alpha.types import access_report, analytics_admin from google.analytics.admin_v1alpha.types import audience from google.analytics.admin_v1alpha.types import audience as gaa_audience +from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport @@ -184,6 +188,25 @@ def transport(self) -> AnalyticsAdminServiceTransport: """ return self._transport + @staticmethod + def access_binding_path( + account: str, + access_binding: str, + ) -> str: + """Returns a fully-qualified access_binding string.""" + return "accounts/{account}/accessBindings/{access_binding}".format( + account=account, + access_binding=access_binding, + ) + + @staticmethod + def parse_access_binding_path(path: str) -> Dict[str, str]: + """Parses a access_binding path into its component segments.""" + m = re.match( + r"^accounts/(?P.+?)/accessBindings/(?P.+?)$", path + ) + return m.groupdict() if m else {} + @staticmethod def account_path( account: str, @@ -1176,10 +1199,10 @@ def sample_update_account(): 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. + must be in snake case (for example, "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 @@ -4489,7 +4512,7 @@ def acknowledge_user_data_collection( r"""Acknowledges the terms of user data collection for the specified property. This acknowledgement must be completed (either in the - Google Analytics UI or via this API) before + Google Analytics UI or through this API) before MeasurementProtocolSecret resources may be created. .. code-block:: python @@ -9889,6 +9912,1458 @@ def sample_run_access_report(): # Done; return the response. return response + def create_access_binding( + self, + request: Optional[ + Union[analytics_admin.CreateAccessBindingRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + access_binding: Optional[resources.AccessBinding] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AccessBinding: + r"""Creates an access binding on an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_create_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + access_binding = admin_v1alpha.AccessBinding() + access_binding.user = "user_value" + + request = admin_v1alpha.CreateAccessBindingRequest( + parent="parent_value", + access_binding=access_binding, + ) + + # Make the request + response = client.create_access_binding(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.CreateAccessBindingRequest, dict]): + The request object. Request message for + CreateAccessBinding RPC. + parent (str): + Required. Formats: + - accounts/{account} + - properties/{property} + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + access_binding (google.analytics.admin_v1alpha.types.AccessBinding): + Required. The access binding to + create. + + This corresponds to the ``access_binding`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AccessBinding: + A binding of a user to a set of + roles. + + """ + # Create or coerce a protobuf request object. + # Quick 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, access_binding]) + if request is 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.CreateAccessBindingRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateAccessBindingRequest): + request = analytics_admin.CreateAccessBindingRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if access_binding is not None: + request.access_binding = access_binding + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_access_binding] + + # 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_access_binding( + self, + request: Optional[Union[analytics_admin.GetAccessBindingRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AccessBinding: + r"""Gets information about an access binding. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_get_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetAccessBindingRequest( + name="name_value", + ) + + # Make the request + response = client.get_access_binding(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.GetAccessBindingRequest, dict]): + The request object. Request message for GetAccessBinding + RPC. + name (str): + Required. The name of the access + binding to retrieve. Formats: + - + accounts/{account}/accessBindings/{accessBinding} + - + properties/{property}/accessBindings/{accessBinding} + + 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.AccessBinding: + A binding of a user to a set of + roles. + + """ + # Create or coerce a protobuf request object. + # Quick 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.GetAccessBindingRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetAccessBindingRequest): + request = analytics_admin.GetAccessBindingRequest(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_access_binding] + + # 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_access_binding( + self, + request: Optional[ + Union[analytics_admin.UpdateAccessBindingRequest, dict] + ] = None, + *, + access_binding: Optional[resources.AccessBinding] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AccessBinding: + r"""Updates an access binding on an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_update_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + access_binding = admin_v1alpha.AccessBinding() + access_binding.user = "user_value" + + request = admin_v1alpha.UpdateAccessBindingRequest( + access_binding=access_binding, + ) + + # Make the request + response = client.update_access_binding(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.UpdateAccessBindingRequest, dict]): + The request object. Request message for + UpdateAccessBinding RPC. + access_binding (google.analytics.admin_v1alpha.types.AccessBinding): + Required. The access binding to + update. + + This corresponds to the ``access_binding`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AccessBinding: + A binding of a user to a set of + roles. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([access_binding]) + if request is 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.UpdateAccessBindingRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateAccessBindingRequest): + request = analytics_admin.UpdateAccessBindingRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if access_binding is not None: + request.access_binding = access_binding + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_access_binding] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("access_binding.name", request.access_binding.name),) + ), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_access_binding( + self, + request: Optional[ + Union[analytics_admin.DeleteAccessBindingRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an access binding on an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_delete_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteAccessBindingRequest( + name="name_value", + ) + + # Make the request + client.delete_access_binding(request=request) + + Args: + request (Union[google.analytics.admin_v1alpha.types.DeleteAccessBindingRequest, dict]): + The request object. Request message for + DeleteAccessBinding RPC. + name (str): + Required. Formats: + - + accounts/{account}/accessBindings/{accessBinding} + - + properties/{property}/accessBindings/{accessBinding} + + 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. + # Quick 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.DeleteAccessBindingRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteAccessBindingRequest): + request = analytics_admin.DeleteAccessBindingRequest(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_access_binding] + + # 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_access_bindings( + self, + request: Optional[ + Union[analytics_admin.ListAccessBindingsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAccessBindingsPager: + r"""Lists all access bindings on an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_list_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListAccessBindingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_access_bindings(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.ListAccessBindingsRequest, dict]): + The request object. Request message for + ListAccessBindings RPC. + parent (str): + Required. Formats: + - accounts/{account} + - properties/{property} + + 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.ListAccessBindingsPager: + Response message for + ListAccessBindings RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick 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.ListAccessBindingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListAccessBindingsRequest): + request = analytics_admin.ListAccessBindingsRequest(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_access_bindings] + + # 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.ListAccessBindingsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_create_access_bindings( + self, + request: Optional[ + Union[analytics_admin.BatchCreateAccessBindingsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchCreateAccessBindingsResponse: + r"""Creates information about multiple access bindings to + an account or property. + + This method is transactional. If any AccessBinding + cannot be created, none of the AccessBindings will be + created. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_batch_create_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + requests = admin_v1alpha.CreateAccessBindingRequest() + requests.parent = "parent_value" + requests.access_binding.user = "user_value" + + request = admin_v1alpha.BatchCreateAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = client.batch_create_access_bindings(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.BatchCreateAccessBindingsRequest, dict]): + The request object. Request message for + BatchCreateAccessBindings RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchCreateAccessBindingsResponse: + Response message for + BatchCreateAccessBindings RPC. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.BatchCreateAccessBindingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.BatchCreateAccessBindingsRequest): + request = analytics_admin.BatchCreateAccessBindingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.batch_create_access_bindings + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_get_access_bindings( + self, + request: Optional[ + Union[analytics_admin.BatchGetAccessBindingsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchGetAccessBindingsResponse: + r"""Gets information about multiple access bindings to an + account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_batch_get_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.BatchGetAccessBindingsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + response = client.batch_get_access_bindings(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.BatchGetAccessBindingsRequest, dict]): + The request object. Request message for + BatchGetAccessBindings RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchGetAccessBindingsResponse: + Response message for + BatchGetAccessBindings RPC. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.BatchGetAccessBindingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.BatchGetAccessBindingsRequest): + request = analytics_admin.BatchGetAccessBindingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.batch_get_access_bindings + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_update_access_bindings( + self, + request: Optional[ + Union[analytics_admin.BatchUpdateAccessBindingsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchUpdateAccessBindingsResponse: + r"""Updates information about multiple access bindings to + an account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_batch_update_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + requests = admin_v1alpha.UpdateAccessBindingRequest() + requests.access_binding.user = "user_value" + + request = admin_v1alpha.BatchUpdateAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = client.batch_update_access_bindings(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsRequest, dict]): + The request object. Request message for + BatchUpdateAccessBindings RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsResponse: + Response message for + BatchUpdateAccessBindings RPC. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.BatchUpdateAccessBindingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.BatchUpdateAccessBindingsRequest): + request = analytics_admin.BatchUpdateAccessBindingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.batch_update_access_bindings + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def batch_delete_access_bindings( + self, + request: Optional[ + Union[analytics_admin.BatchDeleteAccessBindingsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes information about multiple users' links to an + account or property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_batch_delete_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + requests = admin_v1alpha.DeleteAccessBindingRequest() + requests.name = "name_value" + + request = admin_v1alpha.BatchDeleteAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + client.batch_delete_access_bindings(request=request) + + Args: + request (Union[google.analytics.admin_v1alpha.types.BatchDeleteAccessBindingsRequest, dict]): + The request object. Request message for + BatchDeleteAccessBindings RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.BatchDeleteAccessBindingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.BatchDeleteAccessBindingsRequest): + request = analytics_admin.BatchDeleteAccessBindingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.batch_delete_access_bindings + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def get_expanded_data_set( + self, + request: Optional[ + Union[analytics_admin.GetExpandedDataSetRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> expanded_data_set.ExpandedDataSet: + r"""Lookup for a single ExpandedDataSet. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_get_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetExpandedDataSetRequest( + name="name_value", + ) + + # Make the request + response = client.get_expanded_data_set(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.GetExpandedDataSetRequest, dict]): + The request object. Request message for + GetExpandedDataSet RPC. + name (str): + Required. The name of the Audience to + get. Example format: + properties/1234/expandedDataSets/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.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + # Create or coerce a protobuf request object. + # Quick 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.GetExpandedDataSetRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetExpandedDataSetRequest): + request = analytics_admin.GetExpandedDataSetRequest(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_expanded_data_set] + + # 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_expanded_data_sets( + self, + request: Optional[ + Union[analytics_admin.ListExpandedDataSetsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListExpandedDataSetsPager: + r"""Lists ExpandedDataSets on a property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_list_expanded_data_sets(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListExpandedDataSetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_expanded_data_sets(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.ListExpandedDataSetsRequest, dict]): + The request object. Request message for + ListExpandedDataSets 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.ListExpandedDataSetsPager: + Response message for + ListExpandedDataSets RPC. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick 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.ListExpandedDataSetsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListExpandedDataSetsRequest): + request = analytics_admin.ListExpandedDataSetsRequest(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_expanded_data_sets] + + # 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.ListExpandedDataSetsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_expanded_data_set( + self, + request: Optional[ + Union[analytics_admin.CreateExpandedDataSetRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + expanded_data_set: Optional[gaa_expanded_data_set.ExpandedDataSet] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gaa_expanded_data_set.ExpandedDataSet: + r"""Creates a ExpandedDataSet. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_create_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + expanded_data_set = admin_v1alpha.ExpandedDataSet() + expanded_data_set.display_name = "display_name_value" + + request = admin_v1alpha.CreateExpandedDataSetRequest( + parent="parent_value", + expanded_data_set=expanded_data_set, + ) + + # Make the request + response = client.create_expanded_data_set(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.CreateExpandedDataSetRequest, dict]): + The request object. Request message for + CreateExpandedDataSet 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. + expanded_data_set (google.analytics.admin_v1alpha.types.ExpandedDataSet): + Required. The ExpandedDataSet to + create. + + This corresponds to the ``expanded_data_set`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + # Create or coerce a protobuf request object. + # Quick 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, expanded_data_set]) + if request is 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.CreateExpandedDataSetRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateExpandedDataSetRequest): + request = analytics_admin.CreateExpandedDataSetRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if expanded_data_set is not None: + request.expanded_data_set = expanded_data_set + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_expanded_data_set] + + # 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_expanded_data_set( + self, + request: Optional[ + Union[analytics_admin.UpdateExpandedDataSetRequest, dict] + ] = None, + *, + expanded_data_set: Optional[gaa_expanded_data_set.ExpandedDataSet] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gaa_expanded_data_set.ExpandedDataSet: + r"""Updates a ExpandedDataSet on a property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_update_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + expanded_data_set = admin_v1alpha.ExpandedDataSet() + expanded_data_set.display_name = "display_name_value" + + request = admin_v1alpha.UpdateExpandedDataSetRequest( + expanded_data_set=expanded_data_set, + ) + + # Make the request + response = client.update_expanded_data_set(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.UpdateExpandedDataSetRequest, dict]): + The request object. Request message for + UpdateExpandedDataSet RPC. + expanded_data_set (google.analytics.admin_v1alpha.types.ExpandedDataSet): + Required. The ExpandedDataSet to update. The resource's + ``name`` field is used to identify the ExpandedDataSet + to be updated. + + This corresponds to the ``expanded_data_set`` 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.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([expanded_data_set, 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.UpdateExpandedDataSetRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateExpandedDataSetRequest): + request = analytics_admin.UpdateExpandedDataSetRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if expanded_data_set is not None: + request.expanded_data_set = expanded_data_set + 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_expanded_data_set] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("expanded_data_set.name", request.expanded_data_set.name),) + ), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_expanded_data_set( + self, + request: Optional[ + Union[analytics_admin.DeleteExpandedDataSetRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a ExpandedDataSet on a property. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.analytics import admin_v1alpha + + def sample_delete_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteExpandedDataSetRequest( + name="name_value", + ) + + # Make the request + client.delete_expanded_data_set(request=request) + + Args: + request (Union[google.analytics.admin_v1alpha.types.DeleteExpandedDataSetRequest, dict]): + The request object. Request message for + DeleteExpandedDataSet RPC. + name (str): + Required. Example format: + properties/1234/expandedDataSets/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. + # Quick 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.DeleteExpandedDataSetRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteExpandedDataSetRequest): + request = analytics_admin.DeleteExpandedDataSetRequest(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_expanded_data_set] + + # 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 set_automated_ga4_configuration_opt_out( self, request: Optional[ diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py index 85a9750b..d572673a 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py @@ -24,7 +24,12 @@ Tuple, ) -from google.analytics.admin_v1alpha.types import analytics_admin, audience, resources +from google.analytics.admin_v1alpha.types import ( + analytics_admin, + audience, + expanded_data_set, + resources, +) class ListAccountsPager: @@ -2250,6 +2255,264 @@ def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) +class ListAccessBindingsPager: + """A pager for iterating through ``list_access_bindings`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAccessBindingsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``access_bindings`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAccessBindings`` requests and continue to iterate + through the ``access_bindings`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAccessBindingsResponse` + 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.ListAccessBindingsResponse], + request: analytics_admin.ListAccessBindingsRequest, + response: analytics_admin.ListAccessBindingsResponse, + *, + 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.ListAccessBindingsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAccessBindingsResponse): + 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.ListAccessBindingsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[analytics_admin.ListAccessBindingsResponse]: + 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) -> Iterator[resources.AccessBinding]: + for page in self.pages: + yield from page.access_bindings + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAccessBindingsAsyncPager: + """A pager for iterating through ``list_access_bindings`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAccessBindingsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``access_bindings`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAccessBindings`` requests and continue to iterate + through the ``access_bindings`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAccessBindingsResponse` + 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.ListAccessBindingsResponse]], + request: analytics_admin.ListAccessBindingsRequest, + response: analytics_admin.ListAccessBindingsResponse, + *, + 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.ListAccessBindingsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAccessBindingsResponse): + 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.ListAccessBindingsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[analytics_admin.ListAccessBindingsResponse]: + 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) -> AsyncIterator[resources.AccessBinding]: + async def async_generator(): + async for page in self.pages: + for response in page.access_bindings: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListExpandedDataSetsPager: + """A pager for iterating through ``list_expanded_data_sets`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListExpandedDataSetsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``expanded_data_sets`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListExpandedDataSets`` requests and continue to iterate + through the ``expanded_data_sets`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListExpandedDataSetsResponse` + 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.ListExpandedDataSetsResponse], + request: analytics_admin.ListExpandedDataSetsRequest, + response: analytics_admin.ListExpandedDataSetsResponse, + *, + 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.ListExpandedDataSetsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListExpandedDataSetsResponse): + 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.ListExpandedDataSetsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[analytics_admin.ListExpandedDataSetsResponse]: + 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) -> Iterator[expanded_data_set.ExpandedDataSet]: + for page in self.pages: + yield from page.expanded_data_sets + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListExpandedDataSetsAsyncPager: + """A pager for iterating through ``list_expanded_data_sets`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListExpandedDataSetsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``expanded_data_sets`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListExpandedDataSets`` requests and continue to iterate + through the ``expanded_data_sets`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListExpandedDataSetsResponse` + 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.ListExpandedDataSetsResponse]], + request: analytics_admin.ListExpandedDataSetsRequest, + response: analytics_admin.ListExpandedDataSetsResponse, + *, + 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.ListExpandedDataSetsRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListExpandedDataSetsResponse): + 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.ListExpandedDataSetsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[analytics_admin.ListExpandedDataSetsResponse]: + 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) -> AsyncIterator[expanded_data_set.ExpandedDataSet]: + async def async_generator(): + async for page in self.pages: + for response in page.expanded_data_sets: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListBigQueryLinksPager: """A pager for iterating through ``list_big_query_links`` requests. diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py index 092530f9..76ebe25f 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py @@ -26,9 +26,13 @@ from google.protobuf import empty_pb2 # type: ignore from google.analytics.admin_v1alpha import gapic_version as package_version +from google.analytics.admin_v1alpha.types import ( + expanded_data_set as gaa_expanded_data_set, +) from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import audience from google.analytics.admin_v1alpha.types import audience as gaa_audience +from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -551,6 +555,76 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_access_binding: gapic_v1.method.wrap_method( + self.create_access_binding, + default_timeout=None, + client_info=client_info, + ), + self.get_access_binding: gapic_v1.method.wrap_method( + self.get_access_binding, + default_timeout=None, + client_info=client_info, + ), + self.update_access_binding: gapic_v1.method.wrap_method( + self.update_access_binding, + default_timeout=None, + client_info=client_info, + ), + self.delete_access_binding: gapic_v1.method.wrap_method( + self.delete_access_binding, + default_timeout=None, + client_info=client_info, + ), + self.list_access_bindings: gapic_v1.method.wrap_method( + self.list_access_bindings, + default_timeout=None, + client_info=client_info, + ), + self.batch_create_access_bindings: gapic_v1.method.wrap_method( + self.batch_create_access_bindings, + default_timeout=None, + client_info=client_info, + ), + self.batch_get_access_bindings: gapic_v1.method.wrap_method( + self.batch_get_access_bindings, + default_timeout=None, + client_info=client_info, + ), + self.batch_update_access_bindings: gapic_v1.method.wrap_method( + self.batch_update_access_bindings, + default_timeout=None, + client_info=client_info, + ), + self.batch_delete_access_bindings: gapic_v1.method.wrap_method( + self.batch_delete_access_bindings, + default_timeout=None, + client_info=client_info, + ), + self.get_expanded_data_set: gapic_v1.method.wrap_method( + self.get_expanded_data_set, + default_timeout=None, + client_info=client_info, + ), + self.list_expanded_data_sets: gapic_v1.method.wrap_method( + self.list_expanded_data_sets, + default_timeout=None, + client_info=client_info, + ), + self.create_expanded_data_set: gapic_v1.method.wrap_method( + self.create_expanded_data_set, + default_timeout=None, + client_info=client_info, + ), + self.update_expanded_data_set: gapic_v1.method.wrap_method( + self.update_expanded_data_set, + default_timeout=None, + client_info=client_info, + ), + self.delete_expanded_data_set: gapic_v1.method.wrap_method( + self.delete_expanded_data_set, + default_timeout=None, + client_info=client_info, + ), self.set_automated_ga4_configuration_opt_out: gapic_v1.method.wrap_method( self.set_automated_ga4_configuration_opt_out, default_timeout=None, @@ -1449,6 +1523,156 @@ def run_access_report( ]: raise NotImplementedError() + @property + def create_access_binding( + self, + ) -> Callable[ + [analytics_admin.CreateAccessBindingRequest], + Union[resources.AccessBinding, Awaitable[resources.AccessBinding]], + ]: + raise NotImplementedError() + + @property + def get_access_binding( + self, + ) -> Callable[ + [analytics_admin.GetAccessBindingRequest], + Union[resources.AccessBinding, Awaitable[resources.AccessBinding]], + ]: + raise NotImplementedError() + + @property + def update_access_binding( + self, + ) -> Callable[ + [analytics_admin.UpdateAccessBindingRequest], + Union[resources.AccessBinding, Awaitable[resources.AccessBinding]], + ]: + raise NotImplementedError() + + @property + def delete_access_binding( + self, + ) -> Callable[ + [analytics_admin.DeleteAccessBindingRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def list_access_bindings( + self, + ) -> Callable[ + [analytics_admin.ListAccessBindingsRequest], + Union[ + analytics_admin.ListAccessBindingsResponse, + Awaitable[analytics_admin.ListAccessBindingsResponse], + ], + ]: + raise NotImplementedError() + + @property + def batch_create_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchCreateAccessBindingsRequest], + Union[ + analytics_admin.BatchCreateAccessBindingsResponse, + Awaitable[analytics_admin.BatchCreateAccessBindingsResponse], + ], + ]: + raise NotImplementedError() + + @property + def batch_get_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchGetAccessBindingsRequest], + Union[ + analytics_admin.BatchGetAccessBindingsResponse, + Awaitable[analytics_admin.BatchGetAccessBindingsResponse], + ], + ]: + raise NotImplementedError() + + @property + def batch_update_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchUpdateAccessBindingsRequest], + Union[ + analytics_admin.BatchUpdateAccessBindingsResponse, + Awaitable[analytics_admin.BatchUpdateAccessBindingsResponse], + ], + ]: + raise NotImplementedError() + + @property + def batch_delete_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchDeleteAccessBindingsRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def get_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.GetExpandedDataSetRequest], + Union[ + expanded_data_set.ExpandedDataSet, + Awaitable[expanded_data_set.ExpandedDataSet], + ], + ]: + raise NotImplementedError() + + @property + def list_expanded_data_sets( + self, + ) -> Callable[ + [analytics_admin.ListExpandedDataSetsRequest], + Union[ + analytics_admin.ListExpandedDataSetsResponse, + Awaitable[analytics_admin.ListExpandedDataSetsResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.CreateExpandedDataSetRequest], + Union[ + gaa_expanded_data_set.ExpandedDataSet, + Awaitable[gaa_expanded_data_set.ExpandedDataSet], + ], + ]: + raise NotImplementedError() + + @property + def update_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.UpdateExpandedDataSetRequest], + Union[ + gaa_expanded_data_set.ExpandedDataSet, + Awaitable[gaa_expanded_data_set.ExpandedDataSet], + ], + ]: + raise NotImplementedError() + + @property + def delete_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.DeleteExpandedDataSetRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + @property def set_automated_ga4_configuration_opt_out( self, diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py index 841a694a..c6d93dd6 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py @@ -23,9 +23,13 @@ from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore +from google.analytics.admin_v1alpha.types import ( + expanded_data_set as gaa_expanded_data_set, +) from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import audience from google.analytics.admin_v1alpha.types import audience as gaa_audience +from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources from .base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport @@ -1278,7 +1282,7 @@ def acknowledge_user_data_collection( Acknowledges the terms of user data collection for the specified property. This acknowledgement must be completed (either in the - Google Analytics UI or via this API) before + Google Analytics UI or through this API) before MeasurementProtocolSecret resources may be created. Returns: @@ -2717,6 +2721,405 @@ def run_access_report( ) return self._stubs["run_access_report"] + @property + def create_access_binding( + self, + ) -> Callable[ + [analytics_admin.CreateAccessBindingRequest], resources.AccessBinding + ]: + r"""Return a callable for the create access binding method over gRPC. + + Creates an access binding on an account or property. + + Returns: + Callable[[~.CreateAccessBindingRequest], + ~.AccessBinding]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_access_binding" not in self._stubs: + self._stubs["create_access_binding"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAccessBinding", + request_serializer=analytics_admin.CreateAccessBindingRequest.serialize, + response_deserializer=resources.AccessBinding.deserialize, + ) + return self._stubs["create_access_binding"] + + @property + def get_access_binding( + self, + ) -> Callable[[analytics_admin.GetAccessBindingRequest], resources.AccessBinding]: + r"""Return a callable for the get access binding method over gRPC. + + Gets information about an access binding. + + Returns: + Callable[[~.GetAccessBindingRequest], + ~.AccessBinding]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_access_binding" not in self._stubs: + self._stubs["get_access_binding"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccessBinding", + request_serializer=analytics_admin.GetAccessBindingRequest.serialize, + response_deserializer=resources.AccessBinding.deserialize, + ) + return self._stubs["get_access_binding"] + + @property + def update_access_binding( + self, + ) -> Callable[ + [analytics_admin.UpdateAccessBindingRequest], resources.AccessBinding + ]: + r"""Return a callable for the update access binding method over gRPC. + + Updates an access binding on an account or property. + + Returns: + Callable[[~.UpdateAccessBindingRequest], + ~.AccessBinding]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_access_binding" not in self._stubs: + self._stubs["update_access_binding"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccessBinding", + request_serializer=analytics_admin.UpdateAccessBindingRequest.serialize, + response_deserializer=resources.AccessBinding.deserialize, + ) + return self._stubs["update_access_binding"] + + @property + def delete_access_binding( + self, + ) -> Callable[[analytics_admin.DeleteAccessBindingRequest], empty_pb2.Empty]: + r"""Return a callable for the delete access binding method over gRPC. + + Deletes an access binding on an account or property. + + Returns: + Callable[[~.DeleteAccessBindingRequest], + ~.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_access_binding" not in self._stubs: + self._stubs["delete_access_binding"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccessBinding", + request_serializer=analytics_admin.DeleteAccessBindingRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_access_binding"] + + @property + def list_access_bindings( + self, + ) -> Callable[ + [analytics_admin.ListAccessBindingsRequest], + analytics_admin.ListAccessBindingsResponse, + ]: + r"""Return a callable for the list access bindings method over gRPC. + + Lists all access bindings on an account or property. + + Returns: + Callable[[~.ListAccessBindingsRequest], + ~.ListAccessBindingsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_access_bindings" not in self._stubs: + self._stubs["list_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccessBindings", + request_serializer=analytics_admin.ListAccessBindingsRequest.serialize, + response_deserializer=analytics_admin.ListAccessBindingsResponse.deserialize, + ) + return self._stubs["list_access_bindings"] + + @property + def batch_create_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchCreateAccessBindingsRequest], + analytics_admin.BatchCreateAccessBindingsResponse, + ]: + r"""Return a callable for the batch create access bindings method over gRPC. + + Creates information about multiple access bindings to + an account or property. + + This method is transactional. If any AccessBinding + cannot be created, none of the AccessBindings will be + created. + + Returns: + Callable[[~.BatchCreateAccessBindingsRequest], + ~.BatchCreateAccessBindingsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_create_access_bindings" not in self._stubs: + self._stubs["batch_create_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchCreateAccessBindings", + request_serializer=analytics_admin.BatchCreateAccessBindingsRequest.serialize, + response_deserializer=analytics_admin.BatchCreateAccessBindingsResponse.deserialize, + ) + return self._stubs["batch_create_access_bindings"] + + @property + def batch_get_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchGetAccessBindingsRequest], + analytics_admin.BatchGetAccessBindingsResponse, + ]: + r"""Return a callable for the batch get access bindings method over gRPC. + + Gets information about multiple access bindings to an + account or property. + + Returns: + Callable[[~.BatchGetAccessBindingsRequest], + ~.BatchGetAccessBindingsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_get_access_bindings" not in self._stubs: + self._stubs["batch_get_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchGetAccessBindings", + request_serializer=analytics_admin.BatchGetAccessBindingsRequest.serialize, + response_deserializer=analytics_admin.BatchGetAccessBindingsResponse.deserialize, + ) + return self._stubs["batch_get_access_bindings"] + + @property + def batch_update_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchUpdateAccessBindingsRequest], + analytics_admin.BatchUpdateAccessBindingsResponse, + ]: + r"""Return a callable for the batch update access bindings method over gRPC. + + Updates information about multiple access bindings to + an account or property. + + Returns: + Callable[[~.BatchUpdateAccessBindingsRequest], + ~.BatchUpdateAccessBindingsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_update_access_bindings" not in self._stubs: + self._stubs["batch_update_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchUpdateAccessBindings", + request_serializer=analytics_admin.BatchUpdateAccessBindingsRequest.serialize, + response_deserializer=analytics_admin.BatchUpdateAccessBindingsResponse.deserialize, + ) + return self._stubs["batch_update_access_bindings"] + + @property + def batch_delete_access_bindings( + self, + ) -> Callable[[analytics_admin.BatchDeleteAccessBindingsRequest], empty_pb2.Empty]: + r"""Return a callable for the batch delete access bindings method over gRPC. + + Deletes information about multiple users' links to an + account or property. + + Returns: + Callable[[~.BatchDeleteAccessBindingsRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_delete_access_bindings" not in self._stubs: + self._stubs["batch_delete_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteAccessBindings", + request_serializer=analytics_admin.BatchDeleteAccessBindingsRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["batch_delete_access_bindings"] + + @property + def get_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.GetExpandedDataSetRequest], expanded_data_set.ExpandedDataSet + ]: + r"""Return a callable for the get expanded data set method over gRPC. + + Lookup for a single ExpandedDataSet. + + Returns: + Callable[[~.GetExpandedDataSetRequest], + ~.ExpandedDataSet]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_expanded_data_set" not in self._stubs: + self._stubs["get_expanded_data_set"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetExpandedDataSet", + request_serializer=analytics_admin.GetExpandedDataSetRequest.serialize, + response_deserializer=expanded_data_set.ExpandedDataSet.deserialize, + ) + return self._stubs["get_expanded_data_set"] + + @property + def list_expanded_data_sets( + self, + ) -> Callable[ + [analytics_admin.ListExpandedDataSetsRequest], + analytics_admin.ListExpandedDataSetsResponse, + ]: + r"""Return a callable for the list expanded data sets method over gRPC. + + Lists ExpandedDataSets on a property. + + Returns: + Callable[[~.ListExpandedDataSetsRequest], + ~.ListExpandedDataSetsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_expanded_data_sets" not in self._stubs: + self._stubs["list_expanded_data_sets"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListExpandedDataSets", + request_serializer=analytics_admin.ListExpandedDataSetsRequest.serialize, + response_deserializer=analytics_admin.ListExpandedDataSetsResponse.deserialize, + ) + return self._stubs["list_expanded_data_sets"] + + @property + def create_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.CreateExpandedDataSetRequest], + gaa_expanded_data_set.ExpandedDataSet, + ]: + r"""Return a callable for the create expanded data set method over gRPC. + + Creates a ExpandedDataSet. + + Returns: + Callable[[~.CreateExpandedDataSetRequest], + ~.ExpandedDataSet]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_expanded_data_set" not in self._stubs: + self._stubs["create_expanded_data_set"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateExpandedDataSet", + request_serializer=analytics_admin.CreateExpandedDataSetRequest.serialize, + response_deserializer=gaa_expanded_data_set.ExpandedDataSet.deserialize, + ) + return self._stubs["create_expanded_data_set"] + + @property + def update_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.UpdateExpandedDataSetRequest], + gaa_expanded_data_set.ExpandedDataSet, + ]: + r"""Return a callable for the update expanded data set method over gRPC. + + Updates a ExpandedDataSet on a property. + + Returns: + Callable[[~.UpdateExpandedDataSetRequest], + ~.ExpandedDataSet]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_expanded_data_set" not in self._stubs: + self._stubs["update_expanded_data_set"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateExpandedDataSet", + request_serializer=analytics_admin.UpdateExpandedDataSetRequest.serialize, + response_deserializer=gaa_expanded_data_set.ExpandedDataSet.deserialize, + ) + return self._stubs["update_expanded_data_set"] + + @property + def delete_expanded_data_set( + self, + ) -> Callable[[analytics_admin.DeleteExpandedDataSetRequest], empty_pb2.Empty]: + r"""Return a callable for the delete expanded data set method over gRPC. + + Deletes a ExpandedDataSet on a property. + + Returns: + Callable[[~.DeleteExpandedDataSetRequest], + ~.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_expanded_data_set" not in self._stubs: + self._stubs["delete_expanded_data_set"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteExpandedDataSet", + request_serializer=analytics_admin.DeleteExpandedDataSetRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_expanded_data_set"] + @property def set_automated_ga4_configuration_opt_out( self, diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py index 279b4699..2600f360 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py @@ -23,9 +23,13 @@ import grpc # type: ignore from grpc.experimental import aio # type: ignore +from google.analytics.admin_v1alpha.types import ( + expanded_data_set as gaa_expanded_data_set, +) from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import audience from google.analytics.admin_v1alpha.types import audience as gaa_audience +from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources from .base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport @@ -1307,7 +1311,7 @@ def acknowledge_user_data_collection( Acknowledges the terms of user data collection for the specified property. This acknowledgement must be completed (either in the - Google Analytics UI or via this API) before + Google Analytics UI or through this API) before MeasurementProtocolSecret resources may be created. Returns: @@ -2783,6 +2787,414 @@ def run_access_report( ) return self._stubs["run_access_report"] + @property + def create_access_binding( + self, + ) -> Callable[ + [analytics_admin.CreateAccessBindingRequest], Awaitable[resources.AccessBinding] + ]: + r"""Return a callable for the create access binding method over gRPC. + + Creates an access binding on an account or property. + + Returns: + Callable[[~.CreateAccessBindingRequest], + Awaitable[~.AccessBinding]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_access_binding" not in self._stubs: + self._stubs["create_access_binding"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAccessBinding", + request_serializer=analytics_admin.CreateAccessBindingRequest.serialize, + response_deserializer=resources.AccessBinding.deserialize, + ) + return self._stubs["create_access_binding"] + + @property + def get_access_binding( + self, + ) -> Callable[ + [analytics_admin.GetAccessBindingRequest], Awaitable[resources.AccessBinding] + ]: + r"""Return a callable for the get access binding method over gRPC. + + Gets information about an access binding. + + Returns: + Callable[[~.GetAccessBindingRequest], + Awaitable[~.AccessBinding]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_access_binding" not in self._stubs: + self._stubs["get_access_binding"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccessBinding", + request_serializer=analytics_admin.GetAccessBindingRequest.serialize, + response_deserializer=resources.AccessBinding.deserialize, + ) + return self._stubs["get_access_binding"] + + @property + def update_access_binding( + self, + ) -> Callable[ + [analytics_admin.UpdateAccessBindingRequest], Awaitable[resources.AccessBinding] + ]: + r"""Return a callable for the update access binding method over gRPC. + + Updates an access binding on an account or property. + + Returns: + Callable[[~.UpdateAccessBindingRequest], + Awaitable[~.AccessBinding]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_access_binding" not in self._stubs: + self._stubs["update_access_binding"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccessBinding", + request_serializer=analytics_admin.UpdateAccessBindingRequest.serialize, + response_deserializer=resources.AccessBinding.deserialize, + ) + return self._stubs["update_access_binding"] + + @property + def delete_access_binding( + self, + ) -> Callable[ + [analytics_admin.DeleteAccessBindingRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete access binding method over gRPC. + + Deletes an access binding on an account or property. + + Returns: + Callable[[~.DeleteAccessBindingRequest], + 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_access_binding" not in self._stubs: + self._stubs["delete_access_binding"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccessBinding", + request_serializer=analytics_admin.DeleteAccessBindingRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_access_binding"] + + @property + def list_access_bindings( + self, + ) -> Callable[ + [analytics_admin.ListAccessBindingsRequest], + Awaitable[analytics_admin.ListAccessBindingsResponse], + ]: + r"""Return a callable for the list access bindings method over gRPC. + + Lists all access bindings on an account or property. + + Returns: + Callable[[~.ListAccessBindingsRequest], + Awaitable[~.ListAccessBindingsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_access_bindings" not in self._stubs: + self._stubs["list_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccessBindings", + request_serializer=analytics_admin.ListAccessBindingsRequest.serialize, + response_deserializer=analytics_admin.ListAccessBindingsResponse.deserialize, + ) + return self._stubs["list_access_bindings"] + + @property + def batch_create_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchCreateAccessBindingsRequest], + Awaitable[analytics_admin.BatchCreateAccessBindingsResponse], + ]: + r"""Return a callable for the batch create access bindings method over gRPC. + + Creates information about multiple access bindings to + an account or property. + + This method is transactional. If any AccessBinding + cannot be created, none of the AccessBindings will be + created. + + Returns: + Callable[[~.BatchCreateAccessBindingsRequest], + Awaitable[~.BatchCreateAccessBindingsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_create_access_bindings" not in self._stubs: + self._stubs["batch_create_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchCreateAccessBindings", + request_serializer=analytics_admin.BatchCreateAccessBindingsRequest.serialize, + response_deserializer=analytics_admin.BatchCreateAccessBindingsResponse.deserialize, + ) + return self._stubs["batch_create_access_bindings"] + + @property + def batch_get_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchGetAccessBindingsRequest], + Awaitable[analytics_admin.BatchGetAccessBindingsResponse], + ]: + r"""Return a callable for the batch get access bindings method over gRPC. + + Gets information about multiple access bindings to an + account or property. + + Returns: + Callable[[~.BatchGetAccessBindingsRequest], + Awaitable[~.BatchGetAccessBindingsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_get_access_bindings" not in self._stubs: + self._stubs["batch_get_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchGetAccessBindings", + request_serializer=analytics_admin.BatchGetAccessBindingsRequest.serialize, + response_deserializer=analytics_admin.BatchGetAccessBindingsResponse.deserialize, + ) + return self._stubs["batch_get_access_bindings"] + + @property + def batch_update_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchUpdateAccessBindingsRequest], + Awaitable[analytics_admin.BatchUpdateAccessBindingsResponse], + ]: + r"""Return a callable for the batch update access bindings method over gRPC. + + Updates information about multiple access bindings to + an account or property. + + Returns: + Callable[[~.BatchUpdateAccessBindingsRequest], + Awaitable[~.BatchUpdateAccessBindingsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_update_access_bindings" not in self._stubs: + self._stubs["batch_update_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchUpdateAccessBindings", + request_serializer=analytics_admin.BatchUpdateAccessBindingsRequest.serialize, + response_deserializer=analytics_admin.BatchUpdateAccessBindingsResponse.deserialize, + ) + return self._stubs["batch_update_access_bindings"] + + @property + def batch_delete_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchDeleteAccessBindingsRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the batch delete access bindings method over gRPC. + + Deletes information about multiple users' links to an + account or property. + + Returns: + Callable[[~.BatchDeleteAccessBindingsRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_delete_access_bindings" not in self._stubs: + self._stubs["batch_delete_access_bindings"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteAccessBindings", + request_serializer=analytics_admin.BatchDeleteAccessBindingsRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["batch_delete_access_bindings"] + + @property + def get_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.GetExpandedDataSetRequest], + Awaitable[expanded_data_set.ExpandedDataSet], + ]: + r"""Return a callable for the get expanded data set method over gRPC. + + Lookup for a single ExpandedDataSet. + + Returns: + Callable[[~.GetExpandedDataSetRequest], + Awaitable[~.ExpandedDataSet]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_expanded_data_set" not in self._stubs: + self._stubs["get_expanded_data_set"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetExpandedDataSet", + request_serializer=analytics_admin.GetExpandedDataSetRequest.serialize, + response_deserializer=expanded_data_set.ExpandedDataSet.deserialize, + ) + return self._stubs["get_expanded_data_set"] + + @property + def list_expanded_data_sets( + self, + ) -> Callable[ + [analytics_admin.ListExpandedDataSetsRequest], + Awaitable[analytics_admin.ListExpandedDataSetsResponse], + ]: + r"""Return a callable for the list expanded data sets method over gRPC. + + Lists ExpandedDataSets on a property. + + Returns: + Callable[[~.ListExpandedDataSetsRequest], + Awaitable[~.ListExpandedDataSetsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_expanded_data_sets" not in self._stubs: + self._stubs["list_expanded_data_sets"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListExpandedDataSets", + request_serializer=analytics_admin.ListExpandedDataSetsRequest.serialize, + response_deserializer=analytics_admin.ListExpandedDataSetsResponse.deserialize, + ) + return self._stubs["list_expanded_data_sets"] + + @property + def create_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.CreateExpandedDataSetRequest], + Awaitable[gaa_expanded_data_set.ExpandedDataSet], + ]: + r"""Return a callable for the create expanded data set method over gRPC. + + Creates a ExpandedDataSet. + + Returns: + Callable[[~.CreateExpandedDataSetRequest], + Awaitable[~.ExpandedDataSet]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_expanded_data_set" not in self._stubs: + self._stubs["create_expanded_data_set"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateExpandedDataSet", + request_serializer=analytics_admin.CreateExpandedDataSetRequest.serialize, + response_deserializer=gaa_expanded_data_set.ExpandedDataSet.deserialize, + ) + return self._stubs["create_expanded_data_set"] + + @property + def update_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.UpdateExpandedDataSetRequest], + Awaitable[gaa_expanded_data_set.ExpandedDataSet], + ]: + r"""Return a callable for the update expanded data set method over gRPC. + + Updates a ExpandedDataSet on a property. + + Returns: + Callable[[~.UpdateExpandedDataSetRequest], + Awaitable[~.ExpandedDataSet]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_expanded_data_set" not in self._stubs: + self._stubs["update_expanded_data_set"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateExpandedDataSet", + request_serializer=analytics_admin.UpdateExpandedDataSetRequest.serialize, + response_deserializer=gaa_expanded_data_set.ExpandedDataSet.deserialize, + ) + return self._stubs["update_expanded_data_set"] + + @property + def delete_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.DeleteExpandedDataSetRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete expanded data set method over gRPC. + + Deletes a ExpandedDataSet on a property. + + Returns: + Callable[[~.DeleteExpandedDataSetRequest], + 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_expanded_data_set" not in self._stubs: + self._stubs["delete_expanded_data_set"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteExpandedDataSet", + request_serializer=analytics_admin.DeleteExpandedDataSetRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_expanded_data_set"] + @property def set_automated_ga4_configuration_opt_out( self, diff --git a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest.py b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest.py index 82a7a8cc..8ffeb7e7 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest.py @@ -38,9 +38,13 @@ from google.protobuf import empty_pb2 # type: ignore +from google.analytics.admin_v1alpha.types import ( + expanded_data_set as gaa_expanded_data_set, +) from google.analytics.admin_v1alpha.types import analytics_admin from google.analytics.admin_v1alpha.types import audience from google.analytics.admin_v1alpha.types import audience as gaa_audience +from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources from .base import AnalyticsAdminServiceTransport @@ -104,6 +108,14 @@ def post_audit_user_links(self, response): logging.log(f"Received response: {response}") return response + def pre_batch_create_access_bindings(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_batch_create_access_bindings(self, response): + logging.log(f"Received response: {response}") + return response + def pre_batch_create_user_links(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -112,10 +124,22 @@ def post_batch_create_user_links(self, response): logging.log(f"Received response: {response}") return response + def pre_batch_delete_access_bindings(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + def pre_batch_delete_user_links(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata + def pre_batch_get_access_bindings(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_batch_get_access_bindings(self, response): + logging.log(f"Received response: {response}") + return response + def pre_batch_get_user_links(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -124,6 +148,14 @@ def post_batch_get_user_links(self, response): logging.log(f"Received response: {response}") return response + def pre_batch_update_access_bindings(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_batch_update_access_bindings(self, response): + logging.log(f"Received response: {response}") + return response + def pre_batch_update_user_links(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -140,6 +172,14 @@ def post_cancel_display_video360_advertiser_link_proposal(self, response): logging.log(f"Received response: {response}") return response + def pre_create_access_binding(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_access_binding(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_audience(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -196,6 +236,14 @@ def post_create_display_video360_advertiser_link_proposal(self, response): logging.log(f"Received response: {response}") return response + def pre_create_expanded_data_set(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_expanded_data_set(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_firebase_link(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -244,6 +292,10 @@ def post_create_user_link(self, response): logging.log(f"Received response: {response}") return response + def pre_delete_access_binding(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + def pre_delete_account(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -264,6 +316,10 @@ def pre_delete_display_video360_advertiser_link_proposal(self, request, metadata logging.log(f"Received request: {request}") return request, metadata + def pre_delete_expanded_data_set(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + def pre_delete_firebase_link(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -300,6 +356,14 @@ def post_fetch_automated_ga4_configuration_opt_out(self, response): logging.log(f"Received response: {response}") return response + def pre_get_access_binding(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_access_binding(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_account(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -396,6 +460,14 @@ def post_get_display_video360_advertiser_link_proposal(self, response): logging.log(f"Received response: {response}") return response + def pre_get_expanded_data_set(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_expanded_data_set(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_global_site_tag(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -444,6 +516,14 @@ def post_get_user_link(self, response): logging.log(f"Received response: {response}") return response + def pre_list_access_bindings(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_access_bindings(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_accounts(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -524,6 +604,14 @@ def post_list_display_video360_advertiser_links(self, response): logging.log(f"Received response: {response}") return response + def pre_list_expanded_data_sets(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_expanded_data_sets(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_firebase_links(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -604,6 +692,14 @@ def post_set_automated_ga4_configuration_opt_out(self, response): logging.log(f"Received response: {response}") return response + def pre_update_access_binding(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_access_binding(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_account(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -668,6 +764,14 @@ def post_update_display_video360_advertiser_link(self, response): logging.log(f"Received response: {response}") return response + def pre_update_expanded_data_set(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_expanded_data_set(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_google_ads_link(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -835,6 +939,31 @@ def post_audit_user_links( """ return response + def pre_batch_create_access_bindings( + self, + request: analytics_admin.BatchCreateAccessBindingsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + analytics_admin.BatchCreateAccessBindingsRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for batch_create_access_bindings + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_batch_create_access_bindings( + self, response: analytics_admin.BatchCreateAccessBindingsResponse + ) -> analytics_admin.BatchCreateAccessBindingsResponse: + """Post-rpc interceptor for batch_create_access_bindings + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_batch_create_user_links( self, request: analytics_admin.BatchCreateUserLinksRequest, @@ -858,6 +987,20 @@ def post_batch_create_user_links( """ return response + def pre_batch_delete_access_bindings( + self, + request: analytics_admin.BatchDeleteAccessBindingsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + analytics_admin.BatchDeleteAccessBindingsRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for batch_delete_access_bindings + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + def pre_batch_delete_user_links( self, request: analytics_admin.BatchDeleteUserLinksRequest, @@ -870,6 +1013,31 @@ def pre_batch_delete_user_links( """ return request, metadata + def pre_batch_get_access_bindings( + self, + request: analytics_admin.BatchGetAccessBindingsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + analytics_admin.BatchGetAccessBindingsRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for batch_get_access_bindings + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_batch_get_access_bindings( + self, response: analytics_admin.BatchGetAccessBindingsResponse + ) -> analytics_admin.BatchGetAccessBindingsResponse: + """Post-rpc interceptor for batch_get_access_bindings + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_batch_get_user_links( self, request: analytics_admin.BatchGetUserLinksRequest, @@ -893,6 +1061,31 @@ def post_batch_get_user_links( """ return response + def pre_batch_update_access_bindings( + self, + request: analytics_admin.BatchUpdateAccessBindingsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + analytics_admin.BatchUpdateAccessBindingsRequest, Sequence[Tuple[str, str]] + ]: + """Pre-rpc interceptor for batch_update_access_bindings + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_batch_update_access_bindings( + self, response: analytics_admin.BatchUpdateAccessBindingsResponse + ) -> analytics_admin.BatchUpdateAccessBindingsResponse: + """Post-rpc interceptor for batch_update_access_bindings + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_batch_update_user_links( self, request: analytics_admin.BatchUpdateUserLinksRequest, @@ -942,6 +1135,29 @@ def post_cancel_display_video360_advertiser_link_proposal( """ return response + def pre_create_access_binding( + self, + request: analytics_admin.CreateAccessBindingRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.CreateAccessBindingRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_access_binding + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_create_access_binding( + self, response: resources.AccessBinding + ) -> resources.AccessBinding: + """Post-rpc interceptor for create_access_binding + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_create_audience( self, request: analytics_admin.CreateAudienceRequest, @@ -1109,6 +1325,29 @@ def post_create_display_video360_advertiser_link_proposal( """ return response + def pre_create_expanded_data_set( + self, + request: analytics_admin.CreateExpandedDataSetRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.CreateExpandedDataSetRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_expanded_data_set + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_create_expanded_data_set( + self, response: gaa_expanded_data_set.ExpandedDataSet + ) -> gaa_expanded_data_set.ExpandedDataSet: + """Post-rpc interceptor for create_expanded_data_set + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_create_firebase_link( self, request: analytics_admin.CreateFirebaseLinkRequest, @@ -1248,6 +1487,18 @@ def post_create_user_link(self, response: resources.UserLink) -> resources.UserL """ return response + def pre_delete_access_binding( + self, + request: analytics_admin.DeleteAccessBindingRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.DeleteAccessBindingRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_access_binding + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + def pre_delete_account( self, request: analytics_admin.DeleteAccountRequest, @@ -1314,6 +1565,18 @@ def pre_delete_display_video360_advertiser_link_proposal( """ return request, metadata + def pre_delete_expanded_data_set( + self, + request: analytics_admin.DeleteExpandedDataSetRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.DeleteExpandedDataSetRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_expanded_data_set + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + def pre_delete_firebase_link( self, request: analytics_admin.DeleteFirebaseLinkRequest, @@ -1426,6 +1689,29 @@ def post_fetch_automated_ga4_configuration_opt_out( """ return response + def pre_get_access_binding( + self, + request: analytics_admin.GetAccessBindingRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.GetAccessBindingRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_access_binding + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_get_access_binding( + self, response: resources.AccessBinding + ) -> resources.AccessBinding: + """Post-rpc interceptor for get_access_binding + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_get_account( self, request: analytics_admin.GetAccountRequest, @@ -1710,6 +1996,29 @@ def post_get_display_video360_advertiser_link_proposal( """ return response + def pre_get_expanded_data_set( + self, + request: analytics_admin.GetExpandedDataSetRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.GetExpandedDataSetRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_expanded_data_set + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_get_expanded_data_set( + self, response: expanded_data_set.ExpandedDataSet + ) -> expanded_data_set.ExpandedDataSet: + """Post-rpc interceptor for get_expanded_data_set + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_get_global_site_tag( self, request: analytics_admin.GetGlobalSiteTagRequest, @@ -1848,6 +2157,29 @@ def post_get_user_link(self, response: resources.UserLink) -> resources.UserLink """ return response + def pre_list_access_bindings( + self, + request: analytics_admin.ListAccessBindingsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.ListAccessBindingsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_access_bindings + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_list_access_bindings( + self, response: analytics_admin.ListAccessBindingsResponse + ) -> analytics_admin.ListAccessBindingsResponse: + """Post-rpc interceptor for list_access_bindings + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_list_accounts( self, request: analytics_admin.ListAccountsRequest, @@ -2085,6 +2417,29 @@ def post_list_display_video360_advertiser_links( """ return response + def pre_list_expanded_data_sets( + self, + request: analytics_admin.ListExpandedDataSetsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.ListExpandedDataSetsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_expanded_data_sets + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_list_expanded_data_sets( + self, response: analytics_admin.ListExpandedDataSetsResponse + ) -> analytics_admin.ListExpandedDataSetsResponse: + """Post-rpc interceptor for list_expanded_data_sets + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_list_firebase_links( self, request: analytics_admin.ListFirebaseLinksRequest, @@ -2324,20 +2679,22 @@ def post_set_automated_ga4_configuration_opt_out( """ return response - def pre_update_account( + def pre_update_access_binding( self, - request: analytics_admin.UpdateAccountRequest, + request: analytics_admin.UpdateAccessBindingRequest, metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateAccountRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_account + ) -> Tuple[analytics_admin.UpdateAccessBindingRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_access_binding Override in a subclass to manipulate the request or metadata before they are sent to the AnalyticsAdminService server. """ return request, metadata - def post_update_account(self, response: resources.Account) -> resources.Account: - """Post-rpc interceptor for update_account + def post_update_access_binding( + self, response: resources.AccessBinding + ) -> resources.AccessBinding: + """Post-rpc interceptor for update_access_binding Override in a subclass to manipulate the response after it is returned by the AnalyticsAdminService server but before @@ -2345,13 +2702,34 @@ def post_update_account(self, response: resources.Account) -> resources.Account: """ return response - def pre_update_attribution_settings( + def pre_update_account( self, - request: analytics_admin.UpdateAttributionSettingsRequest, + request: analytics_admin.UpdateAccountRequest, metadata: Sequence[Tuple[str, str]], - ) -> Tuple[ - analytics_admin.UpdateAttributionSettingsRequest, Sequence[Tuple[str, str]] - ]: + ) -> Tuple[analytics_admin.UpdateAccountRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_account + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_update_account(self, response: resources.Account) -> resources.Account: + """Post-rpc interceptor for update_account + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + + def pre_update_attribution_settings( + self, + request: analytics_admin.UpdateAttributionSettingsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + analytics_admin.UpdateAttributionSettingsRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for update_attribution_settings Override in a subclass to manipulate the request or metadata @@ -2513,6 +2891,29 @@ def post_update_display_video360_advertiser_link( """ return response + def pre_update_expanded_data_set( + self, + request: analytics_admin.UpdateExpandedDataSetRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.UpdateExpandedDataSetRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_expanded_data_set + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_update_expanded_data_set( + self, response: gaa_expanded_data_set.ExpandedDataSet + ) -> gaa_expanded_data_set.ExpandedDataSet: + """Post-rpc interceptor for update_expanded_data_set + + Override in a subclass to manipulate the response + after it is returned by the AnalyticsAdminService server but before + it is returned to user code. + """ + return response + def pre_update_google_ads_link( self, request: analytics_admin.UpdateGoogleAdsLinkRequest, @@ -3341,6 +3742,113 @@ def __call__( resp = self._interceptor.post_audit_user_links(resp) return resp + class _BatchCreateAccessBindings(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("BatchCreateAccessBindings") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.BatchCreateAccessBindingsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchCreateAccessBindingsResponse: + r"""Call the batch create access + bindings method over HTTP. + + Args: + request (~.analytics_admin.BatchCreateAccessBindingsRequest): + The request object. Request message for + BatchCreateAccessBindings 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: + ~.analytics_admin.BatchCreateAccessBindingsResponse: + Response message for + BatchCreateAccessBindings RPC. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha/{parent=accounts/*}/accessBindings:batchCreate", + "body": "*", + }, + { + "method": "post", + "uri": "/v1alpha/{parent=properties/*}/accessBindings:batchCreate", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_batch_create_access_bindings( + request, metadata + ) + pb_request = analytics_admin.BatchCreateAccessBindingsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = analytics_admin.BatchCreateAccessBindingsResponse() + pb_resp = analytics_admin.BatchCreateAccessBindingsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_access_bindings(resp) + return resp + class _BatchCreateUserLinks(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("BatchCreateUserLinks") @@ -3447,6 +3955,99 @@ def __call__( resp = self._interceptor.post_batch_create_user_links(resp) return resp + class _BatchDeleteAccessBindings(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("BatchDeleteAccessBindings") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.BatchDeleteAccessBindingsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the batch delete access + bindings method over HTTP. + + Args: + request (~.analytics_admin.BatchDeleteAccessBindingsRequest): + The request object. Request message for + BatchDeleteAccessBindings 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. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha/{parent=accounts/*}/accessBindings:batchDelete", + "body": "*", + }, + { + "method": "post", + "uri": "/v1alpha/{parent=properties/*}/accessBindings:batchDelete", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_batch_delete_access_bindings( + request, metadata + ) + pb_request = analytics_admin.BatchDeleteAccessBindingsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + class _BatchDeleteUserLinks(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("BatchDeleteUserLinks") @@ -3539,6 +4140,104 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) + class _BatchGetAccessBindings(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("BatchGetAccessBindings") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "names": "", + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.BatchGetAccessBindingsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchGetAccessBindingsResponse: + r"""Call the batch get access bindings method over HTTP. + + Args: + request (~.analytics_admin.BatchGetAccessBindingsRequest): + The request object. Request message for + BatchGetAccessBindings 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: + ~.analytics_admin.BatchGetAccessBindingsResponse: + Response message for + BatchGetAccessBindings RPC. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/{parent=accounts/*}/accessBindings:batchGet", + }, + { + "method": "get", + "uri": "/v1alpha/{parent=properties/*}/accessBindings:batchGet", + }, + ] + request, metadata = self._interceptor.pre_batch_get_access_bindings( + request, metadata + ) + pb_request = analytics_admin.BatchGetAccessBindingsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = analytics_admin.BatchGetAccessBindingsResponse() + pb_resp = analytics_admin.BatchGetAccessBindingsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_get_access_bindings(resp) + return resp + class _BatchGetUserLinks(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("BatchGetUserLinks") @@ -3637,6 +4336,113 @@ def __call__( resp = self._interceptor.post_batch_get_user_links(resp) return resp + class _BatchUpdateAccessBindings(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("BatchUpdateAccessBindings") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.BatchUpdateAccessBindingsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.BatchUpdateAccessBindingsResponse: + r"""Call the batch update access + bindings method over HTTP. + + Args: + request (~.analytics_admin.BatchUpdateAccessBindingsRequest): + The request object. Request message for + BatchUpdateAccessBindings 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: + ~.analytics_admin.BatchUpdateAccessBindingsResponse: + Response message for + BatchUpdateAccessBindings RPC. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha/{parent=accounts/*}/accessBindings:batchUpdate", + "body": "*", + }, + { + "method": "post", + "uri": "/v1alpha/{parent=properties/*}/accessBindings:batchUpdate", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_batch_update_access_bindings( + request, metadata + ) + pb_request = analytics_admin.BatchUpdateAccessBindingsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = analytics_admin.BatchUpdateAccessBindingsResponse() + pb_resp = analytics_admin.BatchUpdateAccessBindingsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_access_bindings(resp) + return resp + class _BatchUpdateUserLinks(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("BatchUpdateUserLinks") @@ -3687,14 +4493,131 @@ def __call__( }, { "method": "post", - "uri": "/v1alpha/{parent=properties/*}/userLinks:batchUpdate", + "uri": "/v1alpha/{parent=properties/*}/userLinks:batchUpdate", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_batch_update_user_links( + request, metadata + ) + pb_request = analytics_admin.BatchUpdateUserLinksRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = analytics_admin.BatchUpdateUserLinksResponse() + pb_resp = analytics_admin.BatchUpdateUserLinksResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_user_links(resp) + return resp + + class _CancelDisplayVideo360AdvertiserLinkProposal(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("CancelDisplayVideo360AdvertiserLinkProposal") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.DisplayVideo360AdvertiserLinkProposal: + r"""Call the cancel display video360 + advertiser link proposal method over HTTP. + + Args: + request (~.analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest): + The request object. Request message for + CancelDisplayVideo360AdvertiserLinkProposal + 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: + ~.resources.DisplayVideo360AdvertiserLinkProposal: + A proposal for a link between a GA4 + property and a Display & Video 360 + advertiser. + A proposal is converted to a + DisplayVideo360AdvertiserLink once + approved. Google Analytics admins + approve inbound proposals while Display + & Video 360 admins approve outbound + proposals. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}:cancel", "body": "*", }, ] - request, metadata = self._interceptor.pre_batch_update_user_links( + ( + request, + metadata, + ) = self._interceptor.pre_cancel_display_video360_advertiser_link_proposal( request, metadata ) - pb_request = analytics_admin.BatchUpdateUserLinksRequest.pb(request) + pb_request = ( + analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest.pb( + request + ) + ) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body @@ -3736,16 +4659,20 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = analytics_admin.BatchUpdateUserLinksResponse() - pb_resp = analytics_admin.BatchUpdateUserLinksResponse.pb(resp) + resp = resources.DisplayVideo360AdvertiserLinkProposal() + pb_resp = resources.DisplayVideo360AdvertiserLinkProposal.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_batch_update_user_links(resp) + resp = ( + self._interceptor.post_cancel_display_video360_advertiser_link_proposal( + resp + ) + ) return resp - class _CancelDisplayVideo360AdvertiserLinkProposal(AnalyticsAdminServiceRestStub): + class _CreateAccessBinding(AnalyticsAdminServiceRestStub): def __hash__(self): - return hash("CancelDisplayVideo360AdvertiserLinkProposal") + return hash("CreateAccessBinding") __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @@ -3759,59 +4686,48 @@ def _get_unset_required_fields(cls, message_dict): def __call__( self, - request: analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, + request: analytics_admin.CreateAccessBindingRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.DisplayVideo360AdvertiserLinkProposal: - r"""Call the cancel display video360 - advertiser link proposal method over HTTP. + ) -> resources.AccessBinding: + r"""Call the create access binding method over HTTP. - Args: - request (~.analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest): - The request object. Request message for - CancelDisplayVideo360AdvertiserLinkProposal - RPC. + Args: + request (~.analytics_admin.CreateAccessBindingRequest): + The request object. Request message for + CreateAccessBinding 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. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. - Returns: - ~.resources.DisplayVideo360AdvertiserLinkProposal: - A proposal for a link between a GA4 - property and a Display & Video 360 - advertiser. - A proposal is converted to a - DisplayVideo360AdvertiserLink once - approved. Google Analytics admins - approve inbound proposals while Display - & Video 360 admins approve outbound - proposals. + Returns: + ~.resources.AccessBinding: + A binding of a user to a set of + roles. """ http_options: List[Dict[str, str]] = [ { "method": "post", - "uri": "/v1alpha/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}:cancel", - "body": "*", + "uri": "/v1alpha/{parent=accounts/*}/accessBindings", + "body": "access_binding", + }, + { + "method": "post", + "uri": "/v1alpha/{parent=properties/*}/accessBindings", + "body": "access_binding", }, ] - ( - request, - metadata, - ) = self._interceptor.pre_cancel_display_video360_advertiser_link_proposal( + request, metadata = self._interceptor.pre_create_access_binding( request, metadata ) - pb_request = ( - analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest.pb( - request - ) - ) + pb_request = analytics_admin.CreateAccessBindingRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body @@ -3853,15 +4769,11 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = resources.DisplayVideo360AdvertiserLinkProposal() - pb_resp = resources.DisplayVideo360AdvertiserLinkProposal.pb(resp) + resp = resources.AccessBinding() + pb_resp = resources.AccessBinding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = ( - self._interceptor.post_cancel_display_video360_advertiser_link_proposal( - resp - ) - ) + resp = self._interceptor.post_create_access_binding(resp) return resp class _CreateAudience(AnalyticsAdminServiceRestStub): @@ -4591,6 +5503,107 @@ def __call__( ) return resp + class _CreateExpandedDataSet(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("CreateExpandedDataSet") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.CreateExpandedDataSetRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gaa_expanded_data_set.ExpandedDataSet: + r"""Call the create expanded data set method over HTTP. + + Args: + request (~.analytics_admin.CreateExpandedDataSetRequest): + The request object. Request message for + CreateExpandedDataSet 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: + ~.gaa_expanded_data_set.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha/{parent=properties/*}/expandedDataSets", + "body": "expanded_data_set", + }, + ] + request, metadata = self._interceptor.pre_create_expanded_data_set( + request, metadata + ) + pb_request = analytics_admin.CreateExpandedDataSetRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = gaa_expanded_data_set.ExpandedDataSet() + pb_resp = gaa_expanded_data_set.ExpandedDataSet.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_expanded_data_set(resp) + return resp + class _CreateFirebaseLink(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("CreateFirebaseLink") @@ -5155,29 +6168,120 @@ def __call__( http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1alpha/{parent=accounts/*}/userLinks", - "body": "user_link", + "method": "post", + "uri": "/v1alpha/{parent=accounts/*}/userLinks", + "body": "user_link", + }, + { + "method": "post", + "uri": "/v1alpha/{parent=properties/*}/userLinks", + "body": "user_link", + }, + ] + request, metadata = self._interceptor.pre_create_user_link( + request, metadata + ) + pb_request = analytics_admin.CreateUserLinkRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.UserLink() + pb_resp = resources.UserLink.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_user_link(resp) + return resp + + class _DeleteAccessBinding(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("DeleteAccessBinding") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.DeleteAccessBindingRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete access binding method over HTTP. + + Args: + request (~.analytics_admin.DeleteAccessBindingRequest): + The request object. Request message for + DeleteAccessBinding 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. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1alpha/{name=accounts/*/accessBindings/*}", }, { - "method": "post", - "uri": "/v1alpha/{parent=properties/*}/userLinks", - "body": "user_link", + "method": "delete", + "uri": "/v1alpha/{name=properties/*/accessBindings/*}", }, ] - request, metadata = self._interceptor.pre_create_user_link( + request, metadata = self._interceptor.pre_delete_access_binding( request, metadata ) - pb_request = analytics_admin.CreateUserLinkRequest.pb(request) + pb_request = analytics_admin.DeleteAccessBindingRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], - including_default_value_fields=False, - use_integers_for_enums=True, - ) uri = transcoded_request["uri"] method = transcoded_request["method"] @@ -5201,7 +6305,6 @@ def __call__( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -5209,14 +6312,6 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - # Return the response - resp = resources.UserLink() - pb_resp = resources.UserLink.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_user_link(resp) - return resp - class _DeleteAccount(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("DeleteAccount") @@ -5620,6 +6715,84 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) + class _DeleteExpandedDataSet(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("DeleteExpandedDataSet") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.DeleteExpandedDataSetRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete expanded data set method over HTTP. + + Args: + request (~.analytics_admin.DeleteExpandedDataSetRequest): + The request object. Request message for + DeleteExpandedDataSet 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. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1alpha/{name=properties/*/expandedDataSets/*}", + }, + ] + request, metadata = self._interceptor.pre_delete_expanded_data_set( + request, metadata + ) + pb_request = analytics_admin.DeleteExpandedDataSetRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + class _DeleteFirebaseLink(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("DeleteFirebaseLink") @@ -6223,6 +7396,102 @@ def __call__( ) return resp + class _GetAccessBinding(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("GetAccessBinding") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.GetAccessBindingRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AccessBinding: + r"""Call the get access binding method over HTTP. + + Args: + request (~.analytics_admin.GetAccessBindingRequest): + The request object. Request message for GetAccessBinding + 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: + ~.resources.AccessBinding: + A binding of a user to a set of + roles. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/{name=accounts/*/accessBindings/*}", + }, + { + "method": "get", + "uri": "/v1alpha/{name=properties/*/accessBindings/*}", + }, + ] + request, metadata = self._interceptor.pre_get_access_binding( + request, metadata + ) + pb_request = analytics_admin.GetAccessBindingRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.AccessBinding() + pb_resp = resources.AccessBinding.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_access_binding(resp) + return resp + class _GetAccount(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("GetAccount") @@ -7340,6 +8609,98 @@ def __call__( ) return resp + class _GetExpandedDataSet(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("GetExpandedDataSet") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.GetExpandedDataSetRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> expanded_data_set.ExpandedDataSet: + r"""Call the get expanded data set method over HTTP. + + Args: + request (~.analytics_admin.GetExpandedDataSetRequest): + The request object. Request message for + GetExpandedDataSet 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: + ~.expanded_data_set.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/{name=properties/*/expandedDataSets/*}", + }, + ] + request, metadata = self._interceptor.pre_get_expanded_data_set( + request, metadata + ) + pb_request = analytics_admin.GetExpandedDataSetRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = expanded_data_set.ExpandedDataSet() + pb_resp = expanded_data_set.ExpandedDataSet.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_expanded_data_set(resp) + return resp + class _GetGlobalSiteTag(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("GetGlobalSiteTag") @@ -7893,6 +9254,102 @@ def __call__( resp = self._interceptor.post_get_user_link(resp) return resp + class _ListAccessBindings(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("ListAccessBindings") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.ListAccessBindingsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.ListAccessBindingsResponse: + r"""Call the list access bindings method over HTTP. + + Args: + request (~.analytics_admin.ListAccessBindingsRequest): + The request object. Request message for + ListAccessBindings 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: + ~.analytics_admin.ListAccessBindingsResponse: + Response message for + ListAccessBindings RPC. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/{parent=accounts/*}/accessBindings", + }, + { + "method": "get", + "uri": "/v1alpha/{parent=properties/*}/accessBindings", + }, + ] + request, metadata = self._interceptor.pre_list_access_bindings( + request, metadata + ) + pb_request = analytics_admin.ListAccessBindingsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = analytics_admin.ListAccessBindingsResponse() + pb_resp = analytics_admin.ListAccessBindingsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_access_bindings(resp) + return resp + class _ListAccounts(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("ListAccounts") @@ -8809,6 +10266,98 @@ def __call__( resp = self._interceptor.post_list_display_video360_advertiser_links(resp) return resp + class _ListExpandedDataSets(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("ListExpandedDataSets") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.ListExpandedDataSetsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.ListExpandedDataSetsResponse: + r"""Call the list expanded data sets method over HTTP. + + Args: + request (~.analytics_admin.ListExpandedDataSetsRequest): + The request object. Request message for + ListExpandedDataSets 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: + ~.analytics_admin.ListExpandedDataSetsResponse: + Response message for + ListExpandedDataSets RPC. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/{parent=properties/*}/expandedDataSets", + }, + ] + request, metadata = self._interceptor.pre_list_expanded_data_sets( + request, metadata + ) + pb_request = analytics_admin.ListExpandedDataSetsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = analytics_admin.ListExpandedDataSetsResponse() + pb_resp = analytics_admin.ListExpandedDataSetsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_expanded_data_sets(resp) + return resp + class _ListFirebaseLinks(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("ListFirebaseLinks") @@ -9583,23 +11132,132 @@ def __call__( sent along with the request as metadata. Returns: - ~.analytics_admin.SearchChangeHistoryEventsResponse: - Response message for SearchAccounts - RPC. + ~.analytics_admin.SearchChangeHistoryEventsResponse: + Response message for SearchAccounts + RPC. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha/{account=accounts/*}:searchChangeHistoryEvents", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_search_change_history_events( + request, metadata + ) + pb_request = analytics_admin.SearchChangeHistoryEventsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = analytics_admin.SearchChangeHistoryEventsResponse() + pb_resp = analytics_admin.SearchChangeHistoryEventsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_change_history_events(resp) + return resp + + class _SetAutomatedGa4ConfigurationOptOut(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("SetAutomatedGa4ConfigurationOptOut") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse: + r"""Call the set automated ga4 + configuration opt out method over HTTP. + + Args: + request (~.analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest): + The request object. Request for setting the opt out + status for the automated GA4 setup + process. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse: + Response message for setting the opt + out status for the automated GA4 setup + process. """ http_options: List[Dict[str, str]] = [ { "method": "post", - "uri": "/v1alpha/{account=accounts/*}:searchChangeHistoryEvents", + "uri": "/v1alpha/properties:setAutomatedGa4ConfigurationOptOut", "body": "*", }, ] - request, metadata = self._interceptor.pre_search_change_history_events( + ( + request, + metadata, + ) = self._interceptor.pre_set_automated_ga4_configuration_opt_out( request, metadata ) - pb_request = analytics_admin.SearchChangeHistoryEventsRequest.pb(request) + pb_request = analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body @@ -9641,16 +11299,18 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = analytics_admin.SearchChangeHistoryEventsResponse() - pb_resp = analytics_admin.SearchChangeHistoryEventsResponse.pb(resp) + resp = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() + pb_resp = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.pb( + resp + ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_search_change_history_events(resp) + resp = self._interceptor.post_set_automated_ga4_configuration_opt_out(resp) return resp - class _SetAutomatedGa4ConfigurationOptOut(AnalyticsAdminServiceRestStub): + class _UpdateAccessBinding(AnalyticsAdminServiceRestStub): def __hash__(self): - return hash("SetAutomatedGa4ConfigurationOptOut") + return hash("UpdateAccessBinding") __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @@ -9664,51 +11324,48 @@ def _get_unset_required_fields(cls, message_dict): def __call__( self, - request: analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, + request: analytics_admin.UpdateAccessBindingRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse: - r"""Call the set automated ga4 - configuration opt out method over HTTP. + ) -> resources.AccessBinding: + r"""Call the update access binding method over HTTP. - Args: - request (~.analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest): - The request object. Request for setting the opt out - status for the automated GA4 setup - process. + Args: + request (~.analytics_admin.UpdateAccessBindingRequest): + The request object. Request message for + UpdateAccessBinding 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. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. - Returns: - ~.analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse: - Response message for setting the opt - out status for the automated GA4 setup - process. + Returns: + ~.resources.AccessBinding: + A binding of a user to a set of + roles. """ http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1alpha/properties:setAutomatedGa4ConfigurationOptOut", - "body": "*", + "method": "patch", + "uri": "/v1alpha/{access_binding.name=accounts/*/accessBindings/*}", + "body": "access_binding", + }, + { + "method": "patch", + "uri": "/v1alpha/{access_binding.name=properties/*/accessBindings/*}", + "body": "access_binding", }, ] - ( - request, - metadata, - ) = self._interceptor.pre_set_automated_ga4_configuration_opt_out( + request, metadata = self._interceptor.pre_update_access_binding( request, metadata ) - pb_request = analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest.pb( - request - ) + pb_request = analytics_admin.UpdateAccessBindingRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body @@ -9750,13 +11407,11 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() - pb_resp = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.pb( - resp - ) + resp = resources.AccessBinding() + pb_resp = resources.AccessBinding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_set_automated_ga4_configuration_opt_out(resp) + resp = self._interceptor.post_update_access_binding(resp) return resp class _UpdateAccount(AnalyticsAdminServiceRestStub): @@ -10584,6 +12239,109 @@ def __call__( resp = self._interceptor.post_update_display_video360_advertiser_link(resp) return resp + class _UpdateExpandedDataSet(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("UpdateExpandedDataSet") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask": {}, + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: analytics_admin.UpdateExpandedDataSetRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gaa_expanded_data_set.ExpandedDataSet: + r"""Call the update expanded data set method over HTTP. + + Args: + request (~.analytics_admin.UpdateExpandedDataSetRequest): + The request object. Request message for + UpdateExpandedDataSet 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: + ~.gaa_expanded_data_set.ExpandedDataSet: + A resource message representing a GA4 + ExpandedDataSet. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1alpha/{expanded_data_set.name=properties/*/expandedDataSets/*}", + "body": "expanded_data_set", + }, + ] + request, metadata = self._interceptor.pre_update_expanded_data_set( + request, metadata + ) + pb_request = analytics_admin.UpdateExpandedDataSetRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = gaa_expanded_data_set.ExpandedDataSet() + pb_resp = gaa_expanded_data_set.ExpandedDataSet.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_expanded_data_set(resp) + return resp + class _UpdateGoogleAdsLink(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("UpdateGoogleAdsLink") @@ -11265,6 +13023,17 @@ def audit_user_links( # In C++ this would require a dynamic_cast return self._AuditUserLinks(self._session, self._host, self._interceptor) # type: ignore + @property + def batch_create_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchCreateAccessBindingsRequest], + analytics_admin.BatchCreateAccessBindingsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BatchCreateAccessBindings(self._session, self._host, self._interceptor) # type: ignore + @property def batch_create_user_links( self, @@ -11276,6 +13045,14 @@ def batch_create_user_links( # In C++ this would require a dynamic_cast return self._BatchCreateUserLinks(self._session, self._host, self._interceptor) # type: ignore + @property + def batch_delete_access_bindings( + self, + ) -> Callable[[analytics_admin.BatchDeleteAccessBindingsRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BatchDeleteAccessBindings(self._session, self._host, self._interceptor) # type: ignore + @property def batch_delete_user_links( self, @@ -11284,6 +13061,17 @@ def batch_delete_user_links( # In C++ this would require a dynamic_cast return self._BatchDeleteUserLinks(self._session, self._host, self._interceptor) # type: ignore + @property + def batch_get_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchGetAccessBindingsRequest], + analytics_admin.BatchGetAccessBindingsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BatchGetAccessBindings(self._session, self._host, self._interceptor) # type: ignore + @property def batch_get_user_links( self, @@ -11295,6 +13083,17 @@ def batch_get_user_links( # In C++ this would require a dynamic_cast return self._BatchGetUserLinks(self._session, self._host, self._interceptor) # type: ignore + @property + def batch_update_access_bindings( + self, + ) -> Callable[ + [analytics_admin.BatchUpdateAccessBindingsRequest], + analytics_admin.BatchUpdateAccessBindingsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BatchUpdateAccessBindings(self._session, self._host, self._interceptor) # type: ignore + @property def batch_update_user_links( self, @@ -11317,6 +13116,16 @@ def cancel_display_video360_advertiser_link_proposal( # In C++ this would require a dynamic_cast return self._CancelDisplayVideo360AdvertiserLinkProposal(self._session, self._host, self._interceptor) # type: ignore + @property + def create_access_binding( + self, + ) -> Callable[ + [analytics_admin.CreateAccessBindingRequest], resources.AccessBinding + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateAccessBinding(self._session, self._host, self._interceptor) # type: ignore + @property def create_audience( self, @@ -11383,6 +13192,17 @@ def create_display_video360_advertiser_link_proposal( # In C++ this would require a dynamic_cast return self._CreateDisplayVideo360AdvertiserLinkProposal(self._session, self._host, self._interceptor) # type: ignore + @property + def create_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.CreateExpandedDataSetRequest], + gaa_expanded_data_set.ExpandedDataSet, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateExpandedDataSet(self._session, self._host, self._interceptor) # type: ignore + @property def create_firebase_link( self, @@ -11438,6 +13258,14 @@ def create_user_link( # In C++ this would require a dynamic_cast return self._CreateUserLink(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_access_binding( + self, + ) -> Callable[[analytics_admin.DeleteAccessBindingRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteAccessBinding(self._session, self._host, self._interceptor) # type: ignore + @property def delete_account( self, @@ -11483,6 +13311,14 @@ def delete_display_video360_advertiser_link_proposal( # In C++ this would require a dynamic_cast return self._DeleteDisplayVideo360AdvertiserLinkProposal(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_expanded_data_set( + self, + ) -> Callable[[analytics_admin.DeleteExpandedDataSetRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteExpandedDataSet(self._session, self._host, self._interceptor) # type: ignore + @property def delete_firebase_link( self, @@ -11544,6 +13380,14 @@ def fetch_automated_ga4_configuration_opt_out( # In C++ this would require a dynamic_cast return self._FetchAutomatedGa4ConfigurationOptOut(self._session, self._host, self._interceptor) # type: ignore + @property + def get_access_binding( + self, + ) -> Callable[[analytics_admin.GetAccessBindingRequest], resources.AccessBinding]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetAccessBinding(self._session, self._host, self._interceptor) # type: ignore + @property def get_account( self, @@ -11657,6 +13501,16 @@ def get_display_video360_advertiser_link_proposal( # In C++ this would require a dynamic_cast return self._GetDisplayVideo360AdvertiserLinkProposal(self._session, self._host, self._interceptor) # type: ignore + @property + def get_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.GetExpandedDataSetRequest], expanded_data_set.ExpandedDataSet + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetExpandedDataSet(self._session, self._host, self._interceptor) # type: ignore + @property def get_global_site_tag( self, @@ -11713,6 +13567,17 @@ def get_user_link( # In C++ this would require a dynamic_cast return self._GetUserLink(self._session, self._host, self._interceptor) # type: ignore + @property + def list_access_bindings( + self, + ) -> Callable[ + [analytics_admin.ListAccessBindingsRequest], + analytics_admin.ListAccessBindingsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListAccessBindings(self._session, self._host, self._interceptor) # type: ignore + @property def list_accounts( self, @@ -11821,6 +13686,17 @@ def list_display_video360_advertiser_links( # In C++ this would require a dynamic_cast return self._ListDisplayVideo360AdvertiserLinks(self._session, self._host, self._interceptor) # type: ignore + @property + def list_expanded_data_sets( + self, + ) -> Callable[ + [analytics_admin.ListExpandedDataSetsRequest], + analytics_admin.ListExpandedDataSetsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListExpandedDataSets(self._session, self._host, self._interceptor) # type: ignore + @property def list_firebase_links( self, @@ -11929,6 +13805,16 @@ def set_automated_ga4_configuration_opt_out( # In C++ this would require a dynamic_cast return self._SetAutomatedGa4ConfigurationOptOut(self._session, self._host, self._interceptor) # type: ignore + @property + def update_access_binding( + self, + ) -> Callable[ + [analytics_admin.UpdateAccessBindingRequest], resources.AccessBinding + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateAccessBinding(self._session, self._host, self._interceptor) # type: ignore + @property def update_account( self, @@ -12004,6 +13890,17 @@ def update_display_video360_advertiser_link( # In C++ this would require a dynamic_cast return self._UpdateDisplayVideo360AdvertiserLink(self._session, self._host, self._interceptor) # type: ignore + @property + def update_expanded_data_set( + self, + ) -> Callable[ + [analytics_admin.UpdateExpandedDataSetRequest], + gaa_expanded_data_set.ExpandedDataSet, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateExpandedDataSet(self._session, self._host, self._interceptor) # type: ignore + @property def update_google_ads_link( self, diff --git a/google/analytics/admin_v1alpha/types/__init__.py b/google/analytics/admin_v1alpha/types/__init__.py index f45f4bbc..5b991ca8 100644 --- a/google/analytics/admin_v1alpha/types/__init__.py +++ b/google/analytics/admin_v1alpha/types/__init__.py @@ -44,14 +44,22 @@ ArchiveCustomMetricRequest, AuditUserLinksRequest, AuditUserLinksResponse, + BatchCreateAccessBindingsRequest, + BatchCreateAccessBindingsResponse, BatchCreateUserLinksRequest, BatchCreateUserLinksResponse, + BatchDeleteAccessBindingsRequest, BatchDeleteUserLinksRequest, + BatchGetAccessBindingsRequest, + BatchGetAccessBindingsResponse, BatchGetUserLinksRequest, BatchGetUserLinksResponse, + BatchUpdateAccessBindingsRequest, + BatchUpdateAccessBindingsResponse, BatchUpdateUserLinksRequest, BatchUpdateUserLinksResponse, CancelDisplayVideo360AdvertiserLinkProposalRequest, + CreateAccessBindingRequest, CreateAudienceRequest, CreateConversionEventRequest, CreateCustomDimensionRequest, @@ -59,17 +67,20 @@ CreateDataStreamRequest, CreateDisplayVideo360AdvertiserLinkProposalRequest, CreateDisplayVideo360AdvertiserLinkRequest, + CreateExpandedDataSetRequest, CreateFirebaseLinkRequest, CreateGoogleAdsLinkRequest, CreateMeasurementProtocolSecretRequest, CreatePropertyRequest, CreateSearchAds360LinkRequest, CreateUserLinkRequest, + DeleteAccessBindingRequest, DeleteAccountRequest, DeleteConversionEventRequest, DeleteDataStreamRequest, DeleteDisplayVideo360AdvertiserLinkProposalRequest, DeleteDisplayVideo360AdvertiserLinkRequest, + DeleteExpandedDataSetRequest, DeleteFirebaseLinkRequest, DeleteGoogleAdsLinkRequest, DeleteMeasurementProtocolSecretRequest, @@ -78,6 +89,7 @@ DeleteUserLinkRequest, FetchAutomatedGa4ConfigurationOptOutRequest, FetchAutomatedGa4ConfigurationOptOutResponse, + GetAccessBindingRequest, GetAccountRequest, GetAttributionSettingsRequest, GetAudienceRequest, @@ -90,12 +102,15 @@ GetDataStreamRequest, GetDisplayVideo360AdvertiserLinkProposalRequest, GetDisplayVideo360AdvertiserLinkRequest, + GetExpandedDataSetRequest, GetGlobalSiteTagRequest, GetGoogleSignalsSettingsRequest, GetMeasurementProtocolSecretRequest, GetPropertyRequest, GetSearchAds360LinkRequest, GetUserLinkRequest, + ListAccessBindingsRequest, + ListAccessBindingsResponse, ListAccountsRequest, ListAccountsResponse, ListAccountSummariesRequest, @@ -116,6 +131,8 @@ ListDisplayVideo360AdvertiserLinkProposalsResponse, ListDisplayVideo360AdvertiserLinksRequest, ListDisplayVideo360AdvertiserLinksResponse, + ListExpandedDataSetsRequest, + ListExpandedDataSetsResponse, ListFirebaseLinksRequest, ListFirebaseLinksResponse, ListGoogleAdsLinksRequest, @@ -136,6 +153,7 @@ SearchChangeHistoryEventsResponse, SetAutomatedGa4ConfigurationOptOutRequest, SetAutomatedGa4ConfigurationOptOutResponse, + UpdateAccessBindingRequest, UpdateAccountRequest, UpdateAttributionSettingsRequest, UpdateAudienceRequest, @@ -144,6 +162,7 @@ UpdateDataRetentionSettingsRequest, UpdateDataStreamRequest, UpdateDisplayVideo360AdvertiserLinkRequest, + UpdateExpandedDataSetRequest, UpdateGoogleAdsLinkRequest, UpdateGoogleSignalsSettingsRequest, UpdateMeasurementProtocolSecretRequest, @@ -170,6 +189,7 @@ ExpandedDataSetFilterExpressionList, ) from .resources import ( + AccessBinding, Account, AccountSummary, ActionType, @@ -236,14 +256,22 @@ "ArchiveCustomMetricRequest", "AuditUserLinksRequest", "AuditUserLinksResponse", + "BatchCreateAccessBindingsRequest", + "BatchCreateAccessBindingsResponse", "BatchCreateUserLinksRequest", "BatchCreateUserLinksResponse", + "BatchDeleteAccessBindingsRequest", "BatchDeleteUserLinksRequest", + "BatchGetAccessBindingsRequest", + "BatchGetAccessBindingsResponse", "BatchGetUserLinksRequest", "BatchGetUserLinksResponse", + "BatchUpdateAccessBindingsRequest", + "BatchUpdateAccessBindingsResponse", "BatchUpdateUserLinksRequest", "BatchUpdateUserLinksResponse", "CancelDisplayVideo360AdvertiserLinkProposalRequest", + "CreateAccessBindingRequest", "CreateAudienceRequest", "CreateConversionEventRequest", "CreateCustomDimensionRequest", @@ -251,17 +279,20 @@ "CreateDataStreamRequest", "CreateDisplayVideo360AdvertiserLinkProposalRequest", "CreateDisplayVideo360AdvertiserLinkRequest", + "CreateExpandedDataSetRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", "CreateMeasurementProtocolSecretRequest", "CreatePropertyRequest", "CreateSearchAds360LinkRequest", "CreateUserLinkRequest", + "DeleteAccessBindingRequest", "DeleteAccountRequest", "DeleteConversionEventRequest", "DeleteDataStreamRequest", "DeleteDisplayVideo360AdvertiserLinkProposalRequest", "DeleteDisplayVideo360AdvertiserLinkRequest", + "DeleteExpandedDataSetRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", "DeleteMeasurementProtocolSecretRequest", @@ -270,6 +301,7 @@ "DeleteUserLinkRequest", "FetchAutomatedGa4ConfigurationOptOutRequest", "FetchAutomatedGa4ConfigurationOptOutResponse", + "GetAccessBindingRequest", "GetAccountRequest", "GetAttributionSettingsRequest", "GetAudienceRequest", @@ -282,12 +314,15 @@ "GetDataStreamRequest", "GetDisplayVideo360AdvertiserLinkProposalRequest", "GetDisplayVideo360AdvertiserLinkRequest", + "GetExpandedDataSetRequest", "GetGlobalSiteTagRequest", "GetGoogleSignalsSettingsRequest", "GetMeasurementProtocolSecretRequest", "GetPropertyRequest", "GetSearchAds360LinkRequest", "GetUserLinkRequest", + "ListAccessBindingsRequest", + "ListAccessBindingsResponse", "ListAccountsRequest", "ListAccountsResponse", "ListAccountSummariesRequest", @@ -308,6 +343,8 @@ "ListDisplayVideo360AdvertiserLinkProposalsResponse", "ListDisplayVideo360AdvertiserLinksRequest", "ListDisplayVideo360AdvertiserLinksResponse", + "ListExpandedDataSetsRequest", + "ListExpandedDataSetsResponse", "ListFirebaseLinksRequest", "ListFirebaseLinksResponse", "ListGoogleAdsLinksRequest", @@ -328,6 +365,7 @@ "SearchChangeHistoryEventsResponse", "SetAutomatedGa4ConfigurationOptOutRequest", "SetAutomatedGa4ConfigurationOptOutResponse", + "UpdateAccessBindingRequest", "UpdateAccountRequest", "UpdateAttributionSettingsRequest", "UpdateAudienceRequest", @@ -336,6 +374,7 @@ "UpdateDataRetentionSettingsRequest", "UpdateDataStreamRequest", "UpdateDisplayVideo360AdvertiserLinkRequest", + "UpdateExpandedDataSetRequest", "UpdateGoogleAdsLinkRequest", "UpdateGoogleSignalsSettingsRequest", "UpdateMeasurementProtocolSecretRequest", @@ -356,6 +395,7 @@ "ExpandedDataSetFilter", "ExpandedDataSetFilterExpression", "ExpandedDataSetFilterExpressionList", + "AccessBinding", "Account", "AccountSummary", "AttributionSettings", diff --git a/google/analytics/admin_v1alpha/types/analytics_admin.py b/google/analytics/admin_v1alpha/types/analytics_admin.py index aba6ba8d..b6f03c1c 100644 --- a/google/analytics/admin_v1alpha/types/analytics_admin.py +++ b/google/analytics/admin_v1alpha/types/analytics_admin.py @@ -19,6 +19,9 @@ from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore +from google.analytics.admin_v1alpha.types import ( + expanded_data_set as gaa_expanded_data_set, +) from google.analytics.admin_v1alpha.types import access_report from google.analytics.admin_v1alpha.types import audience as gaa_audience from google.analytics.admin_v1alpha.types import resources @@ -134,6 +137,25 @@ "ArchiveAudienceRequest", "GetAttributionSettingsRequest", "UpdateAttributionSettingsRequest", + "GetAccessBindingRequest", + "BatchGetAccessBindingsRequest", + "BatchGetAccessBindingsResponse", + "ListAccessBindingsRequest", + "ListAccessBindingsResponse", + "CreateAccessBindingRequest", + "BatchCreateAccessBindingsRequest", + "BatchCreateAccessBindingsResponse", + "UpdateAccessBindingRequest", + "BatchUpdateAccessBindingsRequest", + "BatchUpdateAccessBindingsResponse", + "DeleteAccessBindingRequest", + "BatchDeleteAccessBindingsRequest", + "CreateExpandedDataSetRequest", + "UpdateExpandedDataSetRequest", + "DeleteExpandedDataSetRequest", + "GetExpandedDataSetRequest", + "ListExpandedDataSetsRequest", + "ListExpandedDataSetsResponse", "SetAutomatedGa4ConfigurationOptOutRequest", "SetAutomatedGa4ConfigurationOptOutResponse", "FetchAutomatedGa4ConfigurationOptOutRequest", @@ -171,7 +193,7 @@ class RunAccessReportRequest(proto.Message): ranges. Requests are allowed up to 2 date ranges. dimension_filter (google.analytics.admin_v1alpha.types.AccessFilterExpression): - Dimension filters allow you to restrict report response to + Dimension filters let you restrict report response to specific dimension values which match the filter. For example, filtering on access records of a single user. To learn more, see `Fundamentals of Dimension @@ -446,9 +468,9 @@ class UpdateAccountRequest(proto.Message): field is used to identify the account. update_mask (google.protobuf.field_mask_pb2.FieldMask): Required. The list of fields to be updated. Field names must - be in snake case (e.g., "field_to_update"). Omitted fields - will not be updated. To replace the entire entity, use one - path with the string "*" to match all fields. + be in snake case (for example, "field_to_update"). Omitted + fields will not be updated. To replace the entire entity, + use one path with the string "*" to match all fields. """ account: resources.Account = proto.Field( @@ -473,7 +495,7 @@ class ProvisionAccountTicketRequest(proto.Message): Redirect URI where the user will be sent after accepting Terms of Service. Must be configured in Developers Console as a Redirect - URI + URI. """ account: resources.Account = proto.Field( @@ -2908,6 +2930,449 @@ class UpdateAttributionSettingsRequest(proto.Message): ) +class GetAccessBindingRequest(proto.Message): + r"""Request message for GetAccessBinding RPC. + + Attributes: + name (str): + Required. The name of the access binding to + retrieve. Formats: + - + accounts/{account}/accessBindings/{accessBinding} + - + properties/{property}/accessBindings/{accessBinding} + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class BatchGetAccessBindingsRequest(proto.Message): + r"""Request message for BatchGetAccessBindings RPC. + + Attributes: + parent (str): + Required. The account or property that owns + the access bindings. The parent of all provided + values for the 'names' field must match this + field. Formats: + - accounts/{account} + - properties/{property} + names (MutableSequence[str]): + Required. The names of the access bindings to + retrieve. A maximum of 1000 access bindings can + be retrieved in a batch. Formats: + - + accounts/{account}/accessBindings/{accessBinding} + - + properties/{property}/accessBindings/{accessBinding} + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + names: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=2, + ) + + +class BatchGetAccessBindingsResponse(proto.Message): + r"""Response message for BatchGetAccessBindings RPC. + + Attributes: + access_bindings (MutableSequence[google.analytics.admin_v1alpha.types.AccessBinding]): + The requested access bindings. + """ + + access_bindings: MutableSequence[resources.AccessBinding] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.AccessBinding, + ) + + +class ListAccessBindingsRequest(proto.Message): + r"""Request message for ListAccessBindings RPC. + + Attributes: + parent (str): + Required. Formats: + - accounts/{account} + - properties/{property} + page_size (int): + The maximum number of access bindings to + return. The service may return fewer than this + value. If unspecified, at most 200 access + bindings will be returned. The maximum value is + 500; values above 500 will be coerced to 500. + page_token (str): + A page token, received from a previous + ``ListAccessBindings`` call. Provide this to retrieve the + subsequent page. When paginating, all other parameters + provided to ``ListAccessBindings`` must match the call that + provided the page token. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListAccessBindingsResponse(proto.Message): + r"""Response message for ListAccessBindings RPC. + + Attributes: + access_bindings (MutableSequence[google.analytics.admin_v1alpha.types.AccessBinding]): + List of AccessBindings. These will be ordered + stably, but in an arbitrary order. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + access_bindings: MutableSequence[resources.AccessBinding] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.AccessBinding, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class CreateAccessBindingRequest(proto.Message): + r"""Request message for CreateAccessBinding RPC. + + Attributes: + parent (str): + Required. Formats: + - accounts/{account} + - properties/{property} + access_binding (google.analytics.admin_v1alpha.types.AccessBinding): + Required. The access binding to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + access_binding: resources.AccessBinding = proto.Field( + proto.MESSAGE, + number=2, + message=resources.AccessBinding, + ) + + +class BatchCreateAccessBindingsRequest(proto.Message): + r"""Request message for BatchCreateAccessBindings RPC. + + Attributes: + parent (str): + Required. The account or property that owns + the access bindings. The parent field in the + CreateAccessBindingRequest messages must either + be empty or match this field. Formats: + - accounts/{account} + - properties/{property} + requests (MutableSequence[google.analytics.admin_v1alpha.types.CreateAccessBindingRequest]): + Required. The requests specifying the access + bindings to create. A maximum of 1000 access + bindings can be created in a batch. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + requests: MutableSequence["CreateAccessBindingRequest"] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="CreateAccessBindingRequest", + ) + + +class BatchCreateAccessBindingsResponse(proto.Message): + r"""Response message for BatchCreateAccessBindings RPC. + + Attributes: + access_bindings (MutableSequence[google.analytics.admin_v1alpha.types.AccessBinding]): + The access bindings created. + """ + + access_bindings: MutableSequence[resources.AccessBinding] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.AccessBinding, + ) + + +class UpdateAccessBindingRequest(proto.Message): + r"""Request message for UpdateAccessBinding RPC. + + Attributes: + access_binding (google.analytics.admin_v1alpha.types.AccessBinding): + Required. The access binding to update. + """ + + access_binding: resources.AccessBinding = proto.Field( + proto.MESSAGE, + number=1, + message=resources.AccessBinding, + ) + + +class BatchUpdateAccessBindingsRequest(proto.Message): + r"""Request message for BatchUpdateAccessBindings RPC. + + Attributes: + parent (str): + Required. The account or property that owns + the access bindings. The parent field in the + UpdateAccessBindingRequest messages must either + be empty or match this field. Formats: + - accounts/{account} + - properties/{property} + requests (MutableSequence[google.analytics.admin_v1alpha.types.UpdateAccessBindingRequest]): + Required. The requests specifying the access + bindings to update. A maximum of 1000 access + bindings can be updated in a batch. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + requests: MutableSequence["UpdateAccessBindingRequest"] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="UpdateAccessBindingRequest", + ) + + +class BatchUpdateAccessBindingsResponse(proto.Message): + r"""Response message for BatchUpdateAccessBindings RPC. + + Attributes: + access_bindings (MutableSequence[google.analytics.admin_v1alpha.types.AccessBinding]): + The access bindings updated. + """ + + access_bindings: MutableSequence[resources.AccessBinding] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.AccessBinding, + ) + + +class DeleteAccessBindingRequest(proto.Message): + r"""Request message for DeleteAccessBinding RPC. + + Attributes: + name (str): + Required. Formats: + - + accounts/{account}/accessBindings/{accessBinding} + - + properties/{property}/accessBindings/{accessBinding} + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class BatchDeleteAccessBindingsRequest(proto.Message): + r"""Request message for BatchDeleteAccessBindings RPC. + + Attributes: + parent (str): + Required. The account or property that owns + the access bindings. The parent field in the + DeleteAccessBindingRequest messages must either + be empty or match this field. Formats: + - accounts/{account} + - properties/{property} + requests (MutableSequence[google.analytics.admin_v1alpha.types.DeleteAccessBindingRequest]): + Required. The requests specifying the access + bindings to delete. A maximum of 1000 access + bindings can be deleted in a batch. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + requests: MutableSequence["DeleteAccessBindingRequest"] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="DeleteAccessBindingRequest", + ) + + +class CreateExpandedDataSetRequest(proto.Message): + r"""Request message for CreateExpandedDataSet RPC. + + Attributes: + parent (str): + Required. Example format: properties/1234 + expanded_data_set (google.analytics.admin_v1alpha.types.ExpandedDataSet): + Required. The ExpandedDataSet to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + expanded_data_set: gaa_expanded_data_set.ExpandedDataSet = proto.Field( + proto.MESSAGE, + number=2, + message=gaa_expanded_data_set.ExpandedDataSet, + ) + + +class UpdateExpandedDataSetRequest(proto.Message): + r"""Request message for UpdateExpandedDataSet RPC. + + Attributes: + expanded_data_set (google.analytics.admin_v1alpha.types.ExpandedDataSet): + Required. The ExpandedDataSet to update. The resource's + ``name`` field is used to identify the ExpandedDataSet 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. + """ + + expanded_data_set: gaa_expanded_data_set.ExpandedDataSet = proto.Field( + proto.MESSAGE, + number=1, + message=gaa_expanded_data_set.ExpandedDataSet, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteExpandedDataSetRequest(proto.Message): + r"""Request message for DeleteExpandedDataSet RPC. + + Attributes: + name (str): + Required. Example format: + properties/1234/expandedDataSets/5678 + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class GetExpandedDataSetRequest(proto.Message): + r"""Request message for GetExpandedDataSet RPC. + + Attributes: + name (str): + Required. The name of the Audience to get. + Example format: + properties/1234/expandedDataSets/5678 + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListExpandedDataSetsRequest(proto.Message): + r"""Request message for ListExpandedDataSets 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 + ``ListExpandedDataSets`` call. Provide this to retrieve the + subsequent page. + + When paginating, all other parameters provided to + ``ListExpandedDataSet`` must match the call that provided + the page token. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListExpandedDataSetsResponse(proto.Message): + r"""Response message for ListExpandedDataSets RPC. + + Attributes: + expanded_data_sets (MutableSequence[google.analytics.admin_v1alpha.types.ExpandedDataSet]): + List of ExpandedDataSet. These will be + ordered stably, but in an arbitrary order. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + expanded_data_sets: MutableSequence[ + gaa_expanded_data_set.ExpandedDataSet + ] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gaa_expanded_data_set.ExpandedDataSet, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + class SetAutomatedGa4ConfigurationOptOutRequest(proto.Message): r"""Request for setting the opt out status for the automated GA4 setup process. diff --git a/google/analytics/admin_v1alpha/types/resources.py b/google/analytics/admin_v1alpha/types/resources.py index b64c9615..674e8c36 100644 --- a/google/analytics/admin_v1alpha/types/resources.py +++ b/google/analytics/admin_v1alpha/types/resources.py @@ -60,6 +60,7 @@ "CustomMetric", "DataRetentionSettings", "AttributionSettings", + "AccessBinding", "BigQueryLink", }, ) @@ -2219,6 +2220,54 @@ class ReportingAttributionModel(proto.Enum): ) +class AccessBinding(proto.Message): + r"""A binding of a user to a set of roles. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + user (str): + If set, the email address of the user to set + roles for. Format: "someuser@gmail.com". + + This field is a member of `oneof`_ ``access_target``. + name (str): + Output only. Resource name of this binding. + + Format: accounts/{account}/accessBindings/{access_binding} + or properties/{property}/accessBindings/{access_binding} + + Example: "accounts/100/accessBindings/200". + roles (MutableSequence[str]): + A list of roles for to grant to the parent + resource. + Valid values: + predefinedRoles/viewer + predefinedRoles/analyst + predefinedRoles/editor + predefinedRoles/admin + predefinedRoles/no-cost-data + predefinedRoles/no-revenue-data + + For users, if an empty list of roles is set, + this AccessBinding will be deleted. + """ + + user: str = proto.Field( + proto.STRING, + number=2, + oneof="access_target", + ) + name: str = proto.Field( + proto.STRING, + number=1, + ) + roles: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + class BigQueryLink(proto.Message): r"""A link between a GA4 Property and BigQuery project. diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_async.py new file mode 100644 index 00000000..87f81595 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchCreateAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateAccessBindings_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_batch_create_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + requests = admin_v1alpha.CreateAccessBindingRequest() + requests.parent = "parent_value" + requests.access_binding.user = "user_value" + + request = admin_v1alpha.BatchCreateAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = await client.batch_create_access_bindings(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateAccessBindings_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_sync.py new file mode 100644 index 00000000..ad38aead --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchCreateAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateAccessBindings_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_batch_create_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + requests = admin_v1alpha.CreateAccessBindingRequest() + requests.parent = "parent_value" + requests.access_binding.user = "user_value" + + request = admin_v1alpha.BatchCreateAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = client.batch_create_access_bindings(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateAccessBindings_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_async.py new file mode 100644 index 00000000..ada36d2f --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchDeleteAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteAccessBindings_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_batch_delete_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + requests = admin_v1alpha.DeleteAccessBindingRequest() + requests.name = "name_value" + + request = admin_v1alpha.BatchDeleteAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + await client.batch_delete_access_bindings(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteAccessBindings_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_sync.py new file mode 100644 index 00000000..6826afd2 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchDeleteAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteAccessBindings_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_batch_delete_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + requests = admin_v1alpha.DeleteAccessBindingRequest() + requests.name = "name_value" + + request = admin_v1alpha.BatchDeleteAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + client.batch_delete_access_bindings(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteAccessBindings_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_async.py new file mode 100644 index 00000000..850dbc29 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchGetAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetAccessBindings_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_batch_get_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.BatchGetAccessBindingsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + response = await client.batch_get_access_bindings(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetAccessBindings_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_sync.py new file mode 100644 index 00000000..b5cd203e --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchGetAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetAccessBindings_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_batch_get_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.BatchGetAccessBindingsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + response = client.batch_get_access_bindings(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetAccessBindings_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_async.py new file mode 100644 index 00000000..d56969d1 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchUpdateAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateAccessBindings_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_batch_update_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + requests = admin_v1alpha.UpdateAccessBindingRequest() + requests.access_binding.user = "user_value" + + request = admin_v1alpha.BatchUpdateAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = await client.batch_update_access_bindings(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateAccessBindings_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_sync.py new file mode 100644 index 00000000..b0a45212 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchUpdateAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateAccessBindings_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_batch_update_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + requests = admin_v1alpha.UpdateAccessBindingRequest() + requests.access_binding.user = "user_value" + + request = admin_v1alpha.BatchUpdateAccessBindingsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = client.batch_update_access_bindings(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateAccessBindings_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_async.py new file mode 100644 index 00000000..c4076b91 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAccessBinding +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAccessBinding_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_create_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + access_binding = admin_v1alpha.AccessBinding() + access_binding.user = "user_value" + + request = admin_v1alpha.CreateAccessBindingRequest( + parent="parent_value", + access_binding=access_binding, + ) + + # Make the request + response = await client.create_access_binding(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAccessBinding_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_sync.py new file mode 100644 index 00000000..9d674282 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAccessBinding +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAccessBinding_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_create_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + access_binding = admin_v1alpha.AccessBinding() + access_binding.user = "user_value" + + request = admin_v1alpha.CreateAccessBindingRequest( + parent="parent_value", + access_binding=access_binding, + ) + + # Make the request + response = client.create_access_binding(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAccessBinding_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_async.py new file mode 100644 index 00000000..1988a378 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateExpandedDataSet +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_create_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + expanded_data_set = admin_v1alpha.ExpandedDataSet() + expanded_data_set.display_name = "display_name_value" + + request = admin_v1alpha.CreateExpandedDataSetRequest( + parent="parent_value", + expanded_data_set=expanded_data_set, + ) + + # Make the request + response = await client.create_expanded_data_set(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_sync.py new file mode 100644 index 00000000..bd0b066d --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateExpandedDataSet +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_create_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + expanded_data_set = admin_v1alpha.ExpandedDataSet() + expanded_data_set.display_name = "display_name_value" + + request = admin_v1alpha.CreateExpandedDataSetRequest( + parent="parent_value", + expanded_data_set=expanded_data_set, + ) + + # Make the request + response = client.create_expanded_data_set(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_async.py new file mode 100644 index 00000000..a17e459e --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAccessBinding +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccessBinding_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_delete_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteAccessBindingRequest( + name="name_value", + ) + + # Make the request + await client.delete_access_binding(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccessBinding_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_sync.py new file mode 100644 index 00000000..9b40c329 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAccessBinding +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccessBinding_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_delete_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteAccessBindingRequest( + name="name_value", + ) + + # Make the request + client.delete_access_binding(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccessBinding_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_async.py new file mode 100644 index 00000000..a9651f56 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteExpandedDataSet +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteExpandedDataSet_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_delete_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteExpandedDataSetRequest( + name="name_value", + ) + + # Make the request + await client.delete_expanded_data_set(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteExpandedDataSet_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_sync.py new file mode 100644 index 00000000..5c90ba9d --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteExpandedDataSet +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteExpandedDataSet_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_delete_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteExpandedDataSetRequest( + name="name_value", + ) + + # Make the request + client.delete_expanded_data_set(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteExpandedDataSet_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_async.py new file mode 100644 index 00000000..946c4d2d --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAccessBinding +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_get_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetAccessBindingRequest( + name="name_value", + ) + + # Make the request + response = await client.get_access_binding(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_sync.py new file mode 100644 index 00000000..0dd2f8dd --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAccessBinding +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_get_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetAccessBindingRequest( + name="name_value", + ) + + # Make the request + response = client.get_access_binding(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_async.py new file mode 100644 index 00000000..62845f8e --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetExpandedDataSet +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetExpandedDataSet_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_get_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetExpandedDataSetRequest( + name="name_value", + ) + + # Make the request + response = await client.get_expanded_data_set(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetExpandedDataSet_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_sync.py new file mode 100644 index 00000000..fb71caf5 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetExpandedDataSet +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetExpandedDataSet_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_get_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetExpandedDataSetRequest( + name="name_value", + ) + + # Make the request + response = client.get_expanded_data_set(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetExpandedDataSet_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_async.py new file mode 100644 index 00000000..c0e912fd --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccessBindings_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_list_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListAccessBindingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_access_bindings(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccessBindings_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_sync.py new file mode 100644 index 00000000..23c3c761 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAccessBindings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccessBindings_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_list_access_bindings(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListAccessBindingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_access_bindings(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccessBindings_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_async.py new file mode 100644 index 00000000..0484eead --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListExpandedDataSets +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListExpandedDataSets_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_list_expanded_data_sets(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListExpandedDataSetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_expanded_data_sets(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListExpandedDataSets_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_sync.py new file mode 100644 index 00000000..c7b92b64 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListExpandedDataSets +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListExpandedDataSets_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_list_expanded_data_sets(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListExpandedDataSetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_expanded_data_sets(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListExpandedDataSets_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_async.py new file mode 100644 index 00000000..f2c17f8d --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateAccessBinding +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateAccessBinding_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_update_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + access_binding = admin_v1alpha.AccessBinding() + access_binding.user = "user_value" + + request = admin_v1alpha.UpdateAccessBindingRequest( + access_binding=access_binding, + ) + + # Make the request + response = await client.update_access_binding(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateAccessBinding_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_sync.py new file mode 100644 index 00000000..01394334 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateAccessBinding +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateAccessBinding_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_update_access_binding(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + access_binding = admin_v1alpha.AccessBinding() + access_binding.user = "user_value" + + request = admin_v1alpha.UpdateAccessBindingRequest( + access_binding=access_binding, + ) + + # Make the request + response = client.update_access_binding(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateAccessBinding_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_async.py new file mode 100644 index 00000000..8e19524a --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateExpandedDataSet +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateExpandedDataSet_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +async def sample_update_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + expanded_data_set = admin_v1alpha.ExpandedDataSet() + expanded_data_set.display_name = "display_name_value" + + request = admin_v1alpha.UpdateExpandedDataSetRequest( + expanded_data_set=expanded_data_set, + ) + + # Make the request + response = await client.update_expanded_data_set(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateExpandedDataSet_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_sync.py new file mode 100644 index 00000000..b6ea3112 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateExpandedDataSet +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-analytics-admin + + +# [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateExpandedDataSet_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.analytics import admin_v1alpha + + +def sample_update_expanded_data_set(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + expanded_data_set = admin_v1alpha.ExpandedDataSet() + expanded_data_set.display_name = "display_name_value" + + request = admin_v1alpha.UpdateExpandedDataSetRequest( + expanded_data_set=expanded_data_set, + ) + + # Make the request + response = client.update_expanded_data_set(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateExpandedDataSet_sync] diff --git a/samples/generated_samples/snippet_metadata_google.analytics.admin.v1alpha.json b/samples/generated_samples/snippet_metadata_google.analytics.admin.v1alpha.json index 97c390e1..29da174f 100644 --- a/samples/generated_samples/snippet_metadata_google.analytics.admin.v1alpha.json +++ b/samples/generated_samples/snippet_metadata_google.analytics.admin.v1alpha.json @@ -935,19 +935,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_create_user_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_create_access_bindings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchCreateUserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchCreateAccessBindings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "BatchCreateUserLinks" + "shortName": "BatchCreateAccessBindings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.BatchCreateAccessBindingsRequest" }, { "name": "retry", @@ -962,22 +962,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse", - "shortName": "batch_create_user_links" + "resultType": "google.analytics.admin_v1alpha.types.BatchCreateAccessBindingsResponse", + "shortName": "batch_create_access_bindings" }, - "description": "Sample for BatchCreateUserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_user_links_async.py", + "description": "Sample for BatchCreateAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateUserLinks_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateAccessBindings_async", "segments": [ { - "end": 55, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 56, "start": 27, "type": "SHORT" }, @@ -987,22 +987,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 50, + "end": 53, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_user_links_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_async.py" }, { "canonical": true, @@ -1011,19 +1011,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_create_user_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_create_access_bindings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchCreateUserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchCreateAccessBindings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "BatchCreateUserLinks" + "shortName": "BatchCreateAccessBindings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.BatchCreateAccessBindingsRequest" }, { "name": "retry", @@ -1038,22 +1038,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse", - "shortName": "batch_create_user_links" + "resultType": "google.analytics.admin_v1alpha.types.BatchCreateAccessBindingsResponse", + "shortName": "batch_create_access_bindings" }, - "description": "Sample for BatchCreateUserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_user_links_sync.py", + "description": "Sample for BatchCreateAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateUserLinks_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateAccessBindings_sync", "segments": [ { - "end": 55, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 56, "start": 27, "type": "SHORT" }, @@ -1063,22 +1063,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 50, + "end": 53, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_user_links_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_access_bindings_sync.py" }, { "canonical": true, @@ -1088,19 +1088,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_delete_user_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_create_user_links", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchDeleteUserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchCreateUserLinks", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "BatchDeleteUserLinks" + "shortName": "BatchCreateUserLinks" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest" }, { "name": "retry", @@ -1115,21 +1115,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "batch_delete_user_links" + "resultType": "google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse", + "shortName": "batch_create_user_links" }, - "description": "Sample for BatchDeleteUserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_user_links_async.py", + "description": "Sample for BatchCreateUserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_user_links_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteUserLinks_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateUserLinks_async", "segments": [ { - "end": 53, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1144,15 +1145,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 52, "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 54, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_user_links_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_user_links_async.py" }, { "canonical": true, @@ -1161,19 +1164,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_delete_user_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_create_user_links", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchDeleteUserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchCreateUserLinks", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "BatchDeleteUserLinks" + "shortName": "BatchCreateUserLinks" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.BatchCreateUserLinksRequest" }, { "name": "retry", @@ -1188,21 +1191,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "batch_delete_user_links" + "resultType": "google.analytics.admin_v1alpha.types.BatchCreateUserLinksResponse", + "shortName": "batch_create_user_links" }, - "description": "Sample for BatchDeleteUserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_user_links_sync.py", + "description": "Sample for BatchCreateUserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_user_links_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteUserLinks_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchCreateUserLinks_sync", "segments": [ { - "end": 53, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1217,15 +1221,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 52, "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 54, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_user_links_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_create_user_links_sync.py" }, { "canonical": true, @@ -1235,19 +1241,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_get_user_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_delete_access_bindings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchGetUserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchDeleteAccessBindings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "BatchGetUserLinks" + "shortName": "BatchDeleteAccessBindings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.BatchDeleteAccessBindingsRequest" }, { "name": "retry", @@ -1262,22 +1268,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse", - "shortName": "batch_get_user_links" + "shortName": "batch_delete_access_bindings" }, - "description": "Sample for BatchGetUserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_user_links_async.py", + "description": "Sample for BatchDeleteAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetUserLinks_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteAccessBindings_async", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -1287,22 +1292,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 54, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_user_links_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_async.py" }, { "canonical": true, @@ -1311,19 +1314,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_get_user_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_delete_access_bindings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchGetUserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchDeleteAccessBindings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "BatchGetUserLinks" + "shortName": "BatchDeleteAccessBindings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.BatchDeleteAccessBindingsRequest" }, { "name": "retry", @@ -1338,22 +1341,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse", - "shortName": "batch_get_user_links" + "shortName": "batch_delete_access_bindings" }, - "description": "Sample for BatchGetUserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_user_links_sync.py", + "description": "Sample for BatchDeleteAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetUserLinks_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteAccessBindings_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -1363,22 +1365,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 54, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_user_links_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_access_bindings_sync.py" }, { "canonical": true, @@ -1388,19 +1388,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_update_user_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_delete_user_links", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchUpdateUserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchDeleteUserLinks", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "BatchUpdateUserLinks" + "shortName": "BatchDeleteUserLinks" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest" }, { "name": "retry", @@ -1415,22 +1415,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse", - "shortName": "batch_update_user_links" + "shortName": "batch_delete_user_links" }, - "description": "Sample for BatchUpdateUserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_user_links_async.py", + "description": "Sample for BatchDeleteUserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_user_links_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateUserLinks_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteUserLinks_async", "segments": [ { - "end": 51, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 53, "start": 27, "type": "SHORT" }, @@ -1440,22 +1439,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 54, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_user_links_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_user_links_async.py" }, { "canonical": true, @@ -1464,19 +1461,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_update_user_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_delete_user_links", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchUpdateUserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchDeleteUserLinks", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "BatchUpdateUserLinks" + "shortName": "BatchDeleteUserLinks" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.BatchDeleteUserLinksRequest" }, { "name": "retry", @@ -1491,22 +1488,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse", - "shortName": "batch_update_user_links" + "shortName": "batch_delete_user_links" }, - "description": "Sample for BatchUpdateUserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_user_links_sync.py", + "description": "Sample for BatchDeleteUserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_user_links_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateUserLinks_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchDeleteUserLinks_sync", "segments": [ { - "end": 51, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 53, "start": 27, "type": "SHORT" }, @@ -1516,22 +1512,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 54, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_user_links_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_delete_user_links_sync.py" }, { "canonical": true, @@ -1541,19 +1535,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.cancel_display_video360_advertiser_link_proposal", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_get_access_bindings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CancelDisplayVideo360AdvertiserLinkProposal", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchGetAccessBindings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CancelDisplayVideo360AdvertiserLinkProposal" + "shortName": "BatchGetAccessBindings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CancelDisplayVideo360AdvertiserLinkProposalRequest" + "type": "google.analytics.admin_v1alpha.types.BatchGetAccessBindingsRequest" }, { "name": "retry", @@ -1568,22 +1562,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", - "shortName": "cancel_display_video360_advertiser_link_proposal" + "resultType": "google.analytics.admin_v1alpha.types.BatchGetAccessBindingsResponse", + "shortName": "batch_get_access_bindings" }, - "description": "Sample for CancelDisplayVideo360AdvertiserLinkProposal", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_cancel_display_video360_advertiser_link_proposal_async.py", + "description": "Sample for BatchGetAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CancelDisplayVideo360AdvertiserLinkProposal_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetAccessBindings_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1593,22 +1587,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_cancel_display_video360_advertiser_link_proposal_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_async.py" }, { "canonical": true, @@ -1617,19 +1611,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.cancel_display_video360_advertiser_link_proposal", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_get_access_bindings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CancelDisplayVideo360AdvertiserLinkProposal", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchGetAccessBindings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CancelDisplayVideo360AdvertiserLinkProposal" + "shortName": "BatchGetAccessBindings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CancelDisplayVideo360AdvertiserLinkProposalRequest" + "type": "google.analytics.admin_v1alpha.types.BatchGetAccessBindingsRequest" }, { "name": "retry", @@ -1644,22 +1638,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", - "shortName": "cancel_display_video360_advertiser_link_proposal" + "resultType": "google.analytics.admin_v1alpha.types.BatchGetAccessBindingsResponse", + "shortName": "batch_get_access_bindings" }, - "description": "Sample for CancelDisplayVideo360AdvertiserLinkProposal", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_cancel_display_video360_advertiser_link_proposal_sync.py", + "description": "Sample for BatchGetAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CancelDisplayVideo360AdvertiserLinkProposal_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetAccessBindings_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1669,22 +1663,803 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_cancel_display_video360_advertiser_link_proposal_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_access_bindings_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_get_user_links", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchGetUserLinks", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "BatchGetUserLinks" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse", + "shortName": "batch_get_user_links" + }, + "description": "Sample for BatchGetUserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_user_links_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetUserLinks_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_user_links_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_get_user_links", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchGetUserLinks", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "BatchGetUserLinks" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.BatchGetUserLinksRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.BatchGetUserLinksResponse", + "shortName": "batch_get_user_links" + }, + "description": "Sample for BatchGetUserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_user_links_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchGetUserLinks_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_get_user_links_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_update_access_bindings", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchUpdateAccessBindings", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "BatchUpdateAccessBindings" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsResponse", + "shortName": "batch_update_access_bindings" + }, + "description": "Sample for BatchUpdateAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateAccessBindings_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_update_access_bindings", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchUpdateAccessBindings", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "BatchUpdateAccessBindings" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsResponse", + "shortName": "batch_update_access_bindings" + }, + "description": "Sample for BatchUpdateAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateAccessBindings_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_access_bindings_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.batch_update_user_links", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchUpdateUserLinks", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "BatchUpdateUserLinks" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse", + "shortName": "batch_update_user_links" + }, + "description": "Sample for BatchUpdateUserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_user_links_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateUserLinks_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_user_links_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_update_user_links", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.BatchUpdateUserLinks", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "BatchUpdateUserLinks" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.BatchUpdateUserLinksRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.BatchUpdateUserLinksResponse", + "shortName": "batch_update_user_links" + }, + "description": "Sample for BatchUpdateUserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_user_links_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_BatchUpdateUserLinks_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_batch_update_user_links_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.cancel_display_video360_advertiser_link_proposal", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CancelDisplayVideo360AdvertiserLinkProposal", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CancelDisplayVideo360AdvertiserLinkProposal" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CancelDisplayVideo360AdvertiserLinkProposalRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", + "shortName": "cancel_display_video360_advertiser_link_proposal" + }, + "description": "Sample for CancelDisplayVideo360AdvertiserLinkProposal", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_cancel_display_video360_advertiser_link_proposal_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CancelDisplayVideo360AdvertiserLinkProposal_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_cancel_display_video360_advertiser_link_proposal_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.cancel_display_video360_advertiser_link_proposal", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CancelDisplayVideo360AdvertiserLinkProposal", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CancelDisplayVideo360AdvertiserLinkProposal" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CancelDisplayVideo360AdvertiserLinkProposalRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", + "shortName": "cancel_display_video360_advertiser_link_proposal" + }, + "description": "Sample for CancelDisplayVideo360AdvertiserLinkProposal", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_cancel_display_video360_advertiser_link_proposal_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CancelDisplayVideo360AdvertiserLinkProposal_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_cancel_display_video360_advertiser_link_proposal_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_access_binding", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateAccessBinding", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateAccessBinding" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateAccessBindingRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "access_binding", + "type": "google.analytics.admin_v1alpha.types.AccessBinding" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", + "shortName": "create_access_binding" + }, + "description": "Sample for CreateAccessBinding", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAccessBinding_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_access_binding", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateAccessBinding", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateAccessBinding" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateAccessBindingRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "access_binding", + "type": "google.analytics.admin_v1alpha.types.AccessBinding" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", + "shortName": "create_access_binding" + }, + "description": "Sample for CreateAccessBinding", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAccessBinding_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_sync.py" }, { "canonical": true, @@ -1696,25 +2471,447 @@ }, "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_audience", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateAudience", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateAudience", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateAudience" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateAudienceRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "audience", + "type": "google.analytics.admin_v1alpha.types.Audience" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.Audience", + "shortName": "create_audience" + }, + "description": "Sample for CreateAudience", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_audience_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAudience_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 53, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 54, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_audience_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_audience", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateAudience", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateAudience" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateAudienceRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "audience", + "type": "google.analytics.admin_v1alpha.types.Audience" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.Audience", + "shortName": "create_audience" + }, + "description": "Sample for CreateAudience", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_audience_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAudience_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 53, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 54, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_audience_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_conversion_event", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateConversionEvent", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateConversionEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateConversionEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "conversion_event", + "type": "google.analytics.admin_v1alpha.types.ConversionEvent" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.ConversionEvent", + "shortName": "create_conversion_event" + }, + "description": "Sample for CreateConversionEvent", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_conversion_event_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateConversionEvent_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_conversion_event_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_conversion_event", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateConversionEvent", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateConversionEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateConversionEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "conversion_event", + "type": "google.analytics.admin_v1alpha.types.ConversionEvent" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.ConversionEvent", + "shortName": "create_conversion_event" + }, + "description": "Sample for CreateConversionEvent", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_conversion_event_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateConversionEvent_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_conversion_event_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_custom_dimension", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateCustomDimension", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateCustomDimension" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "custom_dimension", + "type": "google.analytics.admin_v1alpha.types.CustomDimension" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.CustomDimension", + "shortName": "create_custom_dimension" + }, + "description": "Sample for CreateCustomDimension", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_dimension_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateCustomDimension_async", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_dimension_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_custom_dimension", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateCustomDimension", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateAudience" + "shortName": "CreateCustomDimension" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateAudienceRequest" + "type": "google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest" }, { "name": "parent", "type": "str" }, { - "name": "audience", - "type": "google.analytics.admin_v1alpha.types.Audience" + "name": "custom_dimension", + "type": "google.analytics.admin_v1alpha.types.CustomDimension" }, { "name": "retry", @@ -1729,22 +2926,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.Audience", - "shortName": "create_audience" + "resultType": "google.analytics.admin_v1alpha.types.CustomDimension", + "shortName": "create_custom_dimension" }, - "description": "Sample for CreateAudience", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_audience_async.py", + "description": "Sample for CreateCustomDimension", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_dimension_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAudience_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateCustomDimension_sync", "segments": [ { - "end": 59, + "end": 57, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 57, "start": 27, "type": "SHORT" }, @@ -1754,22 +2951,107 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 53, + "end": 51, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 54, + "end": 54, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 58, + "start": 55, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_audience_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_dimension_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_custom_metric", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateCustomMetric", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateCustomMetric" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateCustomMetricRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "custom_metric", + "type": "google.analytics.admin_v1alpha.types.CustomMetric" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.CustomMetric", + "shortName": "create_custom_metric" + }, + "description": "Sample for CreateCustomMetric", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_metric_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateCustomMetric_async", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_metric_async.py" }, { "canonical": true, @@ -1778,27 +3060,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_audience", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_custom_metric", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateAudience", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateCustomMetric", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateAudience" + "shortName": "CreateCustomMetric" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateAudienceRequest" + "type": "google.analytics.admin_v1alpha.types.CreateCustomMetricRequest" }, { "name": "parent", "type": "str" }, { - "name": "audience", - "type": "google.analytics.admin_v1alpha.types.Audience" + "name": "custom_metric", + "type": "google.analytics.admin_v1alpha.types.CustomMetric" }, { "name": "retry", @@ -1813,22 +3095,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.Audience", - "shortName": "create_audience" + "resultType": "google.analytics.admin_v1alpha.types.CustomMetric", + "shortName": "create_custom_metric" }, - "description": "Sample for CreateAudience", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_audience_sync.py", + "description": "Sample for CreateCustomMetric", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_metric_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAudience_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateCustomMetric_sync", "segments": [ { - "end": 59, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 58, "start": 27, "type": "SHORT" }, @@ -1838,22 +3120,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 53, + "end": 52, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 54, + "end": 55, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_audience_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_metric_sync.py" }, { "canonical": true, @@ -1863,27 +3145,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_conversion_event", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_data_stream", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateConversionEvent", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDataStream", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateConversionEvent" + "shortName": "CreateDataStream" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateConversionEventRequest" + "type": "google.analytics.admin_v1alpha.types.CreateDataStreamRequest" }, { "name": "parent", "type": "str" }, { - "name": "conversion_event", - "type": "google.analytics.admin_v1alpha.types.ConversionEvent" + "name": "data_stream", + "type": "google.analytics.admin_v1alpha.types.DataStream" }, { "name": "retry", @@ -1898,22 +3180,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.ConversionEvent", - "shortName": "create_conversion_event" + "resultType": "google.analytics.admin_v1alpha.types.DataStream", + "shortName": "create_data_stream" }, - "description": "Sample for CreateConversionEvent", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_conversion_event_async.py", + "description": "Sample for CreateDataStream", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_data_stream_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateConversionEvent_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDataStream_async", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1923,22 +3205,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_conversion_event_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_data_stream_async.py" }, { "canonical": true, @@ -1947,27 +3229,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_conversion_event", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_data_stream", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateConversionEvent", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDataStream", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateConversionEvent" + "shortName": "CreateDataStream" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateConversionEventRequest" + "type": "google.analytics.admin_v1alpha.types.CreateDataStreamRequest" }, { "name": "parent", "type": "str" }, { - "name": "conversion_event", - "type": "google.analytics.admin_v1alpha.types.ConversionEvent" + "name": "data_stream", + "type": "google.analytics.admin_v1alpha.types.DataStream" }, { "name": "retry", @@ -1982,22 +3264,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.ConversionEvent", - "shortName": "create_conversion_event" + "resultType": "google.analytics.admin_v1alpha.types.DataStream", + "shortName": "create_data_stream" }, - "description": "Sample for CreateConversionEvent", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_conversion_event_sync.py", + "description": "Sample for CreateDataStream", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_data_stream_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateConversionEvent_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDataStream_sync", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -2007,22 +3289,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_conversion_event_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_data_stream_sync.py" }, { "canonical": true, @@ -2032,27 +3314,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_custom_dimension", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_display_video360_advertiser_link_proposal", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateCustomDimension", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDisplayVideo360AdvertiserLinkProposal", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateCustomDimension" + "shortName": "CreateDisplayVideo360AdvertiserLinkProposal" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest" + "type": "google.analytics.admin_v1alpha.types.CreateDisplayVideo360AdvertiserLinkProposalRequest" }, { "name": "parent", "type": "str" }, { - "name": "custom_dimension", - "type": "google.analytics.admin_v1alpha.types.CustomDimension" + "name": "display_video_360_advertiser_link_proposal", + "type": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal" }, { "name": "retry", @@ -2067,22 +3349,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.CustomDimension", - "shortName": "create_custom_dimension" + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", + "shortName": "create_display_video360_advertiser_link_proposal" }, - "description": "Sample for CreateCustomDimension", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_dimension_async.py", + "description": "Sample for CreateDisplayVideo360AdvertiserLinkProposal", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_proposal_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateCustomDimension_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDisplayVideo360AdvertiserLinkProposal_async", "segments": [ { - "end": 57, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 57, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2092,22 +3374,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 51, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 54, - "start": 52, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 58, - "start": 55, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_dimension_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_proposal_async.py" }, { "canonical": true, @@ -2116,27 +3398,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_custom_dimension", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_display_video360_advertiser_link_proposal", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateCustomDimension", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDisplayVideo360AdvertiserLinkProposal", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateCustomDimension" + "shortName": "CreateDisplayVideo360AdvertiserLinkProposal" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateCustomDimensionRequest" + "type": "google.analytics.admin_v1alpha.types.CreateDisplayVideo360AdvertiserLinkProposalRequest" }, { "name": "parent", "type": "str" }, { - "name": "custom_dimension", - "type": "google.analytics.admin_v1alpha.types.CustomDimension" + "name": "display_video_360_advertiser_link_proposal", + "type": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal" }, { "name": "retry", @@ -2151,22 +3433,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.CustomDimension", - "shortName": "create_custom_dimension" + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", + "shortName": "create_display_video360_advertiser_link_proposal" }, - "description": "Sample for CreateCustomDimension", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_dimension_sync.py", + "description": "Sample for CreateDisplayVideo360AdvertiserLinkProposal", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_proposal_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateCustomDimension_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDisplayVideo360AdvertiserLinkProposal_sync", "segments": [ { - "end": 57, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 57, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2176,22 +3458,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 51, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 54, - "start": 52, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 58, - "start": 55, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_dimension_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_proposal_sync.py" }, { "canonical": true, @@ -2201,27 +3483,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_custom_metric", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_display_video360_advertiser_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateCustomMetric", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDisplayVideo360AdvertiserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateCustomMetric" + "shortName": "CreateDisplayVideo360AdvertiserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateCustomMetricRequest" + "type": "google.analytics.admin_v1alpha.types.CreateDisplayVideo360AdvertiserLinkRequest" }, { "name": "parent", "type": "str" }, { - "name": "custom_metric", - "type": "google.analytics.admin_v1alpha.types.CustomMetric" + "name": "display_video_360_advertiser_link", + "type": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink" }, { "name": "retry", @@ -2236,22 +3518,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.CustomMetric", - "shortName": "create_custom_metric" + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink", + "shortName": "create_display_video360_advertiser_link" }, - "description": "Sample for CreateCustomMetric", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_metric_async.py", + "description": "Sample for CreateDisplayVideo360AdvertiserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateCustomMetric_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDisplayVideo360AdvertiserLink_async", "segments": [ { - "end": 58, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 58, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2261,22 +3543,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 52, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 55, - "start": 53, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 59, - "start": 56, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_metric_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_async.py" }, { "canonical": true, @@ -2285,27 +3567,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_custom_metric", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_display_video360_advertiser_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateCustomMetric", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDisplayVideo360AdvertiserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateCustomMetric" + "shortName": "CreateDisplayVideo360AdvertiserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateCustomMetricRequest" + "type": "google.analytics.admin_v1alpha.types.CreateDisplayVideo360AdvertiserLinkRequest" }, { "name": "parent", "type": "str" }, { - "name": "custom_metric", - "type": "google.analytics.admin_v1alpha.types.CustomMetric" + "name": "display_video_360_advertiser_link", + "type": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink" }, { "name": "retry", @@ -2320,22 +3602,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.CustomMetric", - "shortName": "create_custom_metric" + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink", + "shortName": "create_display_video360_advertiser_link" }, - "description": "Sample for CreateCustomMetric", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_metric_sync.py", + "description": "Sample for CreateDisplayVideo360AdvertiserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateCustomMetric_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDisplayVideo360AdvertiserLink_sync", "segments": [ { - "end": 58, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 58, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2345,22 +3627,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 52, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 55, - "start": 53, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 59, - "start": 56, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_custom_metric_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_sync.py" }, { "canonical": true, @@ -2370,27 +3652,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_data_stream", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_expanded_data_set", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDataStream", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateExpandedDataSet", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateDataStream" + "shortName": "CreateExpandedDataSet" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateDataStreamRequest" + "type": "google.analytics.admin_v1alpha.types.CreateExpandedDataSetRequest" }, { "name": "parent", "type": "str" }, { - "name": "data_stream", - "type": "google.analytics.admin_v1alpha.types.DataStream" + "name": "expanded_data_set", + "type": "google.analytics.admin_v1alpha.types.ExpandedDataSet" }, { "name": "retry", @@ -2405,14 +3687,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DataStream", - "shortName": "create_data_stream" + "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", + "shortName": "create_expanded_data_set" }, - "description": "Sample for CreateDataStream", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_data_stream_async.py", + "description": "Sample for CreateExpandedDataSet", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDataStream_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_async", "segments": [ { "end": 55, @@ -2445,7 +3727,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_data_stream_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_async.py" }, { "canonical": true, @@ -2454,27 +3736,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_data_stream", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_expanded_data_set", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDataStream", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateExpandedDataSet", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateDataStream" + "shortName": "CreateExpandedDataSet" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateDataStreamRequest" + "type": "google.analytics.admin_v1alpha.types.CreateExpandedDataSetRequest" }, { "name": "parent", "type": "str" }, { - "name": "data_stream", - "type": "google.analytics.admin_v1alpha.types.DataStream" + "name": "expanded_data_set", + "type": "google.analytics.admin_v1alpha.types.ExpandedDataSet" }, { "name": "retry", @@ -2489,14 +3771,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DataStream", - "shortName": "create_data_stream" + "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", + "shortName": "create_expanded_data_set" }, - "description": "Sample for CreateDataStream", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_data_stream_sync.py", + "description": "Sample for CreateExpandedDataSet", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDataStream_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_sync", "segments": [ { "end": 55, @@ -2529,7 +3811,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_data_stream_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_sync.py" }, { "canonical": true, @@ -2539,27 +3821,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_display_video360_advertiser_link_proposal", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_firebase_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDisplayVideo360AdvertiserLinkProposal", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateFirebaseLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateDisplayVideo360AdvertiserLinkProposal" + "shortName": "CreateFirebaseLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateDisplayVideo360AdvertiserLinkProposalRequest" + "type": "google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest" }, { "name": "parent", "type": "str" }, { - "name": "display_video_360_advertiser_link_proposal", - "type": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal" + "name": "firebase_link", + "type": "google.analytics.admin_v1alpha.types.FirebaseLink" }, { "name": "retry", @@ -2574,14 +3856,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", - "shortName": "create_display_video360_advertiser_link_proposal" + "resultType": "google.analytics.admin_v1alpha.types.FirebaseLink", + "shortName": "create_firebase_link" }, - "description": "Sample for CreateDisplayVideo360AdvertiserLinkProposal", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_proposal_async.py", + "description": "Sample for CreateFirebaseLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDisplayVideo360AdvertiserLinkProposal_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateFirebaseLink_async", "segments": [ { "end": 51, @@ -2614,7 +3896,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_proposal_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_async.py" }, { "canonical": true, @@ -2623,27 +3905,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_display_video360_advertiser_link_proposal", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_firebase_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDisplayVideo360AdvertiserLinkProposal", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateFirebaseLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateDisplayVideo360AdvertiserLinkProposal" + "shortName": "CreateFirebaseLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateDisplayVideo360AdvertiserLinkProposalRequest" + "type": "google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest" }, { "name": "parent", "type": "str" }, { - "name": "display_video_360_advertiser_link_proposal", - "type": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal" + "name": "firebase_link", + "type": "google.analytics.admin_v1alpha.types.FirebaseLink" }, { "name": "retry", @@ -2658,14 +3940,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", - "shortName": "create_display_video360_advertiser_link_proposal" + "resultType": "google.analytics.admin_v1alpha.types.FirebaseLink", + "shortName": "create_firebase_link" }, - "description": "Sample for CreateDisplayVideo360AdvertiserLinkProposal", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_proposal_sync.py", + "description": "Sample for CreateFirebaseLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDisplayVideo360AdvertiserLinkProposal_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateFirebaseLink_sync", "segments": [ { "end": 51, @@ -2698,7 +3980,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_proposal_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_sync.py" }, { "canonical": true, @@ -2708,27 +3990,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_display_video360_advertiser_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_google_ads_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDisplayVideo360AdvertiserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateGoogleAdsLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateDisplayVideo360AdvertiserLink" + "shortName": "CreateGoogleAdsLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateDisplayVideo360AdvertiserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest" }, { "name": "parent", "type": "str" }, { - "name": "display_video_360_advertiser_link", - "type": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink" + "name": "google_ads_link", + "type": "google.analytics.admin_v1alpha.types.GoogleAdsLink" }, { "name": "retry", @@ -2743,14 +4025,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink", - "shortName": "create_display_video360_advertiser_link" + "resultType": "google.analytics.admin_v1alpha.types.GoogleAdsLink", + "shortName": "create_google_ads_link" }, - "description": "Sample for CreateDisplayVideo360AdvertiserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_async.py", + "description": "Sample for CreateGoogleAdsLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_google_ads_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDisplayVideo360AdvertiserLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateGoogleAdsLink_async", "segments": [ { "end": 51, @@ -2783,7 +4065,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_google_ads_link_async.py" }, { "canonical": true, @@ -2792,27 +4074,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_display_video360_advertiser_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_google_ads_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateDisplayVideo360AdvertiserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateGoogleAdsLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateDisplayVideo360AdvertiserLink" + "shortName": "CreateGoogleAdsLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateDisplayVideo360AdvertiserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest" }, { "name": "parent", "type": "str" }, { - "name": "display_video_360_advertiser_link", - "type": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink" + "name": "google_ads_link", + "type": "google.analytics.admin_v1alpha.types.GoogleAdsLink" }, { "name": "retry", @@ -2827,14 +4109,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink", - "shortName": "create_display_video360_advertiser_link" + "resultType": "google.analytics.admin_v1alpha.types.GoogleAdsLink", + "shortName": "create_google_ads_link" }, - "description": "Sample for CreateDisplayVideo360AdvertiserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_sync.py", + "description": "Sample for CreateGoogleAdsLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_google_ads_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateDisplayVideo360AdvertiserLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateGoogleAdsLink_sync", "segments": [ { "end": 51, @@ -2867,7 +4149,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_display_video360_advertiser_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_google_ads_link_sync.py" }, { "canonical": true, @@ -2877,27 +4159,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_firebase_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_measurement_protocol_secret", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateFirebaseLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateMeasurementProtocolSecret", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateFirebaseLink" + "shortName": "CreateMeasurementProtocolSecret" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest" + "type": "google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest" }, { "name": "parent", "type": "str" }, { - "name": "firebase_link", - "type": "google.analytics.admin_v1alpha.types.FirebaseLink" + "name": "measurement_protocol_secret", + "type": "google.analytics.admin_v1alpha.types.MeasurementProtocolSecret" }, { "name": "retry", @@ -2912,22 +4194,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.FirebaseLink", - "shortName": "create_firebase_link" + "resultType": "google.analytics.admin_v1alpha.types.MeasurementProtocolSecret", + "shortName": "create_measurement_protocol_secret" }, - "description": "Sample for CreateFirebaseLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_async.py", + "description": "Sample for CreateMeasurementProtocolSecret", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_measurement_protocol_secret_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateFirebaseLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateMeasurementProtocolSecret_async", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -2937,22 +4219,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_measurement_protocol_secret_async.py" }, { "canonical": true, @@ -2961,27 +4243,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_firebase_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_measurement_protocol_secret", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateFirebaseLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateMeasurementProtocolSecret", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateFirebaseLink" + "shortName": "CreateMeasurementProtocolSecret" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest" + "type": "google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest" }, { "name": "parent", "type": "str" }, { - "name": "firebase_link", - "type": "google.analytics.admin_v1alpha.types.FirebaseLink" + "name": "measurement_protocol_secret", + "type": "google.analytics.admin_v1alpha.types.MeasurementProtocolSecret" }, { "name": "retry", @@ -2996,22 +4278,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.FirebaseLink", - "shortName": "create_firebase_link" + "resultType": "google.analytics.admin_v1alpha.types.MeasurementProtocolSecret", + "shortName": "create_measurement_protocol_secret" }, - "description": "Sample for CreateFirebaseLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_sync.py", + "description": "Sample for CreateMeasurementProtocolSecret", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_measurement_protocol_secret_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateFirebaseLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateMeasurementProtocolSecret_sync", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3021,22 +4303,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_measurement_protocol_secret_sync.py" }, { "canonical": true, @@ -3046,27 +4328,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_google_ads_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_property", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateGoogleAdsLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateProperty", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateGoogleAdsLink" + "shortName": "CreateProperty" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.analytics.admin_v1alpha.types.CreatePropertyRequest" }, { - "name": "google_ads_link", - "type": "google.analytics.admin_v1alpha.types.GoogleAdsLink" + "name": "property", + "type": "google.analytics.admin_v1alpha.types.Property" }, { "name": "retry", @@ -3081,22 +4359,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.GoogleAdsLink", - "shortName": "create_google_ads_link" + "resultType": "google.analytics.admin_v1alpha.types.Property", + "shortName": "create_property" }, - "description": "Sample for CreateGoogleAdsLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_google_ads_link_async.py", + "description": "Sample for CreateProperty", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_property_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateGoogleAdsLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateProperty_async", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3106,22 +4384,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_google_ads_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_property_async.py" }, { "canonical": true, @@ -3130,27 +4408,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_google_ads_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_property", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateGoogleAdsLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateProperty", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateGoogleAdsLink" + "shortName": "CreateProperty" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateGoogleAdsLinkRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.analytics.admin_v1alpha.types.CreatePropertyRequest" }, { - "name": "google_ads_link", - "type": "google.analytics.admin_v1alpha.types.GoogleAdsLink" + "name": "property", + "type": "google.analytics.admin_v1alpha.types.Property" }, { "name": "retry", @@ -3165,22 +4439,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.GoogleAdsLink", - "shortName": "create_google_ads_link" + "resultType": "google.analytics.admin_v1alpha.types.Property", + "shortName": "create_property" }, - "description": "Sample for CreateGoogleAdsLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_google_ads_link_sync.py", + "description": "Sample for CreateProperty", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_property_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateGoogleAdsLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateProperty_sync", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3190,22 +4464,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_google_ads_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_property_sync.py" }, { "canonical": true, @@ -3215,27 +4489,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_measurement_protocol_secret", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_search_ads360_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateMeasurementProtocolSecret", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateSearchAds360Link", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateMeasurementProtocolSecret" + "shortName": "CreateSearchAds360Link" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest" + "type": "google.analytics.admin_v1alpha.types.CreateSearchAds360LinkRequest" }, { "name": "parent", "type": "str" }, { - "name": "measurement_protocol_secret", - "type": "google.analytics.admin_v1alpha.types.MeasurementProtocolSecret" + "name": "search_ads_360_link", + "type": "google.analytics.admin_v1alpha.types.SearchAds360Link" }, { "name": "retry", @@ -3250,22 +4524,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.MeasurementProtocolSecret", - "shortName": "create_measurement_protocol_secret" + "resultType": "google.analytics.admin_v1alpha.types.SearchAds360Link", + "shortName": "create_search_ads360_link" }, - "description": "Sample for CreateMeasurementProtocolSecret", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_measurement_protocol_secret_async.py", + "description": "Sample for CreateSearchAds360Link", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_search_ads360_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateMeasurementProtocolSecret_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateSearchAds360Link_async", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3275,22 +4549,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 50, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_measurement_protocol_secret_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_search_ads360_link_async.py" }, { "canonical": true, @@ -3299,27 +4573,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_measurement_protocol_secret", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_search_ads360_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateMeasurementProtocolSecret", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateSearchAds360Link", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateMeasurementProtocolSecret" + "shortName": "CreateSearchAds360Link" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateMeasurementProtocolSecretRequest" + "type": "google.analytics.admin_v1alpha.types.CreateSearchAds360LinkRequest" }, { "name": "parent", "type": "str" }, { - "name": "measurement_protocol_secret", - "type": "google.analytics.admin_v1alpha.types.MeasurementProtocolSecret" + "name": "search_ads_360_link", + "type": "google.analytics.admin_v1alpha.types.SearchAds360Link" }, { "name": "retry", @@ -3334,22 +4608,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.MeasurementProtocolSecret", - "shortName": "create_measurement_protocol_secret" + "resultType": "google.analytics.admin_v1alpha.types.SearchAds360Link", + "shortName": "create_search_ads360_link" }, - "description": "Sample for CreateMeasurementProtocolSecret", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_measurement_protocol_secret_sync.py", + "description": "Sample for CreateSearchAds360Link", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_search_ads360_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateMeasurementProtocolSecret_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateSearchAds360Link_sync", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3359,22 +4633,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 50, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_measurement_protocol_secret_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_search_ads360_link_sync.py" }, { "canonical": true, @@ -3384,23 +4658,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_property", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_user_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateProperty", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateUserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateProperty" + "shortName": "CreateUserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreatePropertyRequest" + "type": "google.analytics.admin_v1alpha.types.CreateUserLinkRequest" }, { - "name": "property", - "type": "google.analytics.admin_v1alpha.types.Property" + "name": "parent", + "type": "str" + }, + { + "name": "user_link", + "type": "google.analytics.admin_v1alpha.types.UserLink" }, { "name": "retry", @@ -3415,22 +4693,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.Property", - "shortName": "create_property" + "resultType": "google.analytics.admin_v1alpha.types.UserLink", + "shortName": "create_user_link" }, - "description": "Sample for CreateProperty", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_property_async.py", + "description": "Sample for CreateUserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_user_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateProperty_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateUserLink_async", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3440,22 +4718,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 50, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_property_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_user_link_async.py" }, { "canonical": true, @@ -3464,23 +4742,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_property", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_user_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateProperty", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateUserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateProperty" + "shortName": "CreateUserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreatePropertyRequest" + "type": "google.analytics.admin_v1alpha.types.CreateUserLinkRequest" }, { - "name": "property", - "type": "google.analytics.admin_v1alpha.types.Property" + "name": "parent", + "type": "str" + }, + { + "name": "user_link", + "type": "google.analytics.admin_v1alpha.types.UserLink" }, { "name": "retry", @@ -3495,22 +4777,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.Property", - "shortName": "create_property" + "resultType": "google.analytics.admin_v1alpha.types.UserLink", + "shortName": "create_user_link" }, - "description": "Sample for CreateProperty", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_property_sync.py", + "description": "Sample for CreateUserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_user_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateProperty_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateUserLink_sync", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3520,22 +4802,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 50, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_property_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_user_link_sync.py" }, { "canonical": true, @@ -3545,28 +4827,24 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_search_ads360_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_access_binding", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateSearchAds360Link", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteAccessBinding", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateSearchAds360Link" + "shortName": "DeleteAccessBinding" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateSearchAds360LinkRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteAccessBindingRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, - { - "name": "search_ads_360_link", - "type": "google.analytics.admin_v1alpha.types.SearchAds360Link" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -3580,22 +4858,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.SearchAds360Link", - "shortName": "create_search_ads360_link" + "shortName": "delete_access_binding" }, - "description": "Sample for CreateSearchAds360Link", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_search_ads360_link_async.py", + "description": "Sample for DeleteAccessBinding", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateSearchAds360Link_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccessBinding_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3610,17 +4887,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_search_ads360_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_async.py" }, { "canonical": true, @@ -3629,28 +4904,24 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_search_ads360_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_access_binding", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateSearchAds360Link", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteAccessBinding", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateSearchAds360Link" + "shortName": "DeleteAccessBinding" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateSearchAds360LinkRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteAccessBindingRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, - { - "name": "search_ads_360_link", - "type": "google.analytics.admin_v1alpha.types.SearchAds360Link" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -3664,22 +4935,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.SearchAds360Link", - "shortName": "create_search_ads360_link" + "shortName": "delete_access_binding" }, - "description": "Sample for CreateSearchAds360Link", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_search_ads360_link_sync.py", + "description": "Sample for DeleteAccessBinding", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateSearchAds360Link_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccessBinding_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3694,17 +4964,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_search_ads360_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_access_binding_sync.py" }, { "canonical": true, @@ -3714,28 +4982,24 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_user_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_account", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateUserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteAccount", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateUserLink" + "shortName": "DeleteAccount" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateUserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteAccountRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, - { - "name": "user_link", - "type": "google.analytics.admin_v1alpha.types.UserLink" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -3749,22 +5013,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.UserLink", - "shortName": "create_user_link" + "shortName": "delete_account" }, - "description": "Sample for CreateUserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_user_link_async.py", + "description": "Sample for DeleteAccount", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_account_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateUserLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccount_async", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3779,17 +5042,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_user_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_account_async.py" }, { "canonical": true, @@ -3798,28 +5059,24 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_user_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_account", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateUserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteAccount", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateUserLink" + "shortName": "DeleteAccount" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateUserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteAccountRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, - { - "name": "user_link", - "type": "google.analytics.admin_v1alpha.types.UserLink" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -3833,22 +5090,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.UserLink", - "shortName": "create_user_link" + "shortName": "delete_account" }, - "description": "Sample for CreateUserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_user_link_sync.py", + "description": "Sample for DeleteAccount", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_account_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateUserLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccount_sync", "segments": [ { - "end": 51, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 49, "start": 27, "type": "SHORT" }, @@ -3863,17 +5119,15 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_user_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_account_sync.py" }, { "canonical": true, @@ -3883,19 +5137,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_account", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_conversion_event", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteAccount", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConversionEvent", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteAccount" + "shortName": "DeleteConversionEvent" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteAccountRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteConversionEventRequest" }, { "name": "name", @@ -3914,13 +5168,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_account" + "shortName": "delete_conversion_event" }, - "description": "Sample for DeleteAccount", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_account_async.py", + "description": "Sample for DeleteConversionEvent", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_conversion_event_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccount_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteConversionEvent_async", "segments": [ { "end": 49, @@ -3951,7 +5205,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_account_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_conversion_event_async.py" }, { "canonical": true, @@ -3960,19 +5214,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_account", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_conversion_event", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteAccount", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConversionEvent", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteAccount" + "shortName": "DeleteConversionEvent" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteAccountRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteConversionEventRequest" }, { "name": "name", @@ -3991,13 +5245,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_account" + "shortName": "delete_conversion_event" }, - "description": "Sample for DeleteAccount", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_account_sync.py", + "description": "Sample for DeleteConversionEvent", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_conversion_event_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAccount_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteConversionEvent_sync", "segments": [ { "end": 49, @@ -4028,7 +5282,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_account_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_conversion_event_sync.py" }, { "canonical": true, @@ -4038,19 +5292,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_conversion_event", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_data_stream", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConversionEvent", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDataStream", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteConversionEvent" + "shortName": "DeleteDataStream" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteConversionEventRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteDataStreamRequest" }, { "name": "name", @@ -4069,13 +5323,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_conversion_event" + "shortName": "delete_data_stream" }, - "description": "Sample for DeleteConversionEvent", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_conversion_event_async.py", + "description": "Sample for DeleteDataStream", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_data_stream_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteConversionEvent_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDataStream_async", "segments": [ { "end": 49, @@ -4106,7 +5360,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_conversion_event_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_data_stream_async.py" }, { "canonical": true, @@ -4115,19 +5369,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_conversion_event", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_data_stream", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConversionEvent", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDataStream", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteConversionEvent" + "shortName": "DeleteDataStream" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteConversionEventRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteDataStreamRequest" }, { "name": "name", @@ -4146,13 +5400,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_conversion_event" + "shortName": "delete_data_stream" }, - "description": "Sample for DeleteConversionEvent", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_conversion_event_sync.py", + "description": "Sample for DeleteDataStream", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_data_stream_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteConversionEvent_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDataStream_sync", "segments": [ { "end": 49, @@ -4183,7 +5437,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_conversion_event_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_data_stream_sync.py" }, { "canonical": true, @@ -4193,19 +5447,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_data_stream", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_display_video360_advertiser_link_proposal", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDataStream", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDisplayVideo360AdvertiserLinkProposal", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteDataStream" + "shortName": "DeleteDisplayVideo360AdvertiserLinkProposal" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteDataStreamRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteDisplayVideo360AdvertiserLinkProposalRequest" }, { "name": "name", @@ -4224,13 +5478,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_data_stream" + "shortName": "delete_display_video360_advertiser_link_proposal" }, - "description": "Sample for DeleteDataStream", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_data_stream_async.py", + "description": "Sample for DeleteDisplayVideo360AdvertiserLinkProposal", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_proposal_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDataStream_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDisplayVideo360AdvertiserLinkProposal_async", "segments": [ { "end": 49, @@ -4261,7 +5515,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_data_stream_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_proposal_async.py" }, { "canonical": true, @@ -4270,19 +5524,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_data_stream", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_display_video360_advertiser_link_proposal", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDataStream", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDisplayVideo360AdvertiserLinkProposal", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteDataStream" + "shortName": "DeleteDisplayVideo360AdvertiserLinkProposal" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteDataStreamRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteDisplayVideo360AdvertiserLinkProposalRequest" }, { "name": "name", @@ -4301,13 +5555,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_data_stream" + "shortName": "delete_display_video360_advertiser_link_proposal" }, - "description": "Sample for DeleteDataStream", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_data_stream_sync.py", + "description": "Sample for DeleteDisplayVideo360AdvertiserLinkProposal", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_proposal_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDataStream_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDisplayVideo360AdvertiserLinkProposal_sync", "segments": [ { "end": 49, @@ -4338,7 +5592,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_data_stream_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_proposal_sync.py" }, { "canonical": true, @@ -4348,19 +5602,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_display_video360_advertiser_link_proposal", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_display_video360_advertiser_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDisplayVideo360AdvertiserLinkProposal", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDisplayVideo360AdvertiserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteDisplayVideo360AdvertiserLinkProposal" + "shortName": "DeleteDisplayVideo360AdvertiserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteDisplayVideo360AdvertiserLinkProposalRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteDisplayVideo360AdvertiserLinkRequest" }, { "name": "name", @@ -4379,13 +5633,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_display_video360_advertiser_link_proposal" + "shortName": "delete_display_video360_advertiser_link" }, - "description": "Sample for DeleteDisplayVideo360AdvertiserLinkProposal", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_proposal_async.py", + "description": "Sample for DeleteDisplayVideo360AdvertiserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDisplayVideo360AdvertiserLinkProposal_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDisplayVideo360AdvertiserLink_async", "segments": [ { "end": 49, @@ -4416,7 +5670,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_proposal_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_async.py" }, { "canonical": true, @@ -4425,19 +5679,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_display_video360_advertiser_link_proposal", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_display_video360_advertiser_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDisplayVideo360AdvertiserLinkProposal", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDisplayVideo360AdvertiserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteDisplayVideo360AdvertiserLinkProposal" + "shortName": "DeleteDisplayVideo360AdvertiserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteDisplayVideo360AdvertiserLinkProposalRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteDisplayVideo360AdvertiserLinkRequest" }, { "name": "name", @@ -4456,13 +5710,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_display_video360_advertiser_link_proposal" + "shortName": "delete_display_video360_advertiser_link" }, - "description": "Sample for DeleteDisplayVideo360AdvertiserLinkProposal", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_proposal_sync.py", + "description": "Sample for DeleteDisplayVideo360AdvertiserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDisplayVideo360AdvertiserLinkProposal_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDisplayVideo360AdvertiserLink_sync", "segments": [ { "end": 49, @@ -4493,7 +5747,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_proposal_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_sync.py" }, { "canonical": true, @@ -4503,19 +5757,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_display_video360_advertiser_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_expanded_data_set", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDisplayVideo360AdvertiserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteExpandedDataSet", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteDisplayVideo360AdvertiserLink" + "shortName": "DeleteExpandedDataSet" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteDisplayVideo360AdvertiserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteExpandedDataSetRequest" }, { "name": "name", @@ -4534,13 +5788,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_display_video360_advertiser_link" + "shortName": "delete_expanded_data_set" }, - "description": "Sample for DeleteDisplayVideo360AdvertiserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_async.py", + "description": "Sample for DeleteExpandedDataSet", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDisplayVideo360AdvertiserLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteExpandedDataSet_async", "segments": [ { "end": 49, @@ -4571,7 +5825,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_async.py" }, { "canonical": true, @@ -4580,19 +5834,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_display_video360_advertiser_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_expanded_data_set", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteDisplayVideo360AdvertiserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteExpandedDataSet", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteDisplayVideo360AdvertiserLink" + "shortName": "DeleteExpandedDataSet" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteDisplayVideo360AdvertiserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteExpandedDataSetRequest" }, { "name": "name", @@ -4611,13 +5865,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_display_video360_advertiser_link" + "shortName": "delete_expanded_data_set" }, - "description": "Sample for DeleteDisplayVideo360AdvertiserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_sync.py", + "description": "Sample for DeleteExpandedDataSet", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteDisplayVideo360AdvertiserLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteExpandedDataSet_sync", "segments": [ { "end": 49, @@ -4648,7 +5902,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_display_video360_advertiser_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_expanded_data_set_sync.py" }, { "canonical": true, @@ -5398,7 +6652,162 @@ "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_search_ads360_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteSearchAds360Link_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteSearchAds360Link_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_search_ads360_link_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_user_link", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteUserLink", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "DeleteUserLink" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.DeleteUserLinkRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_user_link" + }, + "description": "Sample for DeleteUserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_user_link_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteUserLink_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_user_link_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_user_link", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteUserLink", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "DeleteUserLink" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.DeleteUserLinkRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_user_link" + }, + "description": "Sample for DeleteUserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_user_link_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteUserLink_sync", "segments": [ { "end": 49, @@ -5429,7 +6838,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_search_ads360_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_user_link_sync.py" }, { "canonical": true, @@ -5439,23 +6848,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_user_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.fetch_automated_ga4_configuration_opt_out", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteUserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.FetchAutomatedGa4ConfigurationOptOut", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteUserLink" + "shortName": "FetchAutomatedGa4ConfigurationOptOut" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteUserLinkRequest" - }, - { - "name": "name", - "type": "str" + "type": "google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutRequest" }, { "name": "retry", @@ -5470,21 +6875,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_user_link" + "resultType": "google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutResponse", + "shortName": "fetch_automated_ga4_configuration_opt_out" }, - "description": "Sample for DeleteUserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_user_link_async.py", + "description": "Sample for FetchAutomatedGa4ConfigurationOptOut", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_automated_ga4_configuration_opt_out_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteUserLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_FetchAutomatedGa4ConfigurationOptOut_async", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -5499,15 +6905,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_user_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_automated_ga4_configuration_opt_out_async.py" }, { "canonical": true, @@ -5516,23 +6924,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_user_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.fetch_automated_ga4_configuration_opt_out", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteUserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.FetchAutomatedGa4ConfigurationOptOut", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteUserLink" + "shortName": "FetchAutomatedGa4ConfigurationOptOut" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteUserLinkRequest" - }, - { - "name": "name", - "type": "str" + "type": "google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutRequest" }, { "name": "retry", @@ -5547,21 +6951,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_user_link" + "resultType": "google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutResponse", + "shortName": "fetch_automated_ga4_configuration_opt_out" }, - "description": "Sample for DeleteUserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_user_link_sync.py", + "description": "Sample for FetchAutomatedGa4ConfigurationOptOut", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_automated_ga4_configuration_opt_out_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteUserLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_FetchAutomatedGa4ConfigurationOptOut_sync", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -5576,15 +6981,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_user_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_automated_ga4_configuration_opt_out_sync.py" }, { "canonical": true, @@ -5594,19 +7001,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.fetch_automated_ga4_configuration_opt_out", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_access_binding", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.FetchAutomatedGa4ConfigurationOptOut", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccessBinding", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "FetchAutomatedGa4ConfigurationOptOut" + "shortName": "GetAccessBinding" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutRequest" + "type": "google.analytics.admin_v1alpha.types.GetAccessBindingRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -5621,14 +7032,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutResponse", - "shortName": "fetch_automated_ga4_configuration_opt_out" + "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", + "shortName": "get_access_binding" }, - "description": "Sample for FetchAutomatedGa4ConfigurationOptOut", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_automated_ga4_configuration_opt_out_async.py", + "description": "Sample for GetAccessBinding", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_FetchAutomatedGa4ConfigurationOptOut_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_async", "segments": [ { "end": 51, @@ -5661,7 +7072,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_automated_ga4_configuration_opt_out_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_async.py" }, { "canonical": true, @@ -5670,19 +7081,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.fetch_automated_ga4_configuration_opt_out", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_access_binding", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.FetchAutomatedGa4ConfigurationOptOut", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccessBinding", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "FetchAutomatedGa4ConfigurationOptOut" + "shortName": "GetAccessBinding" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutRequest" + "type": "google.analytics.admin_v1alpha.types.GetAccessBindingRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -5697,14 +7112,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutResponse", - "shortName": "fetch_automated_ga4_configuration_opt_out" + "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", + "shortName": "get_access_binding" }, - "description": "Sample for FetchAutomatedGa4ConfigurationOptOut", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_automated_ga4_configuration_opt_out_sync.py", + "description": "Sample for GetAccessBinding", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_FetchAutomatedGa4ConfigurationOptOut_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_sync", "segments": [ { "end": 51, @@ -5737,7 +7152,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_automated_ga4_configuration_opt_out_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_sync.py" }, { "canonical": true, @@ -7203,12 +8618,173 @@ "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetDataStream" + "shortName": "GetDataStream" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.GetDataStreamRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.DataStream", + "shortName": "get_data_stream" + }, + "description": "Sample for GetDataStream", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDataStream_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_data_stream", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDataStream", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "GetDataStream" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.GetDataStreamRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.DataStream", + "shortName": "get_data_stream" + }, + "description": "Sample for GetDataStream", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDataStream_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_display_video360_advertiser_link_proposal", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLinkProposal", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "GetDisplayVideo360AdvertiserLinkProposal" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetDataStreamRequest" + "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkProposalRequest" }, { "name": "name", @@ -7227,14 +8803,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DataStream", - "shortName": "get_data_stream" + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", + "shortName": "get_display_video360_advertiser_link_proposal" }, - "description": "Sample for GetDataStream", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_async.py", + "description": "Sample for GetDisplayVideo360AdvertiserLinkProposal", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_proposal_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDataStream_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLinkProposal_async", "segments": [ { "end": 51, @@ -7267,7 +8843,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_proposal_async.py" }, { "canonical": true, @@ -7276,19 +8852,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_data_stream", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_display_video360_advertiser_link_proposal", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDataStream", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLinkProposal", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetDataStream" + "shortName": "GetDisplayVideo360AdvertiserLinkProposal" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetDataStreamRequest" + "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkProposalRequest" }, { "name": "name", @@ -7307,14 +8883,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DataStream", - "shortName": "get_data_stream" + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", + "shortName": "get_display_video360_advertiser_link_proposal" }, - "description": "Sample for GetDataStream", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_sync.py", + "description": "Sample for GetDisplayVideo360AdvertiserLinkProposal", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_proposal_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDataStream_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLinkProposal_sync", "segments": [ { "end": 51, @@ -7347,7 +8923,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_proposal_sync.py" }, { "canonical": true, @@ -7357,19 +8933,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_display_video360_advertiser_link_proposal", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_display_video360_advertiser_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLinkProposal", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetDisplayVideo360AdvertiserLinkProposal" + "shortName": "GetDisplayVideo360AdvertiserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkProposalRequest" + "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkRequest" }, { "name": "name", @@ -7388,14 +8964,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", - "shortName": "get_display_video360_advertiser_link_proposal" + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink", + "shortName": "get_display_video360_advertiser_link" }, - "description": "Sample for GetDisplayVideo360AdvertiserLinkProposal", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_proposal_async.py", + "description": "Sample for GetDisplayVideo360AdvertiserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLinkProposal_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLink_async", "segments": [ { "end": 51, @@ -7428,7 +9004,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_proposal_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_async.py" }, { "canonical": true, @@ -7437,19 +9013,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_display_video360_advertiser_link_proposal", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_display_video360_advertiser_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLinkProposal", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetDisplayVideo360AdvertiserLinkProposal" + "shortName": "GetDisplayVideo360AdvertiserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkProposalRequest" + "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkRequest" }, { "name": "name", @@ -7468,14 +9044,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal", - "shortName": "get_display_video360_advertiser_link_proposal" + "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink", + "shortName": "get_display_video360_advertiser_link" }, - "description": "Sample for GetDisplayVideo360AdvertiserLinkProposal", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_proposal_sync.py", + "description": "Sample for GetDisplayVideo360AdvertiserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLinkProposal_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLink_sync", "segments": [ { "end": 51, @@ -7508,7 +9084,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_proposal_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_sync.py" }, { "canonical": true, @@ -7518,19 +9094,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_display_video360_advertiser_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_expanded_data_set", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetExpandedDataSet", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetDisplayVideo360AdvertiserLink" + "shortName": "GetExpandedDataSet" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.GetExpandedDataSetRequest" }, { "name": "name", @@ -7549,14 +9125,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink", - "shortName": "get_display_video360_advertiser_link" + "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", + "shortName": "get_expanded_data_set" }, - "description": "Sample for GetDisplayVideo360AdvertiserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_async.py", + "description": "Sample for GetExpandedDataSet", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetExpandedDataSet_async", "segments": [ { "end": 51, @@ -7589,7 +9165,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_async.py" }, { "canonical": true, @@ -7598,19 +9174,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_display_video360_advertiser_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_expanded_data_set", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetExpandedDataSet", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetDisplayVideo360AdvertiserLink" + "shortName": "GetExpandedDataSet" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.GetExpandedDataSetRequest" }, { "name": "name", @@ -7629,14 +9205,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink", - "shortName": "get_display_video360_advertiser_link" + "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", + "shortName": "get_expanded_data_set" }, - "description": "Sample for GetDisplayVideo360AdvertiserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_sync.py", + "description": "Sample for GetExpandedDataSet", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetExpandedDataSet_sync", "segments": [ { "end": 51, @@ -7669,7 +9245,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_expanded_data_set_sync.py" }, { "canonical": true, @@ -8244,17 +9820,178 @@ }, "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_property", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetProperty", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetProperty", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "GetProperty" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.GetPropertyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.Property", + "shortName": "get_property" + }, + "description": "Sample for GetProperty", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_property_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetProperty_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_property_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_search_ads360_link", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetSearchAds360Link", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "GetSearchAds360Link" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.GetSearchAds360LinkRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.SearchAds360Link", + "shortName": "get_search_ads360_link" + }, + "description": "Sample for GetSearchAds360Link", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_search_ads360_link_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetSearchAds360Link_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_search_ads360_link_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_search_ads360_link", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetSearchAds360Link", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetProperty" + "shortName": "GetSearchAds360Link" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetPropertyRequest" + "type": "google.analytics.admin_v1alpha.types.GetSearchAds360LinkRequest" }, { "name": "name", @@ -8273,14 +10010,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.Property", - "shortName": "get_property" + "resultType": "google.analytics.admin_v1alpha.types.SearchAds360Link", + "shortName": "get_search_ads360_link" }, - "description": "Sample for GetProperty", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_property_sync.py", + "description": "Sample for GetSearchAds360Link", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_search_ads360_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetProperty_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetSearchAds360Link_sync", "segments": [ { "end": 51, @@ -8313,7 +10050,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_property_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_search_ads360_link_sync.py" }, { "canonical": true, @@ -8323,19 +10060,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_search_ads360_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_user_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetSearchAds360Link", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetUserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetSearchAds360Link" + "shortName": "GetUserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetSearchAds360LinkRequest" + "type": "google.analytics.admin_v1alpha.types.GetUserLinkRequest" }, { "name": "name", @@ -8354,14 +10091,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.SearchAds360Link", - "shortName": "get_search_ads360_link" + "resultType": "google.analytics.admin_v1alpha.types.UserLink", + "shortName": "get_user_link" }, - "description": "Sample for GetSearchAds360Link", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_search_ads360_link_async.py", + "description": "Sample for GetUserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_user_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetSearchAds360Link_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetUserLink_async", "segments": [ { "end": 51, @@ -8394,7 +10131,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_search_ads360_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_user_link_async.py" }, { "canonical": true, @@ -8403,19 +10140,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_search_ads360_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_user_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetSearchAds360Link", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetUserLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetSearchAds360Link" + "shortName": "GetUserLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetSearchAds360LinkRequest" + "type": "google.analytics.admin_v1alpha.types.GetUserLinkRequest" }, { "name": "name", @@ -8434,14 +10171,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.SearchAds360Link", - "shortName": "get_search_ads360_link" + "resultType": "google.analytics.admin_v1alpha.types.UserLink", + "shortName": "get_user_link" }, - "description": "Sample for GetSearchAds360Link", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_search_ads360_link_sync.py", + "description": "Sample for GetUserLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_user_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetSearchAds360Link_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetUserLink_sync", "segments": [ { "end": 51, @@ -8474,7 +10211,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_search_ads360_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_user_link_sync.py" }, { "canonical": true, @@ -8484,22 +10221,22 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_user_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_access_bindings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetUserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccessBindings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetUserLink" + "shortName": "ListAccessBindings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetUserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.ListAccessBindingsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -8515,22 +10252,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.UserLink", - "shortName": "get_user_link" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccessBindingsAsyncPager", + "shortName": "list_access_bindings" }, - "description": "Sample for GetUserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_user_link_async.py", + "description": "Sample for ListAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetUserLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccessBindings_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -8550,12 +10287,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_user_link_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_async.py" }, { "canonical": true, @@ -8564,22 +10301,22 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_user_link", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_access_bindings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetUserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccessBindings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetUserLink" + "shortName": "ListAccessBindings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetUserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.ListAccessBindingsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -8595,22 +10332,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.UserLink", - "shortName": "get_user_link" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccessBindingsPager", + "shortName": "list_access_bindings" }, - "description": "Sample for GetUserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_user_link_sync.py", + "description": "Sample for ListAccessBindings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetUserLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccessBindings_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -8630,12 +10367,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_user_link_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_sync.py" }, { "canonical": true, @@ -9713,7 +11450,168 @@ "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_custom_metrics_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListCustomMetrics_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListCustomMetrics_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_custom_metrics_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_data_streams", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDataStreams", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "ListDataStreams" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.ListDataStreamsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDataStreamsAsyncPager", + "shortName": "list_data_streams" + }, + "description": "Sample for ListDataStreams", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_data_streams_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDataStreams_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_data_streams_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_data_streams", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDataStreams", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "ListDataStreams" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.ListDataStreamsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDataStreamsPager", + "shortName": "list_data_streams" + }, + "description": "Sample for ListDataStreams", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_data_streams_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDataStreams_sync", "segments": [ { "end": 52, @@ -9746,7 +11644,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_custom_metrics_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_data_streams_sync.py" }, { "canonical": true, @@ -9756,19 +11654,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_data_streams", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_display_video360_advertiser_link_proposals", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDataStreams", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinkProposals", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListDataStreams" + "shortName": "ListDisplayVideo360AdvertiserLinkProposals" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListDataStreamsRequest" + "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinkProposalsRequest" }, { "name": "parent", @@ -9787,14 +11685,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDataStreamsAsyncPager", - "shortName": "list_data_streams" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinkProposalsAsyncPager", + "shortName": "list_display_video360_advertiser_link_proposals" }, - "description": "Sample for ListDataStreams", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_data_streams_async.py", + "description": "Sample for ListDisplayVideo360AdvertiserLinkProposals", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_link_proposals_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDataStreams_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinkProposals_async", "segments": [ { "end": 52, @@ -9827,7 +11725,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_data_streams_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_link_proposals_async.py" }, { "canonical": true, @@ -9836,19 +11734,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_data_streams", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_display_video360_advertiser_link_proposals", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDataStreams", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinkProposals", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListDataStreams" + "shortName": "ListDisplayVideo360AdvertiserLinkProposals" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListDataStreamsRequest" + "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinkProposalsRequest" }, { "name": "parent", @@ -9867,14 +11765,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDataStreamsPager", - "shortName": "list_data_streams" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinkProposalsPager", + "shortName": "list_display_video360_advertiser_link_proposals" }, - "description": "Sample for ListDataStreams", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_data_streams_sync.py", + "description": "Sample for ListDisplayVideo360AdvertiserLinkProposals", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_link_proposals_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDataStreams_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinkProposals_sync", "segments": [ { "end": 52, @@ -9907,7 +11805,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_data_streams_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_link_proposals_sync.py" }, { "canonical": true, @@ -9917,19 +11815,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_display_video360_advertiser_link_proposals", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_display_video360_advertiser_links", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinkProposals", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinks", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListDisplayVideo360AdvertiserLinkProposals" + "shortName": "ListDisplayVideo360AdvertiserLinks" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinkProposalsRequest" + "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinksRequest" }, { "name": "parent", @@ -9948,14 +11846,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinkProposalsAsyncPager", - "shortName": "list_display_video360_advertiser_link_proposals" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinksAsyncPager", + "shortName": "list_display_video360_advertiser_links" }, - "description": "Sample for ListDisplayVideo360AdvertiserLinkProposals", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_link_proposals_async.py", + "description": "Sample for ListDisplayVideo360AdvertiserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinkProposals_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinks_async", "segments": [ { "end": 52, @@ -9988,7 +11886,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_link_proposals_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_async.py" }, { "canonical": true, @@ -9997,19 +11895,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_display_video360_advertiser_link_proposals", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_display_video360_advertiser_links", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinkProposals", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinks", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListDisplayVideo360AdvertiserLinkProposals" + "shortName": "ListDisplayVideo360AdvertiserLinks" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinkProposalsRequest" + "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinksRequest" }, { "name": "parent", @@ -10028,14 +11926,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinkProposalsPager", - "shortName": "list_display_video360_advertiser_link_proposals" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinksPager", + "shortName": "list_display_video360_advertiser_links" }, - "description": "Sample for ListDisplayVideo360AdvertiserLinkProposals", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_link_proposals_sync.py", + "description": "Sample for ListDisplayVideo360AdvertiserLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinkProposals_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinks_sync", "segments": [ { "end": 52, @@ -10068,7 +11966,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_link_proposals_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_sync.py" }, { "canonical": true, @@ -10078,19 +11976,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_display_video360_advertiser_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_expanded_data_sets", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListExpandedDataSets", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListDisplayVideo360AdvertiserLinks" + "shortName": "ListExpandedDataSets" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.ListExpandedDataSetsRequest" }, { "name": "parent", @@ -10109,14 +12007,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinksAsyncPager", - "shortName": "list_display_video360_advertiser_links" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListExpandedDataSetsAsyncPager", + "shortName": "list_expanded_data_sets" }, - "description": "Sample for ListDisplayVideo360AdvertiserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_async.py", + "description": "Sample for ListExpandedDataSets", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinks_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListExpandedDataSets_async", "segments": [ { "end": 52, @@ -10149,7 +12047,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_async.py" }, { "canonical": true, @@ -10158,19 +12056,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_display_video360_advertiser_links", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_expanded_data_sets", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListExpandedDataSets", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListDisplayVideo360AdvertiserLinks" + "shortName": "ListExpandedDataSets" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.ListExpandedDataSetsRequest" }, { "name": "parent", @@ -10189,14 +12087,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinksPager", - "shortName": "list_display_video360_advertiser_links" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListExpandedDataSetsPager", + "shortName": "list_expanded_data_sets" }, - "description": "Sample for ListDisplayVideo360AdvertiserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_sync.py", + "description": "Sample for ListExpandedDataSets", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinks_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListExpandedDataSets_sync", "segments": [ { "end": 52, @@ -10229,7 +12127,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_expanded_data_sets_sync.py" }, { "canonical": true, @@ -11488,12 +13386,165 @@ "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_run_access_report_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.search_change_history_events", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.SearchChangeHistoryEvents", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "SearchChangeHistoryEvents" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.SearchChangeHistoryEventsAsyncPager", + "shortName": "search_change_history_events" + }, + "description": "Sample for SearchChangeHistoryEvents", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_search_change_history_events_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_SearchChangeHistoryEvents_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_search_change_history_events_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.search_change_history_events", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.SearchChangeHistoryEvents", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "SearchChangeHistoryEvents" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.SearchChangeHistoryEventsPager", + "shortName": "search_change_history_events" + }, + "description": "Sample for SearchChangeHistoryEvents", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_search_change_history_events_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_SearchChangeHistoryEvents_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_run_access_report_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_search_change_history_events_sync.py" }, { "canonical": true, @@ -11503,19 +13554,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.search_change_history_events", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.set_automated_ga4_configuration_opt_out", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.SearchChangeHistoryEvents", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.SetAutomatedGa4ConfigurationOptOut", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "SearchChangeHistoryEvents" + "shortName": "SetAutomatedGa4ConfigurationOptOut" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest" + "type": "google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutRequest" }, { "name": "retry", @@ -11530,22 +13581,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.SearchChangeHistoryEventsAsyncPager", - "shortName": "search_change_history_events" + "resultType": "google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutResponse", + "shortName": "set_automated_ga4_configuration_opt_out" }, - "description": "Sample for SearchChangeHistoryEvents", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_search_change_history_events_async.py", + "description": "Sample for SetAutomatedGa4ConfigurationOptOut", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_set_automated_ga4_configuration_opt_out_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_SearchChangeHistoryEvents_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_SetAutomatedGa4ConfigurationOptOut_async", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -11565,12 +13616,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_search_change_history_events_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_set_automated_ga4_configuration_opt_out_async.py" }, { "canonical": true, @@ -11579,19 +13630,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.search_change_history_events", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.set_automated_ga4_configuration_opt_out", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.SearchChangeHistoryEvents", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.SetAutomatedGa4ConfigurationOptOut", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "SearchChangeHistoryEvents" + "shortName": "SetAutomatedGa4ConfigurationOptOut" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.SearchChangeHistoryEventsRequest" + "type": "google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutRequest" }, { "name": "retry", @@ -11606,22 +13657,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.SearchChangeHistoryEventsPager", - "shortName": "search_change_history_events" + "resultType": "google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutResponse", + "shortName": "set_automated_ga4_configuration_opt_out" }, - "description": "Sample for SearchChangeHistoryEvents", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_search_change_history_events_sync.py", + "description": "Sample for SetAutomatedGa4ConfigurationOptOut", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_set_automated_ga4_configuration_opt_out_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_SearchChangeHistoryEvents_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_SetAutomatedGa4ConfigurationOptOut_sync", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -11641,12 +13692,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_search_change_history_events_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_set_automated_ga4_configuration_opt_out_sync.py" }, { "canonical": true, @@ -11656,19 +13707,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.set_automated_ga4_configuration_opt_out", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.update_access_binding", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.SetAutomatedGa4ConfigurationOptOut", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.UpdateAccessBinding", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "SetAutomatedGa4ConfigurationOptOut" + "shortName": "UpdateAccessBinding" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutRequest" + "type": "google.analytics.admin_v1alpha.types.UpdateAccessBindingRequest" + }, + { + "name": "access_binding", + "type": "google.analytics.admin_v1alpha.types.AccessBinding" }, { "name": "retry", @@ -11683,22 +13738,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutResponse", - "shortName": "set_automated_ga4_configuration_opt_out" + "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", + "shortName": "update_access_binding" }, - "description": "Sample for SetAutomatedGa4ConfigurationOptOut", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_set_automated_ga4_configuration_opt_out_async.py", + "description": "Sample for UpdateAccessBinding", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_SetAutomatedGa4ConfigurationOptOut_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateAccessBinding_async", "segments": [ { - "end": 51, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 54, "start": 27, "type": "SHORT" }, @@ -11708,22 +13763,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_set_automated_ga4_configuration_opt_out_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_async.py" }, { "canonical": true, @@ -11732,19 +13787,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.set_automated_ga4_configuration_opt_out", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_access_binding", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.SetAutomatedGa4ConfigurationOptOut", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.UpdateAccessBinding", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "SetAutomatedGa4ConfigurationOptOut" + "shortName": "UpdateAccessBinding" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutRequest" + "type": "google.analytics.admin_v1alpha.types.UpdateAccessBindingRequest" + }, + { + "name": "access_binding", + "type": "google.analytics.admin_v1alpha.types.AccessBinding" }, { "name": "retry", @@ -11759,22 +13818,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutResponse", - "shortName": "set_automated_ga4_configuration_opt_out" + "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", + "shortName": "update_access_binding" }, - "description": "Sample for SetAutomatedGa4ConfigurationOptOut", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_set_automated_ga4_configuration_opt_out_sync.py", + "description": "Sample for UpdateAccessBinding", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_SetAutomatedGa4ConfigurationOptOut_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateAccessBinding_sync", "segments": [ { - "end": 51, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 54, "start": 27, "type": "SHORT" }, @@ -11784,22 +13843,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_set_automated_ga4_configuration_opt_out_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_access_binding_sync.py" }, { "canonical": true, @@ -13153,6 +15212,175 @@ ], "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_display_video360_advertiser_link_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.update_expanded_data_set", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.UpdateExpandedDataSet", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "UpdateExpandedDataSet" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.UpdateExpandedDataSetRequest" + }, + { + "name": "expanded_data_set", + "type": "google.analytics.admin_v1alpha.types.ExpandedDataSet" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", + "shortName": "update_expanded_data_set" + }, + "description": "Sample for UpdateExpandedDataSet", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateExpandedDataSet_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_expanded_data_set", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.UpdateExpandedDataSet", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "UpdateExpandedDataSet" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.UpdateExpandedDataSetRequest" + }, + { + "name": "expanded_data_set", + "type": "google.analytics.admin_v1alpha.types.ExpandedDataSet" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", + "shortName": "update_expanded_data_set" + }, + "description": "Sample for UpdateExpandedDataSet", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateExpandedDataSet_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_expanded_data_set_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/scripts/fixup_admin_v1alpha_keywords.py b/scripts/fixup_admin_v1alpha_keywords.py index e61df62c..4d829b4e 100644 --- a/scripts/fixup_admin_v1alpha_keywords.py +++ b/scripts/fixup_admin_v1alpha_keywords.py @@ -45,11 +45,16 @@ class adminCallTransformer(cst.CSTTransformer): 'archive_custom_dimension': ('name', ), 'archive_custom_metric': ('name', ), 'audit_user_links': ('parent', 'page_size', 'page_token', ), + 'batch_create_access_bindings': ('parent', 'requests', ), 'batch_create_user_links': ('parent', 'requests', 'notify_new_users', ), + 'batch_delete_access_bindings': ('parent', 'requests', ), 'batch_delete_user_links': ('parent', 'requests', ), + 'batch_get_access_bindings': ('parent', 'names', ), 'batch_get_user_links': ('parent', 'names', ), + 'batch_update_access_bindings': ('parent', 'requests', ), 'batch_update_user_links': ('parent', 'requests', ), 'cancel_display_video360_advertiser_link_proposal': ('name', ), + 'create_access_binding': ('parent', 'access_binding', ), 'create_audience': ('parent', 'audience', ), 'create_conversion_event': ('conversion_event', 'parent', ), 'create_custom_dimension': ('parent', 'custom_dimension', ), @@ -57,17 +62,20 @@ class adminCallTransformer(cst.CSTTransformer): 'create_data_stream': ('parent', 'data_stream', ), 'create_display_video360_advertiser_link': ('parent', 'display_video_360_advertiser_link', ), 'create_display_video360_advertiser_link_proposal': ('parent', 'display_video_360_advertiser_link_proposal', ), + 'create_expanded_data_set': ('parent', 'expanded_data_set', ), '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_search_ads360_link': ('parent', 'search_ads_360_link', ), 'create_user_link': ('parent', 'user_link', 'notify_new_user', ), + 'delete_access_binding': ('name', ), 'delete_account': ('name', ), 'delete_conversion_event': ('name', ), 'delete_data_stream': ('name', ), 'delete_display_video360_advertiser_link': ('name', ), 'delete_display_video360_advertiser_link_proposal': ('name', ), + 'delete_expanded_data_set': ('name', ), 'delete_firebase_link': ('name', ), 'delete_google_ads_link': ('name', ), 'delete_measurement_protocol_secret': ('name', ), @@ -75,6 +83,7 @@ class adminCallTransformer(cst.CSTTransformer): 'delete_search_ads360_link': ('name', ), 'delete_user_link': ('name', ), 'fetch_automated_ga4_configuration_opt_out': ('property', ), + 'get_access_binding': ('name', ), 'get_account': ('name', ), 'get_attribution_settings': ('name', ), 'get_audience': ('name', ), @@ -87,12 +96,14 @@ class adminCallTransformer(cst.CSTTransformer): 'get_data_stream': ('name', ), 'get_display_video360_advertiser_link': ('name', ), 'get_display_video360_advertiser_link_proposal': ('name', ), + 'get_expanded_data_set': ('name', ), 'get_global_site_tag': ('name', ), 'get_google_signals_settings': ('name', ), 'get_measurement_protocol_secret': ('name', ), 'get_property': ('name', ), 'get_search_ads360_link': ('name', ), 'get_user_link': ('name', ), + 'list_access_bindings': ('parent', 'page_size', 'page_token', ), 'list_accounts': ('page_size', 'page_token', 'show_deleted', ), 'list_account_summaries': ('page_size', 'page_token', ), 'list_audiences': ('parent', 'page_size', 'page_token', ), @@ -103,6 +114,7 @@ class adminCallTransformer(cst.CSTTransformer): 'list_data_streams': ('parent', 'page_size', 'page_token', ), 'list_display_video360_advertiser_link_proposals': ('parent', 'page_size', 'page_token', ), 'list_display_video360_advertiser_links': ('parent', 'page_size', 'page_token', ), + 'list_expanded_data_sets': ('parent', 'page_size', 'page_token', ), 'list_firebase_links': ('parent', 'page_size', 'page_token', ), 'list_google_ads_links': ('parent', 'page_size', 'page_token', ), 'list_measurement_protocol_secrets': ('parent', 'page_size', 'page_token', ), @@ -113,6 +125,7 @@ class adminCallTransformer(cst.CSTTransformer): 'run_access_report': ('entity', 'dimensions', 'metrics', 'date_ranges', 'dimension_filter', 'metric_filter', 'offset', 'limit', 'time_zone', 'order_bys', 'return_entity_quota', ), 'search_change_history_events': ('account', 'property', 'resource_type', 'action', 'actor_email', 'earliest_change_time', 'latest_change_time', 'page_size', 'page_token', ), 'set_automated_ga4_configuration_opt_out': ('property', 'opt_out', ), + 'update_access_binding': ('access_binding', ), 'update_account': ('account', 'update_mask', ), 'update_attribution_settings': ('attribution_settings', 'update_mask', ), 'update_audience': ('audience', 'update_mask', ), @@ -121,6 +134,7 @@ class adminCallTransformer(cst.CSTTransformer): 'update_data_retention_settings': ('data_retention_settings', 'update_mask', ), 'update_data_stream': ('update_mask', 'data_stream', ), 'update_display_video360_advertiser_link': ('update_mask', 'display_video_360_advertiser_link', ), + 'update_expanded_data_set': ('expanded_data_set', 'update_mask', ), 'update_google_ads_link': ('update_mask', 'google_ads_link', ), 'update_google_signals_settings': ('google_signals_settings', 'update_mask', ), 'update_measurement_protocol_secret': ('measurement_protocol_secret', 'update_mask', ), diff --git a/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py b/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py index 15f4570b..49b4e19a 100644 --- a/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +++ b/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py @@ -52,9 +52,13 @@ pagers, transports, ) +from google.analytics.admin_v1alpha.types import ( + expanded_data_set as gaa_expanded_data_set, +) from google.analytics.admin_v1alpha.types import access_report, analytics_admin from google.analytics.admin_v1alpha.types import audience from google.analytics.admin_v1alpha.types import audience as gaa_audience +from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources @@ -23880,11 +23884,11 @@ async def test_run_access_report_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, + analytics_admin.CreateAccessBindingRequest, dict, ], ) -def test_set_automated_ga4_configuration_opt_out(request_type, transport: str = "grpc"): +def test_create_access_binding(request_type, transport: str = "grpc"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -23896,24 +23900,28 @@ def test_set_automated_ga4_configuration_opt_out(request_type, transport: str = # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.set_automated_ga4_configuration_opt_out), "__call__" + type(client.transport.create_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() - response = client.set_automated_ga4_configuration_opt_out(request) + call.return_value = resources.AccessBinding( + name="name_value", + roles=["roles_value"], + user="user_value", + ) + response = client.create_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() + assert args[0] == analytics_admin.CreateAccessBindingRequest() # Establish that the response is the type that we expect. - assert isinstance( - response, analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse - ) + assert isinstance(response, resources.AccessBinding) + assert response.name == "name_value" + assert response.roles == ["roles_value"] -def test_set_automated_ga4_configuration_opt_out_empty_call(): +def test_create_access_binding_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( @@ -23923,18 +23931,18 @@ def test_set_automated_ga4_configuration_opt_out_empty_call(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.set_automated_ga4_configuration_opt_out), "__call__" + type(client.transport.create_access_binding), "__call__" ) as call: - client.set_automated_ga4_configuration_opt_out() + client.create_access_binding() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() + assert args[0] == analytics_admin.CreateAccessBindingRequest() @pytest.mark.asyncio -async def test_set_automated_ga4_configuration_opt_out_async( +async def test_create_access_binding_async( transport: str = "grpc_asyncio", - request_type=analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, + request_type=analytics_admin.CreateAccessBindingRequest, ): client = AnalyticsAdminServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -23947,142 +23955,202 @@ async def test_set_automated_ga4_configuration_opt_out_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.set_automated_ga4_configuration_opt_out), "__call__" + type(client.transport.create_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() + resources.AccessBinding( + name="name_value", + roles=["roles_value"], + ) ) - response = await client.set_automated_ga4_configuration_opt_out(request) + response = await client.create_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() + assert args[0] == analytics_admin.CreateAccessBindingRequest() # Establish that the response is the type that we expect. - assert isinstance( - response, analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse - ) + assert isinstance(response, resources.AccessBinding) + assert response.name == "name_value" + assert response.roles == ["roles_value"] @pytest.mark.asyncio -async def test_set_automated_ga4_configuration_opt_out_async_from_dict(): - await test_set_automated_ga4_configuration_opt_out_async(request_type=dict) +async def test_create_access_binding_async_from_dict(): + await test_create_access_binding_async(request_type=dict) -@pytest.mark.parametrize( - "request_type", - [ - analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, - dict, - ], -) -def test_fetch_automated_ga4_configuration_opt_out( - request_type, transport: str = "grpc" -): +def test_create_access_binding_field_headers(): 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() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateAccessBindingRequest() + + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.fetch_automated_ga4_configuration_opt_out), "__call__" + type(client.transport.create_access_binding), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = ( - analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse( - opt_out=True, - ) - ) - response = client.fetch_automated_ga4_configuration_opt_out(request) + call.return_value = resources.AccessBinding() + client.create_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() + assert args[0] == request - # Establish that the response is the type that we expect. - assert isinstance( - response, analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse + # 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_access_binding_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), ) - assert response.opt_out is True + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.CreateAccessBindingRequest() -def test_fetch_automated_ga4_configuration_opt_out_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_access_binding), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AccessBinding() + ) + await client.create_access_binding(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_access_binding_flattened(): 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.fetch_automated_ga4_configuration_opt_out), "__call__" + type(client.transport.create_access_binding), "__call__" ) as call: - client.fetch_automated_ga4_configuration_opt_out() - call.assert_called() + # Designate an appropriate return value for the call. + call.return_value = resources.AccessBinding() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_access_binding( + parent="parent_value", + access_binding=resources.AccessBinding(user="user_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] == analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].access_binding + mock_val = resources.AccessBinding(user="user_value") + assert arg == mock_val + + +def test_create_access_binding_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_access_binding( + analytics_admin.CreateAccessBindingRequest(), + parent="parent_value", + access_binding=resources.AccessBinding(user="user_value"), + ) @pytest.mark.asyncio -async def test_fetch_automated_ga4_configuration_opt_out_async( - transport: str = "grpc_asyncio", - request_type=analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, -): +async def test_create_access_binding_flattened_async(): 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.fetch_automated_ga4_configuration_opt_out), "__call__" + type(client.transport.create_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. + call.return_value = resources.AccessBinding() + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse( - opt_out=True, - ) + resources.AccessBinding() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_access_binding( + parent="parent_value", + access_binding=resources.AccessBinding(user="user_value"), ) - response = await client.fetch_automated_ga4_configuration_opt_out(request) - # Establish that the underlying gRPC stub method was called. + # 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] == analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() - - # Establish that the response is the type that we expect. - assert isinstance( - response, analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse - ) - assert response.opt_out is True + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].access_binding + mock_val = resources.AccessBinding(user="user_value") + assert arg == mock_val @pytest.mark.asyncio -async def test_fetch_automated_ga4_configuration_opt_out_async_from_dict(): - await test_fetch_automated_ga4_configuration_opt_out_async(request_type=dict) +async def test_create_access_binding_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_access_binding( + analytics_admin.CreateAccessBindingRequest(), + parent="parent_value", + access_binding=resources.AccessBinding(user="user_value"), + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetBigQueryLinkRequest, + analytics_admin.GetAccessBindingRequest, dict, ], ) -def test_get_big_query_link(request_type, transport: str = "grpc"): +def test_get_access_binding(request_type, transport: str = "grpc"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -24094,37 +24162,28 @@ def test_get_big_query_link(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_big_query_link), "__call__" + type(client.transport.get_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.BigQueryLink( + call.return_value = resources.AccessBinding( name="name_value", - project="project_value", - daily_export_enabled=True, - streaming_export_enabled=True, - include_advertising_id=True, - export_streams=["export_streams_value"], - excluded_events=["excluded_events_value"], + roles=["roles_value"], + user="user_value", ) - response = client.get_big_query_link(request) + response = client.get_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetBigQueryLinkRequest() + assert args[0] == analytics_admin.GetAccessBindingRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.BigQueryLink) + assert isinstance(response, resources.AccessBinding) assert response.name == "name_value" - assert response.project == "project_value" - assert response.daily_export_enabled is True - assert response.streaming_export_enabled is True - assert response.include_advertising_id is True - assert response.export_streams == ["export_streams_value"] - assert response.excluded_events == ["excluded_events_value"] + assert response.roles == ["roles_value"] -def test_get_big_query_link_empty_call(): +def test_get_access_binding_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( @@ -24134,17 +24193,18 @@ def test_get_big_query_link_empty_call(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_big_query_link), "__call__" + type(client.transport.get_access_binding), "__call__" ) as call: - client.get_big_query_link() + client.get_access_binding() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetBigQueryLinkRequest() + assert args[0] == analytics_admin.GetAccessBindingRequest() @pytest.mark.asyncio -async def test_get_big_query_link_async( - transport: str = "grpc_asyncio", request_type=analytics_admin.GetBigQueryLinkRequest +async def test_get_access_binding_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetAccessBindingRequest, ): client = AnalyticsAdminServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -24157,60 +24217,50 @@ async def test_get_big_query_link_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_big_query_link), "__call__" + type(client.transport.get_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.BigQueryLink( + resources.AccessBinding( name="name_value", - project="project_value", - daily_export_enabled=True, - streaming_export_enabled=True, - include_advertising_id=True, - export_streams=["export_streams_value"], - excluded_events=["excluded_events_value"], + roles=["roles_value"], ) ) - response = await client.get_big_query_link(request) + response = await client.get_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.GetBigQueryLinkRequest() + assert args[0] == analytics_admin.GetAccessBindingRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.BigQueryLink) + assert isinstance(response, resources.AccessBinding) assert response.name == "name_value" - assert response.project == "project_value" - assert response.daily_export_enabled is True - assert response.streaming_export_enabled is True - assert response.include_advertising_id is True - assert response.export_streams == ["export_streams_value"] - assert response.excluded_events == ["excluded_events_value"] + assert response.roles == ["roles_value"] @pytest.mark.asyncio -async def test_get_big_query_link_async_from_dict(): - await test_get_big_query_link_async(request_type=dict) +async def test_get_access_binding_async_from_dict(): + await test_get_access_binding_async(request_type=dict) -def test_get_big_query_link_field_headers(): +def test_get_access_binding_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.GetBigQueryLinkRequest() + request = analytics_admin.GetAccessBindingRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_big_query_link), "__call__" + type(client.transport.get_access_binding), "__call__" ) as call: - call.return_value = resources.BigQueryLink() - client.get_big_query_link(request) + call.return_value = resources.AccessBinding() + client.get_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -24226,25 +24276,25 @@ def test_get_big_query_link_field_headers(): @pytest.mark.asyncio -async def test_get_big_query_link_field_headers_async(): +async def test_get_access_binding_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.GetBigQueryLinkRequest() + request = analytics_admin.GetAccessBindingRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_big_query_link), "__call__" + type(client.transport.get_access_binding), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.BigQueryLink() + resources.AccessBinding() ) - await client.get_big_query_link(request) + await client.get_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -24259,20 +24309,20 @@ async def test_get_big_query_link_field_headers_async(): ) in kw["metadata"] -def test_get_big_query_link_flattened(): +def test_get_access_binding_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_big_query_link), "__call__" + type(client.transport.get_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.BigQueryLink() + call.return_value = resources.AccessBinding() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_big_query_link( + client.get_access_binding( name="name_value", ) @@ -24285,7 +24335,7 @@ def test_get_big_query_link_flattened(): assert arg == mock_val -def test_get_big_query_link_flattened_error(): +def test_get_access_binding_flattened_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -24293,31 +24343,31 @@ def test_get_big_query_link_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_big_query_link( - analytics_admin.GetBigQueryLinkRequest(), + client.get_access_binding( + analytics_admin.GetAccessBindingRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_get_big_query_link_flattened_async(): +async def test_get_access_binding_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_big_query_link), "__call__" + type(client.transport.get_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.BigQueryLink() + call.return_value = resources.AccessBinding() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.BigQueryLink() + resources.AccessBinding() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_big_query_link( + response = await client.get_access_binding( name="name_value", ) @@ -24331,7 +24381,7 @@ async def test_get_big_query_link_flattened_async(): @pytest.mark.asyncio -async def test_get_big_query_link_flattened_error_async(): +async def test_get_access_binding_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -24339,8 +24389,8 @@ async def test_get_big_query_link_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_big_query_link( - analytics_admin.GetBigQueryLinkRequest(), + await client.get_access_binding( + analytics_admin.GetAccessBindingRequest(), name="name_value", ) @@ -24348,11 +24398,11 @@ async def test_get_big_query_link_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListBigQueryLinksRequest, + analytics_admin.UpdateAccessBindingRequest, dict, ], ) -def test_list_big_query_links(request_type, transport: str = "grpc"): +def test_update_access_binding(request_type, transport: str = "grpc"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -24364,25 +24414,28 @@ def test_list_big_query_links(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_big_query_links), "__call__" + type(client.transport.update_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListBigQueryLinksResponse( - next_page_token="next_page_token_value", + call.return_value = resources.AccessBinding( + name="name_value", + roles=["roles_value"], + user="user_value", ) - response = client.list_big_query_links(request) + response = client.update_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListBigQueryLinksRequest() + assert args[0] == analytics_admin.UpdateAccessBindingRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBigQueryLinksPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.AccessBinding) + assert response.name == "name_value" + assert response.roles == ["roles_value"] -def test_list_big_query_links_empty_call(): +def test_update_access_binding_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AnalyticsAdminServiceClient( @@ -24392,18 +24445,18 @@ def test_list_big_query_links_empty_call(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_big_query_links), "__call__" + type(client.transport.update_access_binding), "__call__" ) as call: - client.list_big_query_links() + client.update_access_binding() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListBigQueryLinksRequest() + assert args[0] == analytics_admin.UpdateAccessBindingRequest() @pytest.mark.asyncio -async def test_list_big_query_links_async( +async def test_update_access_binding_async( transport: str = "grpc_asyncio", - request_type=analytics_admin.ListBigQueryLinksRequest, + request_type=analytics_admin.UpdateAccessBindingRequest, ): client = AnalyticsAdminServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -24416,48 +24469,50 @@ async def test_list_big_query_links_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_big_query_links), "__call__" + type(client.transport.update_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_admin.ListBigQueryLinksResponse( - next_page_token="next_page_token_value", + resources.AccessBinding( + name="name_value", + roles=["roles_value"], ) ) - response = await client.list_big_query_links(request) + response = await client.update_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == analytics_admin.ListBigQueryLinksRequest() + assert args[0] == analytics_admin.UpdateAccessBindingRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBigQueryLinksAsyncPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.AccessBinding) + assert response.name == "name_value" + assert response.roles == ["roles_value"] @pytest.mark.asyncio -async def test_list_big_query_links_async_from_dict(): - await test_list_big_query_links_async(request_type=dict) +async def test_update_access_binding_async_from_dict(): + await test_update_access_binding_async(request_type=dict) -def test_list_big_query_links_field_headers(): +def test_update_access_binding_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.ListBigQueryLinksRequest() + request = analytics_admin.UpdateAccessBindingRequest() - request.parent = "parent_value" + request.access_binding.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_big_query_links), "__call__" + type(client.transport.update_access_binding), "__call__" ) as call: - call.return_value = analytics_admin.ListBigQueryLinksResponse() - client.list_big_query_links(request) + call.return_value = resources.AccessBinding() + client.update_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -24468,30 +24523,30 @@ def test_list_big_query_links_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "access_binding.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_list_big_query_links_field_headers_async(): +async def test_update_access_binding_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.ListBigQueryLinksRequest() + request = analytics_admin.UpdateAccessBindingRequest() - request.parent = "parent_value" + request.access_binding.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_big_query_links), "__call__" + type(client.transport.update_access_binding), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_admin.ListBigQueryLinksResponse() + resources.AccessBinding() ) - await client.list_big_query_links(request) + await client.update_access_binding(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -24502,37 +24557,37 @@ async def test_list_big_query_links_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "access_binding.name=name_value", ) in kw["metadata"] -def test_list_big_query_links_flattened(): +def test_update_access_binding_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_big_query_links), "__call__" + type(client.transport.update_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListBigQueryLinksResponse() + call.return_value = resources.AccessBinding() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_big_query_links( - parent="parent_value", + client.update_access_binding( + access_binding=resources.AccessBinding(user="user_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] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].access_binding + mock_val = resources.AccessBinding(user="user_value") assert arg == mock_val -def test_list_big_query_links_flattened_error(): +def test_update_access_binding_flattened_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -24540,45 +24595,45 @@ def test_list_big_query_links_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_big_query_links( - analytics_admin.ListBigQueryLinksRequest(), - parent="parent_value", + client.update_access_binding( + analytics_admin.UpdateAccessBindingRequest(), + access_binding=resources.AccessBinding(user="user_value"), ) @pytest.mark.asyncio -async def test_list_big_query_links_flattened_async(): +async def test_update_access_binding_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_big_query_links), "__call__" + type(client.transport.update_access_binding), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = analytics_admin.ListBigQueryLinksResponse() + call.return_value = resources.AccessBinding() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_admin.ListBigQueryLinksResponse() + resources.AccessBinding() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_big_query_links( - parent="parent_value", + response = await client.update_access_binding( + access_binding=resources.AccessBinding(user="user_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].access_binding + mock_val = resources.AccessBinding(user="user_value") assert arg == mock_val @pytest.mark.asyncio -async def test_list_big_query_links_flattened_error_async(): +async def test_update_access_binding_flattened_error_async(): client = AnalyticsAdminServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -24586,204 +24641,7602 @@ async def test_list_big_query_links_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_big_query_links( - analytics_admin.ListBigQueryLinksRequest(), - parent="parent_value", + await client.update_access_binding( + analytics_admin.UpdateAccessBindingRequest(), + access_binding=resources.AccessBinding(user="user_value"), ) -def test_list_big_query_links_pager(transport_name: str = "grpc"): +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.DeleteAccessBindingRequest, + dict, + ], +) +def test_delete_access_binding(request_type, transport: str = "grpc"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_big_query_links), "__call__" + type(client.transport.delete_access_binding), "__call__" ) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), - resources.BigQueryLink(), - ], - next_page_token="abc", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[], - next_page_token="def", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - ], - next_page_token="ghi", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_big_query_links(request={}) + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_access_binding(request) - assert pager._metadata == metadata + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteAccessBindingRequest() - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.BigQueryLink) for i in results) + # Establish that the response is the type that we expect. + assert response is None -def test_list_big_query_links_pages(transport_name: str = "grpc"): +def test_delete_access_binding_empty_call(): + # This test 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=transport_name, + 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_big_query_links), "__call__" + type(client.transport.delete_access_binding), "__call__" ) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), - resources.BigQueryLink(), - ], - next_page_token="abc", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[], - next_page_token="def", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - ], - next_page_token="ghi", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), - ], - ), - RuntimeError, - ) - pages = list(client.list_big_query_links(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + client.delete_access_binding() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteAccessBindingRequest() @pytest.mark.asyncio -async def test_list_big_query_links_async_pager(): +async def test_delete_access_binding_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteAccessBindingRequest, +): client = AnalyticsAdminServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_big_query_links), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.delete_access_binding), "__call__" ) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), - resources.BigQueryLink(), - ], - next_page_token="abc", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[], - next_page_token="def", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - ], - next_page_token="ghi", - ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_big_query_links( - request={}, - ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_access_binding(request) - assert len(responses) == 6 - assert all(isinstance(i, resources.BigQueryLink) for i in responses) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteAccessBindingRequest() + + # Establish that the response is the type that we expect. + assert response is None @pytest.mark.asyncio -async def test_list_big_query_links_async_pages(): +async def test_delete_access_binding_async_from_dict(): + await test_delete_access_binding_async(request_type=dict) + + +def test_delete_access_binding_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.DeleteAccessBindingRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_access_binding), "__call__" + ) as call: + call.return_value = None + client.delete_access_binding(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_access_binding_field_headers_async(): client = AnalyticsAdminServiceAsyncClient( - credentials=ga_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.DeleteAccessBindingRequest() + + request.name = "name_value" + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_big_query_links), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.delete_access_binding), "__call__" ) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_admin.ListBigQueryLinksResponse( + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_access_binding(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_access_binding_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_access_binding), "__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_access_binding( + 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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_access_binding_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_access_binding( + analytics_admin.DeleteAccessBindingRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_access_binding_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_access_binding), "__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_access_binding( + 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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_access_binding_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_access_binding( + analytics_admin.DeleteAccessBindingRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListAccessBindingsRequest, + dict, + ], +) +def test_list_access_bindings(request_type, transport: str = "grpc"): + 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_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAccessBindingsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAccessBindingsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_access_bindings_empty_call(): + # This test 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_access_bindings), "__call__" + ) as call: + client.list_access_bindings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListAccessBindingsRequest() + + +@pytest.mark.asyncio +async def test_list_access_bindings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListAccessBindingsRequest, +): + 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_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListAccessBindingsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAccessBindingsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_access_bindings_async_from_dict(): + await test_list_access_bindings_async(request_type=dict) + + +def test_list_access_bindings_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.ListAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_access_bindings), "__call__" + ) as call: + call.return_value = analytics_admin.ListAccessBindingsResponse() + client.list_access_bindings(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_access_bindings_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.ListAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_access_bindings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListAccessBindingsResponse() + ) + await client.list_access_bindings(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_access_bindings_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_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAccessBindingsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_access_bindings( + 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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_access_bindings_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_access_bindings( + analytics_admin.ListAccessBindingsRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_access_bindings_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_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAccessBindingsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListAccessBindingsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_access_bindings( + 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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_access_bindings_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_access_bindings( + analytics_admin.ListAccessBindingsRequest(), + parent="parent_value", + ) + + +def test_list_access_bindings_pager(transport_name: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_access_bindings), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + resources.AccessBinding(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[], + next_page_token="def", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_access_bindings(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.AccessBinding) for i in results) + + +def test_list_access_bindings_pages(transport_name: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_access_bindings), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + resources.AccessBinding(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[], + next_page_token="def", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + ], + ), + RuntimeError, + ) + pages = list(client.list_access_bindings(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_access_bindings_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_access_bindings), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + resources.AccessBinding(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[], + next_page_token="def", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_access_bindings( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.AccessBinding) for i in responses) + + +@pytest.mark.asyncio +async def test_list_access_bindings_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_access_bindings), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + resources.AccessBinding(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[], + next_page_token="def", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_access_bindings(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.BatchCreateAccessBindingsRequest, + dict, + ], +) +def test_batch_create_access_bindings(request_type, transport: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.BatchCreateAccessBindingsResponse() + response = client.batch_create_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchCreateAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchCreateAccessBindingsResponse) + + +def test_batch_create_access_bindings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_access_bindings), "__call__" + ) as call: + client.batch_create_access_bindings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchCreateAccessBindingsRequest() + + +@pytest.mark.asyncio +async def test_batch_create_access_bindings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.BatchCreateAccessBindingsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.BatchCreateAccessBindingsResponse() + ) + response = await client.batch_create_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchCreateAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchCreateAccessBindingsResponse) + + +@pytest.mark.asyncio +async def test_batch_create_access_bindings_async_from_dict(): + await test_batch_create_access_bindings_async(request_type=dict) + + +def test_batch_create_access_bindings_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.BatchCreateAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_access_bindings), "__call__" + ) as call: + call.return_value = analytics_admin.BatchCreateAccessBindingsResponse() + client.batch_create_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_batch_create_access_bindings_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.BatchCreateAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_access_bindings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.BatchCreateAccessBindingsResponse() + ) + await client.batch_create_access_bindings(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"] + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.BatchGetAccessBindingsRequest, + dict, + ], +) +def test_batch_get_access_bindings(request_type, transport: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.BatchGetAccessBindingsResponse() + response = client.batch_get_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchGetAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchGetAccessBindingsResponse) + + +def test_batch_get_access_bindings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_access_bindings), "__call__" + ) as call: + client.batch_get_access_bindings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchGetAccessBindingsRequest() + + +@pytest.mark.asyncio +async def test_batch_get_access_bindings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.BatchGetAccessBindingsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.BatchGetAccessBindingsResponse() + ) + response = await client.batch_get_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchGetAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchGetAccessBindingsResponse) + + +@pytest.mark.asyncio +async def test_batch_get_access_bindings_async_from_dict(): + await test_batch_get_access_bindings_async(request_type=dict) + + +def test_batch_get_access_bindings_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.BatchGetAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_access_bindings), "__call__" + ) as call: + call.return_value = analytics_admin.BatchGetAccessBindingsResponse() + client.batch_get_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_batch_get_access_bindings_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.BatchGetAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_get_access_bindings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.BatchGetAccessBindingsResponse() + ) + await client.batch_get_access_bindings(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"] + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.BatchUpdateAccessBindingsRequest, + dict, + ], +) +def test_batch_update_access_bindings(request_type, transport: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.BatchUpdateAccessBindingsResponse() + response = client.batch_update_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchUpdateAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchUpdateAccessBindingsResponse) + + +def test_batch_update_access_bindings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_access_bindings), "__call__" + ) as call: + client.batch_update_access_bindings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchUpdateAccessBindingsRequest() + + +@pytest.mark.asyncio +async def test_batch_update_access_bindings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.BatchUpdateAccessBindingsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.BatchUpdateAccessBindingsResponse() + ) + response = await client.batch_update_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchUpdateAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchUpdateAccessBindingsResponse) + + +@pytest.mark.asyncio +async def test_batch_update_access_bindings_async_from_dict(): + await test_batch_update_access_bindings_async(request_type=dict) + + +def test_batch_update_access_bindings_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.BatchUpdateAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_access_bindings), "__call__" + ) as call: + call.return_value = analytics_admin.BatchUpdateAccessBindingsResponse() + client.batch_update_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_batch_update_access_bindings_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.BatchUpdateAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_update_access_bindings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.BatchUpdateAccessBindingsResponse() + ) + await client.batch_update_access_bindings(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"] + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.BatchDeleteAccessBindingsRequest, + dict, + ], +) +def test_batch_delete_access_bindings(request_type, transport: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.batch_delete_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchDeleteAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_batch_delete_access_bindings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_access_bindings), "__call__" + ) as call: + client.batch_delete_access_bindings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchDeleteAccessBindingsRequest() + + +@pytest.mark.asyncio +async def test_batch_delete_access_bindings_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.BatchDeleteAccessBindingsRequest, +): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_access_bindings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.batch_delete_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.BatchDeleteAccessBindingsRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_batch_delete_access_bindings_async_from_dict(): + await test_batch_delete_access_bindings_async(request_type=dict) + + +def test_batch_delete_access_bindings_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.BatchDeleteAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_access_bindings), "__call__" + ) as call: + call.return_value = None + client.batch_delete_access_bindings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_batch_delete_access_bindings_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.BatchDeleteAccessBindingsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_access_bindings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.batch_delete_access_bindings(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"] + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.GetExpandedDataSetRequest, + dict, + ], +) +def test_get_expanded_data_set(request_type, transport: str = "grpc"): + 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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = expanded_data_set.ExpandedDataSet( + name="name_value", + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], + ) + response = client.get_expanded_data_set(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetExpandedDataSetRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, expanded_data_set.ExpandedDataSet) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] + + +def test_get_expanded_data_set_empty_call(): + # This test 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_expanded_data_set), "__call__" + ) as call: + client.get_expanded_data_set() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetExpandedDataSetRequest() + + +@pytest.mark.asyncio +async def test_get_expanded_data_set_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetExpandedDataSetRequest, +): + 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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + expanded_data_set.ExpandedDataSet( + name="name_value", + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], + ) + ) + response = await client.get_expanded_data_set(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetExpandedDataSetRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, expanded_data_set.ExpandedDataSet) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] + + +@pytest.mark.asyncio +async def test_get_expanded_data_set_async_from_dict(): + await test_get_expanded_data_set_async(request_type=dict) + + +def test_get_expanded_data_set_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.GetExpandedDataSetRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_expanded_data_set), "__call__" + ) as call: + call.return_value = expanded_data_set.ExpandedDataSet() + client.get_expanded_data_set(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_expanded_data_set_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.GetExpandedDataSetRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_expanded_data_set), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + expanded_data_set.ExpandedDataSet() + ) + await client.get_expanded_data_set(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_expanded_data_set_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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = expanded_data_set.ExpandedDataSet() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_expanded_data_set( + 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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_expanded_data_set_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_expanded_data_set( + analytics_admin.GetExpandedDataSetRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_expanded_data_set_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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = expanded_data_set.ExpandedDataSet() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + expanded_data_set.ExpandedDataSet() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_expanded_data_set( + 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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_expanded_data_set_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_expanded_data_set( + analytics_admin.GetExpandedDataSetRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListExpandedDataSetsRequest, + dict, + ], +) +def test_list_expanded_data_sets(request_type, transport: str = "grpc"): + 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_expanded_data_sets), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListExpandedDataSetsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_expanded_data_sets(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListExpandedDataSetsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListExpandedDataSetsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_expanded_data_sets_empty_call(): + # This test 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_expanded_data_sets), "__call__" + ) as call: + client.list_expanded_data_sets() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListExpandedDataSetsRequest() + + +@pytest.mark.asyncio +async def test_list_expanded_data_sets_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListExpandedDataSetsRequest, +): + 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_expanded_data_sets), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListExpandedDataSetsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_expanded_data_sets(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListExpandedDataSetsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListExpandedDataSetsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_expanded_data_sets_async_from_dict(): + await test_list_expanded_data_sets_async(request_type=dict) + + +def test_list_expanded_data_sets_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.ListExpandedDataSetsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_expanded_data_sets), "__call__" + ) as call: + call.return_value = analytics_admin.ListExpandedDataSetsResponse() + client.list_expanded_data_sets(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_expanded_data_sets_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.ListExpandedDataSetsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_expanded_data_sets), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListExpandedDataSetsResponse() + ) + await client.list_expanded_data_sets(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_expanded_data_sets_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_expanded_data_sets), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListExpandedDataSetsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_expanded_data_sets( + 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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_expanded_data_sets_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_expanded_data_sets( + analytics_admin.ListExpandedDataSetsRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_expanded_data_sets_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_expanded_data_sets), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListExpandedDataSetsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListExpandedDataSetsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_expanded_data_sets( + 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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_expanded_data_sets_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_expanded_data_sets( + analytics_admin.ListExpandedDataSetsRequest(), + parent="parent_value", + ) + + +def test_list_expanded_data_sets_pager(transport_name: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_expanded_data_sets), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="abc", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[], + next_page_token="def", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="ghi", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_expanded_data_sets(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, expanded_data_set.ExpandedDataSet) for i in results) + + +def test_list_expanded_data_sets_pages(transport_name: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_expanded_data_sets), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="abc", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[], + next_page_token="def", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="ghi", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + ), + RuntimeError, + ) + pages = list(client.list_expanded_data_sets(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_expanded_data_sets_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_expanded_data_sets), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="abc", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[], + next_page_token="def", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="ghi", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_expanded_data_sets( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, expanded_data_set.ExpandedDataSet) for i in responses) + + +@pytest.mark.asyncio +async def test_list_expanded_data_sets_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_expanded_data_sets), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="abc", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[], + next_page_token="def", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="ghi", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_expanded_data_sets(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.CreateExpandedDataSetRequest, + dict, + ], +) +def test_create_expanded_data_set(request_type, transport: str = "grpc"): + 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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gaa_expanded_data_set.ExpandedDataSet( + name="name_value", + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], + ) + response = client.create_expanded_data_set(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateExpandedDataSetRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gaa_expanded_data_set.ExpandedDataSet) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] + + +def test_create_expanded_data_set_empty_call(): + # This test 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_expanded_data_set), "__call__" + ) as call: + client.create_expanded_data_set() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateExpandedDataSetRequest() + + +@pytest.mark.asyncio +async def test_create_expanded_data_set_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateExpandedDataSetRequest, +): + 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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gaa_expanded_data_set.ExpandedDataSet( + name="name_value", + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], + ) + ) + response = await client.create_expanded_data_set(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateExpandedDataSetRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gaa_expanded_data_set.ExpandedDataSet) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] + + +@pytest.mark.asyncio +async def test_create_expanded_data_set_async_from_dict(): + await test_create_expanded_data_set_async(request_type=dict) + + +def test_create_expanded_data_set_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.CreateExpandedDataSetRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_expanded_data_set), "__call__" + ) as call: + call.return_value = gaa_expanded_data_set.ExpandedDataSet() + client.create_expanded_data_set(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_expanded_data_set_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.CreateExpandedDataSetRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_expanded_data_set), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gaa_expanded_data_set.ExpandedDataSet() + ) + await client.create_expanded_data_set(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_expanded_data_set_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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gaa_expanded_data_set.ExpandedDataSet() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_expanded_data_set( + parent="parent_value", + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].expanded_data_set + mock_val = gaa_expanded_data_set.ExpandedDataSet(name="name_value") + assert arg == mock_val + + +def test_create_expanded_data_set_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_expanded_data_set( + analytics_admin.CreateExpandedDataSetRequest(), + parent="parent_value", + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_expanded_data_set_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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gaa_expanded_data_set.ExpandedDataSet() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gaa_expanded_data_set.ExpandedDataSet() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_expanded_data_set( + parent="parent_value", + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].expanded_data_set + mock_val = gaa_expanded_data_set.ExpandedDataSet(name="name_value") + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_expanded_data_set_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_expanded_data_set( + analytics_admin.CreateExpandedDataSetRequest(), + parent="parent_value", + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.UpdateExpandedDataSetRequest, + dict, + ], +) +def test_update_expanded_data_set(request_type, transport: str = "grpc"): + 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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gaa_expanded_data_set.ExpandedDataSet( + name="name_value", + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], + ) + response = client.update_expanded_data_set(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateExpandedDataSetRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gaa_expanded_data_set.ExpandedDataSet) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] + + +def test_update_expanded_data_set_empty_call(): + # This test 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_expanded_data_set), "__call__" + ) as call: + client.update_expanded_data_set() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateExpandedDataSetRequest() + + +@pytest.mark.asyncio +async def test_update_expanded_data_set_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateExpandedDataSetRequest, +): + 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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gaa_expanded_data_set.ExpandedDataSet( + name="name_value", + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], + ) + ) + response = await client.update_expanded_data_set(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateExpandedDataSetRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gaa_expanded_data_set.ExpandedDataSet) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] + + +@pytest.mark.asyncio +async def test_update_expanded_data_set_async_from_dict(): + await test_update_expanded_data_set_async(request_type=dict) + + +def test_update_expanded_data_set_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.UpdateExpandedDataSetRequest() + + request.expanded_data_set.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_expanded_data_set), "__call__" + ) as call: + call.return_value = gaa_expanded_data_set.ExpandedDataSet() + client.update_expanded_data_set(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", + "expanded_data_set.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_expanded_data_set_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.UpdateExpandedDataSetRequest() + + request.expanded_data_set.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_expanded_data_set), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gaa_expanded_data_set.ExpandedDataSet() + ) + await client.update_expanded_data_set(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", + "expanded_data_set.name=name_value", + ) in kw["metadata"] + + +def test_update_expanded_data_set_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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gaa_expanded_data_set.ExpandedDataSet() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_expanded_data_set( + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(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] + arg = args[0].expanded_data_set + mock_val = gaa_expanded_data_set.ExpandedDataSet(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_expanded_data_set_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_expanded_data_set( + analytics_admin.UpdateExpandedDataSetRequest(), + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_expanded_data_set_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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gaa_expanded_data_set.ExpandedDataSet() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gaa_expanded_data_set.ExpandedDataSet() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_expanded_data_set( + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(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] + arg = args[0].expanded_data_set + mock_val = gaa_expanded_data_set.ExpandedDataSet(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_expanded_data_set_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_expanded_data_set( + analytics_admin.UpdateExpandedDataSetRequest(), + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.DeleteExpandedDataSetRequest, + dict, + ], +) +def test_delete_expanded_data_set(request_type, transport: str = "grpc"): + 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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_expanded_data_set(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteExpandedDataSetRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_expanded_data_set_empty_call(): + # This test 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_expanded_data_set), "__call__" + ) as call: + client.delete_expanded_data_set() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteExpandedDataSetRequest() + + +@pytest.mark.asyncio +async def test_delete_expanded_data_set_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteExpandedDataSetRequest, +): + 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_expanded_data_set), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_expanded_data_set(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteExpandedDataSetRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_expanded_data_set_async_from_dict(): + await test_delete_expanded_data_set_async(request_type=dict) + + +def test_delete_expanded_data_set_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.DeleteExpandedDataSetRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_expanded_data_set), "__call__" + ) as call: + call.return_value = None + client.delete_expanded_data_set(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_expanded_data_set_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.DeleteExpandedDataSetRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_expanded_data_set), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_expanded_data_set(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_expanded_data_set_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_expanded_data_set), "__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_expanded_data_set( + 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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_expanded_data_set_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_expanded_data_set( + analytics_admin.DeleteExpandedDataSetRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_expanded_data_set_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_expanded_data_set), "__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_expanded_data_set( + 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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_expanded_data_set_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_expanded_data_set( + analytics_admin.DeleteExpandedDataSetRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, + dict, + ], +) +def test_set_automated_ga4_configuration_opt_out(request_type, transport: str = "grpc"): + 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.set_automated_ga4_configuration_opt_out), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() + response = client.set_automated_ga4_configuration_opt_out(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() + + # Establish that the response is the type that we expect. + assert isinstance( + response, analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse + ) + + +def test_set_automated_ga4_configuration_opt_out_empty_call(): + # This test 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.set_automated_ga4_configuration_opt_out), "__call__" + ) as call: + client.set_automated_ga4_configuration_opt_out() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() + + +@pytest.mark.asyncio +async def test_set_automated_ga4_configuration_opt_out_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, +): + 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.set_automated_ga4_configuration_opt_out), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() + ) + response = await client.set_automated_ga4_configuration_opt_out(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() + + # Establish that the response is the type that we expect. + assert isinstance( + response, analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse + ) + + +@pytest.mark.asyncio +async def test_set_automated_ga4_configuration_opt_out_async_from_dict(): + await test_set_automated_ga4_configuration_opt_out_async(request_type=dict) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, + dict, + ], +) +def test_fetch_automated_ga4_configuration_opt_out( + request_type, transport: str = "grpc" +): + 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.fetch_automated_ga4_configuration_opt_out), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = ( + analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse( + opt_out=True, + ) + ) + response = client.fetch_automated_ga4_configuration_opt_out(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() + + # Establish that the response is the type that we expect. + assert isinstance( + response, analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse + ) + assert response.opt_out is True + + +def test_fetch_automated_ga4_configuration_opt_out_empty_call(): + # This test 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.fetch_automated_ga4_configuration_opt_out), "__call__" + ) as call: + client.fetch_automated_ga4_configuration_opt_out() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() + + +@pytest.mark.asyncio +async def test_fetch_automated_ga4_configuration_opt_out_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, +): + 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.fetch_automated_ga4_configuration_opt_out), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse( + opt_out=True, + ) + ) + response = await client.fetch_automated_ga4_configuration_opt_out(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() + + # Establish that the response is the type that we expect. + assert isinstance( + response, analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse + ) + assert response.opt_out is True + + +@pytest.mark.asyncio +async def test_fetch_automated_ga4_configuration_opt_out_async_from_dict(): + await test_fetch_automated_ga4_configuration_opt_out_async(request_type=dict) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.GetBigQueryLinkRequest, + dict, + ], +) +def test_get_big_query_link(request_type, transport: str = "grpc"): + 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_big_query_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.BigQueryLink( + name="name_value", + project="project_value", + daily_export_enabled=True, + streaming_export_enabled=True, + include_advertising_id=True, + export_streams=["export_streams_value"], + excluded_events=["excluded_events_value"], + ) + response = client.get_big_query_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.GetBigQueryLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.BigQueryLink) + assert response.name == "name_value" + assert response.project == "project_value" + assert response.daily_export_enabled is True + assert response.streaming_export_enabled is True + assert response.include_advertising_id is True + assert response.export_streams == ["export_streams_value"] + assert response.excluded_events == ["excluded_events_value"] + + +def test_get_big_query_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_big_query_link), "__call__" + ) as call: + client.get_big_query_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetBigQueryLinkRequest() + + +@pytest.mark.asyncio +async def test_get_big_query_link_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.GetBigQueryLinkRequest +): + 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_big_query_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.BigQueryLink( + name="name_value", + project="project_value", + daily_export_enabled=True, + streaming_export_enabled=True, + include_advertising_id=True, + export_streams=["export_streams_value"], + excluded_events=["excluded_events_value"], + ) + ) + response = await client.get_big_query_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.GetBigQueryLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.BigQueryLink) + assert response.name == "name_value" + assert response.project == "project_value" + assert response.daily_export_enabled is True + assert response.streaming_export_enabled is True + assert response.include_advertising_id is True + assert response.export_streams == ["export_streams_value"] + assert response.excluded_events == ["excluded_events_value"] + + +@pytest.mark.asyncio +async def test_get_big_query_link_async_from_dict(): + await test_get_big_query_link_async(request_type=dict) + + +def test_get_big_query_link_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetBigQueryLinkRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_big_query_link), "__call__" + ) as call: + call.return_value = resources.BigQueryLink() + client.get_big_query_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_big_query_link_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.GetBigQueryLinkRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_big_query_link), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.BigQueryLink() + ) + await client.get_big_query_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_big_query_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_big_query_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.BigQueryLink() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_big_query_link( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_big_query_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_big_query_link( + analytics_admin.GetBigQueryLinkRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_big_query_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_big_query_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.BigQueryLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.BigQueryLink() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_big_query_link( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_big_query_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_big_query_link( + analytics_admin.GetBigQueryLinkRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListBigQueryLinksRequest, + dict, + ], +) +def test_list_big_query_links(request_type, transport: str = "grpc"): + 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_big_query_links), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListBigQueryLinksResponse( + next_page_token="next_page_token_value", + ) + response = client.list_big_query_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.ListBigQueryLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBigQueryLinksPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_big_query_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), "__call__" + ) as call: + client.list_big_query_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListBigQueryLinksRequest() + + +@pytest.mark.asyncio +async def test_list_big_query_links_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListBigQueryLinksRequest, +): + 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_big_query_links), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListBigQueryLinksResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_big_query_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.ListBigQueryLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBigQueryLinksAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_big_query_links_async_from_dict(): + await test_list_big_query_links_async(request_type=dict) + + +def test_list_big_query_links_field_headers(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListBigQueryLinksRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), "__call__" + ) as call: + call.return_value = analytics_admin.ListBigQueryLinksResponse() + client.list_big_query_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_big_query_links_field_headers_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = analytics_admin.ListBigQueryLinksRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListBigQueryLinksResponse() + ) + await client.list_big_query_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_big_query_links_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListBigQueryLinksResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_big_query_links( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_big_query_links_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_big_query_links( + analytics_admin.ListBigQueryLinksRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_big_query_links_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListBigQueryLinksResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListBigQueryLinksResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_big_query_links( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_big_query_links_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_big_query_links( + analytics_admin.ListBigQueryLinksRequest(), + parent="parent_value", + ) + + +def test_list_big_query_links_pager(transport_name: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + resources.BigQueryLink(), + resources.BigQueryLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[], + next_page_token="def", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + resources.BigQueryLink(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_big_query_links(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.BigQueryLink) for i in results) + + +def test_list_big_query_links_pages(transport_name: str = "grpc"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + resources.BigQueryLink(), + resources.BigQueryLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[], + next_page_token="def", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + resources.BigQueryLink(), + ], + ), + RuntimeError, + ) + pages = list(client.list_big_query_links(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_big_query_links_async_pager(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + resources.BigQueryLink(), + resources.BigQueryLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[], + next_page_token="def", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + resources.BigQueryLink(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_big_query_links( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.BigQueryLink) for i in responses) + + +@pytest.mark.asyncio +async def test_list_big_query_links_async_pages(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_big_query_links), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ + resources.BigQueryLink(), + resources.BigQueryLink(), + resources.BigQueryLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[], + next_page_token="def", + ), + analytics_admin.ListBigQueryLinksResponse( bigquery_links=[ resources.BigQueryLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListBigQueryLinksResponse( + bigquery_links=[ resources.BigQueryLink(), resources.BigQueryLink(), ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_big_query_links(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.GetAccountRequest, + dict, + ], +) +def test_get_account_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Account( + name="name_value", + display_name="display_name_value", + region_code="region_code_value", + deleted=True, + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Account.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_account(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Account) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.region_code == "region_code_value" + assert response.deleted is True + + +def test_get_account_rest_required_fields( + request_type=analytics_admin.GetAccountRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_account._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_account._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Account() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Account.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_account(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_account_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_account._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_account_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_get_account" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_account" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.GetAccountRequest.pb( + analytics_admin.GetAccountRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Account.to_json(resources.Account()) + + request = analytics_admin.GetAccountRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Account() + + client.get_account( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_account_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetAccountRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_account(request) + + +def test_get_account_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Account() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "accounts/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Account.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_account(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=accounts/*}" % client.transport._host, args[1] + ) + + +def test_get_account_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_account( + analytics_admin.GetAccountRequest(), + name="name_value", + ) + + +def test_get_account_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListAccountsRequest, + dict, + ], +) +def test_list_accounts_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ListAccountsResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.ListAccountsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_accounts(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAccountsPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_accounts_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_list_accounts" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_accounts" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.ListAccountsRequest.pb( + analytics_admin.ListAccountsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = analytics_admin.ListAccountsResponse.to_json( + analytics_admin.ListAccountsResponse() + ) + + request = analytics_admin.ListAccountsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = analytics_admin.ListAccountsResponse() + + client.list_accounts( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_accounts_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListAccountsRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_accounts(request) + + +def test_list_accounts_rest_pager(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + resources.Account(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccountsResponse( + accounts=[], + next_page_token="def", + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAccountsResponse( + accounts=[ + resources.Account(), + resources.Account(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListAccountsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {} + + pager = client.list_accounts(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Account) for i in results) + + pages = list(client.list_accounts(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.DeleteAccountRequest, + dict, + ], +) +def test_delete_account_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_account(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_account_rest_required_fields( + request_type=analytics_admin.DeleteAccountRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_account._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_account._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_account(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_account_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_account._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_account_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_account" + ) as pre: + pre.assert_not_called() + pb_message = analytics_admin.DeleteAccountRequest.pb( + analytics_admin.DeleteAccountRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = analytics_admin.DeleteAccountRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_account( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_delete_account_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteAccountRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_account(request) + + +def test_delete_account_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "accounts/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_account(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=accounts/*}" % client.transport._host, args[1] + ) + + +def test_delete_account_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_account( + analytics_admin.DeleteAccountRequest(), + name="name_value", + ) + + +def test_delete_account_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.UpdateAccountRequest, + dict, + ], +) +def test_update_account_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"account": {"name": "accounts/sample1"}} + request_init["account"] = { + "name": "accounts/sample1", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "display_name": "display_name_value", + "region_code": "region_code_value", + "deleted": True, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Account( + name="name_value", + display_name="display_name_value", + region_code="region_code_value", + deleted=True, + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Account.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_account(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Account) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.region_code == "region_code_value" + assert response.deleted is True + + +def test_update_account_rest_required_fields( + request_type=analytics_admin.UpdateAccountRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_account._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_account._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Account() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Account.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_account(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_account_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_account._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "account", + "updateMask", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_account_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_update_account" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_account" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.UpdateAccountRequest.pb( + analytics_admin.UpdateAccountRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Account.to_json(resources.Account()) + + request = analytics_admin.UpdateAccountRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Account() + + client.update_account( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_account_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateAccountRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"account": {"name": "accounts/sample1"}} + request_init["account"] = { + "name": "accounts/sample1", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "display_name": "display_name_value", + "region_code": "region_code_value", + "deleted": True, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_account(request) + + +def test_update_account_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Account() + + # get arguments that satisfy an http rule for this method + sample_request = {"account": {"name": "accounts/sample1"}} + + # get truthy value for each flattened field + mock_args = dict( + account=resources.Account(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Account.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_account(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{account.name=accounts/*}" % client.transport._host, args[1] + ) + + +def test_update_account_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_account( + analytics_admin.UpdateAccountRequest(), + account=resources.Account(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_account_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ProvisionAccountTicketRequest, + dict, + ], +) +def test_provision_account_ticket_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ProvisionAccountTicketResponse( + account_ticket_id="account_ticket_id_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.ProvisionAccountTicketResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.provision_account_ticket(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.ProvisionAccountTicketResponse) + assert response.account_ticket_id == "account_ticket_id_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_provision_account_ticket_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_provision_account_ticket" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_provision_account_ticket" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.ProvisionAccountTicketRequest.pb( + analytics_admin.ProvisionAccountTicketRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + analytics_admin.ProvisionAccountTicketResponse.to_json( + analytics_admin.ProvisionAccountTicketResponse() + ) + ) + + request = analytics_admin.ProvisionAccountTicketRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = analytics_admin.ProvisionAccountTicketResponse() + + client.provision_account_ticket( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_provision_account_ticket_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ProvisionAccountTicketRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.provision_account_ticket(request) + + +def test_provision_account_ticket_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListAccountSummariesRequest, + dict, + ], +) +def test_list_account_summaries_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ListAccountSummariesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.ListAccountSummariesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_account_summaries(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAccountSummariesPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_account_summaries_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_list_account_summaries" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_account_summaries" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.ListAccountSummariesRequest.pb( + analytics_admin.ListAccountSummariesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + analytics_admin.ListAccountSummariesResponse.to_json( + analytics_admin.ListAccountSummariesResponse() + ) + ) + + request = analytics_admin.ListAccountSummariesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = analytics_admin.ListAccountSummariesResponse() + + client.list_account_summaries( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_account_summaries_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListAccountSummariesRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_account_summaries(request) + + +def test_list_account_summaries_rest_pager(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + resources.AccountSummary(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[], + next_page_token="def", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAccountSummariesResponse( + account_summaries=[ + resources.AccountSummary(), + resources.AccountSummary(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListAccountSummariesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {} + + pager = client.list_account_summaries(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.AccountSummary) for i in results) + + pages = list(client.list_account_summaries(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.GetPropertyRequest, + dict, + ], +) +def test_get_property_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "properties/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Property( + name="name_value", + property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, + parent="parent_value", + display_name="display_name_value", + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone="time_zone_value", + currency_code="currency_code_value", + service_level=resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD, + account="account_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_property(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Property) + assert response.name == "name_value" + assert response.property_type == resources.PropertyType.PROPERTY_TYPE_ORDINARY + 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.service_level == resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD + assert response.account == "account_value" + + +def test_get_property_rest_required_fields( + request_type=analytics_admin.GetPropertyRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_property._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_property._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Property() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_property(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_property_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_property._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_property_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_get_property" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_property" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.GetPropertyRequest.pb( + analytics_admin.GetPropertyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Property.to_json(resources.Property()) + + request = analytics_admin.GetPropertyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Property() + + client.get_property( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_property_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetPropertyRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "properties/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_property(request) + + +def test_get_property_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Property() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "properties/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_property(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=properties/*}" % client.transport._host, args[1] + ) + + +def test_get_property_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_property( + analytics_admin.GetPropertyRequest(), + name="name_value", + ) + + +def test_get_property_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListPropertiesRequest, + dict, + ], +) +def test_list_properties_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ListPropertiesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.ListPropertiesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_properties(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPropertiesPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_properties_rest_required_fields( + request_type=analytics_admin.ListPropertiesRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["filter"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + assert "filter" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_properties._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "filter" in jsonified_request + assert jsonified_request["filter"] == request_init["filter"] + + jsonified_request["filter"] = "filter_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_properties._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + "show_deleted", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "filter" in jsonified_request + assert jsonified_request["filter"] == "filter_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ListPropertiesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = analytics_admin.ListPropertiesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_properties(request) + + expected_params = [ + ( + "filter", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_properties_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_properties._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + "showDeleted", + ) + ) + & set(("filter",)) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_properties_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_list_properties" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_properties" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.ListPropertiesRequest.pb( + analytics_admin.ListPropertiesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = analytics_admin.ListPropertiesResponse.to_json( + analytics_admin.ListPropertiesResponse() + ) + + request = analytics_admin.ListPropertiesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = analytics_admin.ListPropertiesResponse() + + client.list_properties( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_properties_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListPropertiesRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_properties(request) + + +def test_list_properties_rest_pager(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + resources.Property(), + ], + next_page_token="abc", + ), + analytics_admin.ListPropertiesResponse( + properties=[], + next_page_token="def", + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + ], + next_page_token="ghi", + ), + analytics_admin.ListPropertiesResponse( + properties=[ + resources.Property(), + resources.Property(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListPropertiesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {} + + pager = client.list_properties(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Property) for i in results) + + pages = list(client.list_properties(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.CreatePropertyRequest, + dict, + ], +) +def test_create_property_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {} + request_init["property"] = { + "name": "name_value", + "property_type": 1, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "parent": "parent_value", + "display_name": "display_name_value", + "industry_category": 1, + "time_zone": "time_zone_value", + "currency_code": "currency_code_value", + "service_level": 1, + "delete_time": {}, + "expire_time": {}, + "account": "account_value", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Property( + name="name_value", + property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, + parent="parent_value", + display_name="display_name_value", + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone="time_zone_value", + currency_code="currency_code_value", + service_level=resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD, + account="account_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_property(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Property) + assert response.name == "name_value" + assert response.property_type == resources.PropertyType.PROPERTY_TYPE_ORDINARY + 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.service_level == resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD + assert response.account == "account_value" + + +def test_create_property_rest_required_fields( + request_type=analytics_admin.CreatePropertyRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_property._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_property._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Property() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_property(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_property_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_property._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("property",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_property_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_create_property" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_property" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.CreatePropertyRequest.pb( + analytics_admin.CreatePropertyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Property.to_json(resources.Property()) + + request = analytics_admin.CreatePropertyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Property() + + client.create_property( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_property_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreatePropertyRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {} + request_init["property"] = { + "name": "name_value", + "property_type": 1, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "parent": "parent_value", + "display_name": "display_name_value", + "industry_category": 1, + "time_zone": "time_zone_value", + "currency_code": "currency_code_value", + "service_level": 1, + "delete_time": {}, + "expire_time": {}, + "account": "account_value", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_property(request) + + +def test_create_property_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Property() + + # get arguments that satisfy an http rule for this method + sample_request = {} + + # get truthy value for each flattened field + mock_args = dict( + property=resources.Property(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_property(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/properties" % client.transport._host, args[1] + ) + + +def test_create_property_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_property( + analytics_admin.CreatePropertyRequest(), + property=resources.Property(name="name_value"), + ) + + +def test_create_property_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.DeletePropertyRequest, + dict, + ], +) +def test_delete_property_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "properties/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Property( + name="name_value", + property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, + parent="parent_value", + display_name="display_name_value", + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone="time_zone_value", + currency_code="currency_code_value", + service_level=resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD, + account="account_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_property(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Property) + assert response.name == "name_value" + assert response.property_type == resources.PropertyType.PROPERTY_TYPE_ORDINARY + 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.service_level == resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD + assert response.account == "account_value" + + +def test_delete_property_rest_required_fields( + request_type=analytics_admin.DeletePropertyRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_property._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_property._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Property() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_property(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_property_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_property._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_property_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_delete_property" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_property" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.DeletePropertyRequest.pb( + analytics_admin.DeletePropertyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Property.to_json(resources.Property()) + + request = analytics_admin.DeletePropertyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Property() + + client.delete_property( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_property_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeletePropertyRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "properties/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_property(request) + + +def test_delete_property_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Property() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "properties/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_property(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=properties/*}" % client.transport._host, args[1] + ) + + +def test_delete_property_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_property( + analytics_admin.DeletePropertyRequest(), + name="name_value", + ) + + +def test_delete_property_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.UpdatePropertyRequest, + dict, + ], +) +def test_update_property_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"property": {"name": "properties/sample1"}} + request_init["property"] = { + "name": "properties/sample1", + "property_type": 1, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "parent": "parent_value", + "display_name": "display_name_value", + "industry_category": 1, + "time_zone": "time_zone_value", + "currency_code": "currency_code_value", + "service_level": 1, + "delete_time": {}, + "expire_time": {}, + "account": "account_value", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Property( + name="name_value", + property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, + parent="parent_value", + display_name="display_name_value", + industry_category=resources.IndustryCategory.AUTOMOTIVE, + time_zone="time_zone_value", + currency_code="currency_code_value", + service_level=resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD, + account="account_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_property(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Property) + assert response.name == "name_value" + assert response.property_type == resources.PropertyType.PROPERTY_TYPE_ORDINARY + 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.service_level == resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD + assert response.account == "account_value" + + +def test_update_property_rest_required_fields( + request_type=analytics_admin.UpdatePropertyRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_property._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_property._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Property() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_property(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_property_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_property._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "property", + "updateMask", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_property_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_update_property" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_property" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.UpdatePropertyRequest.pb( + analytics_admin.UpdatePropertyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Property.to_json(resources.Property()) + + request = analytics_admin.UpdatePropertyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Property() + + client.update_property( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_property_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdatePropertyRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"property": {"name": "properties/sample1"}} + request_init["property"] = { + "name": "properties/sample1", + "property_type": 1, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "parent": "parent_value", + "display_name": "display_name_value", + "industry_category": 1, + "time_zone": "time_zone_value", + "currency_code": "currency_code_value", + "service_level": 1, + "delete_time": {}, + "expire_time": {}, + "account": "account_value", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_property(request) + + +def test_update_property_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.Property() + + # get arguments that satisfy an http rule for this method + sample_request = {"property": {"name": "properties/sample1"}} + + # get truthy value for each flattened field + mock_args = dict( + property=resources.Property(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Property.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_property(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{property.name=properties/*}" % client.transport._host, args[1] + ) + + +def test_update_property_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_property( + analytics_admin.UpdatePropertyRequest(), + property=resources.Property(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_property_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.GetUserLinkRequest, + dict, + ], +) +def test_get_user_link_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "accounts/sample1/userLinks/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.UserLink( + name="name_value", + email_address="email_address_value", + direct_roles=["direct_roles_value"], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.UserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_user_link(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.UserLink) + assert response.name == "name_value" + assert response.email_address == "email_address_value" + assert response.direct_roles == ["direct_roles_value"] + + +def test_get_user_link_rest_required_fields( + request_type=analytics_admin.GetUserLinkRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_user_link._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_user_link._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.UserLink() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.UserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_user_link(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_user_link_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_user_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_user_link_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_get_user_link" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_user_link" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.GetUserLinkRequest.pb( + analytics_admin.GetUserLinkRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.UserLink.to_json(resources.UserLink()) + + request = analytics_admin.GetUserLinkRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.UserLink() + + client.get_user_link( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_user_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetUserLinkRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "accounts/sample1/userLinks/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_user_link(request) + + +def test_get_user_link_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.UserLink() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "accounts/sample1/userLinks/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.UserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_user_link(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=accounts/*/userLinks/*}" % client.transport._host, args[1] + ) + + +def test_get_user_link_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_user_link( + analytics_admin.GetUserLinkRequest(), + name="name_value", + ) + + +def test_get_user_link_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.BatchGetUserLinksRequest, + dict, + ], +) +def test_batch_get_user_links_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.BatchGetUserLinksResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.BatchGetUserLinksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.batch_get_user_links(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) + + +def test_batch_get_user_links_rest_required_fields( + request_type=analytics_admin.BatchGetUserLinksRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["names"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + assert "names" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_get_user_links._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "names" in jsonified_request + assert jsonified_request["names"] == request_init["names"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["names"] = "names_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_get_user_links._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("names",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "names" in jsonified_request + assert jsonified_request["names"] == "names_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = analytics_admin.BatchGetUserLinksResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = analytics_admin.BatchGetUserLinksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.batch_get_user_links(request) + + expected_params = [ + ( + "names", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_batch_get_user_links_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.batch_get_user_links._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("names",)) + & set( + ( + "parent", + "names", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_batch_get_user_links_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_batch_get_user_links" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_get_user_links" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.BatchGetUserLinksRequest.pb( + analytics_admin.BatchGetUserLinksRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = analytics_admin.BatchGetUserLinksResponse.to_json( + analytics_admin.BatchGetUserLinksResponse() + ) + + request = analytics_admin.BatchGetUserLinksRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = analytics_admin.BatchGetUserLinksResponse() + + client.batch_get_user_links( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_batch_get_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchGetUserLinksRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.batch_get_user_links(request) + + +def test_batch_get_user_links_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListUserLinksRequest, + dict, + ], +) +def test_list_user_links_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ListUserLinksResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.ListUserLinksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_user_links(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListUserLinksPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_user_links_rest_required_fields( + request_type=analytics_admin.ListUserLinksRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_user_links._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_user_links._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ListUserLinksResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = analytics_admin.ListUserLinksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_user_links(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_user_links_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_user_links._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_user_links_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_list_user_links" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_user_links" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.ListUserLinksRequest.pb( + analytics_admin.ListUserLinksRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = analytics_admin.ListUserLinksResponse.to_json( + analytics_admin.ListUserLinksResponse() + ) + + request = analytics_admin.ListUserLinksRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = analytics_admin.ListUserLinksResponse() + + client.list_user_links( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListUserLinksRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_user_links(request) + + +def test_list_user_links_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ListUserLinksResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "accounts/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.ListUserLinksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_user_links(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{parent=accounts/*}/userLinks" % client.transport._host, args[1] + ) + + +def test_list_user_links_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_user_links( + analytics_admin.ListUserLinksRequest(), + parent="parent_value", + ) + + +def test_list_user_links_rest_pager(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + resources.UserLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListUserLinksResponse( + user_links=[], + next_page_token="def", + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListUserLinksResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "accounts/sample1"} + + pager = client.list_user_links(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.UserLink) for i in results) + + pages = list(client.list_user_links(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.AuditUserLinksRequest, + dict, + ], +) +def test_audit_user_links_rest(request_type): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.AuditUserLinksResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.AuditUserLinksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.audit_user_links(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.AuditUserLinksPager) + assert response.next_page_token == "next_page_token_value" + + +def test_audit_user_links_rest_required_fields( + request_type=analytics_admin.AuditUserLinksRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).audit_user_links._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).audit_user_links._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = analytics_admin.AuditUserLinksResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = analytics_admin.AuditUserLinksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.audit_user_links(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_audit_user_links_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.audit_user_links._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_audit_user_links_rest_interceptors(null_interceptor): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AnalyticsAdminServiceRestInterceptor(), + ) + client = AnalyticsAdminServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_audit_user_links" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_audit_user_links" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.AuditUserLinksRequest.pb( + analytics_admin.AuditUserLinksRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = analytics_admin.AuditUserLinksResponse.to_json( + analytics_admin.AuditUserLinksResponse() + ) + + request = analytics_admin.AuditUserLinksRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = analytics_admin.AuditUserLinksResponse() + + client.audit_user_links( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_audit_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.AuditUserLinksRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "accounts/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.audit_user_links(request) + + +def test_audit_user_links_rest_pager(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + resources.AuditUserLink(), + ], next_page_token="abc", ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[], + analytics_admin.AuditUserLinksResponse( + user_links=[], next_page_token="def", ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), ], next_page_token="ghi", ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), ], ), - RuntimeError, ) - pages = [] - async for page_ in ( - await client.list_big_query_links(request={}) - ).pages: # pragma: no branch - pages.append(page_) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.AuditUserLinksResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "accounts/sample1"} + + pager = client.audit_user_links(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.AuditUserLink) for i in results) + + pages = list(client.audit_user_links(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -24791,55 +32244,58 @@ async def test_list_big_query_links_async_pages(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetAccountRequest, + analytics_admin.CreateUserLinkRequest, dict, ], ) -def test_get_account_rest(request_type): +def test_create_user_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1"} + request_init = {"parent": "accounts/sample1"} + request_init["user_link"] = { + "name": "name_value", + "email_address": "email_address_value", + "direct_roles": ["direct_roles_value1", "direct_roles_value2"], + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Account( + return_value = resources.UserLink( name="name_value", - display_name="display_name_value", - region_code="region_code_value", - deleted=True, + email_address="email_address_value", + direct_roles=["direct_roles_value"], ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Account.pb(return_value) + pb_return_value = resources.UserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_account(request) + response = client.create_user_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Account) + assert isinstance(response, resources.UserLink) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.region_code == "region_code_value" - assert response.deleted is True + assert response.email_address == "email_address_value" + assert response.direct_roles == ["direct_roles_value"] -def test_get_account_rest_required_fields( - request_type=analytics_admin.GetAccountRequest, +def test_create_user_link_rest_required_fields( + request_type=analytics_admin.CreateUserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -24854,21 +32310,23 @@ def test_get_account_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_account._get_unset_required_fields(jsonified_request) + ).create_user_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_account._get_unset_required_fields(jsonified_request) + ).create_user_link._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("notify_new_user",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -24877,7 +32335,7 @@ def test_get_account_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.Account() + return_value = resources.UserLink() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -24889,38 +32347,47 @@ def test_get_account_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Account.pb(return_value) + pb_return_value = resources.UserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_account(request) + response = client.create_user_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_account_rest_unset_required_fields(): +def test_create_user_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_account._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.create_user_link._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("notifyNewUser",)) + & set( + ( + "parent", + "userLink", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_account_rest_interceptors(null_interceptor): +def test_create_user_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -24933,14 +32400,14 @@ def test_get_account_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_account" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_user_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_account" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_user_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetAccountRequest.pb( - analytics_admin.GetAccountRequest() + pb_message = analytics_admin.CreateUserLinkRequest.pb( + analytics_admin.CreateUserLinkRequest() ) transcode.return_value = { "method": "post", @@ -24952,17 +32419,17 @@ def test_get_account_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.Account.to_json(resources.Account()) + req.return_value._content = resources.UserLink.to_json(resources.UserLink()) - request = analytics_admin.GetAccountRequest() + request = analytics_admin.CreateUserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Account() + post.return_value = resources.UserLink() - client.get_account( + client.create_user_link( request, metadata=[ ("key", "val"), @@ -24974,8 +32441,8 @@ def test_get_account_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_account_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetAccountRequest +def test_create_user_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateUserLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -24983,7 +32450,12 @@ def test_get_account_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1"} + request_init = {"parent": "accounts/sample1"} + request_init["user_link"] = { + "name": "name_value", + "email_address": "email_address_value", + "direct_roles": ["direct_roles_value1", "direct_roles_value2"], + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -24995,10 +32467,10 @@ def test_get_account_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_account(request) + client.create_user_link(request) -def test_get_account_rest_flattened(): +def test_create_user_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25007,37 +32479,38 @@ def test_get_account_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Account() + return_value = resources.UserLink() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1"} + sample_request = {"parent": "accounts/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", + user_link=resources.UserLink(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Account.pb(return_value) + pb_return_value = resources.UserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_account(**mock_args) + client.create_user_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=accounts/*}" % client.transport._host, args[1] + "%s/v1alpha/{parent=accounts/*}/userLinks" % client.transport._host, args[1] ) -def test_get_account_rest_flattened_error(transport: str = "rest"): +def test_create_user_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -25046,13 +32519,14 @@ def test_get_account_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_account( - analytics_admin.GetAccountRequest(), - name="name_value", + client.create_user_link( + analytics_admin.CreateUserLinkRequest(), + parent="parent_value", + user_link=resources.UserLink(name="name_value"), ) -def test_get_account_rest_error(): +def test_create_user_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -25061,44 +32535,138 @@ def test_get_account_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListAccountsRequest, + analytics_admin.BatchCreateUserLinksRequest, dict, ], ) -def test_list_accounts_rest(request_type): +def test_batch_create_user_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListAccountsResponse( - next_page_token="next_page_token_value", - ) + return_value = analytics_admin.BatchCreateUserLinksResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListAccountsResponse.pb(return_value) + pb_return_value = analytics_admin.BatchCreateUserLinksResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_accounts(request) + response = client.batch_create_user_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAccountsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) + + +def test_batch_create_user_links_rest_required_fields( + request_type=analytics_admin.BatchCreateUserLinksRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_create_user_links._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_create_user_links._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = analytics_admin.BatchCreateUserLinksResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = analytics_admin.BatchCreateUserLinksResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.batch_create_user_links(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_batch_create_user_links_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.batch_create_user_links._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "requests", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_accounts_rest_interceptors(null_interceptor): +def test_batch_create_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25111,14 +32679,14 @@ def test_list_accounts_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_accounts" + transports.AnalyticsAdminServiceRestInterceptor, "post_batch_create_user_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_accounts" + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_create_user_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListAccountsRequest.pb( - analytics_admin.ListAccountsRequest() + pb_message = analytics_admin.BatchCreateUserLinksRequest.pb( + analytics_admin.BatchCreateUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -25130,19 +32698,21 @@ def test_list_accounts_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ListAccountsResponse.to_json( - analytics_admin.ListAccountsResponse() + req.return_value._content = ( + analytics_admin.BatchCreateUserLinksResponse.to_json( + analytics_admin.BatchCreateUserLinksResponse() + ) ) - request = analytics_admin.ListAccountsRequest() + request = analytics_admin.BatchCreateUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListAccountsResponse() + post.return_value = analytics_admin.BatchCreateUserLinksResponse() - client.list_accounts( + client.batch_create_user_links( request, metadata=[ ("key", "val"), @@ -25154,8 +32724,8 @@ def test_list_accounts_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_accounts_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListAccountsRequest +def test_batch_create_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchCreateUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -25163,7 +32733,7 @@ def test_list_accounts_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -25175,114 +32745,69 @@ def test_list_accounts_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_accounts(request) + client.batch_create_user_links(request) -def test_list_accounts_rest_pager(transport: str = "rest"): +def test_batch_create_user_links_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - resources.Account(), - ], - next_page_token="abc", - ), - analytics_admin.ListAccountsResponse( - accounts=[], - next_page_token="def", - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - ], - next_page_token="ghi", - ), - analytics_admin.ListAccountsResponse( - accounts=[ - resources.Account(), - resources.Account(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListAccountsResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {} - - pager = client.list_accounts(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Account) for i in results) - - pages = list(client.list_accounts(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteAccountRequest, + analytics_admin.UpdateUserLinkRequest, dict, ], ) -def test_delete_account_rest(request_type): +def test_update_user_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1"} + request_init = {"user_link": {"name": "accounts/sample1/userLinks/sample2"}} + request_init["user_link"] = { + "name": "accounts/sample1/userLinks/sample2", + "email_address": "email_address_value", + "direct_roles": ["direct_roles_value1", "direct_roles_value2"], + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.UserLink( + name="name_value", + email_address="email_address_value", + direct_roles=["direct_roles_value"], + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.UserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_account(request) + response = client.update_user_link(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.UserLink) + assert response.name == "name_value" + assert response.email_address == "email_address_value" + assert response.direct_roles == ["direct_roles_value"] -def test_delete_account_rest_required_fields( - request_type=analytics_admin.DeleteAccountRequest, +def test_update_user_link_rest_required_fields( + request_type=analytics_admin.UpdateUserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -25297,21 +32822,17 @@ def test_delete_account_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_account._get_unset_required_fields(jsonified_request) + ).update_user_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_account._get_unset_required_fields(jsonified_request) + ).update_user_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -25320,7 +32841,7 @@ def test_delete_account_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.UserLink() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -25332,36 +32853,39 @@ def test_delete_account_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = resources.UserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_account(request) + response = client.update_user_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_account_rest_unset_required_fields(): +def test_update_user_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_account._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.update_user_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("userLink",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_account_rest_interceptors(null_interceptor): +def test_update_user_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25374,11 +32898,14 @@ def test_delete_account_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_account" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_user_link" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_user_link" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteAccountRequest.pb( - analytics_admin.DeleteAccountRequest() + post.assert_not_called() + pb_message = analytics_admin.UpdateUserLinkRequest.pb( + analytics_admin.UpdateUserLinkRequest() ) transcode.return_value = { "method": "post", @@ -25390,15 +32917,17 @@ def test_delete_account_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.UserLink.to_json(resources.UserLink()) - request = analytics_admin.DeleteAccountRequest() + request = analytics_admin.UpdateUserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.UserLink() - client.delete_account( + client.update_user_link( request, metadata=[ ("key", "val"), @@ -25407,10 +32936,11 @@ def test_delete_account_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_account_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteAccountRequest +def test_update_user_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateUserLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -25418,7 +32948,12 @@ def test_delete_account_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1"} + request_init = {"user_link": {"name": "accounts/sample1/userLinks/sample2"}} + request_init["user_link"] = { + "name": "accounts/sample1/userLinks/sample2", + "email_address": "email_address_value", + "direct_roles": ["direct_roles_value1", "direct_roles_value2"], + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -25430,10 +32965,10 @@ def test_delete_account_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_account(request) + client.update_user_link(request) -def test_delete_account_rest_flattened(): +def test_update_user_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25442,36 +32977,39 @@ def test_delete_account_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.UserLink() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1"} + sample_request = {"user_link": {"name": "accounts/sample1/userLinks/sample2"}} # get truthy value for each flattened field mock_args = dict( - name="name_value", + user_link=resources.UserLink(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.UserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_account(**mock_args) + client.update_user_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=accounts/*}" % client.transport._host, args[1] + "%s/v1alpha/{user_link.name=accounts/*/userLinks/*}" + % client.transport._host, + args[1], ) -def test_delete_account_rest_flattened_error(transport: str = "rest"): +def test_update_user_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -25480,13 +33018,13 @@ def test_delete_account_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_account( - analytics_admin.DeleteAccountRequest(), - name="name_value", + client.update_user_link( + analytics_admin.UpdateUserLinkRequest(), + user_link=resources.UserLink(name="name_value"), ) -def test_delete_account_rest_error(): +def test_update_user_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -25495,62 +33033,46 @@ def test_delete_account_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateAccountRequest, + analytics_admin.BatchUpdateUserLinksRequest, dict, ], ) -def test_update_account_rest(request_type): +def test_batch_update_user_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"account": {"name": "accounts/sample1"}} - request_init["account"] = { - "name": "accounts/sample1", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "display_name": "display_name_value", - "region_code": "region_code_value", - "deleted": True, - } + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Account( - name="name_value", - display_name="display_name_value", - region_code="region_code_value", - deleted=True, - ) + return_value = analytics_admin.BatchUpdateUserLinksResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Account.pb(return_value) + pb_return_value = analytics_admin.BatchUpdateUserLinksResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_account(request) + response = client.batch_update_user_links(request) # 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 + assert isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) -def test_update_account_rest_required_fields( - request_type=analytics_admin.UpdateAccountRequest, +def test_batch_update_user_links_rest_required_fields( + request_type=analytics_admin.BatchUpdateUserLinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -25565,19 +33087,21 @@ def test_update_account_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_account._get_unset_required_fields(jsonified_request) + ).batch_update_user_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_account._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + ).batch_update_user_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -25586,7 +33110,7 @@ def test_update_account_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.Account() + return_value = analytics_admin.BatchUpdateUserLinksResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -25598,7 +33122,7 @@ def test_update_account_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "post", "query_params": pb_request, } transcode_result["body"] = pb_request @@ -25607,38 +33131,40 @@ def test_update_account_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Account.pb(return_value) + pb_return_value = analytics_admin.BatchUpdateUserLinksResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_account(request) + response = client.batch_update_user_links(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_account_rest_unset_required_fields(): +def test_batch_update_user_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_account._get_unset_required_fields({}) + unset_fields = transport.batch_update_user_links._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("updateMask",)) + set(()) & set( ( - "account", - "updateMask", + "parent", + "requests", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_account_rest_interceptors(null_interceptor): +def test_batch_update_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25651,14 +33177,14 @@ def test_update_account_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_account" + transports.AnalyticsAdminServiceRestInterceptor, "post_batch_update_user_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_account" + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_update_user_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateAccountRequest.pb( - analytics_admin.UpdateAccountRequest() + pb_message = analytics_admin.BatchUpdateUserLinksRequest.pb( + analytics_admin.BatchUpdateUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -25670,17 +33196,21 @@ def test_update_account_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.Account.to_json(resources.Account()) + req.return_value._content = ( + analytics_admin.BatchUpdateUserLinksResponse.to_json( + analytics_admin.BatchUpdateUserLinksResponse() + ) + ) - request = analytics_admin.UpdateAccountRequest() + request = analytics_admin.BatchUpdateUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Account() + post.return_value = analytics_admin.BatchUpdateUserLinksResponse() - client.update_account( + client.batch_update_user_links( request, metadata=[ ("key", "val"), @@ -25692,8 +33222,8 @@ def test_update_account_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_account_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateAccountRequest +def test_batch_update_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchUpdateUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -25701,15 +33231,7 @@ def test_update_account_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"account": {"name": "accounts/sample1"}} - request_init["account"] = { - "name": "accounts/sample1", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "display_name": "display_name_value", - "region_code": "region_code_value", - "deleted": True, - } + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -25721,66 +33243,10 @@ def test_update_account_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_account(request) - - -def test_update_account_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Account() - - # get arguments that satisfy an http rule for this method - sample_request = {"account": {"name": "accounts/sample1"}} - - # get truthy value for each flattened field - mock_args = dict( - account=resources.Account(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Account.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.update_account(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{account.name=accounts/*}" % client.transport._host, args[1] - ) - - -def test_update_account_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_account( - analytics_admin.UpdateAccountRequest(), - account=resources.Account(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) + client.batch_update_user_links(request) -def test_update_account_rest_error(): +def test_batch_update_user_links_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -25789,174 +33255,124 @@ def test_update_account_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ProvisionAccountTicketRequest, + analytics_admin.DeleteUserLinkRequest, dict, ], ) -def test_provision_account_ticket_rest(request_type): +def test_delete_user_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"name": "accounts/sample1/userLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ProvisionAccountTicketResponse( - account_ticket_id="account_ticket_id_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ProvisionAccountTicketResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.provision_account_ticket(request) + response = client.delete_user_link(request) # 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" + assert response is None -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_provision_account_ticket_rest_interceptors(null_interceptor): - transport = transports.AnalyticsAdminServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.AnalyticsAdminServiceRestInterceptor(), - ) - client = AnalyticsAdminServiceClient(transport=transport) - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_provision_account_ticket" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_provision_account_ticket" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.ProvisionAccountTicketRequest.pb( - analytics_admin.ProvisionAccountTicketRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } +def test_delete_user_link_rest_required_fields( + request_type=analytics_admin.DeleteUserLinkRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.ProvisionAccountTicketResponse.to_json( - analytics_admin.ProvisionAccountTicketResponse() - ) + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, ) + ) - request = analytics_admin.ProvisionAccountTicketRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = analytics_admin.ProvisionAccountTicketResponse() + # verify fields with default values are dropped - client.provision_account_ticket( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_user_link._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - pre.assert_called_once() - post.assert_called_once() + # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_user_link._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -def test_provision_account_ticket_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ProvisionAccountTicketRequest -): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) - - # send a request that will satisfy transcoding - request_init = {} request = request_type(**request_init) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.provision_account_ticket(request) - - -def test_provision_account_ticket_rest_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + response_value = Response() + response_value.status_code = 200 + json_return_value = "" -@pytest.mark.parametrize( - "request_type", - [ - analytics_admin.ListAccountSummariesRequest, - dict, - ], -) -def test_list_account_summaries_rest(request_type): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # send a request that will satisfy transcoding - request_init = {} - request = request_type(**request_init) + response = client.delete_user_link(request) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListAccountSummariesResponse( - next_page_token="next_page_token_value", - ) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = analytics_admin.ListAccountSummariesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.list_account_summaries(request) +def test_delete_user_link_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAccountSummariesPager) - assert response.next_page_token == "next_page_token_value" + unset_fields = transport.delete_user_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_account_summaries_rest_interceptors(null_interceptor): +def test_delete_user_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25969,14 +33385,11 @@ def test_list_account_summaries_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_account_summaries" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_account_summaries" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_user_link" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.ListAccountSummariesRequest.pb( - analytics_admin.ListAccountSummariesRequest() + pb_message = analytics_admin.DeleteUserLinkRequest.pb( + analytics_admin.DeleteUserLinkRequest() ) transcode.return_value = { "method": "post", @@ -25988,21 +33401,15 @@ def test_list_account_summaries_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.ListAccountSummariesResponse.to_json( - analytics_admin.ListAccountSummariesResponse() - ) - ) - request = analytics_admin.ListAccountSummariesRequest() + request = analytics_admin.DeleteUserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListAccountSummariesResponse() - client.list_account_summaries( + client.delete_user_link( request, metadata=[ ("key", "val"), @@ -26011,11 +33418,10 @@ def test_list_account_summaries_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_list_account_summaries_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListAccountSummariesRequest +def test_delete_user_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteUserLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -26023,7 +33429,7 @@ def test_list_account_summaries_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"name": "accounts/sample1/userLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26035,134 +33441,110 @@ def test_list_account_summaries_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_account_summaries(request) + client.delete_user_link(request) -def test_list_account_summaries_rest_pager(transport: str = "rest"): +def test_delete_user_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - resources.AccountSummary(), - ], - next_page_token="abc", - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[], - next_page_token="def", - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - ], - next_page_token="ghi", - ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - ], - ), + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "accounts/sample1/userLinks/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", ) - # Two responses for two calls - response = response + response + mock_args.update(sample_request) - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListAccountSummariesResponse.to_json(x) for x in response + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_user_link(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=accounts/*/userLinks/*}" % client.transport._host, args[1] ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - sample_request = {} - pager = client.list_account_summaries(request=sample_request) +def test_delete_user_link_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.AccountSummary) for i in results) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_user_link( + analytics_admin.DeleteUserLinkRequest(), + name="name_value", + ) - pages = list(client.list_account_summaries(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + +def test_delete_user_link_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetPropertyRequest, + analytics_admin.BatchDeleteUserLinksRequest, dict, ], ) -def test_get_property_rest(request_type): +def test_batch_delete_user_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Property( - name="name_value", - property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, - parent="parent_value", - display_name="display_name_value", - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone="time_zone_value", - currency_code="currency_code_value", - service_level=resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD, - account="account_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_property(request) + response = client.batch_delete_user_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) - assert response.name == "name_value" - assert response.property_type == resources.PropertyType.PROPERTY_TYPE_ORDINARY - 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.service_level == resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD - assert response.account == "account_value" + assert response is None -def test_get_property_rest_required_fields( - request_type=analytics_admin.GetPropertyRequest, +def test_batch_delete_user_links_rest_required_fields( + request_type=analytics_admin.BatchDeleteUserLinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -26177,21 +33559,21 @@ def test_get_property_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_property._get_unset_required_fields(jsonified_request) + ).batch_delete_user_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_property._get_unset_required_fields(jsonified_request) + ).batch_delete_user_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -26200,7 +33582,7 @@ def test_get_property_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.Property() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -26212,38 +33594,45 @@ def test_get_property_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.Property.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_property(request) + response = client.batch_delete_user_links(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_property_rest_unset_required_fields(): +def test_batch_delete_user_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_property._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.batch_delete_user_links._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "requests", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_property_rest_interceptors(null_interceptor): +def test_batch_delete_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26256,14 +33645,11 @@ def test_get_property_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_property" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_property" + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_delete_user_links" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.GetPropertyRequest.pb( - analytics_admin.GetPropertyRequest() + pb_message = analytics_admin.BatchDeleteUserLinksRequest.pb( + analytics_admin.BatchDeleteUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -26275,17 +33661,15 @@ def test_get_property_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.Property.to_json(resources.Property()) - request = analytics_admin.GetPropertyRequest() + request = analytics_admin.BatchDeleteUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Property() - client.get_property( + client.batch_delete_user_links( request, metadata=[ ("key", "val"), @@ -26294,11 +33678,10 @@ def test_get_property_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_get_property_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetPropertyRequest +def test_batch_delete_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchDeleteUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -26306,7 +33689,7 @@ def test_get_property_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26318,64 +33701,10 @@ def test_get_property_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_property(request) - - -def test_get_property_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.Property() - - # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.get_property(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{name=properties/*}" % client.transport._host, args[1] - ) - - -def test_get_property_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_property( - analytics_admin.GetPropertyRequest(), - name="name_value", - ) + client.batch_delete_user_links(request) -def test_get_property_rest_error(): +def test_batch_delete_user_links_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -26384,49 +33713,56 @@ def test_get_property_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListPropertiesRequest, + analytics_admin.CreateFirebaseLinkRequest, dict, ], ) -def test_list_properties_rest(request_type): +def test_create_firebase_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"parent": "properties/sample1"} + request_init["firebase_link"] = { + "name": "name_value", + "project": "project_value", + "create_time": {"seconds": 751, "nanos": 543}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListPropertiesResponse( - next_page_token="next_page_token_value", + return_value = resources.FirebaseLink( + name="name_value", + project="project_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListPropertiesResponse.pb(return_value) + pb_return_value = resources.FirebaseLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_properties(request) + response = client.create_firebase_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPropertiesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.FirebaseLink) + assert response.name == "name_value" + assert response.project == "project_value" -def test_list_properties_rest_required_fields( - request_type=analytics_admin.ListPropertiesRequest, +def test_create_firebase_link_rest_required_fields( + request_type=analytics_admin.CreateFirebaseLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["filter"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -26438,36 +33774,24 @@ def test_list_properties_rest_required_fields( ) # verify fields with default values are dropped - assert "filter" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_properties._get_unset_required_fields(jsonified_request) + ).create_firebase_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - assert "filter" in jsonified_request - assert jsonified_request["filter"] == request_init["filter"] - jsonified_request["filter"] = "filter_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_properties._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "page_size", - "page_token", - "show_deleted", - ) - ) + ).create_firebase_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "filter" in jsonified_request - assert jsonified_request["filter"] == "filter_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -26476,7 +33800,7 @@ def test_list_properties_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListPropertiesResponse() + return_value = resources.FirebaseLink() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -26488,54 +33812,47 @@ def test_list_properties_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListPropertiesResponse.pb(return_value) + pb_return_value = resources.FirebaseLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_properties(request) + response = client.create_firebase_link(request) - expected_params = [ - ( - "filter", - "", - ), - ("$alt", "json;enum-encoding=int"), - ] + expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_properties_rest_unset_required_fields(): +def test_create_firebase_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_properties._get_unset_required_fields({}) + unset_fields = transport.create_firebase_link._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(()) + & set( ( - "filter", - "pageSize", - "pageToken", - "showDeleted", + "parent", + "firebaseLink", ) ) - & set(("filter",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_properties_rest_interceptors(null_interceptor): +def test_create_firebase_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26548,14 +33865,14 @@ def test_list_properties_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_properties" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_firebase_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_properties" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_firebase_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListPropertiesRequest.pb( - analytics_admin.ListPropertiesRequest() + pb_message = analytics_admin.CreateFirebaseLinkRequest.pb( + analytics_admin.CreateFirebaseLinkRequest() ) transcode.return_value = { "method": "post", @@ -26567,19 +33884,19 @@ def test_list_properties_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ListPropertiesResponse.to_json( - analytics_admin.ListPropertiesResponse() + req.return_value._content = resources.FirebaseLink.to_json( + resources.FirebaseLink() ) - request = analytics_admin.ListPropertiesRequest() + request = analytics_admin.CreateFirebaseLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListPropertiesResponse() + post.return_value = resources.FirebaseLink() - client.list_properties( + client.create_firebase_link( request, metadata=[ ("key", "val"), @@ -26591,8 +33908,8 @@ def test_list_properties_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_properties_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListPropertiesRequest +def test_create_firebase_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateFirebaseLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -26600,7 +33917,12 @@ def test_list_properties_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"parent": "properties/sample1"} + request_init["firebase_link"] = { + "name": "name_value", + "project": "project_value", + "create_time": {"seconds": 751, "nanos": 543}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26612,148 +33934,114 @@ def test_list_properties_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_properties(request) + client.create_firebase_link(request) -def test_list_properties_rest_pager(transport: str = "rest"): +def test_create_firebase_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - resources.Property(), - ], - next_page_token="abc", - ), - analytics_admin.ListPropertiesResponse( - properties=[], - next_page_token="def", - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - ], - next_page_token="ghi", - ), - analytics_admin.ListPropertiesResponse( - properties=[ - resources.Property(), - resources.Property(), - ], - ), + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.FirebaseLink() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "properties/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + firebase_link=resources.FirebaseLink(name="name_value"), ) - # Two responses for two calls - response = response + response + mock_args.update(sample_request) - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListPropertiesResponse.to_json(x) for x in response + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.FirebaseLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_firebase_link(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{parent=properties/*}/firebaseLinks" % client.transport._host, + args[1], ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - sample_request = {} - pager = client.list_properties(request=sample_request) +def test_create_firebase_link_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Property) for i in results) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_firebase_link( + analytics_admin.CreateFirebaseLinkRequest(), + parent="parent_value", + firebase_link=resources.FirebaseLink(name="name_value"), + ) - pages = list(client.list_properties(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + +def test_create_firebase_link_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreatePropertyRequest, + analytics_admin.DeleteFirebaseLinkRequest, dict, ], ) -def test_create_property_rest(request_type): +def test_delete_firebase_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {} - request_init["property"] = { - "name": "name_value", - "property_type": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "parent": "parent_value", - "display_name": "display_name_value", - "industry_category": 1, - "time_zone": "time_zone_value", - "currency_code": "currency_code_value", - "service_level": 1, - "delete_time": {}, - "expire_time": {}, - "account": "account_value", - } + request_init = {"name": "properties/sample1/firebaseLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Property( - name="name_value", - property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, - parent="parent_value", - display_name="display_name_value", - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone="time_zone_value", - currency_code="currency_code_value", - service_level=resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD, - account="account_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_property(request) + response = client.delete_firebase_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) - assert response.name == "name_value" - assert response.property_type == resources.PropertyType.PROPERTY_TYPE_ORDINARY - 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.service_level == resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD - assert response.account == "account_value" + assert response is None -def test_create_property_rest_required_fields( - request_type=analytics_admin.CreatePropertyRequest, +def test_delete_firebase_link_rest_required_fields( + request_type=analytics_admin.DeleteFirebaseLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -26768,17 +34056,21 @@ def test_create_property_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_property._get_unset_required_fields(jsonified_request) + ).delete_firebase_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_property._get_unset_required_fields(jsonified_request) + ).delete_firebase_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -26787,7 +34079,7 @@ def test_create_property_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.Property() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -26799,39 +34091,36 @@ def test_create_property_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "delete", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.Property.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_property(request) + response = client.delete_firebase_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_property_rest_unset_required_fields(): +def test_delete_firebase_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_property._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("property",))) + unset_fields = transport.delete_firebase_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_property_rest_interceptors(null_interceptor): +def test_delete_firebase_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26844,14 +34133,11 @@ def test_create_property_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_property" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_property" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_firebase_link" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreatePropertyRequest.pb( - analytics_admin.CreatePropertyRequest() + pb_message = analytics_admin.DeleteFirebaseLinkRequest.pb( + analytics_admin.DeleteFirebaseLinkRequest() ) transcode.return_value = { "method": "post", @@ -26863,17 +34149,15 @@ def test_create_property_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.Property.to_json(resources.Property()) - request = analytics_admin.CreatePropertyRequest() + request = analytics_admin.DeleteFirebaseLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Property() - client.create_property( + client.delete_firebase_link( request, metadata=[ ("key", "val"), @@ -26882,11 +34166,10 @@ def test_create_property_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_property_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreatePropertyRequest +def test_delete_firebase_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteFirebaseLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -26894,22 +34177,7 @@ def test_create_property_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} - request_init["property"] = { - "name": "name_value", - "property_type": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "parent": "parent_value", - "display_name": "display_name_value", - "industry_category": 1, - "time_zone": "time_zone_value", - "currency_code": "currency_code_value", - "service_level": 1, - "delete_time": {}, - "expire_time": {}, - "account": "account_value", - } + request_init = {"name": "properties/sample1/firebaseLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26921,10 +34189,10 @@ def test_create_property_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_property(request) + client.delete_firebase_link(request) -def test_create_property_rest_flattened(): +def test_delete_firebase_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -26933,37 +34201,37 @@ def test_create_property_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Property() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = {} + sample_request = {"name": "properties/sample1/firebaseLinks/sample2"} # get truthy value for each flattened field mock_args = dict( - property=resources.Property(name="name_value"), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_property(**mock_args) + client.delete_firebase_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/properties" % client.transport._host, args[1] + "%s/v1alpha/{name=properties/*/firebaseLinks/*}" % client.transport._host, + args[1], ) -def test_create_property_rest_flattened_error(transport: str = "rest"): +def test_delete_firebase_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -26972,13 +34240,13 @@ def test_create_property_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_property( - analytics_admin.CreatePropertyRequest(), - property=resources.Property(name="name_value"), + client.delete_firebase_link( + analytics_admin.DeleteFirebaseLinkRequest(), + name="name_value", ) -def test_create_property_rest_error(): +def test_delete_firebase_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -26987,65 +34255,49 @@ def test_create_property_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeletePropertyRequest, + analytics_admin.ListFirebaseLinksRequest, dict, ], ) -def test_delete_property_rest(request_type): +def test_list_firebase_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Property( - name="name_value", - property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, - parent="parent_value", - display_name="display_name_value", - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone="time_zone_value", - currency_code="currency_code_value", - service_level=resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD, - account="account_value", + return_value = analytics_admin.ListFirebaseLinksResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) + pb_return_value = analytics_admin.ListFirebaseLinksResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_property(request) + response = client.list_firebase_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) - assert response.name == "name_value" - assert response.property_type == resources.PropertyType.PROPERTY_TYPE_ORDINARY - 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.service_level == resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD - assert response.account == "account_value" + assert isinstance(response, pagers.ListFirebaseLinksPager) + assert response.next_page_token == "next_page_token_value" -def test_delete_property_rest_required_fields( - request_type=analytics_admin.DeletePropertyRequest, +def test_list_firebase_links_rest_required_fields( + request_type=analytics_admin.ListFirebaseLinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -27060,21 +34312,28 @@ def test_delete_property_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_property._get_unset_required_fields(jsonified_request) + ).list_firebase_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_property._get_unset_required_fields(jsonified_request) + ).list_firebase_links._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -27083,7 +34342,7 @@ def test_delete_property_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.Property() + return_value = analytics_admin.ListFirebaseLinksResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -27095,7 +34354,7 @@ def test_delete_property_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "get", "query_params": pb_request, } transcode.return_value = transcode_result @@ -27103,30 +34362,38 @@ def test_delete_property_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) + pb_return_value = analytics_admin.ListFirebaseLinksResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_property(request) + response = client.list_firebase_links(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_property_rest_unset_required_fields(): +def test_list_firebase_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_property._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.list_firebase_links._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_property_rest_interceptors(null_interceptor): +def test_list_firebase_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27139,14 +34406,14 @@ def test_delete_property_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_delete_property" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_firebase_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_property" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_firebase_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.DeletePropertyRequest.pb( - analytics_admin.DeletePropertyRequest() + pb_message = analytics_admin.ListFirebaseLinksRequest.pb( + analytics_admin.ListFirebaseLinksRequest() ) transcode.return_value = { "method": "post", @@ -27158,17 +34425,19 @@ def test_delete_property_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.Property.to_json(resources.Property()) + req.return_value._content = analytics_admin.ListFirebaseLinksResponse.to_json( + analytics_admin.ListFirebaseLinksResponse() + ) - request = analytics_admin.DeletePropertyRequest() + request = analytics_admin.ListFirebaseLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Property() + post.return_value = analytics_admin.ListFirebaseLinksResponse() - client.delete_property( + client.list_firebase_links( request, metadata=[ ("key", "val"), @@ -27180,8 +34449,8 @@ def test_delete_property_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_property_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeletePropertyRequest +def test_list_firebase_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListFirebaseLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -27189,7 +34458,7 @@ def test_delete_property_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -27201,10 +34470,10 @@ def test_delete_property_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_property(request) + client.list_firebase_links(request) -def test_delete_property_rest_flattened(): +def test_list_firebase_links_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -27213,37 +34482,38 @@ def test_delete_property_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Property() + return_value = analytics_admin.ListFirebaseLinksResponse() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) + pb_return_value = analytics_admin.ListFirebaseLinksResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_property(**mock_args) + client.list_firebase_links(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*}" % client.transport._host, args[1] + "%s/v1alpha/{parent=properties/*}/firebaseLinks" % client.transport._host, + args[1], ) -def test_delete_property_rest_flattened_error(transport: str = "rest"): +def test_list_firebase_links_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -27252,94 +34522,123 @@ def test_delete_property_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_property( - analytics_admin.DeletePropertyRequest(), - name="name_value", + client.list_firebase_links( + analytics_admin.ListFirebaseLinksRequest(), + parent="parent_value", ) -def test_delete_property_rest_error(): +def test_list_firebase_links_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[], + next_page_token="def", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListFirebaseLinksResponse( + firebase_links=[ + resources.FirebaseLink(), + resources.FirebaseLink(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListFirebaseLinksResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1"} + + pager = client.list_firebase_links(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.FirebaseLink) for i in results) + + pages = list(client.list_firebase_links(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdatePropertyRequest, + analytics_admin.GetGlobalSiteTagRequest, dict, ], ) -def test_update_property_rest(request_type): +def test_get_global_site_tag_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"property": {"name": "properties/sample1"}} - request_init["property"] = { - "name": "properties/sample1", - "property_type": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "parent": "parent_value", - "display_name": "display_name_value", - "industry_category": 1, - "time_zone": "time_zone_value", - "currency_code": "currency_code_value", - "service_level": 1, - "delete_time": {}, - "expire_time": {}, - "account": "account_value", - } + request_init = {"name": "properties/sample1/dataStreams/sample2/globalSiteTag"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Property( + return_value = resources.GlobalSiteTag( name="name_value", - property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, - parent="parent_value", - display_name="display_name_value", - industry_category=resources.IndustryCategory.AUTOMOTIVE, - time_zone="time_zone_value", - currency_code="currency_code_value", - service_level=resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD, - account="account_value", + snippet="snippet_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) + pb_return_value = resources.GlobalSiteTag.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_property(request) + response = client.get_global_site_tag(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) + assert isinstance(response, resources.GlobalSiteTag) assert response.name == "name_value" - assert response.property_type == resources.PropertyType.PROPERTY_TYPE_ORDINARY - 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.service_level == resources.ServiceLevel.GOOGLE_ANALYTICS_STANDARD - assert response.account == "account_value" + assert response.snippet == "snippet_value" -def test_update_property_rest_required_fields( - request_type=analytics_admin.UpdatePropertyRequest, +def test_get_global_site_tag_rest_required_fields( + request_type=analytics_admin.GetGlobalSiteTagRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -27354,19 +34653,21 @@ def test_update_property_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_property._get_unset_required_fields(jsonified_request) + ).get_global_site_tag._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_property._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + ).get_global_site_tag._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -27375,7 +34676,7 @@ def test_update_property_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.Property() + return_value = resources.GlobalSiteTag() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -27387,47 +34688,38 @@ def test_update_property_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) + pb_return_value = resources.GlobalSiteTag.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_property(request) + response = client.get_global_site_tag(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_property_rest_unset_required_fields(): +def test_get_global_site_tag_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_property._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("updateMask",)) - & set( - ( - "property", - "updateMask", - ) - ) - ) + unset_fields = transport.get_global_site_tag._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_property_rest_interceptors(null_interceptor): +def test_get_global_site_tag_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27440,14 +34732,14 @@ def test_update_property_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_property" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_global_site_tag" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_property" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_global_site_tag" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdatePropertyRequest.pb( - analytics_admin.UpdatePropertyRequest() + pb_message = analytics_admin.GetGlobalSiteTagRequest.pb( + analytics_admin.GetGlobalSiteTagRequest() ) transcode.return_value = { "method": "post", @@ -27459,17 +34751,19 @@ def test_update_property_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.Property.to_json(resources.Property()) + req.return_value._content = resources.GlobalSiteTag.to_json( + resources.GlobalSiteTag() + ) - request = analytics_admin.UpdatePropertyRequest() + request = analytics_admin.GetGlobalSiteTagRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Property() + post.return_value = resources.GlobalSiteTag() - client.update_property( + client.get_global_site_tag( request, metadata=[ ("key", "val"), @@ -27481,8 +34775,8 @@ def test_update_property_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_property_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdatePropertyRequest +def test_get_global_site_tag_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetGlobalSiteTagRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -27490,22 +34784,7 @@ def test_update_property_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"property": {"name": "properties/sample1"}} - request_init["property"] = { - "name": "properties/sample1", - "property_type": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "parent": "parent_value", - "display_name": "display_name_value", - "industry_category": 1, - "time_zone": "time_zone_value", - "currency_code": "currency_code_value", - "service_level": 1, - "delete_time": {}, - "expire_time": {}, - "account": "account_value", - } + request_init = {"name": "properties/sample1/dataStreams/sample2/globalSiteTag"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -27517,10 +34796,10 @@ def test_update_property_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_property(request) + client.get_global_site_tag(request) -def test_update_property_rest_flattened(): +def test_get_global_site_tag_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -27529,38 +34808,41 @@ def test_update_property_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.Property() + return_value = resources.GlobalSiteTag() # get arguments that satisfy an http rule for this method - sample_request = {"property": {"name": "properties/sample1"}} + sample_request = { + "name": "properties/sample1/dataStreams/sample2/globalSiteTag" + } # get truthy value for each flattened field mock_args = dict( - property=resources.Property(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Property.pb(return_value) + pb_return_value = resources.GlobalSiteTag.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_property(**mock_args) + client.get_global_site_tag(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{property.name=properties/*}" % client.transport._host, args[1] + "%s/v1alpha/{name=properties/*/dataStreams/*/globalSiteTag}" + % client.transport._host, + args[1], ) -def test_update_property_rest_flattened_error(transport: str = "rest"): +def test_get_global_site_tag_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -27569,14 +34851,13 @@ def test_update_property_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_property( - analytics_admin.UpdatePropertyRequest(), - property=resources.Property(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_global_site_tag( + analytics_admin.GetGlobalSiteTagRequest(), + name="name_value", ) -def test_update_property_rest_error(): +def test_get_global_site_tag_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -27585,53 +34866,64 @@ def test_update_property_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetUserLinkRequest, + analytics_admin.CreateGoogleAdsLinkRequest, dict, ], ) -def test_get_user_link_rest(request_type): +def test_create_google_ads_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1/userLinks/sample2"} + request_init = {"parent": "properties/sample1"} + request_init["google_ads_link"] = { + "name": "name_value", + "customer_id": "customer_id_value", + "can_manage_clients": True, + "ads_personalization_enabled": {"value": True}, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "creator_email_address": "creator_email_address_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.UserLink( + return_value = resources.GoogleAdsLink( name="name_value", - email_address="email_address_value", - direct_roles=["direct_roles_value"], + customer_id="customer_id_value", + can_manage_clients=True, + creator_email_address="creator_email_address_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = resources.GoogleAdsLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_user_link(request) + response = client.create_google_ads_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.UserLink) + assert isinstance(response, resources.GoogleAdsLink) assert response.name == "name_value" - assert response.email_address == "email_address_value" - assert response.direct_roles == ["direct_roles_value"] + assert response.customer_id == "customer_id_value" + assert response.can_manage_clients is True + assert response.creator_email_address == "creator_email_address_value" -def test_get_user_link_rest_required_fields( - request_type=analytics_admin.GetUserLinkRequest, +def test_create_google_ads_link_rest_required_fields( + request_type=analytics_admin.CreateGoogleAdsLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -27646,21 +34938,21 @@ def test_get_user_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_user_link._get_unset_required_fields(jsonified_request) + ).create_google_ads_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_user_link._get_unset_required_fields(jsonified_request) + ).create_google_ads_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -27669,7 +34961,7 @@ def test_get_user_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.UserLink() + return_value = resources.GoogleAdsLink() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -27681,38 +34973,47 @@ def test_get_user_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = resources.GoogleAdsLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_user_link(request) + response = client.create_google_ads_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_user_link_rest_unset_required_fields(): +def test_create_google_ads_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_user_link._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.create_google_ads_link._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "googleAdsLink", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_user_link_rest_interceptors(null_interceptor): +def test_create_google_ads_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27725,14 +35026,14 @@ def test_get_user_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_user_link" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_google_ads_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_user_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_google_ads_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetUserLinkRequest.pb( - analytics_admin.GetUserLinkRequest() + pb_message = analytics_admin.CreateGoogleAdsLinkRequest.pb( + analytics_admin.CreateGoogleAdsLinkRequest() ) transcode.return_value = { "method": "post", @@ -27744,17 +35045,19 @@ def test_get_user_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.UserLink.to_json(resources.UserLink()) + req.return_value._content = resources.GoogleAdsLink.to_json( + resources.GoogleAdsLink() + ) - request = analytics_admin.GetUserLinkRequest() + request = analytics_admin.CreateGoogleAdsLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.UserLink() + post.return_value = resources.GoogleAdsLink() - client.get_user_link( + client.create_google_ads_link( request, metadata=[ ("key", "val"), @@ -27766,8 +35069,8 @@ def test_get_user_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_user_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetUserLinkRequest +def test_create_google_ads_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -27775,7 +35078,16 @@ def test_get_user_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1/userLinks/sample2"} + request_init = {"parent": "properties/sample1"} + request_init["google_ads_link"] = { + "name": "name_value", + "customer_id": "customer_id_value", + "can_manage_clients": True, + "ads_personalization_enabled": {"value": True}, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "creator_email_address": "creator_email_address_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -27787,10 +35099,10 @@ def test_get_user_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_user_link(request) + client.create_google_ads_link(request) -def test_get_user_link_rest_flattened(): +def test_create_google_ads_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -27799,37 +35111,39 @@ def test_get_user_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.UserLink() + return_value = resources.GoogleAdsLink() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1/userLinks/sample2"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", + google_ads_link=resources.GoogleAdsLink(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = resources.GoogleAdsLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_user_link(**mock_args) + client.create_google_ads_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=accounts/*/userLinks/*}" % client.transport._host, args[1] + "%s/v1alpha/{parent=properties/*}/googleAdsLinks" % client.transport._host, + args[1], ) -def test_get_user_link_rest_flattened_error(transport: str = "rest"): +def test_create_google_ads_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -27838,13 +35152,14 @@ def test_get_user_link_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_user_link( - analytics_admin.GetUserLinkRequest(), - name="name_value", + client.create_google_ads_link( + analytics_admin.CreateGoogleAdsLinkRequest(), + parent="parent_value", + google_ads_link=resources.GoogleAdsLink(name="name_value"), ) -def test_get_user_link_rest_error(): +def test_create_google_ads_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -27853,47 +35168,65 @@ def test_get_user_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchGetUserLinksRequest, + analytics_admin.UpdateGoogleAdsLinkRequest, dict, ], ) -def test_batch_get_user_links_rest(request_type): +def test_update_google_ads_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = { + "google_ads_link": {"name": "properties/sample1/googleAdsLinks/sample2"} + } + request_init["google_ads_link"] = { + "name": "properties/sample1/googleAdsLinks/sample2", + "customer_id": "customer_id_value", + "can_manage_clients": True, + "ads_personalization_enabled": {"value": True}, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "creator_email_address": "creator_email_address_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchGetUserLinksResponse() + return_value = resources.GoogleAdsLink( + name="name_value", + customer_id="customer_id_value", + can_manage_clients=True, + creator_email_address="creator_email_address_value", + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchGetUserLinksResponse.pb(return_value) + pb_return_value = resources.GoogleAdsLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_get_user_links(request) + response = client.update_google_ads_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) + 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.creator_email_address == "creator_email_address_value" -def test_batch_get_user_links_rest_required_fields( - request_type=analytics_admin.BatchGetUserLinksRequest, +def test_update_google_ads_link_rest_required_fields( + request_type=analytics_admin.UpdateGoogleAdsLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" - request_init["names"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -27905,32 +35238,22 @@ def test_batch_get_user_links_rest_required_fields( ) # verify fields with default values are dropped - assert "names" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_get_user_links._get_unset_required_fields(jsonified_request) + ).update_google_ads_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - assert "names" in jsonified_request - assert jsonified_request["names"] == request_init["names"] - - jsonified_request["parent"] = "parent_value" - jsonified_request["names"] = "names_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_get_user_links._get_unset_required_fields(jsonified_request) + ).update_google_ads_link._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("names",)) + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - assert "names" in jsonified_request - assert jsonified_request["names"] == "names_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -27939,7 +35262,7 @@ def test_batch_get_user_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchGetUserLinksResponse() + return_value = resources.GoogleAdsLink() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -27951,52 +35274,39 @@ def test_batch_get_user_links_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchGetUserLinksResponse.pb(return_value) + pb_return_value = resources.GoogleAdsLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_get_user_links(request) + response = client.update_google_ads_link(request) - expected_params = [ - ( - "names", - "", - ), - ("$alt", "json;enum-encoding=int"), - ] + expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_batch_get_user_links_rest_unset_required_fields(): +def test_update_google_ads_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_get_user_links._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("names",)) - & set( - ( - "parent", - "names", - ) - ) - ) + unset_fields = transport.update_google_ads_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_get_user_links_rest_interceptors(null_interceptor): +def test_update_google_ads_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28009,14 +35319,14 @@ def test_batch_get_user_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_batch_get_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_google_ads_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_get_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_google_ads_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.BatchGetUserLinksRequest.pb( - analytics_admin.BatchGetUserLinksRequest() + pb_message = analytics_admin.UpdateGoogleAdsLinkRequest.pb( + analytics_admin.UpdateGoogleAdsLinkRequest() ) transcode.return_value = { "method": "post", @@ -28028,19 +35338,19 @@ def test_batch_get_user_links_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.BatchGetUserLinksResponse.to_json( - analytics_admin.BatchGetUserLinksResponse() + req.return_value._content = resources.GoogleAdsLink.to_json( + resources.GoogleAdsLink() ) - request = analytics_admin.BatchGetUserLinksRequest() + request = analytics_admin.UpdateGoogleAdsLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchGetUserLinksResponse() + post.return_value = resources.GoogleAdsLink() - client.batch_get_user_links( + client.update_google_ads_link( request, metadata=[ ("key", "val"), @@ -28052,8 +35362,8 @@ def test_batch_get_user_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_batch_get_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.BatchGetUserLinksRequest +def test_update_google_ads_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -28061,7 +35371,18 @@ def test_batch_get_user_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = { + "google_ads_link": {"name": "properties/sample1/googleAdsLinks/sample2"} + } + request_init["google_ads_link"] = { + "name": "properties/sample1/googleAdsLinks/sample2", + "customer_id": "customer_id_value", + "can_manage_clients": True, + "ads_personalization_enabled": {"value": True}, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "creator_email_address": "creator_email_address_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28073,10 +35394,70 @@ def test_batch_get_user_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.batch_get_user_links(request) + client.update_google_ads_link(request) -def test_batch_get_user_links_rest_error(): +def test_update_google_ads_link_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.GoogleAdsLink() + + # get arguments that satisfy an http rule for this method + sample_request = { + "google_ads_link": {"name": "properties/sample1/googleAdsLinks/sample2"} + } + + # get truthy value for each flattened field + mock_args = dict( + google_ads_link=resources.GoogleAdsLink(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.GoogleAdsLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_google_ads_link(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{google_ads_link.name=properties/*/googleAdsLinks/*}" + % client.transport._host, + args[1], + ) + + +def test_update_google_ads_link_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_google_ads_link( + analytics_admin.UpdateGoogleAdsLinkRequest(), + google_ads_link=resources.GoogleAdsLink(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_google_ads_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -28085,49 +35466,45 @@ def test_batch_get_user_links_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListUserLinksRequest, + analytics_admin.DeleteGoogleAdsLinkRequest, dict, ], ) -def test_list_user_links_rest(request_type): +def test_delete_google_ads_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = {"name": "properties/sample1/googleAdsLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListUserLinksResponse( - next_page_token="next_page_token_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListUserLinksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_user_links(request) + response = client.delete_google_ads_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListUserLinksPager) - assert response.next_page_token == "next_page_token_value" + assert response is None -def test_list_user_links_rest_required_fields( - request_type=analytics_admin.ListUserLinksRequest, +def test_delete_google_ads_link_rest_required_fields( + request_type=analytics_admin.DeleteGoogleAdsLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -28142,28 +35519,21 @@ def test_list_user_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_user_links._get_unset_required_fields(jsonified_request) + ).delete_google_ads_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_user_links._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).delete_google_ads_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -28172,7 +35542,7 @@ def test_list_user_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListUserLinksResponse() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -28184,46 +35554,36 @@ def test_list_user_links_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "delete", "query_params": pb_request, } transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = analytics_admin.ListUserLinksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_user_links(request) + response = client.delete_google_ads_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_user_links_rest_unset_required_fields(): +def test_delete_google_ads_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_user_links._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.delete_google_ads_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_user_links_rest_interceptors(null_interceptor): +def test_delete_google_ads_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28236,14 +35596,11 @@ def test_list_user_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_user_links" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_google_ads_link" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.ListUserLinksRequest.pb( - analytics_admin.ListUserLinksRequest() + pb_message = analytics_admin.DeleteGoogleAdsLinkRequest.pb( + analytics_admin.DeleteGoogleAdsLinkRequest() ) transcode.return_value = { "method": "post", @@ -28255,19 +35612,15 @@ def test_list_user_links_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ListUserLinksResponse.to_json( - analytics_admin.ListUserLinksResponse() - ) - request = analytics_admin.ListUserLinksRequest() + request = analytics_admin.DeleteGoogleAdsLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListUserLinksResponse() - client.list_user_links( + client.delete_google_ads_link( request, metadata=[ ("key", "val"), @@ -28276,11 +35629,10 @@ def test_list_user_links_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_list_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListUserLinksRequest +def test_delete_google_ads_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -28288,7 +35640,7 @@ def test_list_user_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = {"name": "properties/sample1/googleAdsLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28300,10 +35652,10 @@ def test_list_user_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_user_links(request) + client.delete_google_ads_link(request) -def test_list_user_links_rest_flattened(): +def test_delete_google_ads_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -28312,155 +35664,98 @@ def test_list_user_links_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListUserLinksResponse() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"parent": "accounts/sample1"} + sample_request = {"name": "properties/sample1/googleAdsLinks/sample2"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListUserLinksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_user_links(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{parent=accounts/*}/userLinks" % client.transport._host, args[1] - ) - - -def test_list_user_links_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_user_links( - analytics_admin.ListUserLinksRequest(), - parent="parent_value", - ) - - -def test_list_user_links_rest_pager(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - resources.UserLink(), - ], - next_page_token="abc", - ), - analytics_admin.ListUserLinksResponse( - user_links=[], - next_page_token="def", - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - ], - next_page_token="ghi", - ), - analytics_admin.ListUserLinksResponse( - user_links=[ - resources.UserLink(), - resources.UserLink(), - ], - ), - ) - # Two responses for two calls - response = response + response + client.delete_google_ads_link(**mock_args) - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListUserLinksResponse.to_json(x) for x in response + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=properties/*/googleAdsLinks/*}" % client.transport._host, + args[1], ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - sample_request = {"parent": "accounts/sample1"} - pager = client.list_user_links(request=sample_request) +def test_delete_google_ads_link_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.UserLink) for i in results) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_google_ads_link( + analytics_admin.DeleteGoogleAdsLinkRequest(), + name="name_value", + ) - pages = list(client.list_user_links(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + +def test_delete_google_ads_link_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.AuditUserLinksRequest, + analytics_admin.ListGoogleAdsLinksRequest, dict, ], ) -def test_audit_user_links_rest(request_type): +def test_list_google_ads_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.AuditUserLinksResponse( + return_value = analytics_admin.ListGoogleAdsLinksResponse( next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.AuditUserLinksResponse.pb(return_value) + pb_return_value = analytics_admin.ListGoogleAdsLinksResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.audit_user_links(request) + response = client.list_google_ads_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.AuditUserLinksPager) + assert isinstance(response, pagers.ListGoogleAdsLinksPager) assert response.next_page_token == "next_page_token_value" -def test_audit_user_links_rest_required_fields( - request_type=analytics_admin.AuditUserLinksRequest, +def test_list_google_ads_links_rest_required_fields( + request_type=analytics_admin.ListGoogleAdsLinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -28480,7 +35775,7 @@ def test_audit_user_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).audit_user_links._get_unset_required_fields(jsonified_request) + ).list_google_ads_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -28489,7 +35784,14 @@ def test_audit_user_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).audit_user_links._get_unset_required_fields(jsonified_request) + ).list_google_ads_links._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -28503,7 +35805,7 @@ def test_audit_user_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.AuditUserLinksResponse() + return_value = analytics_admin.ListGoogleAdsLinksResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -28515,39 +35817,48 @@ def test_audit_user_links_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.AuditUserLinksResponse.pb(return_value) + pb_return_value = analytics_admin.ListGoogleAdsLinksResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.audit_user_links(request) + response = client.list_google_ads_links(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_audit_user_links_rest_unset_required_fields(): +def test_list_google_ads_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.audit_user_links._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + unset_fields = transport.list_google_ads_links._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_audit_user_links_rest_interceptors(null_interceptor): +def test_list_google_ads_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28560,14 +35871,14 @@ def test_audit_user_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_audit_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_google_ads_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_audit_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_google_ads_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.AuditUserLinksRequest.pb( - analytics_admin.AuditUserLinksRequest() + pb_message = analytics_admin.ListGoogleAdsLinksRequest.pb( + analytics_admin.ListGoogleAdsLinksRequest() ) transcode.return_value = { "method": "post", @@ -28579,19 +35890,19 @@ def test_audit_user_links_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.AuditUserLinksResponse.to_json( - analytics_admin.AuditUserLinksResponse() + req.return_value._content = analytics_admin.ListGoogleAdsLinksResponse.to_json( + analytics_admin.ListGoogleAdsLinksResponse() ) - request = analytics_admin.AuditUserLinksRequest() + request = analytics_admin.ListGoogleAdsLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.AuditUserLinksResponse() + post.return_value = analytics_admin.ListGoogleAdsLinksResponse() - client.audit_user_links( + client.list_google_ads_links( request, metadata=[ ("key", "val"), @@ -28603,8 +35914,8 @@ def test_audit_user_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_audit_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.AuditUserLinksRequest +def test_list_google_ads_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListGoogleAdsLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -28612,7 +35923,7 @@ def test_audit_user_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28624,10 +35935,65 @@ def test_audit_user_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.audit_user_links(request) + client.list_google_ads_links(request) -def test_audit_user_links_rest_pager(transport: str = "rest"): +def test_list_google_ads_links_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = analytics_admin.ListGoogleAdsLinksResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "properties/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.ListGoogleAdsLinksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_google_ads_links(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{parent=properties/*}/googleAdsLinks" % client.transport._host, + args[1], + ) + + +def test_list_google_ads_links_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_google_ads_links( + analytics_admin.ListGoogleAdsLinksRequest(), + parent="parent_value", + ) + + +def test_list_google_ads_links_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -28639,28 +36005,28 @@ def test_audit_user_links_rest_pager(transport: str = "rest"): # with mock.patch.object(path_template, 'transcode') as transcode: # Set the response as a series of pages response = ( - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - resources.AuditUserLink(), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), ], next_page_token="abc", ), - analytics_admin.AuditUserLinksResponse( - user_links=[], + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[], next_page_token="def", ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), ], next_page_token="ghi", ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), ], ), ) @@ -28669,7 +36035,7 @@ def test_audit_user_links_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.AuditUserLinksResponse.to_json(x) for x in response + analytics_admin.ListGoogleAdsLinksResponse.to_json(x) for x in response ) return_values = tuple(Response() for i in response) for return_val, response_val in zip(return_values, response): @@ -28677,15 +36043,15 @@ def test_audit_user_links_rest_pager(transport: str = "rest"): return_val.status_code = 200 req.side_effect = return_values - sample_request = {"parent": "accounts/sample1"} + sample_request = {"parent": "properties/sample1"} - pager = client.audit_user_links(request=sample_request) + pager = client.list_google_ads_links(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.AuditUserLink) for i in results) + assert all(isinstance(i, resources.GoogleAdsLink) for i in results) - pages = list(client.audit_user_links(request=sample_request).pages) + pages = list(client.list_google_ads_links(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -28693,58 +36059,59 @@ def test_audit_user_links_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateUserLinkRequest, + analytics_admin.GetDataSharingSettingsRequest, dict, ], ) -def test_create_user_link_rest(request_type): +def test_get_data_sharing_settings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} - request_init["user_link"] = { - "name": "name_value", - "email_address": "email_address_value", - "direct_roles": ["direct_roles_value1", "direct_roles_value2"], - } + request_init = {"name": "accounts/sample1/dataSharingSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.UserLink( + return_value = resources.DataSharingSettings( name="name_value", - email_address="email_address_value", - direct_roles=["direct_roles_value"], + sharing_with_google_support_enabled=True, + sharing_with_google_assigned_sales_enabled=True, + sharing_with_google_any_sales_enabled=True, + sharing_with_google_products_enabled=True, + sharing_with_others_enabled=True, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = resources.DataSharingSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_user_link(request) + response = client.get_data_sharing_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.UserLink) + assert isinstance(response, resources.DataSharingSettings) assert response.name == "name_value" - assert response.email_address == "email_address_value" - assert response.direct_roles == ["direct_roles_value"] + assert response.sharing_with_google_support_enabled is True + assert response.sharing_with_google_assigned_sales_enabled is True + assert response.sharing_with_google_any_sales_enabled is True + assert response.sharing_with_google_products_enabled is True + assert response.sharing_with_others_enabled is True -def test_create_user_link_rest_required_fields( - request_type=analytics_admin.CreateUserLinkRequest, +def test_get_data_sharing_settings_rest_required_fields( + request_type=analytics_admin.GetDataSharingSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -28759,23 +36126,21 @@ def test_create_user_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_user_link._get_unset_required_fields(jsonified_request) + ).get_data_sharing_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_user_link._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("notify_new_user",)) + ).get_data_sharing_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -28784,7 +36149,7 @@ def test_create_user_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.UserLink() + return_value = resources.DataSharingSettings() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -28796,47 +36161,38 @@ def test_create_user_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = resources.DataSharingSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_user_link(request) + response = client.get_data_sharing_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_user_link_rest_unset_required_fields(): +def test_get_data_sharing_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_user_link._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("notifyNewUser",)) - & set( - ( - "parent", - "userLink", - ) - ) - ) + unset_fields = transport.get_data_sharing_settings._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_user_link_rest_interceptors(null_interceptor): +def test_get_data_sharing_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -28849,14 +36205,15 @@ def test_create_user_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_user_link" + transports.AnalyticsAdminServiceRestInterceptor, + "post_get_data_sharing_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_user_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_data_sharing_settings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateUserLinkRequest.pb( - analytics_admin.CreateUserLinkRequest() + pb_message = analytics_admin.GetDataSharingSettingsRequest.pb( + analytics_admin.GetDataSharingSettingsRequest() ) transcode.return_value = { "method": "post", @@ -28868,17 +36225,19 @@ def test_create_user_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.UserLink.to_json(resources.UserLink()) + req.return_value._content = resources.DataSharingSettings.to_json( + resources.DataSharingSettings() + ) - request = analytics_admin.CreateUserLinkRequest() + request = analytics_admin.GetDataSharingSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.UserLink() + post.return_value = resources.DataSharingSettings() - client.create_user_link( + client.get_data_sharing_settings( request, metadata=[ ("key", "val"), @@ -28890,8 +36249,8 @@ def test_create_user_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_user_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateUserLinkRequest +def test_get_data_sharing_settings_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetDataSharingSettingsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -28899,12 +36258,7 @@ def test_create_user_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} - request_init["user_link"] = { - "name": "name_value", - "email_address": "email_address_value", - "direct_roles": ["direct_roles_value1", "direct_roles_value2"], - } + request_init = {"name": "accounts/sample1/dataSharingSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -28916,10 +36270,10 @@ def test_create_user_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_user_link(request) + client.get_data_sharing_settings(request) -def test_create_user_link_rest_flattened(): +def test_get_data_sharing_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -28928,38 +36282,38 @@ def test_create_user_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.UserLink() + return_value = resources.DataSharingSettings() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "accounts/sample1"} + sample_request = {"name": "accounts/sample1/dataSharingSettings"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - user_link=resources.UserLink(name="name_value"), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = resources.DataSharingSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_user_link(**mock_args) + client.get_data_sharing_settings(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=accounts/*}/userLinks" % client.transport._host, args[1] + "%s/v1alpha/{name=accounts/*/dataSharingSettings}" % client.transport._host, + args[1], ) -def test_create_user_link_rest_flattened_error(transport: str = "rest"): +def test_get_data_sharing_settings_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -28968,14 +36322,13 @@ def test_create_user_link_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_user_link( - analytics_admin.CreateUserLinkRequest(), - parent="parent_value", - user_link=resources.UserLink(name="name_value"), + client.get_data_sharing_settings( + analytics_admin.GetDataSharingSettingsRequest(), + name="name_value", ) -def test_create_user_link_rest_error(): +def test_get_data_sharing_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -28984,46 +36337,55 @@ def test_create_user_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchCreateUserLinksRequest, + analytics_admin.GetMeasurementProtocolSecretRequest, dict, ], ) -def test_batch_create_user_links_rest(request_type): +def test_get_measurement_protocol_secret_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchCreateUserLinksResponse() + return_value = resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchCreateUserLinksResponse.pb(return_value) + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_create_user_links(request) + response = client.get_measurement_protocol_secret(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) + 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_batch_create_user_links_rest_required_fields( - request_type=analytics_admin.BatchCreateUserLinksRequest, +def test_get_measurement_protocol_secret_rest_required_fields( + request_type=analytics_admin.GetMeasurementProtocolSecretRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -29038,21 +36400,21 @@ def test_batch_create_user_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_create_user_links._get_unset_required_fields(jsonified_request) + ).get_measurement_protocol_secret._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_create_user_links._get_unset_required_fields(jsonified_request) + ).get_measurement_protocol_secret._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -29061,7 +36423,7 @@ def test_batch_create_user_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchCreateUserLinksResponse() + return_value = resources.MeasurementProtocolSecret() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -29073,49 +36435,40 @@ def test_batch_create_user_links_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchCreateUserLinksResponse.pb( - return_value - ) + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_create_user_links(request) + response = client.get_measurement_protocol_secret(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_batch_create_user_links_rest_unset_required_fields(): +def test_get_measurement_protocol_secret_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_create_user_links._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "requests", - ) - ) + unset_fields = transport.get_measurement_protocol_secret._get_unset_required_fields( + {} ) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_create_user_links_rest_interceptors(null_interceptor): +def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29128,14 +36481,16 @@ def test_batch_create_user_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_batch_create_user_links" + transports.AnalyticsAdminServiceRestInterceptor, + "post_get_measurement_protocol_secret", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_create_user_links" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_get_measurement_protocol_secret", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.BatchCreateUserLinksRequest.pb( - analytics_admin.BatchCreateUserLinksRequest() + pb_message = analytics_admin.GetMeasurementProtocolSecretRequest.pb( + analytics_admin.GetMeasurementProtocolSecretRequest() ) transcode.return_value = { "method": "post", @@ -29147,21 +36502,19 @@ def test_batch_create_user_links_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.BatchCreateUserLinksResponse.to_json( - analytics_admin.BatchCreateUserLinksResponse() - ) + req.return_value._content = resources.MeasurementProtocolSecret.to_json( + resources.MeasurementProtocolSecret() ) - request = analytics_admin.BatchCreateUserLinksRequest() + request = analytics_admin.GetMeasurementProtocolSecretRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchCreateUserLinksResponse() + post.return_value = resources.MeasurementProtocolSecret() - client.batch_create_user_links( + client.get_measurement_protocol_secret( request, metadata=[ ("key", "val"), @@ -29173,8 +36526,9 @@ def test_batch_create_user_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_batch_create_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.BatchCreateUserLinksRequest +def test_get_measurement_protocol_secret_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.GetMeasurementProtocolSecretRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -29182,7 +36536,9 @@ def test_batch_create_user_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29194,10 +36550,68 @@ def test_batch_create_user_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.batch_create_user_links(request) + client.get_measurement_protocol_secret(request) -def test_batch_create_user_links_rest_error(): +def test_get_measurement_protocol_secret_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.MeasurementProtocolSecret() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_measurement_protocol_secret(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + % client.transport._host, + args[1], + ) + + +def test_get_measurement_protocol_secret_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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", + ) + + +def test_get_measurement_protocol_secret_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -29206,57 +36620,51 @@ def test_batch_create_user_links_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateUserLinkRequest, + analytics_admin.ListMeasurementProtocolSecretsRequest, dict, ], ) -def test_update_user_link_rest(request_type): +def test_list_measurement_protocol_secrets_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"user_link": {"name": "accounts/sample1/userLinks/sample2"}} - request_init["user_link"] = { - "name": "accounts/sample1/userLinks/sample2", - "email_address": "email_address_value", - "direct_roles": ["direct_roles_value1", "direct_roles_value2"], - } + request_init = {"parent": "properties/sample1/dataStreams/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.UserLink( - name="name_value", - email_address="email_address_value", - direct_roles=["direct_roles_value"], + return_value = analytics_admin.ListMeasurementProtocolSecretsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = analytics_admin.ListMeasurementProtocolSecretsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_user_link(request) + response = client.list_measurement_protocol_secrets(request) # 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"] + assert isinstance(response, pagers.ListMeasurementProtocolSecretsPager) + assert response.next_page_token == "next_page_token_value" -def test_update_user_link_rest_required_fields( - request_type=analytics_admin.UpdateUserLinkRequest, +def test_list_measurement_protocol_secrets_rest_required_fields( + request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -29271,17 +36679,28 @@ def test_update_user_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_user_link._get_unset_required_fields(jsonified_request) + ).list_measurement_protocol_secrets._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_user_link._get_unset_required_fields(jsonified_request) + ).list_measurement_protocol_secrets._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -29290,7 +36709,7 @@ def test_update_user_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.UserLink() + return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -29302,39 +36721,50 @@ def test_update_user_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = analytics_admin.ListMeasurementProtocolSecretsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_user_link(request) + response = client.list_measurement_protocol_secrets(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_user_link_rest_unset_required_fields(): +def test_list_measurement_protocol_secrets_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_user_link._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("userLink",))) + unset_fields = ( + transport.list_measurement_protocol_secrets._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_user_link_rest_interceptors(null_interceptor): +def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29347,14 +36777,16 @@ def test_update_user_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_user_link" + transports.AnalyticsAdminServiceRestInterceptor, + "post_list_measurement_protocol_secrets", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_user_link" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_list_measurement_protocol_secrets", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateUserLinkRequest.pb( - analytics_admin.UpdateUserLinkRequest() + pb_message = analytics_admin.ListMeasurementProtocolSecretsRequest.pb( + analytics_admin.ListMeasurementProtocolSecretsRequest() ) transcode.return_value = { "method": "post", @@ -29366,17 +36798,21 @@ def test_update_user_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.UserLink.to_json(resources.UserLink()) + req.return_value._content = ( + analytics_admin.ListMeasurementProtocolSecretsResponse.to_json( + analytics_admin.ListMeasurementProtocolSecretsResponse() + ) + ) - request = analytics_admin.UpdateUserLinkRequest() + request = analytics_admin.ListMeasurementProtocolSecretsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.UserLink() + post.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() - client.update_user_link( + client.list_measurement_protocol_secrets( request, metadata=[ ("key", "val"), @@ -29388,8 +36824,9 @@ def test_update_user_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_user_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateUserLinkRequest +def test_list_measurement_protocol_secrets_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -29397,12 +36834,7 @@ def test_update_user_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"user_link": {"name": "accounts/sample1/userLinks/sample2"}} - request_init["user_link"] = { - "name": "accounts/sample1/userLinks/sample2", - "email_address": "email_address_value", - "direct_roles": ["direct_roles_value1", "direct_roles_value2"], - } + request_init = {"parent": "properties/sample1/dataStreams/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29414,10 +36846,10 @@ def test_update_user_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_user_link(request) + client.list_measurement_protocol_secrets(request) -def test_update_user_link_rest_flattened(): +def test_list_measurement_protocol_secrets_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -29426,39 +36858,43 @@ def test_update_user_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.UserLink() + return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() # get arguments that satisfy an http rule for this method - sample_request = {"user_link": {"name": "accounts/sample1/userLinks/sample2"}} + sample_request = {"parent": "properties/sample1/dataStreams/sample2"} # get truthy value for each flattened field mock_args = dict( - user_link=resources.UserLink(name="name_value"), + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.UserLink.pb(return_value) + pb_return_value = analytics_admin.ListMeasurementProtocolSecretsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_user_link(**mock_args) + client.list_measurement_protocol_secrets(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{user_link.name=accounts/*/userLinks/*}" + "%s/v1alpha/{parent=properties/*/dataStreams/*}/measurementProtocolSecrets" % client.transport._host, args[1], ) -def test_update_user_link_rest_flattened_error(transport: str = "rest"): +def test_list_measurement_protocol_secrets_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -29467,56 +36903,128 @@ def test_update_user_link_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_user_link( - analytics_admin.UpdateUserLinkRequest(), - user_link=resources.UserLink(name="name_value"), + client.list_measurement_protocol_secrets( + analytics_admin.ListMeasurementProtocolSecretsRequest(), + parent="parent_value", ) -def test_update_user_link_rest_error(): +def test_list_measurement_protocol_secrets_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListMeasurementProtocolSecretsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1/dataStreams/sample2"} + + pager = client.list_measurement_protocol_secrets(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.MeasurementProtocolSecret) for i in results) + + pages = list( + client.list_measurement_protocol_secrets(request=sample_request).pages + ) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchUpdateUserLinksRequest, + analytics_admin.CreateMeasurementProtocolSecretRequest, dict, ], ) -def test_batch_update_user_links_rest(request_type): +def test_create_measurement_protocol_secret_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = {"parent": "properties/sample1/dataStreams/sample2"} + request_init["measurement_protocol_secret"] = { + "name": "name_value", + "display_name": "display_name_value", + "secret_value": "secret_value_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchUpdateUserLinksResponse() + return_value = resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchUpdateUserLinksResponse.pb(return_value) + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_update_user_links(request) + response = client.create_measurement_protocol_secret(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) + 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_batch_update_user_links_rest_required_fields( - request_type=analytics_admin.BatchUpdateUserLinksRequest, +def test_create_measurement_protocol_secret_rest_required_fields( + request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -29536,7 +37044,7 @@ def test_batch_update_user_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_update_user_links._get_unset_required_fields(jsonified_request) + ).create_measurement_protocol_secret._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -29545,7 +37053,7 @@ def test_batch_update_user_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_update_user_links._get_unset_required_fields(jsonified_request) + ).create_measurement_protocol_secret._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -29559,7 +37067,7 @@ def test_batch_update_user_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchUpdateUserLinksResponse() + return_value = resources.MeasurementProtocolSecret() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -29580,40 +37088,40 @@ def test_batch_update_user_links_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchUpdateUserLinksResponse.pb( - return_value - ) + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_update_user_links(request) + response = client.create_measurement_protocol_secret(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_batch_update_user_links_rest_unset_required_fields(): +def test_create_measurement_protocol_secret_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_update_user_links._get_unset_required_fields({}) + unset_fields = ( + transport.create_measurement_protocol_secret._get_unset_required_fields({}) + ) assert set(unset_fields) == ( set(()) & set( ( "parent", - "requests", + "measurementProtocolSecret", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_update_user_links_rest_interceptors(null_interceptor): +def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29626,14 +37134,16 @@ def test_batch_update_user_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_batch_update_user_links" + transports.AnalyticsAdminServiceRestInterceptor, + "post_create_measurement_protocol_secret", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_update_user_links" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_create_measurement_protocol_secret", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.BatchUpdateUserLinksRequest.pb( - analytics_admin.BatchUpdateUserLinksRequest() + pb_message = analytics_admin.CreateMeasurementProtocolSecretRequest.pb( + analytics_admin.CreateMeasurementProtocolSecretRequest() ) transcode.return_value = { "method": "post", @@ -29645,21 +37155,19 @@ def test_batch_update_user_links_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.BatchUpdateUserLinksResponse.to_json( - analytics_admin.BatchUpdateUserLinksResponse() - ) + req.return_value._content = resources.MeasurementProtocolSecret.to_json( + resources.MeasurementProtocolSecret() ) - request = analytics_admin.BatchUpdateUserLinksRequest() + request = analytics_admin.CreateMeasurementProtocolSecretRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchUpdateUserLinksResponse() + post.return_value = resources.MeasurementProtocolSecret() - client.batch_update_user_links( + client.create_measurement_protocol_secret( request, metadata=[ ("key", "val"), @@ -29671,8 +37179,9 @@ def test_batch_update_user_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_batch_update_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.BatchUpdateUserLinksRequest +def test_create_measurement_protocol_secret_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -29680,7 +37189,12 @@ def test_batch_update_user_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = {"parent": "properties/sample1/dataStreams/sample2"} + request_init["measurement_protocol_secret"] = { + "name": "name_value", + "display_name": "display_name_value", + "secret_value": "secret_value_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29692,10 +37206,74 @@ def test_batch_update_user_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.batch_update_user_links(request) + client.create_measurement_protocol_secret(request) -def test_batch_update_user_links_rest_error(): +def test_create_measurement_protocol_secret_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.MeasurementProtocolSecret() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "properties/sample1/dataStreams/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_measurement_protocol_secret(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{parent=properties/*/dataStreams/*}/measurementProtocolSecrets" + % client.transport._host, + args[1], + ) + + +def test_create_measurement_protocol_secret_rest_flattened_error( + transport: str = "rest", +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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" + ), + ) + + +def test_create_measurement_protocol_secret_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -29704,18 +37282,20 @@ def test_batch_update_user_links_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteUserLinkRequest, + analytics_admin.DeleteMeasurementProtocolSecretRequest, dict, ], ) -def test_delete_user_link_rest(request_type): +def test_delete_measurement_protocol_secret_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1/userLinks/sample2"} + request_init = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -29730,14 +37310,14 @@ def test_delete_user_link_rest(request_type): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_user_link(request) + response = client.delete_measurement_protocol_secret(request) # Establish that the response is the type that we expect. assert response is None -def test_delete_user_link_rest_required_fields( - request_type=analytics_admin.DeleteUserLinkRequest, +def test_delete_measurement_protocol_secret_rest_required_fields( + request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -29757,7 +37337,7 @@ def test_delete_user_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_user_link._get_unset_required_fields(jsonified_request) + ).delete_measurement_protocol_secret._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -29766,7 +37346,7 @@ def test_delete_user_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_user_link._get_unset_required_fields(jsonified_request) + ).delete_measurement_protocol_secret._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -29804,24 +37384,26 @@ def test_delete_user_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_user_link(request) + response = client.delete_measurement_protocol_secret(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_user_link_rest_unset_required_fields(): +def test_delete_measurement_protocol_secret_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_user_link._get_unset_required_fields({}) + unset_fields = ( + transport.delete_measurement_protocol_secret._get_unset_required_fields({}) + ) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_user_link_rest_interceptors(null_interceptor): +def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -29834,11 +37416,12 @@ def test_delete_user_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_user_link" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_delete_measurement_protocol_secret", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteUserLinkRequest.pb( - analytics_admin.DeleteUserLinkRequest() + pb_message = analytics_admin.DeleteMeasurementProtocolSecretRequest.pb( + analytics_admin.DeleteMeasurementProtocolSecretRequest() ) transcode.return_value = { "method": "post", @@ -29851,14 +37434,14 @@ def test_delete_user_link_rest_interceptors(null_interceptor): req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - request = analytics_admin.DeleteUserLinkRequest() + request = analytics_admin.DeleteMeasurementProtocolSecretRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - client.delete_user_link( + client.delete_measurement_protocol_secret( request, metadata=[ ("key", "val"), @@ -29869,8 +37452,9 @@ def test_delete_user_link_rest_interceptors(null_interceptor): pre.assert_called_once() -def test_delete_user_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteUserLinkRequest +def test_delete_measurement_protocol_secret_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -29878,7 +37462,9 @@ def test_delete_user_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1/userLinks/sample2"} + request_init = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -29890,10 +37476,10 @@ def test_delete_user_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_user_link(request) + client.delete_measurement_protocol_secret(request) -def test_delete_user_link_rest_flattened(): +def test_delete_measurement_protocol_secret_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -29905,7 +37491,9 @@ def test_delete_user_link_rest_flattened(): return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1/userLinks/sample2"} + sample_request = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } # get truthy value for each flattened field mock_args = dict( @@ -29920,18 +37508,22 @@ def test_delete_user_link_rest_flattened(): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_user_link(**mock_args) + client.delete_measurement_protocol_secret(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=accounts/*/userLinks/*}" % client.transport._host, args[1] + "%s/v1alpha/{name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + % client.transport._host, + args[1], ) -def test_delete_user_link_rest_flattened_error(transport: str = "rest"): +def test_delete_measurement_protocol_secret_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -29940,13 +37532,13 @@ def test_delete_user_link_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_user_link( - analytics_admin.DeleteUserLinkRequest(), + client.delete_measurement_protocol_secret( + analytics_admin.DeleteMeasurementProtocolSecretRequest(), name="name_value", ) -def test_delete_user_link_rest_error(): +def test_delete_measurement_protocol_secret_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -29955,45 +37547,61 @@ def test_delete_user_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchDeleteUserLinksRequest, + analytics_admin.UpdateMeasurementProtocolSecretRequest, dict, ], ) -def test_batch_delete_user_links_rest(request_type): +def test_update_measurement_protocol_secret_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = { + "measurement_protocol_secret": { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } + } + request_init["measurement_protocol_secret"] = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3", + "display_name": "display_name_value", + "secret_value": "secret_value_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.MeasurementProtocolSecret( + name="name_value", + display_name="display_name_value", + secret_value="secret_value_value", + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_delete_user_links(request) + response = client.update_measurement_protocol_secret(request) # Establish that the response is the type that we expect. - assert response is None + 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_batch_delete_user_links_rest_required_fields( - request_type=analytics_admin.BatchDeleteUserLinksRequest, +def test_update_measurement_protocol_secret_rest_required_fields( + request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -30008,21 +37616,19 @@ def test_batch_delete_user_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_delete_user_links._get_unset_required_fields(jsonified_request) + ).update_measurement_protocol_secret._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_delete_user_links._get_unset_required_fields(jsonified_request) + ).update_measurement_protocol_secret._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30031,7 +37637,7 @@ def test_batch_delete_user_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.MeasurementProtocolSecret() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -30043,7 +37649,7 @@ def test_batch_delete_user_links_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "patch", "query_params": pb_request, } transcode_result["body"] = pb_request @@ -30051,37 +37657,35 @@ def test_batch_delete_user_links_rest_required_fields( response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_delete_user_links(request) + response = client.update_measurement_protocol_secret(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_batch_delete_user_links_rest_unset_required_fields(): +def test_update_measurement_protocol_secret_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_delete_user_links._get_unset_required_fields({}) + unset_fields = ( + transport.update_measurement_protocol_secret._get_unset_required_fields({}) + ) assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "requests", - ) - ) + set(("updateMask",)) & set(("measurementProtocolSecret",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_delete_user_links_rest_interceptors(null_interceptor): +def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30094,11 +37698,16 @@ def test_batch_delete_user_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_delete_user_links" + transports.AnalyticsAdminServiceRestInterceptor, + "post_update_measurement_protocol_secret", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_measurement_protocol_secret", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.BatchDeleteUserLinksRequest.pb( - analytics_admin.BatchDeleteUserLinksRequest() + post.assert_not_called() + pb_message = analytics_admin.UpdateMeasurementProtocolSecretRequest.pb( + analytics_admin.UpdateMeasurementProtocolSecretRequest() ) transcode.return_value = { "method": "post", @@ -30110,15 +37719,19 @@ def test_batch_delete_user_links_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.MeasurementProtocolSecret.to_json( + resources.MeasurementProtocolSecret() + ) - request = analytics_admin.BatchDeleteUserLinksRequest() + request = analytics_admin.UpdateMeasurementProtocolSecretRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.MeasurementProtocolSecret() - client.batch_delete_user_links( + client.update_measurement_protocol_secret( request, metadata=[ ("key", "val"), @@ -30127,10 +37740,12 @@ def test_batch_delete_user_links_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_batch_delete_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.BatchDeleteUserLinksRequest +def test_update_measurement_protocol_secret_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30138,7 +37753,16 @@ def test_batch_delete_user_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = { + "measurement_protocol_secret": { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } + } + request_init["measurement_protocol_secret"] = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3", + "display_name": "display_name_value", + "secret_value": "secret_value_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30150,10 +37774,78 @@ def test_batch_delete_user_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.batch_delete_user_links(request) + client.update_measurement_protocol_secret(request) -def test_batch_delete_user_links_rest_error(): +def test_update_measurement_protocol_secret_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.MeasurementProtocolSecret() + + # get arguments that satisfy an http rule for this method + sample_request = { + "measurement_protocol_secret": { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_measurement_protocol_secret(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{measurement_protocol_secret.name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + % client.transport._host, + args[1], + ) + + +def test_update_measurement_protocol_secret_rest_flattened_error( + transport: str = "rest", +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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"]), + ) + + +def test_update_measurement_protocol_secret_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -30162,56 +37854,49 @@ def test_batch_delete_user_links_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateFirebaseLinkRequest, + analytics_admin.AcknowledgeUserDataCollectionRequest, dict, ], ) -def test_create_firebase_link_rest(request_type): +def test_acknowledge_user_data_collection_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["firebase_link"] = { - "name": "name_value", - "project": "project_value", - "create_time": {"seconds": 751, "nanos": 543}, - } + request_init = {"property": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.FirebaseLink( - name="name_value", - project="project_value", - ) + return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.FirebaseLink.pb(return_value) + pb_return_value = analytics_admin.AcknowledgeUserDataCollectionResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_firebase_link(request) + response = client.acknowledge_user_data_collection(request) # 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 isinstance(response, analytics_admin.AcknowledgeUserDataCollectionResponse) -def test_create_firebase_link_rest_required_fields( - request_type=analytics_admin.CreateFirebaseLinkRequest, +def test_acknowledge_user_data_collection_rest_required_fields( + request_type=analytics_admin.AcknowledgeUserDataCollectionRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["property"] = "" + request_init["acknowledgement"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -30226,21 +37911,24 @@ def test_create_firebase_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_firebase_link._get_unset_required_fields(jsonified_request) + ).acknowledge_user_data_collection._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["property"] = "property_value" + jsonified_request["acknowledgement"] = "acknowledgement_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_firebase_link._get_unset_required_fields(jsonified_request) + ).acknowledge_user_data_collection._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "property" in jsonified_request + assert jsonified_request["property"] == "property_value" + assert "acknowledgement" in jsonified_request + assert jsonified_request["acknowledgement"] == "acknowledgement_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30249,7 +37937,7 @@ def test_create_firebase_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.FirebaseLink() + return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -30270,38 +37958,42 @@ def test_create_firebase_link_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.FirebaseLink.pb(return_value) + pb_return_value = analytics_admin.AcknowledgeUserDataCollectionResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_firebase_link(request) + response = client.acknowledge_user_data_collection(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_firebase_link_rest_unset_required_fields(): +def test_acknowledge_user_data_collection_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_firebase_link._get_unset_required_fields({}) + unset_fields = ( + transport.acknowledge_user_data_collection._get_unset_required_fields({}) + ) assert set(unset_fields) == ( set(()) & set( ( - "parent", - "firebaseLink", + "property", + "acknowledgement", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_firebase_link_rest_interceptors(null_interceptor): +def test_acknowledge_user_data_collection_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30314,14 +38006,16 @@ def test_create_firebase_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_firebase_link" + transports.AnalyticsAdminServiceRestInterceptor, + "post_acknowledge_user_data_collection", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_firebase_link" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_acknowledge_user_data_collection", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateFirebaseLinkRequest.pb( - analytics_admin.CreateFirebaseLinkRequest() + pb_message = analytics_admin.AcknowledgeUserDataCollectionRequest.pb( + analytics_admin.AcknowledgeUserDataCollectionRequest() ) transcode.return_value = { "method": "post", @@ -30333,19 +38027,21 @@ def test_create_firebase_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.FirebaseLink.to_json( - resources.FirebaseLink() + req.return_value._content = ( + analytics_admin.AcknowledgeUserDataCollectionResponse.to_json( + analytics_admin.AcknowledgeUserDataCollectionResponse() + ) ) - request = analytics_admin.CreateFirebaseLinkRequest() + request = analytics_admin.AcknowledgeUserDataCollectionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.FirebaseLink() + post.return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() - client.create_firebase_link( + client.acknowledge_user_data_collection( request, metadata=[ ("key", "val"), @@ -30357,8 +38053,9 @@ def test_create_firebase_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_firebase_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateFirebaseLinkRequest +def test_acknowledge_user_data_collection_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.AcknowledgeUserDataCollectionRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30366,12 +38063,7 @@ def test_create_firebase_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["firebase_link"] = { - "name": "name_value", - "project": "project_value", - "create_time": {"seconds": 751, "nanos": 543}, - } + request_init = {"property": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30383,67 +38075,10 @@ def test_create_firebase_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_firebase_link(request) - - -def test_create_firebase_link_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.FirebaseLink() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - firebase_link=resources.FirebaseLink(name="name_value"), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.FirebaseLink.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.create_firebase_link(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/firebaseLinks" % client.transport._host, - args[1], - ) - - -def test_create_firebase_link_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_firebase_link( - analytics_admin.CreateFirebaseLinkRequest(), - parent="parent_value", - firebase_link=resources.FirebaseLink(name="name_value"), - ) + client.acknowledge_user_data_collection(request) -def test_create_firebase_link_rest_error(): +def test_acknowledge_user_data_collection_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -30452,45 +38087,51 @@ def test_create_firebase_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteFirebaseLinkRequest, + analytics_admin.SearchChangeHistoryEventsRequest, dict, ], ) -def test_delete_firebase_link_rest(request_type): +def test_search_change_history_events_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/firebaseLinks/sample2"} + request_init = {"account": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = analytics_admin.SearchChangeHistoryEventsResponse( + next_page_token="next_page_token_value", + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = analytics_admin.SearchChangeHistoryEventsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_firebase_link(request) + response = client.search_change_history_events(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, pagers.SearchChangeHistoryEventsPager) + assert response.next_page_token == "next_page_token_value" -def test_delete_firebase_link_rest_required_fields( - request_type=analytics_admin.DeleteFirebaseLinkRequest, +def test_search_change_history_events_rest_required_fields( + request_type=analytics_admin.SearchChangeHistoryEventsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["account"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -30505,21 +38146,21 @@ def test_delete_firebase_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_firebase_link._get_unset_required_fields(jsonified_request) + ).search_change_history_events._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["account"] = "account_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_firebase_link._get_unset_required_fields(jsonified_request) + ).search_change_history_events._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "account" in jsonified_request + assert jsonified_request["account"] == "account_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30528,7 +38169,7 @@ def test_delete_firebase_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = analytics_admin.SearchChangeHistoryEventsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -30540,36 +38181,41 @@ def test_delete_firebase_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = analytics_admin.SearchChangeHistoryEventsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_firebase_link(request) + response = client.search_change_history_events(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_firebase_link_rest_unset_required_fields(): +def test_search_change_history_events_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_firebase_link._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.search_change_history_events._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("account",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_firebase_link_rest_interceptors(null_interceptor): +def test_search_change_history_events_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30582,11 +38228,16 @@ def test_delete_firebase_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_firebase_link" + transports.AnalyticsAdminServiceRestInterceptor, + "post_search_change_history_events", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_search_change_history_events", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteFirebaseLinkRequest.pb( - analytics_admin.DeleteFirebaseLinkRequest() + post.assert_not_called() + pb_message = analytics_admin.SearchChangeHistoryEventsRequest.pb( + analytics_admin.SearchChangeHistoryEventsRequest() ) transcode.return_value = { "method": "post", @@ -30598,15 +38249,21 @@ def test_delete_firebase_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = ( + analytics_admin.SearchChangeHistoryEventsResponse.to_json( + analytics_admin.SearchChangeHistoryEventsResponse() + ) + ) - request = analytics_admin.DeleteFirebaseLinkRequest() + request = analytics_admin.SearchChangeHistoryEventsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = analytics_admin.SearchChangeHistoryEventsResponse() - client.delete_firebase_link( + client.search_change_history_events( request, metadata=[ ("key", "val"), @@ -30615,10 +38272,12 @@ def test_delete_firebase_link_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_firebase_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteFirebaseLinkRequest +def test_search_change_history_events_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.SearchChangeHistoryEventsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30626,7 +38285,7 @@ def test_delete_firebase_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/firebaseLinks/sample2"} + request_init = {"account": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30638,115 +38297,126 @@ def test_delete_firebase_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_firebase_link(request) + client.search_change_history_events(request) -def test_delete_firebase_link_rest_flattened(): +def test_search_change_history_events_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/firebaseLinks/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = "" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.delete_firebase_link(**mock_args) + # Two responses for two calls + response = response + response - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{name=properties/*/firebaseLinks/*}" % client.transport._host, - args[1], + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.SearchChangeHistoryEventsResponse.to_json(x) + for x in response ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + sample_request = {"account": "accounts/sample1"} -def test_delete_firebase_link_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_firebase_link( - analytics_admin.DeleteFirebaseLinkRequest(), - name="name_value", - ) + pager = client.search_change_history_events(request=sample_request) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.ChangeHistoryEvent) for i in results) -def test_delete_firebase_link_rest_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) + pages = list(client.search_change_history_events(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListFirebaseLinksRequest, + analytics_admin.GetGoogleSignalsSettingsRequest, dict, ], ) -def test_list_firebase_links_rest(request_type): +def test_get_google_signals_settings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/googleSignalsSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListFirebaseLinksResponse( - next_page_token="next_page_token_value", + return_value = resources.GoogleSignalsSettings( + name="name_value", + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListFirebaseLinksResponse.pb(return_value) + pb_return_value = resources.GoogleSignalsSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_firebase_links(request) + response = client.get_google_signals_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFirebaseLinksPager) - assert response.next_page_token == "next_page_token_value" + 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_list_firebase_links_rest_required_fields( - request_type=analytics_admin.ListFirebaseLinksRequest, +def test_get_google_signals_settings_rest_required_fields( + request_type=analytics_admin.GetGoogleSignalsSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -30761,28 +38431,21 @@ def test_list_firebase_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_firebase_links._get_unset_required_fields(jsonified_request) + ).get_google_signals_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_firebase_links._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).get_google_signals_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30791,7 +38454,7 @@ def test_list_firebase_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListFirebaseLinksResponse() + return_value = resources.GoogleSignalsSettings() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -30811,38 +38474,30 @@ def test_list_firebase_links_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListFirebaseLinksResponse.pb(return_value) + pb_return_value = resources.GoogleSignalsSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_firebase_links(request) + response = client.get_google_signals_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_firebase_links_rest_unset_required_fields(): +def test_get_google_signals_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_firebase_links._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.get_google_signals_settings._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_firebase_links_rest_interceptors(null_interceptor): +def test_get_google_signals_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30855,14 +38510,16 @@ def test_list_firebase_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_firebase_links" + transports.AnalyticsAdminServiceRestInterceptor, + "post_get_google_signals_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_firebase_links" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_get_google_signals_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListFirebaseLinksRequest.pb( - analytics_admin.ListFirebaseLinksRequest() + pb_message = analytics_admin.GetGoogleSignalsSettingsRequest.pb( + analytics_admin.GetGoogleSignalsSettingsRequest() ) transcode.return_value = { "method": "post", @@ -30874,19 +38531,19 @@ def test_list_firebase_links_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ListFirebaseLinksResponse.to_json( - analytics_admin.ListFirebaseLinksResponse() + req.return_value._content = resources.GoogleSignalsSettings.to_json( + resources.GoogleSignalsSettings() ) - request = analytics_admin.ListFirebaseLinksRequest() + request = analytics_admin.GetGoogleSignalsSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListFirebaseLinksResponse() + post.return_value = resources.GoogleSignalsSettings() - client.list_firebase_links( + client.get_google_signals_settings( request, metadata=[ ("key", "val"), @@ -30898,8 +38555,9 @@ def test_list_firebase_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_firebase_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListFirebaseLinksRequest +def test_get_google_signals_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.GetGoogleSignalsSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30907,7 +38565,7 @@ def test_list_firebase_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/googleSignalsSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30919,10 +38577,10 @@ def test_list_firebase_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_firebase_links(request) + client.get_google_signals_settings(request) -def test_list_firebase_links_rest_flattened(): +def test_get_google_signals_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -30931,38 +38589,39 @@ def test_list_firebase_links_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListFirebaseLinksResponse() + return_value = resources.GoogleSignalsSettings() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "properties/sample1/googleSignalsSettings"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListFirebaseLinksResponse.pb(return_value) + pb_return_value = resources.GoogleSignalsSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_firebase_links(**mock_args) + client.get_google_signals_settings(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/firebaseLinks" % client.transport._host, + "%s/v1alpha/{name=properties/*/googleSignalsSettings}" + % client.transport._host, args[1], ) -def test_list_firebase_links_rest_flattened_error(transport: str = "rest"): +def test_get_google_signals_settings_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -30971,123 +38630,77 @@ def test_list_firebase_links_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_firebase_links( - analytics_admin.ListFirebaseLinksRequest(), - parent="parent_value", + client.get_google_signals_settings( + analytics_admin.GetGoogleSignalsSettingsRequest(), + name="name_value", ) -def test_list_firebase_links_rest_pager(transport: str = "rest"): +def test_get_google_signals_settings_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - next_page_token="abc", - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[], - next_page_token="def", - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - ], - next_page_token="ghi", - ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListFirebaseLinksResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1"} - - pager = client.list_firebase_links(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.FirebaseLink) for i in results) - - pages = list(client.list_firebase_links(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetGlobalSiteTagRequest, + analytics_admin.UpdateGoogleSignalsSettingsRequest, dict, ], ) -def test_get_global_site_tag_rest(request_type): +def test_update_google_signals_settings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/dataStreams/sample2/globalSiteTag"} + request_init = { + "google_signals_settings": {"name": "properties/sample1/googleSignalsSettings"} + } + request_init["google_signals_settings"] = { + "name": "properties/sample1/googleSignalsSettings", + "state": 1, + "consent": 2, + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GlobalSiteTag( + return_value = resources.GoogleSignalsSettings( name="name_value", - snippet="snippet_value", + state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, + consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GlobalSiteTag.pb(return_value) + pb_return_value = resources.GoogleSignalsSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_global_site_tag(request) + response = client.update_google_signals_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.GlobalSiteTag) + assert isinstance(response, resources.GoogleSignalsSettings) assert response.name == "name_value" - assert response.snippet == "snippet_value" + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert ( + response.consent + == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + ) -def test_get_global_site_tag_rest_required_fields( - request_type=analytics_admin.GetGlobalSiteTagRequest, +def test_update_google_signals_settings_rest_required_fields( + request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -31102,21 +38715,19 @@ def test_get_global_site_tag_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_global_site_tag._get_unset_required_fields(jsonified_request) + ).update_google_signals_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_global_site_tag._get_unset_required_fields(jsonified_request) + ).update_google_signals_settings._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31125,7 +38736,7 @@ def test_get_global_site_tag_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.GlobalSiteTag() + return_value = resources.GoogleSignalsSettings() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -31137,38 +38748,49 @@ def test_get_global_site_tag_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GlobalSiteTag.pb(return_value) + pb_return_value = resources.GoogleSignalsSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_global_site_tag(request) + response = client.update_google_signals_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_global_site_tag_rest_unset_required_fields(): +def test_update_google_signals_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_global_site_tag._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.update_google_signals_settings._get_unset_required_fields( + {} + ) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "googleSignalsSettings", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_global_site_tag_rest_interceptors(null_interceptor): +def test_update_google_signals_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31181,14 +38803,16 @@ def test_get_global_site_tag_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_global_site_tag" + transports.AnalyticsAdminServiceRestInterceptor, + "post_update_google_signals_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_global_site_tag" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_google_signals_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetGlobalSiteTagRequest.pb( - analytics_admin.GetGlobalSiteTagRequest() + pb_message = analytics_admin.UpdateGoogleSignalsSettingsRequest.pb( + analytics_admin.UpdateGoogleSignalsSettingsRequest() ) transcode.return_value = { "method": "post", @@ -31200,19 +38824,19 @@ def test_get_global_site_tag_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.GlobalSiteTag.to_json( - resources.GlobalSiteTag() + req.return_value._content = resources.GoogleSignalsSettings.to_json( + resources.GoogleSignalsSettings() ) - request = analytics_admin.GetGlobalSiteTagRequest() + request = analytics_admin.UpdateGoogleSignalsSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GlobalSiteTag() + post.return_value = resources.GoogleSignalsSettings() - client.get_global_site_tag( + client.update_google_signals_settings( request, metadata=[ ("key", "val"), @@ -31224,8 +38848,9 @@ def test_get_global_site_tag_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_global_site_tag_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetGlobalSiteTagRequest +def test_update_google_signals_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31233,7 +38858,14 @@ def test_get_global_site_tag_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/dataStreams/sample2/globalSiteTag"} + request_init = { + "google_signals_settings": {"name": "properties/sample1/googleSignalsSettings"} + } + request_init["google_signals_settings"] = { + "name": "properties/sample1/googleSignalsSettings", + "state": 1, + "consent": 2, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -31245,10 +38877,10 @@ def test_get_global_site_tag_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_global_site_tag(request) + client.update_google_signals_settings(request) -def test_get_global_site_tag_rest_flattened(): +def test_update_google_signals_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -31257,41 +38889,44 @@ def test_get_global_site_tag_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GlobalSiteTag() + return_value = resources.GoogleSignalsSettings() # get arguments that satisfy an http rule for this method sample_request = { - "name": "properties/sample1/dataStreams/sample2/globalSiteTag" + "google_signals_settings": { + "name": "properties/sample1/googleSignalsSettings" + } } # get truthy value for each flattened field mock_args = dict( - name="name_value", + google_signals_settings=resources.GoogleSignalsSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GlobalSiteTag.pb(return_value) + pb_return_value = resources.GoogleSignalsSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_global_site_tag(**mock_args) + client.update_google_signals_settings(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/dataStreams/*/globalSiteTag}" + "%s/v1alpha/{google_signals_settings.name=properties/*/googleSignalsSettings}" % client.transport._host, args[1], ) -def test_get_global_site_tag_rest_flattened_error(transport: str = "rest"): +def test_update_google_signals_settings_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -31300,13 +38935,14 @@ def test_get_global_site_tag_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_global_site_tag( - analytics_admin.GetGlobalSiteTagRequest(), - name="name_value", + 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_get_global_site_tag_rest_error(): +def test_update_google_signals_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -31315,11 +38951,11 @@ def test_get_global_site_tag_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateGoogleAdsLinkRequest, + analytics_admin.CreateConversionEventRequest, dict, ], ) -def test_create_google_ads_link_rest(request_type): +def test_create_conversion_event_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -31327,47 +38963,45 @@ def test_create_google_ads_link_rest(request_type): # send a request that will satisfy transcoding request_init = {"parent": "properties/sample1"} - request_init["google_ads_link"] = { + request_init["conversion_event"] = { "name": "name_value", - "customer_id": "customer_id_value", - "can_manage_clients": True, - "ads_personalization_enabled": {"value": True}, + "event_name": "event_name_value", "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "creator_email_address": "creator_email_address_value", + "deletable": True, + "custom": True, } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GoogleAdsLink( + return_value = resources.ConversionEvent( name="name_value", - customer_id="customer_id_value", - can_manage_clients=True, - creator_email_address="creator_email_address_value", + event_name="event_name_value", + deletable=True, + custom=True, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleAdsLink.pb(return_value) + pb_return_value = resources.ConversionEvent.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_google_ads_link(request) + response = client.create_conversion_event(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleAdsLink) + assert isinstance(response, resources.ConversionEvent) assert response.name == "name_value" - assert response.customer_id == "customer_id_value" - assert response.can_manage_clients is True - assert response.creator_email_address == "creator_email_address_value" + assert response.event_name == "event_name_value" + assert response.deletable is True + assert response.custom is True -def test_create_google_ads_link_rest_required_fields( - request_type=analytics_admin.CreateGoogleAdsLinkRequest, +def test_create_conversion_event_rest_required_fields( + request_type=analytics_admin.CreateConversionEventRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -31387,7 +39021,7 @@ def test_create_google_ads_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_google_ads_link._get_unset_required_fields(jsonified_request) + ).create_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -31396,7 +39030,7 @@ def test_create_google_ads_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_google_ads_link._get_unset_required_fields(jsonified_request) + ).create_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -31410,7 +39044,7 @@ def test_create_google_ads_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.GoogleAdsLink() + return_value = resources.ConversionEvent() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -31431,38 +39065,38 @@ def test_create_google_ads_link_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleAdsLink.pb(return_value) + pb_return_value = resources.ConversionEvent.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_google_ads_link(request) + response = client.create_conversion_event(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_google_ads_link_rest_unset_required_fields(): +def test_create_conversion_event_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_google_ads_link._get_unset_required_fields({}) + unset_fields = transport.create_conversion_event._get_unset_required_fields({}) assert set(unset_fields) == ( set(()) & set( ( + "conversionEvent", "parent", - "googleAdsLink", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_google_ads_link_rest_interceptors(null_interceptor): +def test_create_conversion_event_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31475,14 +39109,14 @@ def test_create_google_ads_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_google_ads_link" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_conversion_event" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_google_ads_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_conversion_event" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateGoogleAdsLinkRequest.pb( - analytics_admin.CreateGoogleAdsLinkRequest() + pb_message = analytics_admin.CreateConversionEventRequest.pb( + analytics_admin.CreateConversionEventRequest() ) transcode.return_value = { "method": "post", @@ -31494,19 +39128,19 @@ def test_create_google_ads_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.GoogleAdsLink.to_json( - resources.GoogleAdsLink() + req.return_value._content = resources.ConversionEvent.to_json( + resources.ConversionEvent() ) - request = analytics_admin.CreateGoogleAdsLinkRequest() + request = analytics_admin.CreateConversionEventRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GoogleAdsLink() + post.return_value = resources.ConversionEvent() - client.create_google_ads_link( + client.create_conversion_event( request, metadata=[ ("key", "val"), @@ -31518,8 +39152,8 @@ def test_create_google_ads_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_google_ads_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateGoogleAdsLinkRequest +def test_create_conversion_event_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateConversionEventRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31528,14 +39162,12 @@ def test_create_google_ads_link_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "properties/sample1"} - request_init["google_ads_link"] = { + request_init["conversion_event"] = { "name": "name_value", - "customer_id": "customer_id_value", - "can_manage_clients": True, - "ads_personalization_enabled": {"value": True}, + "event_name": "event_name_value", "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "creator_email_address": "creator_email_address_value", + "deletable": True, + "custom": True, } request = request_type(**request_init) @@ -31548,10 +39180,10 @@ def test_create_google_ads_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_google_ads_link(request) + client.create_conversion_event(request) -def test_create_google_ads_link_rest_flattened(): +def test_create_conversion_event_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -31560,7 +39192,7 @@ def test_create_google_ads_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GoogleAdsLink() + return_value = resources.ConversionEvent() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -31568,31 +39200,32 @@ def test_create_google_ads_link_rest_flattened(): # get truthy value for each flattened field mock_args = dict( parent="parent_value", - google_ads_link=resources.GoogleAdsLink(name="name_value"), + conversion_event=resources.ConversionEvent(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleAdsLink.pb(return_value) + pb_return_value = resources.ConversionEvent.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_google_ads_link(**mock_args) + client.create_conversion_event(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/googleAdsLinks" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/conversionEvents" + % client.transport._host, args[1], ) -def test_create_google_ads_link_rest_flattened_error(transport: str = "rest"): +def test_create_conversion_event_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -31601,14 +39234,14 @@ def test_create_google_ads_link_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_google_ads_link( - analytics_admin.CreateGoogleAdsLinkRequest(), + client.create_conversion_event( + analytics_admin.CreateConversionEventRequest(), parent="parent_value", - google_ads_link=resources.GoogleAdsLink(name="name_value"), + conversion_event=resources.ConversionEvent(name="name_value"), ) -def test_create_google_ads_link_rest_error(): +def test_create_conversion_event_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -31617,65 +39250,55 @@ def test_create_google_ads_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateGoogleAdsLinkRequest, + analytics_admin.GetConversionEventRequest, dict, ], ) -def test_update_google_ads_link_rest(request_type): +def test_get_conversion_event_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "google_ads_link": {"name": "properties/sample1/googleAdsLinks/sample2"} - } - request_init["google_ads_link"] = { - "name": "properties/sample1/googleAdsLinks/sample2", - "customer_id": "customer_id_value", - "can_manage_clients": True, - "ads_personalization_enabled": {"value": True}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "creator_email_address": "creator_email_address_value", - } + request_init = {"name": "properties/sample1/conversionEvents/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GoogleAdsLink( + return_value = resources.ConversionEvent( name="name_value", - customer_id="customer_id_value", - can_manage_clients=True, - creator_email_address="creator_email_address_value", + event_name="event_name_value", + deletable=True, + custom=True, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleAdsLink.pb(return_value) + pb_return_value = resources.ConversionEvent.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_google_ads_link(request) + response = client.get_conversion_event(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleAdsLink) + assert isinstance(response, resources.ConversionEvent) assert response.name == "name_value" - assert response.customer_id == "customer_id_value" - assert response.can_manage_clients is True - assert response.creator_email_address == "creator_email_address_value" + assert response.event_name == "event_name_value" + assert response.deletable is True + assert response.custom is True -def test_update_google_ads_link_rest_required_fields( - request_type=analytics_admin.UpdateGoogleAdsLinkRequest, +def test_get_conversion_event_rest_required_fields( + request_type=analytics_admin.GetConversionEventRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -31690,19 +39313,21 @@ def test_update_google_ads_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_google_ads_link._get_unset_required_fields(jsonified_request) + ).get_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_google_ads_link._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + ).get_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31711,7 +39336,7 @@ def test_update_google_ads_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.GoogleAdsLink() + return_value = resources.ConversionEvent() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -31723,39 +39348,38 @@ def test_update_google_ads_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleAdsLink.pb(return_value) + pb_return_value = resources.ConversionEvent.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_google_ads_link(request) + response = client.get_conversion_event(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_google_ads_link_rest_unset_required_fields(): +def test_get_conversion_event_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_google_ads_link._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) + unset_fields = transport.get_conversion_event._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_google_ads_link_rest_interceptors(null_interceptor): +def test_get_conversion_event_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31768,14 +39392,14 @@ def test_update_google_ads_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_google_ads_link" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_conversion_event" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_google_ads_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_conversion_event" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateGoogleAdsLinkRequest.pb( - analytics_admin.UpdateGoogleAdsLinkRequest() + pb_message = analytics_admin.GetConversionEventRequest.pb( + analytics_admin.GetConversionEventRequest() ) transcode.return_value = { "method": "post", @@ -31787,19 +39411,19 @@ def test_update_google_ads_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.GoogleAdsLink.to_json( - resources.GoogleAdsLink() + req.return_value._content = resources.ConversionEvent.to_json( + resources.ConversionEvent() ) - request = analytics_admin.UpdateGoogleAdsLinkRequest() + request = analytics_admin.GetConversionEventRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GoogleAdsLink() + post.return_value = resources.ConversionEvent() - client.update_google_ads_link( + client.get_conversion_event( request, metadata=[ ("key", "val"), @@ -31811,8 +39435,8 @@ def test_update_google_ads_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_google_ads_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateGoogleAdsLinkRequest +def test_get_conversion_event_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetConversionEventRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31820,18 +39444,7 @@ def test_update_google_ads_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "google_ads_link": {"name": "properties/sample1/googleAdsLinks/sample2"} - } - request_init["google_ads_link"] = { - "name": "properties/sample1/googleAdsLinks/sample2", - "customer_id": "customer_id_value", - "can_manage_clients": True, - "ads_personalization_enabled": {"value": True}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "creator_email_address": "creator_email_address_value", - } + request_init = {"name": "properties/sample1/conversionEvents/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -31843,10 +39456,10 @@ def test_update_google_ads_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_google_ads_link(request) + client.get_conversion_event(request) -def test_update_google_ads_link_rest_flattened(): +def test_get_conversion_event_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -31855,42 +39468,39 @@ def test_update_google_ads_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GoogleAdsLink() + return_value = resources.ConversionEvent() # get arguments that satisfy an http rule for this method - sample_request = { - "google_ads_link": {"name": "properties/sample1/googleAdsLinks/sample2"} - } + sample_request = {"name": "properties/sample1/conversionEvents/sample2"} # get truthy value for each flattened field mock_args = dict( - google_ads_link=resources.GoogleAdsLink(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleAdsLink.pb(return_value) + pb_return_value = resources.ConversionEvent.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_google_ads_link(**mock_args) + client.get_conversion_event(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{google_ads_link.name=properties/*/googleAdsLinks/*}" + "%s/v1alpha/{name=properties/*/conversionEvents/*}" % client.transport._host, args[1], ) -def test_update_google_ads_link_rest_flattened_error(transport: str = "rest"): +def test_get_conversion_event_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -31899,14 +39509,13 @@ def test_update_google_ads_link_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_google_ads_link( - analytics_admin.UpdateGoogleAdsLinkRequest(), - google_ads_link=resources.GoogleAdsLink(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_conversion_event( + analytics_admin.GetConversionEventRequest(), + name="name_value", ) -def test_update_google_ads_link_rest_error(): +def test_get_conversion_event_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -31915,18 +39524,18 @@ def test_update_google_ads_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteGoogleAdsLinkRequest, + analytics_admin.DeleteConversionEventRequest, dict, ], ) -def test_delete_google_ads_link_rest(request_type): +def test_delete_conversion_event_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/googleAdsLinks/sample2"} + request_init = {"name": "properties/sample1/conversionEvents/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -31941,14 +39550,14 @@ def test_delete_google_ads_link_rest(request_type): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_google_ads_link(request) + response = client.delete_conversion_event(request) # Establish that the response is the type that we expect. assert response is None -def test_delete_google_ads_link_rest_required_fields( - request_type=analytics_admin.DeleteGoogleAdsLinkRequest, +def test_delete_conversion_event_rest_required_fields( + request_type=analytics_admin.DeleteConversionEventRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -31968,7 +39577,7 @@ def test_delete_google_ads_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_google_ads_link._get_unset_required_fields(jsonified_request) + ).delete_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -31977,7 +39586,7 @@ def test_delete_google_ads_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_google_ads_link._get_unset_required_fields(jsonified_request) + ).delete_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -32015,24 +39624,24 @@ def test_delete_google_ads_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_google_ads_link(request) + response = client.delete_conversion_event(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_google_ads_link_rest_unset_required_fields(): +def test_delete_conversion_event_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_google_ads_link._get_unset_required_fields({}) + unset_fields = transport.delete_conversion_event._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_google_ads_link_rest_interceptors(null_interceptor): +def test_delete_conversion_event_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32045,11 +39654,11 @@ def test_delete_google_ads_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_google_ads_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_conversion_event" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteGoogleAdsLinkRequest.pb( - analytics_admin.DeleteGoogleAdsLinkRequest() + pb_message = analytics_admin.DeleteConversionEventRequest.pb( + analytics_admin.DeleteConversionEventRequest() ) transcode.return_value = { "method": "post", @@ -32062,14 +39671,14 @@ def test_delete_google_ads_link_rest_interceptors(null_interceptor): req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - request = analytics_admin.DeleteGoogleAdsLinkRequest() + request = analytics_admin.DeleteConversionEventRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - client.delete_google_ads_link( + client.delete_conversion_event( request, metadata=[ ("key", "val"), @@ -32080,8 +39689,8 @@ def test_delete_google_ads_link_rest_interceptors(null_interceptor): pre.assert_called_once() -def test_delete_google_ads_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteGoogleAdsLinkRequest +def test_delete_conversion_event_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteConversionEventRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32089,7 +39698,7 @@ def test_delete_google_ads_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/googleAdsLinks/sample2"} + request_init = {"name": "properties/sample1/conversionEvents/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -32101,10 +39710,10 @@ def test_delete_google_ads_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_google_ads_link(request) + client.delete_conversion_event(request) -def test_delete_google_ads_link_rest_flattened(): +def test_delete_conversion_event_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -32116,7 +39725,7 @@ def test_delete_google_ads_link_rest_flattened(): return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/googleAdsLinks/sample2"} + sample_request = {"name": "properties/sample1/conversionEvents/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -32131,19 +39740,20 @@ def test_delete_google_ads_link_rest_flattened(): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_google_ads_link(**mock_args) + client.delete_conversion_event(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/googleAdsLinks/*}" % client.transport._host, + "%s/v1alpha/{name=properties/*/conversionEvents/*}" + % client.transport._host, args[1], ) -def test_delete_google_ads_link_rest_flattened_error(transport: str = "rest"): +def test_delete_conversion_event_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -32152,13 +39762,13 @@ def test_delete_google_ads_link_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_google_ads_link( - analytics_admin.DeleteGoogleAdsLinkRequest(), + client.delete_conversion_event( + analytics_admin.DeleteConversionEventRequest(), name="name_value", ) -def test_delete_google_ads_link_rest_error(): +def test_delete_conversion_event_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -32167,11 +39777,11 @@ def test_delete_google_ads_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListGoogleAdsLinksRequest, + analytics_admin.ListConversionEventsRequest, dict, ], ) -def test_list_google_ads_links_rest(request_type): +def test_list_conversion_events_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -32184,27 +39794,27 @@ def test_list_google_ads_links_rest(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListGoogleAdsLinksResponse( + return_value = analytics_admin.ListConversionEventsResponse( next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListGoogleAdsLinksResponse.pb(return_value) + pb_return_value = analytics_admin.ListConversionEventsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_google_ads_links(request) + response = client.list_conversion_events(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListGoogleAdsLinksPager) + assert isinstance(response, pagers.ListConversionEventsPager) assert response.next_page_token == "next_page_token_value" -def test_list_google_ads_links_rest_required_fields( - request_type=analytics_admin.ListGoogleAdsLinksRequest, +def test_list_conversion_events_rest_required_fields( + request_type=analytics_admin.ListConversionEventsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -32224,7 +39834,7 @@ def test_list_google_ads_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_google_ads_links._get_unset_required_fields(jsonified_request) + ).list_conversion_events._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -32233,7 +39843,7 @@ def test_list_google_ads_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_google_ads_links._get_unset_required_fields(jsonified_request) + ).list_conversion_events._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set( ( @@ -32254,7 +39864,7 @@ def test_list_google_ads_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListGoogleAdsLinksResponse() + return_value = analytics_admin.ListConversionEventsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -32274,7 +39884,7 @@ def test_list_google_ads_links_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListGoogleAdsLinksResponse.pb( + pb_return_value = analytics_admin.ListConversionEventsResponse.pb( return_value ) json_return_value = json_format.MessageToJson(pb_return_value) @@ -32282,19 +39892,19 @@ def test_list_google_ads_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_google_ads_links(request) + response = client.list_conversion_events(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_google_ads_links_rest_unset_required_fields(): +def test_list_conversion_events_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_google_ads_links._get_unset_required_fields({}) + unset_fields = transport.list_conversion_events._get_unset_required_fields({}) assert set(unset_fields) == ( set( ( @@ -32307,7 +39917,7 @@ def test_list_google_ads_links_rest_unset_required_fields(): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_google_ads_links_rest_interceptors(null_interceptor): +def test_list_conversion_events_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32320,14 +39930,14 @@ def test_list_google_ads_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_google_ads_links" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_conversion_events" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_google_ads_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_conversion_events" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListGoogleAdsLinksRequest.pb( - analytics_admin.ListGoogleAdsLinksRequest() + pb_message = analytics_admin.ListConversionEventsRequest.pb( + analytics_admin.ListConversionEventsRequest() ) transcode.return_value = { "method": "post", @@ -32339,19 +39949,21 @@ def test_list_google_ads_links_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ListGoogleAdsLinksResponse.to_json( - analytics_admin.ListGoogleAdsLinksResponse() + req.return_value._content = ( + analytics_admin.ListConversionEventsResponse.to_json( + analytics_admin.ListConversionEventsResponse() + ) ) - request = analytics_admin.ListGoogleAdsLinksRequest() + request = analytics_admin.ListConversionEventsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListGoogleAdsLinksResponse() + post.return_value = analytics_admin.ListConversionEventsResponse() - client.list_google_ads_links( + client.list_conversion_events( request, metadata=[ ("key", "val"), @@ -32363,8 +39975,8 @@ def test_list_google_ads_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_google_ads_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListGoogleAdsLinksRequest +def test_list_conversion_events_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListConversionEventsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32384,10 +39996,10 @@ def test_list_google_ads_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_google_ads_links(request) + client.list_conversion_events(request) -def test_list_google_ads_links_rest_flattened(): +def test_list_conversion_events_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -32396,7 +40008,7 @@ def test_list_google_ads_links_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListGoogleAdsLinksResponse() + return_value = analytics_admin.ListConversionEventsResponse() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -32410,24 +40022,25 @@ def test_list_google_ads_links_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListGoogleAdsLinksResponse.pb(return_value) + pb_return_value = analytics_admin.ListConversionEventsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_google_ads_links(**mock_args) + client.list_conversion_events(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/googleAdsLinks" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/conversionEvents" + % client.transport._host, args[1], ) -def test_list_google_ads_links_rest_flattened_error(transport: str = "rest"): +def test_list_conversion_events_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -32436,13 +40049,13 @@ def test_list_google_ads_links_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_google_ads_links( - analytics_admin.ListGoogleAdsLinksRequest(), + client.list_conversion_events( + analytics_admin.ListConversionEventsRequest(), parent="parent_value", ) -def test_list_google_ads_links_rest_pager(transport: str = "rest"): +def test_list_conversion_events_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -32454,28 +40067,28 @@ def test_list_google_ads_links_rest_pager(transport: str = "rest"): # with mock.patch.object(path_template, 'transcode') as transcode: # Set the response as a series of pages response = ( - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), ], next_page_token="abc", ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[], + analytics_admin.ListConversionEventsResponse( + conversion_events=[], next_page_token="def", ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), ], next_page_token="ghi", ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), ], ), ) @@ -32484,7 +40097,7 @@ def test_list_google_ads_links_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.ListGoogleAdsLinksResponse.to_json(x) for x in response + analytics_admin.ListConversionEventsResponse.to_json(x) for x in response ) return_values = tuple(Response() for i in response) for return_val, response_val in zip(return_values, response): @@ -32494,13 +40107,13 @@ def test_list_google_ads_links_rest_pager(transport: str = "rest"): sample_request = {"parent": "properties/sample1"} - pager = client.list_google_ads_links(request=sample_request) + pager = client.list_conversion_events(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.GoogleAdsLink) for i in results) + assert all(isinstance(i, resources.ConversionEvent) for i in results) - pages = list(client.list_google_ads_links(request=sample_request).pages) + pages = list(client.list_conversion_events(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -32508,54 +40121,48 @@ def test_list_google_ads_links_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDataSharingSettingsRequest, + analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, dict, ], ) -def test_get_data_sharing_settings_rest(request_type): +def test_get_display_video360_advertiser_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1/dataSharingSettings"} + request_init = {"name": "properties/sample1/displayVideo360AdvertiserLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataSharingSettings( + return_value = resources.DisplayVideo360AdvertiserLink( name="name_value", - sharing_with_google_support_enabled=True, - sharing_with_google_assigned_sales_enabled=True, - sharing_with_google_any_sales_enabled=True, - sharing_with_google_products_enabled=True, - sharing_with_others_enabled=True, + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataSharingSettings.pb(return_value) + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_data_sharing_settings(request) + response = client.get_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataSharingSettings) + assert isinstance(response, resources.DisplayVideo360AdvertiserLink) 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 + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" -def test_get_data_sharing_settings_rest_required_fields( - request_type=analytics_admin.GetDataSharingSettingsRequest, +def test_get_display_video360_advertiser_link_rest_required_fields( + request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -32575,7 +40182,7 @@ def test_get_data_sharing_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_data_sharing_settings._get_unset_required_fields(jsonified_request) + ).get_display_video360_advertiser_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -32584,7 +40191,7 @@ def test_get_data_sharing_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_data_sharing_settings._get_unset_required_fields(jsonified_request) + ).get_display_video360_advertiser_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -32598,7 +40205,7 @@ def test_get_data_sharing_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DataSharingSettings() + return_value = resources.DisplayVideo360AdvertiserLink() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -32618,30 +40225,32 @@ def test_get_data_sharing_settings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataSharingSettings.pb(return_value) + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_data_sharing_settings(request) + response = client.get_display_video360_advertiser_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_data_sharing_settings_rest_unset_required_fields(): +def test_get_display_video360_advertiser_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_data_sharing_settings._get_unset_required_fields({}) + unset_fields = ( + transport.get_display_video360_advertiser_link._get_unset_required_fields({}) + ) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_data_sharing_settings_rest_interceptors(null_interceptor): +def test_get_display_video360_advertiser_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32655,14 +40264,15 @@ def test_get_data_sharing_settings_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_get_data_sharing_settings", + "post_get_display_video360_advertiser_link", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_data_sharing_settings" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_get_display_video360_advertiser_link", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetDataSharingSettingsRequest.pb( - analytics_admin.GetDataSharingSettingsRequest() + pb_message = analytics_admin.GetDisplayVideo360AdvertiserLinkRequest.pb( + analytics_admin.GetDisplayVideo360AdvertiserLinkRequest() ) transcode.return_value = { "method": "post", @@ -32674,19 +40284,19 @@ def test_get_data_sharing_settings_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DataSharingSettings.to_json( - resources.DataSharingSettings() + req.return_value._content = resources.DisplayVideo360AdvertiserLink.to_json( + resources.DisplayVideo360AdvertiserLink() ) - request = analytics_admin.GetDataSharingSettingsRequest() + request = analytics_admin.GetDisplayVideo360AdvertiserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataSharingSettings() + post.return_value = resources.DisplayVideo360AdvertiserLink() - client.get_data_sharing_settings( + client.get_display_video360_advertiser_link( request, metadata=[ ("key", "val"), @@ -32698,8 +40308,9 @@ def test_get_data_sharing_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_data_sharing_settings_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetDataSharingSettingsRequest +def test_get_display_video360_advertiser_link_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32707,7 +40318,7 @@ def test_get_data_sharing_settings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1/dataSharingSettings"} + request_init = {"name": "properties/sample1/displayVideo360AdvertiserLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -32719,10 +40330,10 @@ def test_get_data_sharing_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_data_sharing_settings(request) + client.get_display_video360_advertiser_link(request) -def test_get_data_sharing_settings_rest_flattened(): +def test_get_display_video360_advertiser_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -32731,10 +40342,12 @@ def test_get_data_sharing_settings_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataSharingSettings() + return_value = resources.DisplayVideo360AdvertiserLink() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1/dataSharingSettings"} + sample_request = { + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" + } # get truthy value for each flattened field mock_args = dict( @@ -32745,24 +40358,27 @@ def test_get_data_sharing_settings_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataSharingSettings.pb(return_value) + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_data_sharing_settings(**mock_args) + client.get_display_video360_advertiser_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=accounts/*/dataSharingSettings}" % client.transport._host, + "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinks/*}" + % client.transport._host, args[1], ) -def test_get_data_sharing_settings_rest_flattened_error(transport: str = "rest"): +def test_get_display_video360_advertiser_link_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -32771,13 +40387,13 @@ def test_get_data_sharing_settings_rest_flattened_error(transport: str = "rest") # 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(), + client.get_display_video360_advertiser_link( + analytics_admin.GetDisplayVideo360AdvertiserLinkRequest(), name="name_value", ) -def test_get_data_sharing_settings_rest_error(): +def test_get_display_video360_advertiser_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -32786,55 +40402,51 @@ def test_get_data_sharing_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetMeasurementProtocolSecretRequest, + analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, dict, ], ) -def test_get_measurement_protocol_secret_rest(request_type): +def test_list_display_video360_advertiser_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret( - name="name_value", - display_name="display_name_value", - secret_value="secret_value_value", + return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + pb_return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_measurement_protocol_secret(request) + response = client.list_display_video360_advertiser_links(request) # 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" + assert isinstance(response, pagers.ListDisplayVideo360AdvertiserLinksPager) + assert response.next_page_token == "next_page_token_value" -def test_get_measurement_protocol_secret_rest_required_fields( - request_type=analytics_admin.GetMeasurementProtocolSecretRequest, +def test_list_display_video360_advertiser_links_rest_required_fields( + request_type=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -32849,21 +40461,32 @@ def test_get_measurement_protocol_secret_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_measurement_protocol_secret._get_unset_required_fields(jsonified_request) + ).list_display_video360_advertiser_links._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_measurement_protocol_secret._get_unset_required_fields(jsonified_request) + ).list_display_video360_advertiser_links._get_unset_required_fields( + jsonified_request + ) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32872,7 +40495,7 @@ def test_get_measurement_protocol_secret_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret() + return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -32892,32 +40515,44 @@ def test_get_measurement_protocol_secret_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + pb_return_value = ( + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.pb( + return_value + ) + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_measurement_protocol_secret(request) + response = client.list_display_video360_advertiser_links(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_measurement_protocol_secret_rest_unset_required_fields(): +def test_list_display_video360_advertiser_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_measurement_protocol_secret._get_unset_required_fields( - {} + unset_fields = ( + transport.list_display_video360_advertiser_links._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) ) - assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): +def test_list_display_video360_advertiser_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32931,15 +40566,15 @@ def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_get_measurement_protocol_secret", + "post_list_display_video360_advertiser_links", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_measurement_protocol_secret", + "pre_list_display_video360_advertiser_links", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetMeasurementProtocolSecretRequest.pb( - analytics_admin.GetMeasurementProtocolSecretRequest() + pb_message = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest.pb( + analytics_admin.ListDisplayVideo360AdvertiserLinksRequest() ) transcode.return_value = { "method": "post", @@ -32951,19 +40586,21 @@ def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.MeasurementProtocolSecret.to_json( - resources.MeasurementProtocolSecret() + req.return_value._content = ( + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.to_json( + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() + ) ) - request = analytics_admin.GetMeasurementProtocolSecretRequest() + request = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.MeasurementProtocolSecret() + post.return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() - client.get_measurement_protocol_secret( + client.list_display_video360_advertiser_links( request, metadata=[ ("key", "val"), @@ -32975,9 +40612,9 @@ def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_measurement_protocol_secret_rest_bad_request( +def test_list_display_video360_advertiser_links_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.GetMeasurementProtocolSecretRequest, + request_type=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32985,9 +40622,7 @@ def test_get_measurement_protocol_secret_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -32999,10 +40634,10 @@ def test_get_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_measurement_protocol_secret(request) + client.list_display_video360_advertiser_links(request) -def test_get_measurement_protocol_secret_rest_flattened(): +def test_list_display_video360_advertiser_links_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33011,41 +40646,43 @@ def test_get_measurement_protocol_secret_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret() + return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" - } + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + pb_return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_measurement_protocol_secret(**mock_args) + client.list_display_video360_advertiser_links(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinks" % client.transport._host, args[1], ) -def test_get_measurement_protocol_secret_rest_flattened_error(transport: str = "rest"): +def test_list_display_video360_advertiser_links_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -33054,61 +40691,133 @@ def test_get_measurement_protocol_secret_rest_flattened_error(transport: str = " # 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", + client.list_display_video360_advertiser_links( + analytics_admin.ListDisplayVideo360AdvertiserLinksRequest(), + parent="parent_value", ) -def test_get_measurement_protocol_secret_rest_error(): +def test_list_display_video360_advertiser_links_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + display_video_360_advertiser_links=[ + resources.DisplayVideo360AdvertiserLink(), + resources.DisplayVideo360AdvertiserLink(), + resources.DisplayVideo360AdvertiserLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + display_video_360_advertiser_links=[], + next_page_token="def", + ), + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + display_video_360_advertiser_links=[ + resources.DisplayVideo360AdvertiserLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + display_video_360_advertiser_links=[ + resources.DisplayVideo360AdvertiserLink(), + resources.DisplayVideo360AdvertiserLink(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1"} + + pager = client.list_display_video360_advertiser_links(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all( + isinstance(i, resources.DisplayVideo360AdvertiserLink) for i in results + ) + + pages = list( + client.list_display_video360_advertiser_links(request=sample_request).pages + ) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListMeasurementProtocolSecretsRequest, + analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, dict, ], ) -def test_list_measurement_protocol_secrets_rest(request_type): +def test_create_display_video360_advertiser_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1/dataStreams/sample2"} + request_init = {"parent": "properties/sample1"} + request_init["display_video_360_advertiser_link"] = { + "name": "name_value", + "advertiser_id": "advertiser_id_value", + "advertiser_display_name": "advertiser_display_name_value", + "ads_personalization_enabled": {"value": True}, + "campaign_data_sharing_enabled": {}, + "cost_data_sharing_enabled": {}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListMeasurementProtocolSecretsResponse( - next_page_token="next_page_token_value", + return_value = resources.DisplayVideo360AdvertiserLink( + name="name_value", + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListMeasurementProtocolSecretsResponse.pb( - return_value - ) + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_measurement_protocol_secrets(request) + response = client.create_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMeasurementProtocolSecretsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.DisplayVideo360AdvertiserLink) + assert response.name == "name_value" + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" -def test_list_measurement_protocol_secrets_rest_required_fields( - request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, +def test_create_display_video360_advertiser_link_rest_required_fields( + request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -33128,7 +40837,9 @@ def test_list_measurement_protocol_secrets_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_measurement_protocol_secrets._get_unset_required_fields(jsonified_request) + ).create_display_video360_advertiser_link._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -33137,13 +40848,8 @@ def test_list_measurement_protocol_secrets_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_measurement_protocol_secrets._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) + ).create_display_video360_advertiser_link._get_unset_required_fields( + jsonified_request ) jsonified_request.update(unset_fields) @@ -33158,7 +40864,7 @@ def test_list_measurement_protocol_secrets_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + return_value = resources.DisplayVideo360AdvertiserLink() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -33170,50 +40876,49 @@ def test_list_measurement_protocol_secrets_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListMeasurementProtocolSecretsResponse.pb( - return_value - ) + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_measurement_protocol_secrets(request) + response = client.create_display_video360_advertiser_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_measurement_protocol_secrets_rest_unset_required_fields(): +def test_create_display_video360_advertiser_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) unset_fields = ( - transport.list_measurement_protocol_secrets._get_unset_required_fields({}) + transport.create_display_video360_advertiser_link._get_unset_required_fields({}) ) assert set(unset_fields) == ( - set( + set(()) + & set( ( - "pageSize", - "pageToken", + "parent", + "displayVideo360AdvertiserLink", ) ) - & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): +def test_create_display_video360_advertiser_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -33227,15 +40932,15 @@ def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_list_measurement_protocol_secrets", + "post_create_display_video360_advertiser_link", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_list_measurement_protocol_secrets", + "pre_create_display_video360_advertiser_link", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListMeasurementProtocolSecretsRequest.pb( - analytics_admin.ListMeasurementProtocolSecretsRequest() + pb_message = analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest.pb( + analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest() ) transcode.return_value = { "method": "post", @@ -33247,21 +40952,19 @@ def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.ListMeasurementProtocolSecretsResponse.to_json( - analytics_admin.ListMeasurementProtocolSecretsResponse() - ) + req.return_value._content = resources.DisplayVideo360AdvertiserLink.to_json( + resources.DisplayVideo360AdvertiserLink() ) - request = analytics_admin.ListMeasurementProtocolSecretsRequest() + request = analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + post.return_value = resources.DisplayVideo360AdvertiserLink() - client.list_measurement_protocol_secrets( + client.create_display_video360_advertiser_link( request, metadata=[ ("key", "val"), @@ -33273,9 +40976,9 @@ def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_measurement_protocol_secrets_rest_bad_request( +def test_create_display_video360_advertiser_link_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, + request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -33283,7 +40986,15 @@ def test_list_measurement_protocol_secrets_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1/dataStreams/sample2"} + request_init = {"parent": "properties/sample1"} + request_init["display_video_360_advertiser_link"] = { + "name": "name_value", + "advertiser_id": "advertiser_id_value", + "advertiser_display_name": "advertiser_display_name_value", + "ads_personalization_enabled": {"value": True}, + "campaign_data_sharing_enabled": {}, + "cost_data_sharing_enabled": {}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -33295,10 +41006,10 @@ def test_list_measurement_protocol_secrets_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_measurement_protocol_secrets(request) + client.create_display_video360_advertiser_link(request) -def test_list_measurement_protocol_secrets_rest_flattened(): +def test_create_display_video360_advertiser_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33307,41 +41018,42 @@ def test_list_measurement_protocol_secrets_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + return_value = resources.DisplayVideo360AdvertiserLink() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1/dataStreams/sample2"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( parent="parent_value", + display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( + name="name_value" + ), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListMeasurementProtocolSecretsResponse.pb( - return_value - ) + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_measurement_protocol_secrets(**mock_args) + client.create_display_video360_advertiser_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*/dataStreams/*}/measurementProtocolSecrets" + "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinks" % client.transport._host, args[1], ) -def test_list_measurement_protocol_secrets_rest_flattened_error( +def test_create_display_video360_advertiser_link_rest_flattened_error( transport: str = "rest", ): client = AnalyticsAdminServiceClient( @@ -33352,133 +41064,63 @@ def test_list_measurement_protocol_secrets_rest_flattened_error( # 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(), + client.create_display_video360_advertiser_link( + analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest(), parent="parent_value", + display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( + name="name_value" + ), ) -def test_list_measurement_protocol_secrets_rest_pager(transport: str = "rest"): +def test_create_display_video360_advertiser_link_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListMeasurementProtocolSecretsResponse.to_json(x) - for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1/dataStreams/sample2"} - - pager = client.list_measurement_protocol_secrets(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.MeasurementProtocolSecret) for i in results) - - pages = list( - client.list_measurement_protocol_secrets(request=sample_request).pages - ) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateMeasurementProtocolSecretRequest, + analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, dict, ], ) -def test_create_measurement_protocol_secret_rest(request_type): +def test_delete_display_video360_advertiser_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1/dataStreams/sample2"} - request_init["measurement_protocol_secret"] = { - "name": "name_value", - "display_name": "display_name_value", - "secret_value": "secret_value_value", - } + request_init = {"name": "properties/sample1/displayVideo360AdvertiserLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret( - name="name_value", - display_name="display_name_value", - secret_value="secret_value_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_measurement_protocol_secret(request) + response = client.delete_display_video360_advertiser_link(request) # 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" + assert response is None -def test_create_measurement_protocol_secret_rest_required_fields( - request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, +def test_delete_display_video360_advertiser_link_rest_required_fields( + request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -33493,21 +41135,25 @@ def test_create_measurement_protocol_secret_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_measurement_protocol_secret._get_unset_required_fields(jsonified_request) + ).delete_display_video360_advertiser_link._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_measurement_protocol_secret._get_unset_required_fields(jsonified_request) + ).delete_display_video360_advertiser_link._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -33516,7 +41162,7 @@ def test_create_measurement_protocol_secret_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -33528,49 +41174,38 @@ def test_create_measurement_protocol_secret_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "delete", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_measurement_protocol_secret(request) + response = client.delete_display_video360_advertiser_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_measurement_protocol_secret_rest_unset_required_fields(): +def test_delete_display_video360_advertiser_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) unset_fields = ( - transport.create_measurement_protocol_secret._get_unset_required_fields({}) - ) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "measurementProtocolSecret", - ) - ) + transport.delete_display_video360_advertiser_link._get_unset_required_fields({}) ) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): +def test_delete_display_video360_advertiser_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -33584,15 +41219,11 @@ def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_create_measurement_protocol_secret", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_create_measurement_protocol_secret", + "pre_delete_display_video360_advertiser_link", ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreateMeasurementProtocolSecretRequest.pb( - analytics_admin.CreateMeasurementProtocolSecretRequest() + pb_message = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest.pb( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() ) transcode.return_value = { "method": "post", @@ -33604,19 +41235,15 @@ def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.MeasurementProtocolSecret.to_json( - resources.MeasurementProtocolSecret() - ) - request = analytics_admin.CreateMeasurementProtocolSecretRequest() + request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.MeasurementProtocolSecret() - client.create_measurement_protocol_secret( + client.delete_display_video360_advertiser_link( request, metadata=[ ("key", "val"), @@ -33625,12 +41252,11 @@ def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_measurement_protocol_secret_rest_bad_request( +def test_delete_display_video360_advertiser_link_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, + request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -33638,12 +41264,7 @@ def test_create_measurement_protocol_secret_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1/dataStreams/sample2"} - request_init["measurement_protocol_secret"] = { - "name": "name_value", - "display_name": "display_name_value", - "secret_value": "secret_value_value", - } + request_init = {"name": "properties/sample1/displayVideo360AdvertiserLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -33655,10 +41276,10 @@ def test_create_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_measurement_protocol_secret(request) + client.delete_display_video360_advertiser_link(request) -def test_create_measurement_protocol_secret_rest_flattened(): +def test_delete_display_video360_advertiser_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33667,42 +41288,40 @@ def test_create_measurement_protocol_secret_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1/dataStreams/sample2"} + sample_request = { + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - measurement_protocol_secret=resources.MeasurementProtocolSecret( - name="name_value" - ), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_measurement_protocol_secret(**mock_args) + client.delete_display_video360_advertiser_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*/dataStreams/*}/measurementProtocolSecrets" + "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinks/*}" % client.transport._host, args[1], ) -def test_create_measurement_protocol_secret_rest_flattened_error( +def test_delete_display_video360_advertiser_link_rest_flattened_error( transport: str = "rest", ): client = AnalyticsAdminServiceClient( @@ -33713,16 +41332,13 @@ def test_create_measurement_protocol_secret_rest_flattened_error( # 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" - ), + client.delete_display_video360_advertiser_link( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest(), + name="name_value", ) -def test_create_measurement_protocol_secret_rest_error(): +def test_delete_display_video360_advertiser_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -33731,11 +41347,11 @@ def test_create_measurement_protocol_secret_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteMeasurementProtocolSecretRequest, + analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, dict, ], ) -def test_delete_measurement_protocol_secret_rest(request_type): +def test_update_display_video360_advertiser_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33743,35 +41359,52 @@ def test_delete_measurement_protocol_secret_rest(request_type): # send a request that will satisfy transcoding request_init = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + "display_video_360_advertiser_link": { + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" + } + } + request_init["display_video_360_advertiser_link"] = { + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2", + "advertiser_id": "advertiser_id_value", + "advertiser_display_name": "advertiser_display_name_value", + "ads_personalization_enabled": {"value": True}, + "campaign_data_sharing_enabled": {}, + "cost_data_sharing_enabled": {}, } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.DisplayVideo360AdvertiserLink( + name="name_value", + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_measurement_protocol_secret(request) + response = client.update_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.DisplayVideo360AdvertiserLink) + assert response.name == "name_value" + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" -def test_delete_measurement_protocol_secret_rest_required_fields( - request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, +def test_update_display_video360_advertiser_link_rest_required_fields( + request_type=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -33786,21 +41419,23 @@ def test_delete_measurement_protocol_secret_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_measurement_protocol_secret._get_unset_required_fields(jsonified_request) + ).update_display_video360_advertiser_link._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_measurement_protocol_secret._get_unset_required_fields(jsonified_request) + ).update_display_video360_advertiser_link._get_unset_required_fields( + jsonified_request + ) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -33809,7 +41444,7 @@ def test_delete_measurement_protocol_secret_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.DisplayVideo360AdvertiserLink() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -33821,38 +41456,41 @@ def test_delete_measurement_protocol_secret_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_measurement_protocol_secret(request) + response = client.update_display_video360_advertiser_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_measurement_protocol_secret_rest_unset_required_fields(): +def test_update_display_video360_advertiser_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) unset_fields = ( - transport.delete_measurement_protocol_secret._get_unset_required_fields({}) + transport.update_display_video360_advertiser_link._get_unset_required_fields({}) ) - assert set(unset_fields) == (set(()) & set(("name",))) + assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): +def test_update_display_video360_advertiser_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -33866,11 +41504,15 @@ def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_delete_measurement_protocol_secret", + "post_update_display_video360_advertiser_link", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_display_video360_advertiser_link", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteMeasurementProtocolSecretRequest.pb( - analytics_admin.DeleteMeasurementProtocolSecretRequest() + post.assert_not_called() + pb_message = analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest.pb( + analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest() ) transcode.return_value = { "method": "post", @@ -33882,15 +41524,19 @@ def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.DisplayVideo360AdvertiserLink.to_json( + resources.DisplayVideo360AdvertiserLink() + ) - request = analytics_admin.DeleteMeasurementProtocolSecretRequest() + request = analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.DisplayVideo360AdvertiserLink() - client.delete_measurement_protocol_secret( + client.update_display_video360_advertiser_link( request, metadata=[ ("key", "val"), @@ -33899,11 +41545,12 @@ def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_measurement_protocol_secret_rest_bad_request( +def test_update_display_video360_advertiser_link_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, + request_type=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -33912,7 +41559,17 @@ def test_delete_measurement_protocol_secret_rest_bad_request( # send a request that will satisfy transcoding request_init = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + "display_video_360_advertiser_link": { + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" + } + } + request_init["display_video_360_advertiser_link"] = { + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2", + "advertiser_id": "advertiser_id_value", + "advertiser_display_name": "advertiser_display_name_value", + "ads_personalization_enabled": {"value": True}, + "campaign_data_sharing_enabled": {}, + "cost_data_sharing_enabled": {}, } request = request_type(**request_init) @@ -33925,10 +41582,10 @@ def test_delete_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_measurement_protocol_secret(request) + client.update_display_video360_advertiser_link(request) -def test_delete_measurement_protocol_secret_rest_flattened(): +def test_update_display_video360_advertiser_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33937,40 +41594,46 @@ def test_delete_measurement_protocol_secret_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.DisplayVideo360AdvertiserLink() # get arguments that satisfy an http rule for this method sample_request = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + "display_video_360_advertiser_link": { + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" + } } # get truthy value for each flattened field mock_args = dict( - name="name_value", + display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_measurement_protocol_secret(**mock_args) + client.update_display_video360_advertiser_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + "%s/v1alpha/{display_video_360_advertiser_link.name=properties/*/displayVideo360AdvertiserLinks/*}" % client.transport._host, args[1], ) -def test_delete_measurement_protocol_secret_rest_flattened_error( +def test_update_display_video360_advertiser_link_rest_flattened_error( transport: str = "rest", ): client = AnalyticsAdminServiceClient( @@ -33981,13 +41644,16 @@ def test_delete_measurement_protocol_secret_rest_flattened_error( # 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", + client.update_display_video360_advertiser_link( + analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest(), + display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_delete_measurement_protocol_secret_rest_error(): +def test_update_display_video360_advertiser_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -33996,11 +41662,11 @@ def test_delete_measurement_protocol_secret_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateMeasurementProtocolSecretRequest, + analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_update_measurement_protocol_secret_rest(request_type): +def test_get_display_video360_advertiser_link_proposal_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34008,49 +41674,47 @@ def test_update_measurement_protocol_secret_rest(request_type): # send a request that will satisfy transcoding request_init = { - "measurement_protocol_secret": { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" - } - } - request_init["measurement_protocol_secret"] = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3", - "display_name": "display_name_value", - "secret_value": "secret_value_value", + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret( + return_value = resources.DisplayVideo360AdvertiserLinkProposal( name="name_value", - display_name="display_name_value", - secret_value="secret_value_value", + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", + validation_email="validation_email_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_measurement_protocol_secret(request) + response = client.get_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) + assert isinstance(response, resources.DisplayVideo360AdvertiserLinkProposal) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.secret_value == "secret_value_value" + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" + assert response.validation_email == "validation_email_value" -def test_update_measurement_protocol_secret_rest_required_fields( - request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, +def test_get_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -34065,19 +41729,25 @@ def test_update_measurement_protocol_secret_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_measurement_protocol_secret._get_unset_required_fields(jsonified_request) + ).get_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_measurement_protocol_secret._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + ).get_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34086,7 +41756,7 @@ def test_update_measurement_protocol_secret_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret() + return_value = resources.DisplayVideo360AdvertiserLinkProposal() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -34098,43 +41768,44 @@ def test_update_measurement_protocol_secret_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_measurement_protocol_secret(request) + response = client.get_display_video360_advertiser_link_proposal(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_measurement_protocol_secret_rest_unset_required_fields(): +def test_get_display_video360_advertiser_link_proposal_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.update_measurement_protocol_secret._get_unset_required_fields({}) - ) - assert set(unset_fields) == ( - set(("updateMask",)) & set(("measurementProtocolSecret",)) + unset_fields = transport.get_display_video360_advertiser_link_proposal._get_unset_required_fields( + {} ) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): +def test_get_display_video360_advertiser_link_proposal_rest_interceptors( + null_interceptor, +): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -34148,15 +41819,15 @@ def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_update_measurement_protocol_secret", + "post_get_display_video360_advertiser_link_proposal", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_measurement_protocol_secret", + "pre_get_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateMeasurementProtocolSecretRequest.pb( - analytics_admin.UpdateMeasurementProtocolSecretRequest() + pb_message = analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest() ) transcode.return_value = { "method": "post", @@ -34168,19 +41839,21 @@ def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.MeasurementProtocolSecret.to_json( - resources.MeasurementProtocolSecret() + req.return_value._content = ( + resources.DisplayVideo360AdvertiserLinkProposal.to_json( + resources.DisplayVideo360AdvertiserLinkProposal() + ) ) - request = analytics_admin.UpdateMeasurementProtocolSecretRequest() + request = analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.MeasurementProtocolSecret() + post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() - client.update_measurement_protocol_secret( + client.get_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -34192,9 +41865,9 @@ def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_measurement_protocol_secret_rest_bad_request( +def test_get_display_video360_advertiser_link_proposal_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, + request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34203,14 +41876,7 @@ def test_update_measurement_protocol_secret_rest_bad_request( # send a request that will satisfy transcoding request_init = { - "measurement_protocol_secret": { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" - } - } - request_init["measurement_protocol_secret"] = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3", - "display_name": "display_name_value", - "secret_value": "secret_value_value", + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } request = request_type(**request_init) @@ -34223,10 +41889,10 @@ def test_update_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_measurement_protocol_secret(request) + client.get_display_video360_advertiser_link_proposal(request) -def test_update_measurement_protocol_secret_rest_flattened(): +def test_get_display_video360_advertiser_link_proposal_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34235,46 +41901,43 @@ def test_update_measurement_protocol_secret_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.MeasurementProtocolSecret() + return_value = resources.DisplayVideo360AdvertiserLinkProposal() # get arguments that satisfy an http rule for this method sample_request = { - "measurement_protocol_secret": { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" - } + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } # get truthy value for each flattened field mock_args = dict( - measurement_protocol_secret=resources.MeasurementProtocolSecret( - name="name_value" - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.MeasurementProtocolSecret.pb(return_value) + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_measurement_protocol_secret(**mock_args) + client.get_display_video360_advertiser_link_proposal(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{measurement_protocol_secret.name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}" % client.transport._host, args[1], ) -def test_update_measurement_protocol_secret_rest_flattened_error( +def test_get_display_video360_advertiser_link_proposal_rest_flattened_error( transport: str = "rest", ): client = AnalyticsAdminServiceClient( @@ -34285,16 +41948,13 @@ def test_update_measurement_protocol_secret_rest_flattened_error( # 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"]), + client.get_display_video360_advertiser_link_proposal( + analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest(), + name="name_value", ) -def test_update_measurement_protocol_secret_rest_error(): +def test_get_display_video360_advertiser_link_proposal_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -34303,49 +41963,55 @@ def test_update_measurement_protocol_secret_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.AcknowledgeUserDataCollectionRequest, + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, dict, ], ) -def test_acknowledge_user_data_collection_rest(request_type): +def test_list_display_video360_advertiser_link_proposals_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"property": "properties/sample1"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() + return_value = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( + next_page_token="next_page_token_value", + ) + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.AcknowledgeUserDataCollectionResponse.pb( - return_value + pb_return_value = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.pb( + return_value + ) ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.acknowledge_user_data_collection(request) + response = client.list_display_video360_advertiser_link_proposals(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.AcknowledgeUserDataCollectionResponse) + assert isinstance(response, pagers.ListDisplayVideo360AdvertiserLinkProposalsPager) + assert response.next_page_token == "next_page_token_value" -def test_acknowledge_user_data_collection_rest_required_fields( - request_type=analytics_admin.AcknowledgeUserDataCollectionRequest, +def test_list_display_video360_advertiser_link_proposals_rest_required_fields( + request_type=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["property"] = "" - request_init["acknowledgement"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -34360,24 +42026,32 @@ def test_acknowledge_user_data_collection_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).acknowledge_user_data_collection._get_unset_required_fields(jsonified_request) + ).list_display_video360_advertiser_link_proposals._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["property"] = "property_value" - jsonified_request["acknowledgement"] = "acknowledgement_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).acknowledge_user_data_collection._get_unset_required_fields(jsonified_request) + ).list_display_video360_advertiser_link_proposals._get_unset_required_fields( + jsonified_request + ) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "property" in jsonified_request - assert jsonified_request["property"] == "property_value" - assert "acknowledgement" in jsonified_request - assert jsonified_request["acknowledgement"] == "acknowledgement_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34386,7 +42060,7 @@ def test_acknowledge_user_data_collection_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() + return_value = analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -34398,51 +42072,54 @@ def test_acknowledge_user_data_collection_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.AcknowledgeUserDataCollectionResponse.pb( - return_value + pb_return_value = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.pb( + return_value + ) ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.acknowledge_user_data_collection(request) + response = client.list_display_video360_advertiser_link_proposals(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_acknowledge_user_data_collection_rest_unset_required_fields(): +def test_list_display_video360_advertiser_link_proposals_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.acknowledge_user_data_collection._get_unset_required_fields({}) + unset_fields = transport.list_display_video360_advertiser_link_proposals._get_unset_required_fields( + {} ) assert set(unset_fields) == ( - set(()) - & set( + set( ( - "property", - "acknowledgement", + "pageSize", + "pageToken", ) ) + & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_acknowledge_user_data_collection_rest_interceptors(null_interceptor): +def test_list_display_video360_advertiser_link_proposals_rest_interceptors( + null_interceptor, +): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -34456,15 +42133,17 @@ def test_acknowledge_user_data_collection_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_acknowledge_user_data_collection", + "post_list_display_video360_advertiser_link_proposals", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_acknowledge_user_data_collection", + "pre_list_display_video360_advertiser_link_proposals", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.AcknowledgeUserDataCollectionRequest.pb( - analytics_admin.AcknowledgeUserDataCollectionRequest() + pb_message = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest.pb( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest() + ) ) transcode.return_value = { "method": "post", @@ -34477,20 +42156,22 @@ def test_acknowledge_user_data_collection_rest_interceptors(null_interceptor): req.return_value.status_code = 200 req.return_value.request = PreparedRequest() req.return_value._content = ( - analytics_admin.AcknowledgeUserDataCollectionResponse.to_json( - analytics_admin.AcknowledgeUserDataCollectionResponse() + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.to_json( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() ) ) - request = analytics_admin.AcknowledgeUserDataCollectionRequest() + request = analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() + post.return_value = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() + ) - client.acknowledge_user_data_collection( + client.list_display_video360_advertiser_link_proposals( request, metadata=[ ("key", "val"), @@ -34502,9 +42183,9 @@ def test_acknowledge_user_data_collection_rest_interceptors(null_interceptor): post.assert_called_once() -def test_acknowledge_user_data_collection_rest_bad_request( +def test_list_display_video360_advertiser_link_proposals_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.AcknowledgeUserDataCollectionRequest, + request_type=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34512,7 +42193,7 @@ def test_acknowledge_user_data_collection_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"property": "properties/sample1"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -34524,63 +42205,218 @@ def test_acknowledge_user_data_collection_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.acknowledge_user_data_collection(request) + client.list_display_video360_advertiser_link_proposals(request) -def test_acknowledge_user_data_collection_rest_error(): +def test_list_display_video360_advertiser_link_proposals_rest_flattened(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() + ) + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "properties/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.pb( + return_value + ) + ) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_display_video360_advertiser_link_proposals(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinkProposals" + % client.transport._host, + args[1], + ) + + +def test_list_display_video360_advertiser_link_proposals_rest_flattened_error( + transport: str = "rest", +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_display_video360_advertiser_link_proposals( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest(), + parent="parent_value", + ) + + +def test_list_display_video360_advertiser_link_proposals_rest_pager( + transport: str = "rest", +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( + display_video_360_advertiser_link_proposals=[ + resources.DisplayVideo360AdvertiserLinkProposal(), + resources.DisplayVideo360AdvertiserLinkProposal(), + resources.DisplayVideo360AdvertiserLinkProposal(), + ], + next_page_token="abc", + ), + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( + display_video_360_advertiser_link_proposals=[], + next_page_token="def", + ), + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( + display_video_360_advertiser_link_proposals=[ + resources.DisplayVideo360AdvertiserLinkProposal(), + ], + next_page_token="ghi", + ), + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( + display_video_360_advertiser_link_proposals=[ + resources.DisplayVideo360AdvertiserLinkProposal(), + resources.DisplayVideo360AdvertiserLinkProposal(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.to_json( + x + ) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1"} + + pager = client.list_display_video360_advertiser_link_proposals( + request=sample_request + ) + + results = list(pager) + assert len(results) == 6 + assert all( + isinstance(i, resources.DisplayVideo360AdvertiserLinkProposal) + for i in results + ) + + pages = list( + client.list_display_video360_advertiser_link_proposals( + request=sample_request + ).pages + ) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.SearchChangeHistoryEventsRequest, + analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_search_change_history_events_rest(request_type): +def test_create_display_video360_advertiser_link_proposal_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"account": "accounts/sample1"} + request_init = {"parent": "properties/sample1"} + request_init["display_video_360_advertiser_link_proposal"] = { + "name": "name_value", + "advertiser_id": "advertiser_id_value", + "link_proposal_status_details": { + "link_proposal_initiating_product": 1, + "requestor_email": "requestor_email_value", + "link_proposal_state": 1, + }, + "advertiser_display_name": "advertiser_display_name_value", + "validation_email": "validation_email_value", + "ads_personalization_enabled": {"value": True}, + "campaign_data_sharing_enabled": {}, + "cost_data_sharing_enabled": {}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.SearchChangeHistoryEventsResponse( - next_page_token="next_page_token_value", + return_value = resources.DisplayVideo360AdvertiserLinkProposal( + name="name_value", + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", + validation_email="validation_email_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.SearchChangeHistoryEventsResponse.pb( + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( return_value ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.search_change_history_events(request) + response = client.create_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchChangeHistoryEventsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.DisplayVideo360AdvertiserLinkProposal) + assert response.name == "name_value" + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" + assert response.validation_email == "validation_email_value" -def test_search_change_history_events_rest_required_fields( - request_type=analytics_admin.SearchChangeHistoryEventsRequest, +def test_create_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["account"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -34595,21 +42431,25 @@ def test_search_change_history_events_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).search_change_history_events._get_unset_required_fields(jsonified_request) + ).create_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["account"] = "account_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).search_change_history_events._get_unset_required_fields(jsonified_request) + ).create_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "account" in jsonified_request - assert jsonified_request["account"] == "account_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34618,7 +42458,7 @@ def test_search_change_history_events_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.SearchChangeHistoryEventsResponse() + return_value = resources.DisplayVideo360AdvertiserLinkProposal() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -34639,7 +42479,7 @@ def test_search_change_history_events_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.SearchChangeHistoryEventsResponse.pb( + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( return_value ) json_return_value = json_format.MessageToJson(pb_return_value) @@ -34647,24 +42487,36 @@ def test_search_change_history_events_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.search_change_history_events(request) + response = client.create_display_video360_advertiser_link_proposal(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_search_change_history_events_rest_unset_required_fields(): +def test_create_display_video360_advertiser_link_proposal_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.search_change_history_events._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("account",))) + unset_fields = transport.create_display_video360_advertiser_link_proposal._get_unset_required_fields( + {} + ) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "displayVideo360AdvertiserLinkProposal", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_search_change_history_events_rest_interceptors(null_interceptor): +def test_create_display_video360_advertiser_link_proposal_rest_interceptors( + null_interceptor, +): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -34678,15 +42530,17 @@ def test_search_change_history_events_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_search_change_history_events", + "post_create_display_video360_advertiser_link_proposal", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_search_change_history_events", + "pre_create_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.SearchChangeHistoryEventsRequest.pb( - analytics_admin.SearchChangeHistoryEventsRequest() + pb_message = ( + analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest() + ) ) transcode.return_value = { "method": "post", @@ -34699,20 +42553,20 @@ def test_search_change_history_events_rest_interceptors(null_interceptor): req.return_value.status_code = 200 req.return_value.request = PreparedRequest() req.return_value._content = ( - analytics_admin.SearchChangeHistoryEventsResponse.to_json( - analytics_admin.SearchChangeHistoryEventsResponse() + resources.DisplayVideo360AdvertiserLinkProposal.to_json( + resources.DisplayVideo360AdvertiserLinkProposal() ) ) - request = analytics_admin.SearchChangeHistoryEventsRequest() + request = analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.SearchChangeHistoryEventsResponse() + post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() - client.search_change_history_events( + client.create_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -34724,9 +42578,9 @@ def test_search_change_history_events_rest_interceptors(null_interceptor): post.assert_called_once() -def test_search_change_history_events_rest_bad_request( +def test_create_display_video360_advertiser_link_proposal_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.SearchChangeHistoryEventsRequest, + request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34734,7 +42588,21 @@ def test_search_change_history_events_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"account": "accounts/sample1"} + request_init = {"parent": "properties/sample1"} + request_init["display_video_360_advertiser_link_proposal"] = { + "name": "name_value", + "advertiser_id": "advertiser_id_value", + "link_proposal_status_details": { + "link_proposal_initiating_product": 1, + "requestor_email": "requestor_email_value", + "link_proposal_state": 1, + }, + "advertiser_display_name": "advertiser_display_name_value", + "validation_email": "validation_email_value", + "ads_personalization_enabled": {"value": True}, + "campaign_data_sharing_enabled": {}, + "cost_data_sharing_enabled": {}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -34746,121 +42614,120 @@ def test_search_change_history_events_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.search_change_history_events(request) + client.create_display_video360_advertiser_link_proposal(request) -def test_search_change_history_events_rest_pager(transport: str = "rest"): +def test_create_display_video360_advertiser_link_proposal_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.DisplayVideo360AdvertiserLinkProposal() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "properties/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + display_video_360_advertiser_link_proposal=resources.DisplayVideo360AdvertiserLinkProposal( + name="name_value" ), ) - # Two responses for two calls - response = response + response + mock_args.update(sample_request) - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.SearchChangeHistoryEventsResponse.to_json(x) - for x in response + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( + return_value ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - sample_request = {"account": "accounts/sample1"} + client.create_display_video360_advertiser_link_proposal(**mock_args) - pager = client.search_change_history_events(request=sample_request) + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinkProposals" + % client.transport._host, + args[1], + ) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.ChangeHistoryEvent) for i in results) - pages = list(client.search_change_history_events(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +def test_create_display_video360_advertiser_link_proposal_rest_flattened_error( + transport: str = "rest", +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_display_video360_advertiser_link_proposal( + analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest(), + parent="parent_value", + display_video_360_advertiser_link_proposal=resources.DisplayVideo360AdvertiserLinkProposal( + name="name_value" + ), + ) + + +def test_create_display_video360_advertiser_link_proposal_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetGoogleSignalsSettingsRequest, + analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_get_google_signals_settings_rest(request_type): +def test_delete_display_video360_advertiser_link_proposal_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/googleSignalsSettings"} + request_init = { + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GoogleSignalsSettings( - name="name_value", - state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, - consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleSignalsSettings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_google_signals_settings(request) + response = client.delete_display_video360_advertiser_link_proposal(request) # 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 - ) + assert response is None -def test_get_google_signals_settings_rest_required_fields( - request_type=analytics_admin.GetGoogleSignalsSettingsRequest, +def test_delete_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -34880,7 +42747,9 @@ def test_get_google_signals_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_google_signals_settings._get_unset_required_fields(jsonified_request) + ).delete_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -34889,7 +42758,9 @@ def test_get_google_signals_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_google_signals_settings._get_unset_required_fields(jsonified_request) + ).delete_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -34903,7 +42774,7 @@ def test_get_google_signals_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.GoogleSignalsSettings() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -34915,38 +42786,40 @@ def test_get_google_signals_settings_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "delete", "query_params": pb_request, } transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.GoogleSignalsSettings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_google_signals_settings(request) + response = client.delete_display_video360_advertiser_link_proposal(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_google_signals_settings_rest_unset_required_fields(): +def test_delete_display_video360_advertiser_link_proposal_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_google_signals_settings._get_unset_required_fields({}) + unset_fields = transport.delete_display_video360_advertiser_link_proposal._get_unset_required_fields( + {} + ) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_google_signals_settings_rest_interceptors(null_interceptor): +def test_delete_display_video360_advertiser_link_proposal_rest_interceptors( + null_interceptor, +): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -34960,15 +42833,13 @@ def test_get_google_signals_settings_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_get_google_signals_settings", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_google_signals_settings", + "pre_delete_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.GetGoogleSignalsSettingsRequest.pb( - analytics_admin.GetGoogleSignalsSettingsRequest() + pb_message = ( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest() + ) ) transcode.return_value = { "method": "post", @@ -34980,19 +42851,15 @@ def test_get_google_signals_settings_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.GoogleSignalsSettings.to_json( - resources.GoogleSignalsSettings() - ) - request = analytics_admin.GetGoogleSignalsSettingsRequest() + request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GoogleSignalsSettings() - client.get_google_signals_settings( + client.delete_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -35001,12 +42868,11 @@ def test_get_google_signals_settings_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_get_google_signals_settings_rest_bad_request( +def test_delete_display_video360_advertiser_link_proposal_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.GetGoogleSignalsSettingsRequest, + request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35014,7 +42880,9 @@ def test_get_google_signals_settings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/googleSignalsSettings"} + request_init = { + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -35026,10 +42894,10 @@ def test_get_google_signals_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_google_signals_settings(request) + client.delete_display_video360_advertiser_link_proposal(request) -def test_get_google_signals_settings_rest_flattened(): +def test_delete_display_video360_advertiser_link_proposal_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -35038,10 +42906,12 @@ def test_get_google_signals_settings_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GoogleSignalsSettings() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/googleSignalsSettings"} + sample_request = { + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + } # get truthy value for each flattened field mock_args = dict( @@ -35052,25 +42922,26 @@ def test_get_google_signals_settings_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleSignalsSettings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_google_signals_settings(**mock_args) + client.delete_display_video360_advertiser_link_proposal(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/googleSignalsSettings}" + "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}" % client.transport._host, args[1], ) -def test_get_google_signals_settings_rest_flattened_error(transport: str = "rest"): +def test_delete_display_video360_advertiser_link_proposal_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -35079,13 +42950,13 @@ def test_get_google_signals_settings_rest_flattened_error(transport: str = "rest # 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(), + client.delete_display_video360_advertiser_link_proposal( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest(), name="name_value", ) -def test_get_google_signals_settings_rest_error(): +def test_delete_display_video360_advertiser_link_proposal_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -35094,11 +42965,11 @@ def test_get_google_signals_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateGoogleSignalsSettingsRequest, + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_update_google_signals_settings_rest(request_type): +def test_approve_display_video360_advertiser_link_proposal_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -35106,50 +42977,44 @@ def test_update_google_signals_settings_rest(request_type): # send a request that will satisfy transcoding request_init = { - "google_signals_settings": {"name": "properties/sample1/googleSignalsSettings"} - } - request_init["google_signals_settings"] = { - "name": "properties/sample1/googleSignalsSettings", - "state": 1, - "consent": 2, + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.GoogleSignalsSettings( - name="name_value", - state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, - consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + return_value = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleSignalsSettings.pb(return_value) + pb_return_value = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.pb( + return_value + ) + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_google_signals_settings(request) + response = client.approve_display_video360_advertiser_link_proposal(request) # 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 + assert isinstance( + response, analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse ) -def test_update_google_signals_settings_rest_required_fields( - request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, +def test_approve_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -35164,19 +43029,25 @@ def test_update_google_signals_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_google_signals_settings._get_unset_required_fields(jsonified_request) + ).approve_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_google_signals_settings._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + ).approve_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35185,7 +43056,9 @@ def test_update_google_signals_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.GoogleSignalsSettings() + return_value = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() + ) # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -35197,7 +43070,7 @@ def test_update_google_signals_settings_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "post", "query_params": pb_request, } transcode_result["body"] = pb_request @@ -35206,40 +43079,38 @@ def test_update_google_signals_settings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.GoogleSignalsSettings.pb(return_value) + pb_return_value = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.pb( + return_value + ) + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_google_signals_settings(request) + response = client.approve_display_video360_advertiser_link_proposal(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_google_signals_settings_rest_unset_required_fields(): +def test_approve_display_video360_advertiser_link_proposal_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_google_signals_settings._get_unset_required_fields( + unset_fields = transport.approve_display_video360_advertiser_link_proposal._get_unset_required_fields( {} ) - assert set(unset_fields) == ( - set(("updateMask",)) - & set( - ( - "googleSignalsSettings", - "updateMask", - ) - ) - ) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_google_signals_settings_rest_interceptors(null_interceptor): +def test_approve_display_video360_advertiser_link_proposal_rest_interceptors( + null_interceptor, +): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -35253,15 +43124,17 @@ def test_update_google_signals_settings_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_update_google_signals_settings", + "post_approve_display_video360_advertiser_link_proposal", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_google_signals_settings", + "pre_approve_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateGoogleSignalsSettingsRequest.pb( - analytics_admin.UpdateGoogleSignalsSettingsRequest() + pb_message = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest() + ) ) transcode.return_value = { "method": "post", @@ -35273,19 +43146,21 @@ def test_update_google_signals_settings_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.GoogleSignalsSettings.to_json( - resources.GoogleSignalsSettings() + req.return_value._content = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.to_json( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() ) - request = analytics_admin.UpdateGoogleSignalsSettingsRequest() + request = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GoogleSignalsSettings() + post.return_value = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() + ) - client.update_google_signals_settings( + client.approve_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -35297,9 +43172,9 @@ def test_update_google_signals_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_google_signals_settings_rest_bad_request( +def test_approve_display_video360_advertiser_link_proposal_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, + request_type=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35308,12 +43183,7 @@ def test_update_google_signals_settings_rest_bad_request( # send a request that will satisfy transcoding request_init = { - "google_signals_settings": {"name": "properties/sample1/googleSignalsSettings"} - } - request_init["google_signals_settings"] = { - "name": "properties/sample1/googleSignalsSettings", - "state": 1, - "consent": 2, + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } request = request_type(**request_init) @@ -35326,72 +43196,10 @@ def test_update_google_signals_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_google_signals_settings(request) - - -def test_update_google_signals_settings_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.GoogleSignalsSettings() - - # get arguments that satisfy an http rule for this method - sample_request = { - "google_signals_settings": { - "name": "properties/sample1/googleSignalsSettings" - } - } - - # get truthy value for each flattened field - mock_args = dict( - google_signals_settings=resources.GoogleSignalsSettings(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.GoogleSignalsSettings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.update_google_signals_settings(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{google_signals_settings.name=properties/*/googleSignalsSettings}" - % client.transport._host, - args[1], - ) - - -def test_update_google_signals_settings_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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"]), - ) + client.approve_display_video360_advertiser_link_proposal(request) -def test_update_google_signals_settings_rest_error(): +def test_approve_display_video360_advertiser_link_proposal_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -35400,62 +43208,59 @@ def test_update_google_signals_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateConversionEventRequest, + analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_create_conversion_event_rest(request_type): +def test_cancel_display_video360_advertiser_link_proposal_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["conversion_event"] = { - "name": "name_value", - "event_name": "event_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "deletable": True, - "custom": True, + request_init = { + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.ConversionEvent( + return_value = resources.DisplayVideo360AdvertiserLinkProposal( name="name_value", - event_name="event_name_value", - deletable=True, - custom=True, + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", + validation_email="validation_email_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.ConversionEvent.pb(return_value) + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_conversion_event(request) + response = client.cancel_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.ConversionEvent) + assert isinstance(response, resources.DisplayVideo360AdvertiserLinkProposal) assert response.name == "name_value" - assert response.event_name == "event_name_value" - assert response.deletable is True - assert response.custom is True + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" + assert response.validation_email == "validation_email_value" -def test_create_conversion_event_rest_required_fields( - request_type=analytics_admin.CreateConversionEventRequest, +def test_cancel_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -35470,21 +43275,25 @@ def test_create_conversion_event_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_conversion_event._get_unset_required_fields(jsonified_request) + ).cancel_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_conversion_event._get_unset_required_fields(jsonified_request) + ).cancel_display_video360_advertiser_link_proposal._get_unset_required_fields( + jsonified_request + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35493,7 +43302,7 @@ def test_create_conversion_event_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.ConversionEvent() + return_value = resources.DisplayVideo360AdvertiserLinkProposal() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -35514,38 +43323,36 @@ def test_create_conversion_event_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.ConversionEvent.pb(return_value) + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_conversion_event(request) + response = client.cancel_display_video360_advertiser_link_proposal(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_conversion_event_rest_unset_required_fields(): +def test_cancel_display_video360_advertiser_link_proposal_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_conversion_event._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "conversionEvent", - "parent", - ) - ) + unset_fields = transport.cancel_display_video360_advertiser_link_proposal._get_unset_required_fields( + {} ) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_conversion_event_rest_interceptors(null_interceptor): +def test_cancel_display_video360_advertiser_link_proposal_rest_interceptors( + null_interceptor, +): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -35558,14 +43365,18 @@ def test_create_conversion_event_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_conversion_event" + transports.AnalyticsAdminServiceRestInterceptor, + "post_cancel_display_video360_advertiser_link_proposal", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_conversion_event" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_cancel_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateConversionEventRequest.pb( - analytics_admin.CreateConversionEventRequest() + pb_message = ( + analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest() + ) ) transcode.return_value = { "method": "post", @@ -35577,19 +43388,21 @@ def test_create_conversion_event_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.ConversionEvent.to_json( - resources.ConversionEvent() + req.return_value._content = ( + resources.DisplayVideo360AdvertiserLinkProposal.to_json( + resources.DisplayVideo360AdvertiserLinkProposal() + ) ) - request = analytics_admin.CreateConversionEventRequest() + request = analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.ConversionEvent() + post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() - client.create_conversion_event( + client.cancel_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -35601,8 +43414,9 @@ def test_create_conversion_event_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_conversion_event_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateConversionEventRequest +def test_cancel_display_video360_advertiser_link_proposal_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35610,13 +43424,8 @@ def test_create_conversion_event_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["conversion_event"] = { - "name": "name_value", - "event_name": "event_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "deletable": True, - "custom": True, + request_init = { + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } request = request_type(**request_init) @@ -35629,68 +43438,10 @@ def test_create_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_conversion_event(request) - - -def test_create_conversion_event_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.ConversionEvent() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - conversion_event=resources.ConversionEvent(name="name_value"), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.ConversionEvent.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.create_conversion_event(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/conversionEvents" - % client.transport._host, - args[1], - ) - - -def test_create_conversion_event_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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"), - ) + client.cancel_display_video360_advertiser_link_proposal(request) -def test_create_conversion_event_rest_error(): +def test_cancel_display_video360_advertiser_link_proposal_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -35699,55 +43450,67 @@ def test_create_conversion_event_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetConversionEventRequest, + analytics_admin.CreateCustomDimensionRequest, dict, ], ) -def test_get_conversion_event_rest(request_type): +def test_create_custom_dimension_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/conversionEvents/sample2"} + request_init = {"parent": "properties/sample1"} + request_init["custom_dimension"] = { + "name": "name_value", + "parameter_name": "parameter_name_value", + "display_name": "display_name_value", + "description": "description_value", + "scope": 1, + "disallow_ads_personalization": True, + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.ConversionEvent( + return_value = resources.CustomDimension( name="name_value", - event_name="event_name_value", - deletable=True, - custom=True, + parameter_name="parameter_name_value", + display_name="display_name_value", + description="description_value", + scope=resources.CustomDimension.DimensionScope.EVENT, + disallow_ads_personalization=True, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.ConversionEvent.pb(return_value) + pb_return_value = resources.CustomDimension.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_conversion_event(request) + response = client.create_custom_dimension(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.ConversionEvent) + assert isinstance(response, resources.CustomDimension) assert response.name == "name_value" - assert response.event_name == "event_name_value" - assert response.deletable is True - assert response.custom is True + 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_conversion_event_rest_required_fields( - request_type=analytics_admin.GetConversionEventRequest, +def test_create_custom_dimension_rest_required_fields( + request_type=analytics_admin.CreateCustomDimensionRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -35762,21 +43525,21 @@ def test_get_conversion_event_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_conversion_event._get_unset_required_fields(jsonified_request) + ).create_custom_dimension._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_conversion_event._get_unset_required_fields(jsonified_request) + ).create_custom_dimension._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35785,7 +43548,7 @@ def test_get_conversion_event_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.ConversionEvent() + return_value = resources.CustomDimension() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -35797,38 +43560,47 @@ def test_get_conversion_event_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.ConversionEvent.pb(return_value) + pb_return_value = resources.CustomDimension.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_conversion_event(request) + response = client.create_custom_dimension(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_conversion_event_rest_unset_required_fields(): +def test_create_custom_dimension_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_conversion_event._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.create_custom_dimension._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "customDimension", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_conversion_event_rest_interceptors(null_interceptor): +def test_create_custom_dimension_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -35841,14 +43613,14 @@ def test_get_conversion_event_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_conversion_event" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_custom_dimension" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_conversion_event" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_custom_dimension" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetConversionEventRequest.pb( - analytics_admin.GetConversionEventRequest() + pb_message = analytics_admin.CreateCustomDimensionRequest.pb( + analytics_admin.CreateCustomDimensionRequest() ) transcode.return_value = { "method": "post", @@ -35860,19 +43632,19 @@ def test_get_conversion_event_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.ConversionEvent.to_json( - resources.ConversionEvent() + req.return_value._content = resources.CustomDimension.to_json( + resources.CustomDimension() ) - request = analytics_admin.GetConversionEventRequest() + request = analytics_admin.CreateCustomDimensionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.ConversionEvent() + post.return_value = resources.CustomDimension() - client.get_conversion_event( + client.create_custom_dimension( request, metadata=[ ("key", "val"), @@ -35884,8 +43656,8 @@ def test_get_conversion_event_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_conversion_event_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetConversionEventRequest +def test_create_custom_dimension_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateCustomDimensionRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35893,7 +43665,15 @@ def test_get_conversion_event_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/conversionEvents/sample2"} + request_init = {"parent": "properties/sample1"} + request_init["custom_dimension"] = { + "name": "name_value", + "parameter_name": "parameter_name_value", + "display_name": "display_name_value", + "description": "description_value", + "scope": 1, + "disallow_ads_personalization": True, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -35905,10 +43685,10 @@ def test_get_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_conversion_event(request) + client.create_custom_dimension(request) -def test_get_conversion_event_rest_flattened(): +def test_create_custom_dimension_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -35917,39 +43697,40 @@ def test_get_conversion_event_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.ConversionEvent() + return_value = resources.CustomDimension() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/conversionEvents/sample2"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", + custom_dimension=resources.CustomDimension(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.ConversionEvent.pb(return_value) + pb_return_value = resources.CustomDimension.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_conversion_event(**mock_args) + client.create_custom_dimension(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/conversionEvents/*}" + "%s/v1alpha/{parent=properties/*}/customDimensions" % client.transport._host, args[1], ) -def test_get_conversion_event_rest_flattened_error(transport: str = "rest"): +def test_create_custom_dimension_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -35958,13 +43739,14 @@ def test_get_conversion_event_rest_flattened_error(transport: str = "rest"): # 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", + client.create_custom_dimension( + analytics_admin.CreateCustomDimensionRequest(), + parent="parent_value", + custom_dimension=resources.CustomDimension(name="name_value"), ) -def test_get_conversion_event_rest_error(): +def test_create_custom_dimension_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -35973,45 +43755,68 @@ def test_get_conversion_event_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteConversionEventRequest, + analytics_admin.UpdateCustomDimensionRequest, dict, ], ) -def test_delete_conversion_event_rest(request_type): +def test_update_custom_dimension_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/conversionEvents/sample2"} + request_init = { + "custom_dimension": {"name": "properties/sample1/customDimensions/sample2"} + } + request_init["custom_dimension"] = { + "name": "properties/sample1/customDimensions/sample2", + "parameter_name": "parameter_name_value", + "display_name": "display_name_value", + "description": "description_value", + "scope": 1, + "disallow_ads_personalization": True, + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + 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, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.CustomDimension.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_conversion_event(request) + response = client.update_custom_dimension(request) # Establish that the response is the type that we expect. - assert response is None + 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_delete_conversion_event_rest_required_fields( - request_type=analytics_admin.DeleteConversionEventRequest, +def test_update_custom_dimension_rest_required_fields( + request_type=analytics_admin.UpdateCustomDimensionRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -36026,21 +43831,19 @@ def test_delete_conversion_event_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_conversion_event._get_unset_required_fields(jsonified_request) + ).update_custom_dimension._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_conversion_event._get_unset_required_fields(jsonified_request) + ).update_custom_dimension._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -36049,7 +43852,7 @@ def test_delete_conversion_event_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.CustomDimension() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -36061,36 +43864,39 @@ def test_delete_conversion_event_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = resources.CustomDimension.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_conversion_event(request) + response = client.update_custom_dimension(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_conversion_event_rest_unset_required_fields(): +def test_update_custom_dimension_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_conversion_event._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.update_custom_dimension._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_conversion_event_rest_interceptors(null_interceptor): +def test_update_custom_dimension_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -36103,11 +43909,14 @@ def test_delete_conversion_event_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_conversion_event" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_custom_dimension" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_custom_dimension" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteConversionEventRequest.pb( - analytics_admin.DeleteConversionEventRequest() + post.assert_not_called() + pb_message = analytics_admin.UpdateCustomDimensionRequest.pb( + analytics_admin.UpdateCustomDimensionRequest() ) transcode.return_value = { "method": "post", @@ -36119,15 +43928,19 @@ def test_delete_conversion_event_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.CustomDimension.to_json( + resources.CustomDimension() + ) - request = analytics_admin.DeleteConversionEventRequest() + request = analytics_admin.UpdateCustomDimensionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.CustomDimension() - client.delete_conversion_event( + client.update_custom_dimension( request, metadata=[ ("key", "val"), @@ -36136,10 +43949,11 @@ def test_delete_conversion_event_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_conversion_event_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteConversionEventRequest +def test_update_custom_dimension_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateCustomDimensionRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -36147,7 +43961,17 @@ def test_delete_conversion_event_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/conversionEvents/sample2"} + request_init = { + "custom_dimension": {"name": "properties/sample1/customDimensions/sample2"} + } + request_init["custom_dimension"] = { + "name": "properties/sample1/customDimensions/sample2", + "parameter_name": "parameter_name_value", + "display_name": "display_name_value", + "description": "description_value", + "scope": 1, + "disallow_ads_personalization": True, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -36159,10 +43983,10 @@ def test_delete_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_conversion_event(request) + client.update_custom_dimension(request) -def test_delete_conversion_event_rest_flattened(): +def test_update_custom_dimension_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -36171,38 +43995,42 @@ def test_delete_conversion_event_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.CustomDimension() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/conversionEvents/sample2"} + sample_request = { + "custom_dimension": {"name": "properties/sample1/customDimensions/sample2"} + } # get truthy value for each flattened field mock_args = dict( - name="name_value", + custom_dimension=resources.CustomDimension(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.CustomDimension.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_conversion_event(**mock_args) + client.update_custom_dimension(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/conversionEvents/*}" + "%s/v1alpha/{custom_dimension.name=properties/*/customDimensions/*}" % client.transport._host, args[1], ) -def test_delete_conversion_event_rest_flattened_error(transport: str = "rest"): +def test_update_custom_dimension_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -36211,13 +44039,14 @@ def test_delete_conversion_event_rest_flattened_error(transport: str = "rest"): # 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", + 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_delete_conversion_event_rest_error(): +def test_update_custom_dimension_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -36226,11 +44055,11 @@ def test_delete_conversion_event_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListConversionEventsRequest, + analytics_admin.ListCustomDimensionsRequest, dict, ], ) -def test_list_conversion_events_rest(request_type): +def test_list_custom_dimensions_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -36243,27 +44072,27 @@ def test_list_conversion_events_rest(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListConversionEventsResponse( + return_value = analytics_admin.ListCustomDimensionsResponse( next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListConversionEventsResponse.pb(return_value) + pb_return_value = analytics_admin.ListCustomDimensionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_conversion_events(request) + response = client.list_custom_dimensions(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConversionEventsPager) + assert isinstance(response, pagers.ListCustomDimensionsPager) assert response.next_page_token == "next_page_token_value" -def test_list_conversion_events_rest_required_fields( - request_type=analytics_admin.ListConversionEventsRequest, +def test_list_custom_dimensions_rest_required_fields( + request_type=analytics_admin.ListCustomDimensionsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -36283,7 +44112,7 @@ def test_list_conversion_events_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_conversion_events._get_unset_required_fields(jsonified_request) + ).list_custom_dimensions._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -36292,7 +44121,7 @@ def test_list_conversion_events_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_conversion_events._get_unset_required_fields(jsonified_request) + ).list_custom_dimensions._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set( ( @@ -36313,7 +44142,7 @@ def test_list_conversion_events_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListConversionEventsResponse() + return_value = analytics_admin.ListCustomDimensionsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -36333,7 +44162,7 @@ def test_list_conversion_events_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListConversionEventsResponse.pb( + pb_return_value = analytics_admin.ListCustomDimensionsResponse.pb( return_value ) json_return_value = json_format.MessageToJson(pb_return_value) @@ -36341,19 +44170,19 @@ def test_list_conversion_events_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_conversion_events(request) + response = client.list_custom_dimensions(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_conversion_events_rest_unset_required_fields(): +def test_list_custom_dimensions_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_conversion_events._get_unset_required_fields({}) + unset_fields = transport.list_custom_dimensions._get_unset_required_fields({}) assert set(unset_fields) == ( set( ( @@ -36366,7 +44195,7 @@ def test_list_conversion_events_rest_unset_required_fields(): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_conversion_events_rest_interceptors(null_interceptor): +def test_list_custom_dimensions_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -36379,14 +44208,14 @@ def test_list_conversion_events_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_conversion_events" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_custom_dimensions" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_conversion_events" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_custom_dimensions" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListConversionEventsRequest.pb( - analytics_admin.ListConversionEventsRequest() + pb_message = analytics_admin.ListCustomDimensionsRequest.pb( + analytics_admin.ListCustomDimensionsRequest() ) transcode.return_value = { "method": "post", @@ -36399,20 +44228,20 @@ def test_list_conversion_events_rest_interceptors(null_interceptor): req.return_value.status_code = 200 req.return_value.request = PreparedRequest() req.return_value._content = ( - analytics_admin.ListConversionEventsResponse.to_json( - analytics_admin.ListConversionEventsResponse() + analytics_admin.ListCustomDimensionsResponse.to_json( + analytics_admin.ListCustomDimensionsResponse() ) ) - request = analytics_admin.ListConversionEventsRequest() + request = analytics_admin.ListCustomDimensionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListConversionEventsResponse() + post.return_value = analytics_admin.ListCustomDimensionsResponse() - client.list_conversion_events( + client.list_custom_dimensions( request, metadata=[ ("key", "val"), @@ -36424,8 +44253,8 @@ def test_list_conversion_events_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_conversion_events_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListConversionEventsRequest +def test_list_custom_dimensions_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListCustomDimensionsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -36445,10 +44274,10 @@ def test_list_conversion_events_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_conversion_events(request) + client.list_custom_dimensions(request) -def test_list_conversion_events_rest_flattened(): +def test_list_custom_dimensions_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -36457,7 +44286,7 @@ def test_list_conversion_events_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListConversionEventsResponse() + return_value = analytics_admin.ListCustomDimensionsResponse() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -36471,25 +44300,25 @@ def test_list_conversion_events_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListConversionEventsResponse.pb(return_value) + pb_return_value = analytics_admin.ListCustomDimensionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_conversion_events(**mock_args) + client.list_custom_dimensions(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/conversionEvents" + "%s/v1alpha/{parent=properties/*}/customDimensions" % client.transport._host, args[1], ) -def test_list_conversion_events_rest_flattened_error(transport: str = "rest"): +def test_list_custom_dimensions_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -36498,13 +44327,13 @@ def test_list_conversion_events_rest_flattened_error(transport: str = "rest"): # 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(), + client.list_custom_dimensions( + analytics_admin.ListCustomDimensionsRequest(), parent="parent_value", ) -def test_list_conversion_events_rest_pager(transport: str = "rest"): +def test_list_custom_dimensions_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -36516,28 +44345,28 @@ def test_list_conversion_events_rest_pager(transport: str = "rest"): # with mock.patch.object(path_template, 'transcode') as transcode: # Set the response as a series of pages response = ( - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - resources.ConversionEvent(), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), + resources.CustomDimension(), ], next_page_token="abc", - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[], + ), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[], next_page_token="def", ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), ], next_page_token="ghi", ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), + analytics_admin.ListCustomDimensionsResponse( + custom_dimensions=[ + resources.CustomDimension(), + resources.CustomDimension(), ], ), ) @@ -36546,7 +44375,7 @@ def test_list_conversion_events_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.ListConversionEventsResponse.to_json(x) for x in response + analytics_admin.ListCustomDimensionsResponse.to_json(x) for x in response ) return_values = tuple(Response() for i in response) for return_val, response_val in zip(return_values, response): @@ -36556,13 +44385,13 @@ def test_list_conversion_events_rest_pager(transport: str = "rest"): sample_request = {"parent": "properties/sample1"} - pager = client.list_conversion_events(request=sample_request) + pager = client.list_custom_dimensions(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.ConversionEvent) for i in results) + assert all(isinstance(i, resources.CustomDimension) for i in results) - pages = list(client.list_conversion_events(request=sample_request).pages) + pages = list(client.list_custom_dimensions(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -36570,48 +44399,40 @@ def test_list_conversion_events_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, + analytics_admin.ArchiveCustomDimensionRequest, dict, ], ) -def test_get_display_video360_advertiser_link_rest(request_type): +def test_archive_custom_dimension_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/displayVideo360AdvertiserLinks/sample2"} + request_init = {"name": "properties/sample1/customDimensions/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink( - name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_display_video360_advertiser_link(request) + response = client.archive_custom_dimension(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLink) - assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" + assert response is None -def test_get_display_video360_advertiser_link_rest_required_fields( - request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, +def test_archive_custom_dimension_rest_required_fields( + request_type=analytics_admin.ArchiveCustomDimensionRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -36631,7 +44452,7 @@ def test_get_display_video360_advertiser_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_display_video360_advertiser_link._get_unset_required_fields(jsonified_request) + ).archive_custom_dimension._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -36640,7 +44461,7 @@ def test_get_display_video360_advertiser_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_display_video360_advertiser_link._get_unset_required_fields(jsonified_request) + ).archive_custom_dimension._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -36654,7 +44475,7 @@ def test_get_display_video360_advertiser_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -36666,40 +44487,37 @@ def test_get_display_video360_advertiser_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_display_video360_advertiser_link(request) + response = client.archive_custom_dimension(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_display_video360_advertiser_link_rest_unset_required_fields(): +def test_archive_custom_dimension_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.get_display_video360_advertiser_link._get_unset_required_fields({}) - ) + unset_fields = transport.archive_custom_dimension._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_display_video360_advertiser_link_rest_interceptors(null_interceptor): +def test_archive_custom_dimension_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -36712,16 +44530,11 @@ def test_get_display_video360_advertiser_link_rest_interceptors(null_interceptor ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_get_display_video360_advertiser_link", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_display_video360_advertiser_link", + transports.AnalyticsAdminServiceRestInterceptor, "pre_archive_custom_dimension" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.GetDisplayVideo360AdvertiserLinkRequest.pb( - analytics_admin.GetDisplayVideo360AdvertiserLinkRequest() + pb_message = analytics_admin.ArchiveCustomDimensionRequest.pb( + analytics_admin.ArchiveCustomDimensionRequest() ) transcode.return_value = { "method": "post", @@ -36733,19 +44546,15 @@ def test_get_display_video360_advertiser_link_rest_interceptors(null_interceptor req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DisplayVideo360AdvertiserLink.to_json( - resources.DisplayVideo360AdvertiserLink() - ) - request = analytics_admin.GetDisplayVideo360AdvertiserLinkRequest() + request = analytics_admin.ArchiveCustomDimensionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLink() - client.get_display_video360_advertiser_link( + client.archive_custom_dimension( request, metadata=[ ("key", "val"), @@ -36754,12 +44563,10 @@ def test_get_display_video360_advertiser_link_rest_interceptors(null_interceptor ) pre.assert_called_once() - post.assert_called_once() -def test_get_display_video360_advertiser_link_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, +def test_archive_custom_dimension_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ArchiveCustomDimensionRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -36767,7 +44574,7 @@ def test_get_display_video360_advertiser_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/displayVideo360AdvertiserLinks/sample2"} + request_init = {"name": "properties/sample1/customDimensions/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -36779,10 +44586,10 @@ def test_get_display_video360_advertiser_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_display_video360_advertiser_link(request) + client.archive_custom_dimension(request) -def test_get_display_video360_advertiser_link_rest_flattened(): +def test_archive_custom_dimension_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -36791,12 +44598,10 @@ def test_get_display_video360_advertiser_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" - } + sample_request = {"name": "properties/sample1/customDimensions/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -36807,27 +44612,24 @@ def test_get_display_video360_advertiser_link_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_display_video360_advertiser_link(**mock_args) + client.archive_custom_dimension(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinks/*}" + "%s/v1alpha/{name=properties/*/customDimensions/*}:archive" % client.transport._host, args[1], ) -def test_get_display_video360_advertiser_link_rest_flattened_error( - transport: str = "rest", -): +def test_archive_custom_dimension_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -36836,13 +44638,13 @@ def test_get_display_video360_advertiser_link_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_display_video360_advertiser_link( - analytics_admin.GetDisplayVideo360AdvertiserLinkRequest(), + client.archive_custom_dimension( + analytics_admin.ArchiveCustomDimensionRequest(), name="name_value", ) -def test_get_display_video360_advertiser_link_rest_error(): +def test_archive_custom_dimension_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -36851,51 +44653,59 @@ def test_get_display_video360_advertiser_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, + analytics_admin.GetCustomDimensionRequest, dict, ], ) -def test_list_display_video360_advertiser_links_rest(request_type): +def test_get_custom_dimension_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/customDimensions/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( - next_page_token="next_page_token_value", + 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, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.pb( - return_value - ) + pb_return_value = resources.CustomDimension.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_display_video360_advertiser_links(request) + response = client.get_custom_dimension(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDisplayVideo360AdvertiserLinksPager) - assert response.next_page_token == "next_page_token_value" + 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_list_display_video360_advertiser_links_rest_required_fields( - request_type=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, +def test_get_custom_dimension_rest_required_fields( + request_type=analytics_admin.GetCustomDimensionRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -36910,32 +44720,21 @@ def test_list_display_video360_advertiser_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_display_video360_advertiser_links._get_unset_required_fields( - jsonified_request - ) + ).get_custom_dimension._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_display_video360_advertiser_links._get_unset_required_fields( - jsonified_request - ) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).get_custom_dimension._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -36944,7 +44743,7 @@ def test_list_display_video360_advertiser_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() + return_value = resources.CustomDimension() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -36964,44 +44763,30 @@ def test_list_display_video360_advertiser_links_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = ( - analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.pb( - return_value - ) - ) + pb_return_value = resources.CustomDimension.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_display_video360_advertiser_links(request) + response = client.get_custom_dimension(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_display_video360_advertiser_links_rest_unset_required_fields(): +def test_get_custom_dimension_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.list_display_video360_advertiser_links._get_unset_required_fields({}) - ) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.get_custom_dimension._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_display_video360_advertiser_links_rest_interceptors(null_interceptor): +def test_get_custom_dimension_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -37014,16 +44799,14 @@ def test_list_display_video360_advertiser_links_rest_interceptors(null_intercept ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_list_display_video360_advertiser_links", + transports.AnalyticsAdminServiceRestInterceptor, "post_get_custom_dimension" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_list_display_video360_advertiser_links", + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_custom_dimension" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest.pb( - analytics_admin.ListDisplayVideo360AdvertiserLinksRequest() + pb_message = analytics_admin.GetCustomDimensionRequest.pb( + analytics_admin.GetCustomDimensionRequest() ) transcode.return_value = { "method": "post", @@ -37035,21 +44818,19 @@ def test_list_display_video360_advertiser_links_rest_interceptors(null_intercept req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.to_json( - analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() - ) + req.return_value._content = resources.CustomDimension.to_json( + resources.CustomDimension() ) - request = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest() + request = analytics_admin.GetCustomDimensionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() + post.return_value = resources.CustomDimension() - client.list_display_video360_advertiser_links( + client.get_custom_dimension( request, metadata=[ ("key", "val"), @@ -37061,9 +44842,8 @@ def test_list_display_video360_advertiser_links_rest_interceptors(null_intercept post.assert_called_once() -def test_list_display_video360_advertiser_links_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, +def test_get_custom_dimension_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetCustomDimensionRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -37071,7 +44851,7 @@ def test_list_display_video360_advertiser_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/customDimensions/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -37083,10 +44863,10 @@ def test_list_display_video360_advertiser_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_display_video360_advertiser_links(request) + client.get_custom_dimension(request) -def test_list_display_video360_advertiser_links_rest_flattened(): +def test_get_custom_dimension_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -37095,43 +44875,39 @@ def test_list_display_video360_advertiser_links_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() + return_value = resources.CustomDimension() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "properties/sample1/customDimensions/sample2"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.pb( - return_value - ) + pb_return_value = resources.CustomDimension.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_display_video360_advertiser_links(**mock_args) + client.get_custom_dimension(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinks" + "%s/v1alpha/{name=properties/*/customDimensions/*}" % client.transport._host, args[1], ) -def test_list_display_video360_advertiser_links_rest_flattened_error( - transport: str = "rest", -): +def test_get_custom_dimension_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -37140,88 +44916,26 @@ def test_list_display_video360_advertiser_links_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_display_video360_advertiser_links( - analytics_admin.ListDisplayVideo360AdvertiserLinksRequest(), - parent="parent_value", + client.get_custom_dimension( + analytics_admin.GetCustomDimensionRequest(), + name="name_value", ) -def test_list_display_video360_advertiser_links_rest_pager(transport: str = "rest"): +def test_get_custom_dimension_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( - display_video_360_advertiser_links=[ - resources.DisplayVideo360AdvertiserLink(), - resources.DisplayVideo360AdvertiserLink(), - resources.DisplayVideo360AdvertiserLink(), - ], - next_page_token="abc", - ), - analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( - display_video_360_advertiser_links=[], - next_page_token="def", - ), - analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( - display_video_360_advertiser_links=[ - resources.DisplayVideo360AdvertiserLink(), - ], - next_page_token="ghi", - ), - analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( - display_video_360_advertiser_links=[ - resources.DisplayVideo360AdvertiserLink(), - resources.DisplayVideo360AdvertiserLink(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.to_json(x) - for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1"} - - pager = client.list_display_video360_advertiser_links(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all( - isinstance(i, resources.DisplayVideo360AdvertiserLink) for i in results - ) - - pages = list( - client.list_display_video360_advertiser_links(request=sample_request).pages - ) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, + analytics_admin.CreateCustomMetricRequest, dict, ], ) -def test_create_display_video360_advertiser_link_rest(request_type): +def test_create_custom_metric_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -37229,44 +44943,57 @@ def test_create_display_video360_advertiser_link_rest(request_type): # send a request that will satisfy transcoding request_init = {"parent": "properties/sample1"} - request_init["display_video_360_advertiser_link"] = { + request_init["custom_metric"] = { "name": "name_value", - "advertiser_id": "advertiser_id_value", - "advertiser_display_name": "advertiser_display_name_value", - "ads_personalization_enabled": {"value": True}, - "campaign_data_sharing_enabled": {}, - "cost_data_sharing_enabled": {}, + "parameter_name": "parameter_name_value", + "display_name": "display_name_value", + "description": "description_value", + "measurement_unit": 1, + "scope": 1, + "restricted_metric_type": [1], } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink( + return_value = resources.CustomMetric( name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_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, + restricted_metric_type=[ + resources.CustomMetric.RestrictedMetricType.COST_DATA + ], ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + pb_return_value = resources.CustomMetric.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_display_video360_advertiser_link(request) + response = client.create_custom_metric(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLink) + assert isinstance(response, resources.CustomMetric) assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_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 + assert response.restricted_metric_type == [ + resources.CustomMetric.RestrictedMetricType.COST_DATA + ] -def test_create_display_video360_advertiser_link_rest_required_fields( - request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, +def test_create_custom_metric_rest_required_fields( + request_type=analytics_admin.CreateCustomMetricRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -37286,9 +45013,7 @@ def test_create_display_video360_advertiser_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_display_video360_advertiser_link._get_unset_required_fields( - jsonified_request - ) + ).create_custom_metric._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -37297,9 +45022,7 @@ def test_create_display_video360_advertiser_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_display_video360_advertiser_link._get_unset_required_fields( - jsonified_request - ) + ).create_custom_metric._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -37313,7 +45036,7 @@ def test_create_display_video360_advertiser_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink() + return_value = resources.CustomMetric() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -37334,40 +45057,38 @@ def test_create_display_video360_advertiser_link_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + pb_return_value = resources.CustomMetric.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_display_video360_advertiser_link(request) + response = client.create_custom_metric(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_display_video360_advertiser_link_rest_unset_required_fields(): +def test_create_custom_metric_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.create_display_video360_advertiser_link._get_unset_required_fields({}) - ) + unset_fields = transport.create_custom_metric._get_unset_required_fields({}) assert set(unset_fields) == ( set(()) & set( ( "parent", - "displayVideo360AdvertiserLink", + "customMetric", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_display_video360_advertiser_link_rest_interceptors(null_interceptor): +def test_create_custom_metric_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -37380,16 +45101,14 @@ def test_create_display_video360_advertiser_link_rest_interceptors(null_intercep ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_create_display_video360_advertiser_link", + transports.AnalyticsAdminServiceRestInterceptor, "post_create_custom_metric" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_create_display_video360_advertiser_link", + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_custom_metric" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest.pb( - analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest() + pb_message = analytics_admin.CreateCustomMetricRequest.pb( + analytics_admin.CreateCustomMetricRequest() ) transcode.return_value = { "method": "post", @@ -37401,19 +45120,19 @@ def test_create_display_video360_advertiser_link_rest_interceptors(null_intercep req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DisplayVideo360AdvertiserLink.to_json( - resources.DisplayVideo360AdvertiserLink() + req.return_value._content = resources.CustomMetric.to_json( + resources.CustomMetric() ) - request = analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest() + request = analytics_admin.CreateCustomMetricRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLink() + post.return_value = resources.CustomMetric() - client.create_display_video360_advertiser_link( + client.create_custom_metric( request, metadata=[ ("key", "val"), @@ -37425,9 +45144,8 @@ def test_create_display_video360_advertiser_link_rest_interceptors(null_intercep post.assert_called_once() -def test_create_display_video360_advertiser_link_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, +def test_create_custom_metric_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateCustomMetricRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -37436,13 +45154,14 @@ def test_create_display_video360_advertiser_link_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "properties/sample1"} - request_init["display_video_360_advertiser_link"] = { + request_init["custom_metric"] = { "name": "name_value", - "advertiser_id": "advertiser_id_value", - "advertiser_display_name": "advertiser_display_name_value", - "ads_personalization_enabled": {"value": True}, - "campaign_data_sharing_enabled": {}, - "cost_data_sharing_enabled": {}, + "parameter_name": "parameter_name_value", + "display_name": "display_name_value", + "description": "description_value", + "measurement_unit": 1, + "scope": 1, + "restricted_metric_type": [1], } request = request_type(**request_init) @@ -37455,10 +45174,10 @@ def test_create_display_video360_advertiser_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_display_video360_advertiser_link(request) + client.create_custom_metric(request) -def test_create_display_video360_advertiser_link_rest_flattened(): +def test_create_custom_metric_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -37467,7 +45186,7 @@ def test_create_display_video360_advertiser_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink() + return_value = resources.CustomMetric() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -37475,36 +45194,31 @@ def test_create_display_video360_advertiser_link_rest_flattened(): # get truthy value for each flattened field mock_args = dict( parent="parent_value", - display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( - name="name_value" - ), + custom_metric=resources.CustomMetric(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + pb_return_value = resources.CustomMetric.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_display_video360_advertiser_link(**mock_args) + client.create_custom_metric(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinks" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/customMetrics" % client.transport._host, args[1], ) -def test_create_display_video360_advertiser_link_rest_flattened_error( - transport: str = "rest", -): +def test_create_custom_metric_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -37513,16 +45227,14 @@ def test_create_display_video360_advertiser_link_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_display_video360_advertiser_link( - analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest(), + client.create_custom_metric( + analytics_admin.CreateCustomMetricRequest(), parent="parent_value", - display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( - name="name_value" - ), + custom_metric=resources.CustomMetric(name="name_value"), ) -def test_create_display_video360_advertiser_link_rest_error(): +def test_create_custom_metric_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -37531,45 +45243,75 @@ def test_create_display_video360_advertiser_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, + analytics_admin.UpdateCustomMetricRequest, dict, ], ) -def test_delete_display_video360_advertiser_link_rest(request_type): +def test_update_custom_metric_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/displayVideo360AdvertiserLinks/sample2"} + request_init = { + "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} + } + request_init["custom_metric"] = { + "name": "properties/sample1/customMetrics/sample2", + "parameter_name": "parameter_name_value", + "display_name": "display_name_value", + "description": "description_value", + "measurement_unit": 1, + "scope": 1, + "restricted_metric_type": [1], + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + 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, + restricted_metric_type=[ + resources.CustomMetric.RestrictedMetricType.COST_DATA + ], + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.CustomMetric.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_display_video360_advertiser_link(request) + response = client.update_custom_metric(request) # Establish that the response is the type that we expect. - assert response is None + 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 + assert response.restricted_metric_type == [ + resources.CustomMetric.RestrictedMetricType.COST_DATA + ] -def test_delete_display_video360_advertiser_link_rest_required_fields( - request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, +def test_update_custom_metric_rest_required_fields( + request_type=analytics_admin.UpdateCustomMetricRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -37584,25 +45326,19 @@ def test_delete_display_video360_advertiser_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_display_video360_advertiser_link._get_unset_required_fields( - jsonified_request - ) + ).update_custom_metric._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_display_video360_advertiser_link._get_unset_required_fields( - jsonified_request - ) + ).update_custom_metric._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -37611,7 +45347,7 @@ def test_delete_display_video360_advertiser_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.CustomMetric() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -37623,38 +45359,39 @@ def test_delete_display_video360_advertiser_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = resources.CustomMetric.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_display_video360_advertiser_link(request) + response = client.update_custom_metric(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_display_video360_advertiser_link_rest_unset_required_fields(): +def test_update_custom_metric_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.delete_display_video360_advertiser_link._get_unset_required_fields({}) - ) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.update_custom_metric._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_display_video360_advertiser_link_rest_interceptors(null_interceptor): +def test_update_custom_metric_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -37667,12 +45404,14 @@ def test_delete_display_video360_advertiser_link_rest_interceptors(null_intercep ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_delete_display_video360_advertiser_link", + transports.AnalyticsAdminServiceRestInterceptor, "post_update_custom_metric" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_custom_metric" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest.pb( - analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() + post.assert_not_called() + pb_message = analytics_admin.UpdateCustomMetricRequest.pb( + analytics_admin.UpdateCustomMetricRequest() ) transcode.return_value = { "method": "post", @@ -37684,15 +45423,19 @@ def test_delete_display_video360_advertiser_link_rest_interceptors(null_intercep req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.CustomMetric.to_json( + resources.CustomMetric() + ) - request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() + request = analytics_admin.UpdateCustomMetricRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.CustomMetric() - client.delete_display_video360_advertiser_link( + client.update_custom_metric( request, metadata=[ ("key", "val"), @@ -37701,11 +45444,11 @@ def test_delete_display_video360_advertiser_link_rest_interceptors(null_intercep ) pre.assert_called_once() + post.assert_called_once() -def test_delete_display_video360_advertiser_link_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, +def test_update_custom_metric_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateCustomMetricRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -37713,7 +45456,18 @@ def test_delete_display_video360_advertiser_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/displayVideo360AdvertiserLinks/sample2"} + request_init = { + "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} + } + request_init["custom_metric"] = { + "name": "properties/sample1/customMetrics/sample2", + "parameter_name": "parameter_name_value", + "display_name": "display_name_value", + "description": "description_value", + "measurement_unit": 1, + "scope": 1, + "restricted_metric_type": [1], + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -37725,10 +45479,10 @@ def test_delete_display_video360_advertiser_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_display_video360_advertiser_link(request) + client.update_custom_metric(request) -def test_delete_display_video360_advertiser_link_rest_flattened(): +def test_update_custom_metric_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -37737,42 +45491,42 @@ def test_delete_display_video360_advertiser_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.CustomMetric() # get arguments that satisfy an http rule for this method sample_request = { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" + "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} } # get truthy value for each flattened field mock_args = dict( - name="name_value", + custom_metric=resources.CustomMetric(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.CustomMetric.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_display_video360_advertiser_link(**mock_args) + client.update_custom_metric(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinks/*}" + "%s/v1alpha/{custom_metric.name=properties/*/customMetrics/*}" % client.transport._host, args[1], ) -def test_delete_display_video360_advertiser_link_rest_flattened_error( - transport: str = "rest", -): +def test_update_custom_metric_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -37781,13 +45535,14 @@ def test_delete_display_video360_advertiser_link_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_display_video360_advertiser_link( - analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest(), - name="name_value", + 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_delete_display_video360_advertiser_link_rest_error(): +def test_update_custom_metric_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -37796,64 +45551,49 @@ def test_delete_display_video360_advertiser_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, + analytics_admin.ListCustomMetricsRequest, dict, ], ) -def test_update_display_video360_advertiser_link_rest(request_type): +def test_list_custom_metrics_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "display_video_360_advertiser_link": { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" - } - } - request_init["display_video_360_advertiser_link"] = { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2", - "advertiser_id": "advertiser_id_value", - "advertiser_display_name": "advertiser_display_name_value", - "ads_personalization_enabled": {"value": True}, - "campaign_data_sharing_enabled": {}, - "cost_data_sharing_enabled": {}, - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink( - name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", + return_value = analytics_admin.ListCustomMetricsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + pb_return_value = analytics_admin.ListCustomMetricsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_display_video360_advertiser_link(request) + response = client.list_custom_metrics(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLink) - assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" + assert isinstance(response, pagers.ListCustomMetricsPager) + assert response.next_page_token == "next_page_token_value" -def test_update_display_video360_advertiser_link_rest_required_fields( - request_type=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, +def test_list_custom_metrics_rest_required_fields( + request_type=analytics_admin.ListCustomMetricsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -37868,23 +45608,28 @@ def test_update_display_video360_advertiser_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_display_video360_advertiser_link._get_unset_required_fields( - jsonified_request - ) + ).list_custom_metrics._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_display_video360_advertiser_link._get_unset_required_fields( - jsonified_request - ) + ).list_custom_metrics._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -37893,7 +45638,7 @@ def test_update_display_video360_advertiser_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink() + return_value = analytics_admin.ListCustomMetricsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -37905,41 +45650,46 @@ def test_update_display_video360_advertiser_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + pb_return_value = analytics_admin.ListCustomMetricsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_display_video360_advertiser_link(request) + response = client.list_custom_metrics(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_display_video360_advertiser_link_rest_unset_required_fields(): +def test_list_custom_metrics_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.update_display_video360_advertiser_link._get_unset_required_fields({}) + unset_fields = transport.list_custom_metrics._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) ) - assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_display_video360_advertiser_link_rest_interceptors(null_interceptor): +def test_list_custom_metrics_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -37952,16 +45702,14 @@ def test_update_display_video360_advertiser_link_rest_interceptors(null_intercep ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_update_display_video360_advertiser_link", + transports.AnalyticsAdminServiceRestInterceptor, "post_list_custom_metrics" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_display_video360_advertiser_link", + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_custom_metrics" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest.pb( - analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest() + pb_message = analytics_admin.ListCustomMetricsRequest.pb( + analytics_admin.ListCustomMetricsRequest() ) transcode.return_value = { "method": "post", @@ -37973,19 +45721,19 @@ def test_update_display_video360_advertiser_link_rest_interceptors(null_intercep req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DisplayVideo360AdvertiserLink.to_json( - resources.DisplayVideo360AdvertiserLink() + req.return_value._content = analytics_admin.ListCustomMetricsResponse.to_json( + analytics_admin.ListCustomMetricsResponse() ) - request = analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest() + request = analytics_admin.ListCustomMetricsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLink() + post.return_value = analytics_admin.ListCustomMetricsResponse() - client.update_display_video360_advertiser_link( + client.list_custom_metrics( request, metadata=[ ("key", "val"), @@ -37997,9 +45745,8 @@ def test_update_display_video360_advertiser_link_rest_interceptors(null_intercep post.assert_called_once() -def test_update_display_video360_advertiser_link_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, +def test_list_custom_metrics_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListCustomMetricsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38007,19 +45754,7 @@ def test_update_display_video360_advertiser_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "display_video_360_advertiser_link": { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" - } - } - request_init["display_video_360_advertiser_link"] = { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2", - "advertiser_id": "advertiser_id_value", - "advertiser_display_name": "advertiser_display_name_value", - "ads_personalization_enabled": {"value": True}, - "campaign_data_sharing_enabled": {}, - "cost_data_sharing_enabled": {}, - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -38031,10 +45766,10 @@ def test_update_display_video360_advertiser_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_display_video360_advertiser_link(request) + client.list_custom_metrics(request) -def test_update_display_video360_advertiser_link_rest_flattened(): +def test_list_custom_metrics_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -38043,48 +45778,38 @@ def test_update_display_video360_advertiser_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLink() + return_value = analytics_admin.ListCustomMetricsResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "display_video_360_advertiser_link": { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" - } - } + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( - name="name_value" - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLink.pb(return_value) + pb_return_value = analytics_admin.ListCustomMetricsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_display_video360_advertiser_link(**mock_args) + client.list_custom_metrics(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{display_video_360_advertiser_link.name=properties/*/displayVideo360AdvertiserLinks/*}" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/customMetrics" % client.transport._host, args[1], ) -def test_update_display_video360_advertiser_link_rest_flattened_error( - transport: str = "rest", -): +def test_list_custom_metrics_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -38093,72 +45818,112 @@ def test_update_display_video360_advertiser_link_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_display_video360_advertiser_link( - analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest(), - display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( - name="name_value" - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.list_custom_metrics( + analytics_admin.ListCustomMetricsRequest(), + parent="parent_value", ) -def test_update_display_video360_advertiser_link_rest_error(): +def test_list_custom_metrics_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListCustomMetricsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1"} + + pager = client.list_custom_metrics(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.CustomMetric) for i in results) + + pages = list(client.list_custom_metrics(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.ArchiveCustomMetricRequest, dict, ], ) -def test_get_display_video360_advertiser_link_proposal_rest(request_type): +def test_archive_custom_metric_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" - } + request_init = {"name": "properties/sample1/customMetrics/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLinkProposal( - name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", - validation_email="validation_email_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_display_video360_advertiser_link_proposal(request) + response = client.archive_custom_metric(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLinkProposal) - assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" - assert response.validation_email == "validation_email_value" + assert response is None -def test_get_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, +def test_archive_custom_metric_rest_required_fields( + request_type=analytics_admin.ArchiveCustomMetricRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -38178,9 +45943,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).archive_custom_metric._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -38189,9 +45952,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).archive_custom_metric._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -38205,7 +45966,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLinkProposal() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -38217,44 +45978,37 @@ def test_get_display_video360_advertiser_link_proposal_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_display_video360_advertiser_link_proposal(request) + response = client.archive_custom_metric(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_archive_custom_metric_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_display_video360_advertiser_link_proposal._get_unset_required_fields( - {} - ) + unset_fields = transport.archive_custom_metric._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +def test_archive_custom_metric_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -38267,16 +46021,11 @@ def test_get_display_video360_advertiser_link_proposal_rest_interceptors( ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_get_display_video360_advertiser_link_proposal", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "pre_archive_custom_metric" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest() + pb_message = analytics_admin.ArchiveCustomMetricRequest.pb( + analytics_admin.ArchiveCustomMetricRequest() ) transcode.return_value = { "method": "post", @@ -38288,21 +46037,15 @@ def test_get_display_video360_advertiser_link_proposal_rest_interceptors( req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - resources.DisplayVideo360AdvertiserLinkProposal.to_json( - resources.DisplayVideo360AdvertiserLinkProposal() - ) - ) - request = analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.ArchiveCustomMetricRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() - client.get_display_video360_advertiser_link_proposal( + client.archive_custom_metric( request, metadata=[ ("key", "val"), @@ -38311,12 +46054,10 @@ def test_get_display_video360_advertiser_link_proposal_rest_interceptors( ) pre.assert_called_once() - post.assert_called_once() -def test_get_display_video360_advertiser_link_proposal_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, +def test_archive_custom_metric_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ArchiveCustomMetricRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38324,9 +46065,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" - } + request_init = {"name": "properties/sample1/customMetrics/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -38338,10 +46077,10 @@ def test_get_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_display_video360_advertiser_link_proposal(request) + client.archive_custom_metric(request) -def test_get_display_video360_advertiser_link_proposal_rest_flattened(): +def test_archive_custom_metric_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -38350,12 +46089,10 @@ def test_get_display_video360_advertiser_link_proposal_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLinkProposal() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" - } + sample_request = {"name": "properties/sample1/customMetrics/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -38366,29 +46103,24 @@ def test_get_display_video360_advertiser_link_proposal_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_display_video360_advertiser_link_proposal(**mock_args) + client.archive_custom_metric(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}" + "%s/v1alpha/{name=properties/*/customMetrics/*}:archive" % client.transport._host, args[1], ) -def test_get_display_video360_advertiser_link_proposal_rest_flattened_error( - transport: str = "rest", -): +def test_archive_custom_metric_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -38397,13 +46129,13 @@ def test_get_display_video360_advertiser_link_proposal_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_display_video360_advertiser_link_proposal( - analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest(), + client.archive_custom_metric( + analytics_admin.ArchiveCustomMetricRequest(), name="name_value", ) -def test_get_display_video360_advertiser_link_proposal_rest_error(): +def test_archive_custom_metric_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -38412,55 +46144,65 @@ def test_get_display_video360_advertiser_link_proposal_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, + analytics_admin.GetCustomMetricRequest, dict, ], ) -def test_list_display_video360_advertiser_link_proposals_rest(request_type): +def test_get_custom_metric_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/customMetrics/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( - next_page_token="next_page_token_value", - ) + 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, + restricted_metric_type=[ + resources.CustomMetric.RestrictedMetricType.COST_DATA + ], ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.pb( - return_value - ) - ) + pb_return_value = resources.CustomMetric.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_display_video360_advertiser_link_proposals(request) + response = client.get_custom_metric(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDisplayVideo360AdvertiserLinkProposalsPager) - assert response.next_page_token == "next_page_token_value" + 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 + assert response.restricted_metric_type == [ + resources.CustomMetric.RestrictedMetricType.COST_DATA + ] -def test_list_display_video360_advertiser_link_proposals_rest_required_fields( - request_type=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, +def test_get_custom_metric_rest_required_fields( + request_type=analytics_admin.GetCustomMetricRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -38475,32 +46217,21 @@ def test_list_display_video360_advertiser_link_proposals_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_display_video360_advertiser_link_proposals._get_unset_required_fields( - jsonified_request - ) + ).get_custom_metric._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_display_video360_advertiser_link_proposals._get_unset_required_fields( - jsonified_request - ) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).get_custom_metric._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38509,7 +46240,7 @@ def test_list_display_video360_advertiser_link_proposals_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() + return_value = resources.CustomMetric() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -38529,46 +46260,30 @@ def test_list_display_video360_advertiser_link_proposals_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.pb( - return_value - ) - ) + pb_return_value = resources.CustomMetric.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_display_video360_advertiser_link_proposals(request) + response = client.get_custom_metric(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_display_video360_advertiser_link_proposals_rest_unset_required_fields(): +def test_get_custom_metric_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_display_video360_advertiser_link_proposals._get_unset_required_fields( - {} - ) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.get_custom_metric._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_display_video360_advertiser_link_proposals_rest_interceptors( - null_interceptor, -): +def test_get_custom_metric_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -38581,18 +46296,14 @@ def test_list_display_video360_advertiser_link_proposals_rest_interceptors( ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_list_display_video360_advertiser_link_proposals", + transports.AnalyticsAdminServiceRestInterceptor, "post_get_custom_metric" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_list_display_video360_advertiser_link_proposals", + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_custom_metric" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest.pb( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest() - ) + pb_message = analytics_admin.GetCustomMetricRequest.pb( + analytics_admin.GetCustomMetricRequest() ) transcode.return_value = { "method": "post", @@ -38604,23 +46315,19 @@ def test_list_display_video360_advertiser_link_proposals_rest_interceptors( req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.to_json( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() - ) + req.return_value._content = resources.CustomMetric.to_json( + resources.CustomMetric() ) - request = analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest() + request = analytics_admin.GetCustomMetricRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() - ) + post.return_value = resources.CustomMetric() - client.list_display_video360_advertiser_link_proposals( + client.get_custom_metric( request, metadata=[ ("key", "val"), @@ -38632,9 +46339,8 @@ def test_list_display_video360_advertiser_link_proposals_rest_interceptors( post.assert_called_once() -def test_list_display_video360_advertiser_link_proposals_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, +def test_get_custom_metric_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetCustomMetricRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38642,7 +46348,7 @@ def test_list_display_video360_advertiser_link_proposals_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/customMetrics/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -38654,10 +46360,10 @@ def test_list_display_video360_advertiser_link_proposals_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_display_video360_advertiser_link_proposals(request) + client.get_custom_metric(request) -def test_list_display_video360_advertiser_link_proposals_rest_flattened(): +def test_get_custom_metric_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -38666,47 +46372,38 @@ def test_list_display_video360_advertiser_link_proposals_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() - ) + return_value = resources.CustomMetric() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "properties/sample1/customMetrics/sample2"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.pb( - return_value - ) - ) + pb_return_value = resources.CustomMetric.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_display_video360_advertiser_link_proposals(**mock_args) + client.get_custom_metric(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinkProposals" - % client.transport._host, + "%s/v1alpha/{name=properties/*/customMetrics/*}" % client.transport._host, args[1], ) -def test_list_display_video360_advertiser_link_proposals_rest_flattened_error( - transport: str = "rest", -): +def test_get_custom_metric_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -38715,157 +46412,71 @@ def test_list_display_video360_advertiser_link_proposals_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_display_video360_advertiser_link_proposals( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest(), - parent="parent_value", + client.get_custom_metric( + analytics_admin.GetCustomMetricRequest(), + name="name_value", ) -def test_list_display_video360_advertiser_link_proposals_rest_pager( - transport: str = "rest", -): +def test_get_custom_metric_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( - display_video_360_advertiser_link_proposals=[ - resources.DisplayVideo360AdvertiserLinkProposal(), - resources.DisplayVideo360AdvertiserLinkProposal(), - resources.DisplayVideo360AdvertiserLinkProposal(), - ], - next_page_token="abc", - ), - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( - display_video_360_advertiser_link_proposals=[], - next_page_token="def", - ), - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( - display_video_360_advertiser_link_proposals=[ - resources.DisplayVideo360AdvertiserLinkProposal(), - ], - next_page_token="ghi", - ), - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse( - display_video_360_advertiser_link_proposals=[ - resources.DisplayVideo360AdvertiserLinkProposal(), - resources.DisplayVideo360AdvertiserLinkProposal(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.to_json( - x - ) - for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1"} - - pager = client.list_display_video360_advertiser_link_proposals( - request=sample_request - ) - - results = list(pager) - assert len(results) == 6 - assert all( - isinstance(i, resources.DisplayVideo360AdvertiserLinkProposal) - for i in results - ) - - pages = list( - client.list_display_video360_advertiser_link_proposals( - request=sample_request - ).pages - ) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.GetDataRetentionSettingsRequest, dict, ], ) -def test_create_display_video360_advertiser_link_proposal_rest(request_type): +def test_get_data_retention_settings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["display_video_360_advertiser_link_proposal"] = { - "name": "name_value", - "advertiser_id": "advertiser_id_value", - "link_proposal_status_details": { - "link_proposal_initiating_product": 1, - "requestor_email": "requestor_email_value", - "link_proposal_state": 1, - }, - "advertiser_display_name": "advertiser_display_name_value", - "validation_email": "validation_email_value", - "ads_personalization_enabled": {"value": True}, - "campaign_data_sharing_enabled": {}, - "cost_data_sharing_enabled": {}, - } + request_init = {"name": "properties/sample1/dataRetentionSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLinkProposal( + return_value = resources.DataRetentionSettings( name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", - validation_email="validation_email_value", + event_data_retention=resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS, + reset_user_data_on_new_activity=True, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( - return_value - ) + pb_return_value = resources.DataRetentionSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_display_video360_advertiser_link_proposal(request) + response = client.get_data_retention_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLinkProposal) + assert isinstance(response, resources.DataRetentionSettings) assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" - assert response.validation_email == "validation_email_value" + assert ( + response.event_data_retention + == resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS + ) + assert response.reset_user_data_on_new_activity is True -def test_create_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, +def test_get_data_retention_settings_rest_required_fields( + request_type=analytics_admin.GetDataRetentionSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -38880,25 +46491,21 @@ def test_create_display_video360_advertiser_link_proposal_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).get_data_retention_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).get_data_retention_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38907,7 +46514,7 @@ def test_create_display_video360_advertiser_link_proposal_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLinkProposal() + return_value = resources.DataRetentionSettings() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -38919,53 +46526,38 @@ def test_create_display_video360_advertiser_link_proposal_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( - return_value - ) + pb_return_value = resources.DataRetentionSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_display_video360_advertiser_link_proposal(request) + response = client.get_data_retention_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_get_data_retention_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_display_video360_advertiser_link_proposal._get_unset_required_fields( - {} - ) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "displayVideo360AdvertiserLinkProposal", - ) - ) - ) + unset_fields = transport.get_data_retention_settings._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +def test_get_data_retention_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -38979,17 +46571,15 @@ def test_create_display_video360_advertiser_link_proposal_rest_interceptors( path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_create_display_video360_advertiser_link_proposal", + "post_get_data_retention_settings", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_create_display_video360_advertiser_link_proposal", + "pre_get_data_retention_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest() - ) + pb_message = analytics_admin.GetDataRetentionSettingsRequest.pb( + analytics_admin.GetDataRetentionSettingsRequest() ) transcode.return_value = { "method": "post", @@ -39001,21 +46591,19 @@ def test_create_display_video360_advertiser_link_proposal_rest_interceptors( req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - resources.DisplayVideo360AdvertiserLinkProposal.to_json( - resources.DisplayVideo360AdvertiserLinkProposal() - ) + req.return_value._content = resources.DataRetentionSettings.to_json( + resources.DataRetentionSettings() ) - request = analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.GetDataRetentionSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() + post.return_value = resources.DataRetentionSettings() - client.create_display_video360_advertiser_link_proposal( + client.get_data_retention_settings( request, metadata=[ ("key", "val"), @@ -39027,9 +46615,9 @@ def test_create_display_video360_advertiser_link_proposal_rest_interceptors( post.assert_called_once() -def test_create_display_video360_advertiser_link_proposal_rest_bad_request( +def test_get_data_retention_settings_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, + request_type=analytics_admin.GetDataRetentionSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39037,21 +46625,7 @@ def test_create_display_video360_advertiser_link_proposal_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["display_video_360_advertiser_link_proposal"] = { - "name": "name_value", - "advertiser_id": "advertiser_id_value", - "link_proposal_status_details": { - "link_proposal_initiating_product": 1, - "requestor_email": "requestor_email_value", - "link_proposal_state": 1, - }, - "advertiser_display_name": "advertiser_display_name_value", - "validation_email": "validation_email_value", - "ads_personalization_enabled": {"value": True}, - "campaign_data_sharing_enabled": {}, - "cost_data_sharing_enabled": {}, - } + request_init = {"name": "properties/sample1/dataRetentionSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -39063,10 +46637,10 @@ def test_create_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_display_video360_advertiser_link_proposal(request) + client.get_data_retention_settings(request) -def test_create_display_video360_advertiser_link_proposal_rest_flattened(): +def test_get_data_retention_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -39075,46 +46649,39 @@ def test_create_display_video360_advertiser_link_proposal_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLinkProposal() + return_value = resources.DataRetentionSettings() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "properties/sample1/dataRetentionSettings"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - display_video_360_advertiser_link_proposal=resources.DisplayVideo360AdvertiserLinkProposal( - name="name_value" - ), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( - return_value - ) + pb_return_value = resources.DataRetentionSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_display_video360_advertiser_link_proposal(**mock_args) + client.get_data_retention_settings(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinkProposals" + "%s/v1alpha/{name=properties/*/dataRetentionSettings}" % client.transport._host, args[1], ) -def test_create_display_video360_advertiser_link_proposal_rest_flattened_error( - transport: str = "rest", -): +def test_get_data_retention_settings_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -39123,16 +46690,13 @@ def test_create_display_video360_advertiser_link_proposal_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_display_video360_advertiser_link_proposal( - analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest(), - parent="parent_value", - display_video_360_advertiser_link_proposal=resources.DisplayVideo360AdvertiserLinkProposal( - name="name_value" - ), + client.get_data_retention_settings( + analytics_admin.GetDataRetentionSettingsRequest(), + name="name_value", ) -def test_create_display_video360_advertiser_link_proposal_rest_error(): +def test_get_data_retention_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -39141,11 +46705,11 @@ def test_create_display_video360_advertiser_link_proposal_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.UpdateDataRetentionSettingsRequest, dict, ], ) -def test_delete_display_video360_advertiser_link_proposal_rest(request_type): +def test_update_data_retention_settings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -39153,35 +46717,50 @@ def test_delete_display_video360_advertiser_link_proposal_rest(request_type): # send a request that will satisfy transcoding request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + "data_retention_settings": {"name": "properties/sample1/dataRetentionSettings"} + } + request_init["data_retention_settings"] = { + "name": "properties/sample1/dataRetentionSettings", + "event_data_retention": 1, + "reset_user_data_on_new_activity": True, } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.DataRetentionSettings( + name="name_value", + event_data_retention=resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS, + reset_user_data_on_new_activity=True, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.DataRetentionSettings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_display_video360_advertiser_link_proposal(request) + response = client.update_data_retention_settings(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.DataRetentionSettings) + assert response.name == "name_value" + assert ( + response.event_data_retention + == resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS + ) + assert response.reset_user_data_on_new_activity is True -def test_delete_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, +def test_update_data_retention_settings_rest_required_fields( + request_type=analytics_admin.UpdateDataRetentionSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -39196,25 +46775,19 @@ def test_delete_display_video360_advertiser_link_proposal_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).update_data_retention_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).update_data_retention_settings._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39223,7 +46796,7 @@ def test_delete_display_video360_advertiser_link_proposal_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.DataRetentionSettings() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -39235,40 +46808,49 @@ def test_delete_display_video360_advertiser_link_proposal_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = resources.DataRetentionSettings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_display_video360_advertiser_link_proposal(request) + response = client.update_data_retention_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_update_data_retention_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_display_video360_advertiser_link_proposal._get_unset_required_fields( + unset_fields = transport.update_data_retention_settings._get_unset_required_fields( {} ) - assert set(unset_fields) == (set(()) & set(("name",))) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "dataRetentionSettings", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +def test_update_data_retention_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -39282,13 +46864,15 @@ def test_delete_display_video360_advertiser_link_proposal_rest_interceptors( path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_delete_display_video360_advertiser_link_proposal", + "post_update_data_retention_settings", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_data_retention_settings", ) as pre: pre.assert_not_called() - pb_message = ( - analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest() - ) + post.assert_not_called() + pb_message = analytics_admin.UpdateDataRetentionSettingsRequest.pb( + analytics_admin.UpdateDataRetentionSettingsRequest() ) transcode.return_value = { "method": "post", @@ -39300,15 +46884,19 @@ def test_delete_display_video360_advertiser_link_proposal_rest_interceptors( req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.DataRetentionSettings.to_json( + resources.DataRetentionSettings() + ) - request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.UpdateDataRetentionSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.DataRetentionSettings() - client.delete_display_video360_advertiser_link_proposal( + client.update_data_retention_settings( request, metadata=[ ("key", "val"), @@ -39317,11 +46905,12 @@ def test_delete_display_video360_advertiser_link_proposal_rest_interceptors( ) pre.assert_called_once() + post.assert_called_once() -def test_delete_display_video360_advertiser_link_proposal_rest_bad_request( +def test_update_data_retention_settings_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, + request_type=analytics_admin.UpdateDataRetentionSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39330,7 +46919,12 @@ def test_delete_display_video360_advertiser_link_proposal_rest_bad_request( # send a request that will satisfy transcoding request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + "data_retention_settings": {"name": "properties/sample1/dataRetentionSettings"} + } + request_init["data_retention_settings"] = { + "name": "properties/sample1/dataRetentionSettings", + "event_data_retention": 1, + "reset_user_data_on_new_activity": True, } request = request_type(**request_init) @@ -39343,10 +46937,10 @@ def test_delete_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_display_video360_advertiser_link_proposal(request) + client.update_data_retention_settings(request) -def test_delete_display_video360_advertiser_link_proposal_rest_flattened(): +def test_update_data_retention_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -39355,42 +46949,44 @@ def test_delete_display_video360_advertiser_link_proposal_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.DataRetentionSettings() # get arguments that satisfy an http rule for this method sample_request = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + "data_retention_settings": { + "name": "properties/sample1/dataRetentionSettings" + } } # get truthy value for each flattened field mock_args = dict( - name="name_value", + data_retention_settings=resources.DataRetentionSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.DataRetentionSettings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_display_video360_advertiser_link_proposal(**mock_args) + client.update_data_retention_settings(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}" + "%s/v1alpha/{data_retention_settings.name=properties/*/dataRetentionSettings}" % client.transport._host, args[1], ) -def test_delete_display_video360_advertiser_link_proposal_rest_flattened_error( - transport: str = "rest", -): +def test_update_data_retention_settings_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -39399,13 +46995,14 @@ def test_delete_display_video360_advertiser_link_proposal_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_display_video360_advertiser_link_proposal( - analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest(), - name="name_value", + client.update_data_retention_settings( + analytics_admin.UpdateDataRetentionSettingsRequest(), + data_retention_settings=resources.DataRetentionSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_delete_display_video360_advertiser_link_proposal_rest_error(): +def test_update_data_retention_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -39414,56 +47011,76 @@ def test_delete_display_video360_advertiser_link_proposal_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.CreateDataStreamRequest, dict, ], ) -def test_approve_display_video360_advertiser_link_proposal_rest(request_type): +def test_create_data_stream_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + request_init = {"parent": "properties/sample1"} + request_init["data_stream"] = { + "web_stream_data": { + "measurement_id": "measurement_id_value", + "firebase_app_id": "firebase_app_id_value", + "default_uri": "default_uri_value", + }, + "android_app_stream_data": { + "firebase_app_id": "firebase_app_id_value", + "package_name": "package_name_value", + }, + "ios_app_stream_data": { + "firebase_app_id": "firebase_app_id_value", + "bundle_id": "bundle_id_value", + }, + "name": "name_value", + "type_": 1, + "display_name": "display_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() + return_value = resources.DataStream( + name="name_value", + type_=resources.DataStream.DataStreamType.WEB_DATA_STREAM, + display_name="display_name_value", + web_stream_data=resources.DataStream.WebStreamData( + measurement_id="measurement_id_value" + ), ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.pb( - return_value - ) - ) + pb_return_value = resources.DataStream.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.approve_display_video360_advertiser_link_proposal(request) + response = client.create_data_stream(request) # Establish that the response is the type that we expect. - assert isinstance( - response, analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse - ) + assert isinstance(response, resources.DataStream) + assert response.name == "name_value" + assert response.type_ == resources.DataStream.DataStreamType.WEB_DATA_STREAM + assert response.display_name == "display_name_value" -def test_approve_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, +def test_create_data_stream_rest_required_fields( + request_type=analytics_admin.CreateDataStreamRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -39478,25 +47095,21 @@ def test_approve_display_video360_advertiser_link_proposal_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).approve_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).create_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).approve_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).create_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39505,9 +47118,7 @@ def test_approve_display_video360_advertiser_link_proposal_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() - ) + return_value = resources.DataStream() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -39528,38 +47139,38 @@ def test_approve_display_video360_advertiser_link_proposal_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.pb( - return_value - ) - ) + pb_return_value = resources.DataStream.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.approve_display_video360_advertiser_link_proposal(request) + response = client.create_data_stream(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_approve_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_create_data_stream_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.approve_display_video360_advertiser_link_proposal._get_unset_required_fields( - {} + unset_fields = transport.create_data_stream._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "dataStream", + ) + ) ) - assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_approve_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +def test_create_data_stream_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -39572,18 +47183,14 @@ def test_approve_display_video360_advertiser_link_proposal_rest_interceptors( ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_approve_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "post_create_data_stream" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_approve_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_data_stream" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest() - ) + pb_message = analytics_admin.CreateDataStreamRequest.pb( + analytics_admin.CreateDataStreamRequest() ) transcode.return_value = { "method": "post", @@ -39595,21 +47202,17 @@ def test_approve_display_video360_advertiser_link_proposal_rest_interceptors( req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.to_json( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() - ) + req.return_value._content = resources.DataStream.to_json(resources.DataStream()) - request = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.CreateDataStreamRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() - ) + post.return_value = resources.DataStream() - client.approve_display_video360_advertiser_link_proposal( + client.create_data_stream( request, metadata=[ ("key", "val"), @@ -39621,9 +47224,8 @@ def test_approve_display_video360_advertiser_link_proposal_rest_interceptors( post.assert_called_once() -def test_approve_display_video360_advertiser_link_proposal_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, +def test_create_data_stream_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateDataStreamRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39631,8 +47233,26 @@ def test_approve_display_video360_advertiser_link_proposal_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + request_init = {"parent": "properties/sample1"} + request_init["data_stream"] = { + "web_stream_data": { + "measurement_id": "measurement_id_value", + "firebase_app_id": "firebase_app_id_value", + "default_uri": "default_uri_value", + }, + "android_app_stream_data": { + "firebase_app_id": "firebase_app_id_value", + "package_name": "package_name_value", + }, + "ios_app_stream_data": { + "firebase_app_id": "firebase_app_id_value", + "bundle_id": "bundle_id_value", + }, + "name": "name_value", + "type_": 1, + "display_name": "display_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, } request = request_type(**request_init) @@ -39645,10 +47265,75 @@ def test_approve_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.approve_display_video360_advertiser_link_proposal(request) + client.create_data_stream(request) -def test_approve_display_video360_advertiser_link_proposal_rest_error(): +def test_create_data_stream_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = resources.DataStream() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "properties/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + data_stream=resources.DataStream( + web_stream_data=resources.DataStream.WebStreamData( + measurement_id="measurement_id_value" + ) + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.DataStream.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_data_stream(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{parent=properties/*}/dataStreams" % client.transport._host, + args[1], + ) + + +def test_create_data_stream_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_data_stream( + analytics_admin.CreateDataStreamRequest(), + parent="parent_value", + data_stream=resources.DataStream( + web_stream_data=resources.DataStream.WebStreamData( + measurement_id="measurement_id_value" + ) + ), + ) + + +def test_create_data_stream_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -39657,54 +47342,40 @@ def test_approve_display_video360_advertiser_link_proposal_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.DeleteDataStreamRequest, dict, ], ) -def test_cancel_display_video360_advertiser_link_proposal_rest(request_type): +def test_delete_data_stream_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" - } + request_init = {"name": "properties/sample1/dataStreams/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLinkProposal( - name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", - validation_email="validation_email_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.cancel_display_video360_advertiser_link_proposal(request) + response = client.delete_data_stream(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLinkProposal) - assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" - assert response.validation_email == "validation_email_value" + assert response is None -def test_cancel_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, +def test_delete_data_stream_rest_required_fields( + request_type=analytics_admin.DeleteDataStreamRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -39724,9 +47395,7 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).cancel_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).delete_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -39735,9 +47404,7 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).cancel_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).delete_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -39751,7 +47418,7 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DisplayVideo360AdvertiserLinkProposal() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -39763,45 +47430,36 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "delete", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.cancel_display_video360_advertiser_link_proposal(request) + response = client.delete_data_stream(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_cancel_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_delete_data_stream_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.cancel_display_video360_advertiser_link_proposal._get_unset_required_fields( - {} - ) + unset_fields = transport.delete_data_stream._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_cancel_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +def test_delete_data_stream_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -39814,18 +47472,11 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_interceptors( ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_cancel_display_video360_advertiser_link_proposal", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_cancel_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_data_stream" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = ( - analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest() - ) + pb_message = analytics_admin.DeleteDataStreamRequest.pb( + analytics_admin.DeleteDataStreamRequest() ) transcode.return_value = { "method": "post", @@ -39837,21 +47488,15 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_interceptors( req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - resources.DisplayVideo360AdvertiserLinkProposal.to_json( - resources.DisplayVideo360AdvertiserLinkProposal() - ) - ) - request = analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.DeleteDataStreamRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() - client.cancel_display_video360_advertiser_link_proposal( + client.delete_data_stream( request, metadata=[ ("key", "val"), @@ -39860,12 +47505,10 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_interceptors( ) pre.assert_called_once() - post.assert_called_once() -def test_cancel_display_video360_advertiser_link_proposal_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, +def test_delete_data_stream_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteDataStreamRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39873,9 +47516,7 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" - } + request_init = {"name": "properties/sample1/dataStreams/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -39887,10 +47528,64 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.cancel_display_video360_advertiser_link_proposal(request) + client.delete_data_stream(request) -def test_cancel_display_video360_advertiser_link_proposal_rest_error(): +def test_delete_data_stream_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "properties/sample1/dataStreams/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_data_stream(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=properties/*/dataStreams/*}" % client.transport._host, + args[1], + ) + + +def test_delete_data_stream_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_data_stream( + analytics_admin.DeleteDataStreamRequest(), + name="name_value", + ) + + +def test_delete_data_stream_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -39899,67 +47594,75 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateCustomDimensionRequest, + analytics_admin.UpdateDataStreamRequest, dict, ], ) -def test_create_custom_dimension_rest(request_type): +def test_update_data_stream_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["custom_dimension"] = { - "name": "name_value", - "parameter_name": "parameter_name_value", + request_init = {"data_stream": {"name": "properties/sample1/dataStreams/sample2"}} + request_init["data_stream"] = { + "web_stream_data": { + "measurement_id": "measurement_id_value", + "firebase_app_id": "firebase_app_id_value", + "default_uri": "default_uri_value", + }, + "android_app_stream_data": { + "firebase_app_id": "firebase_app_id_value", + "package_name": "package_name_value", + }, + "ios_app_stream_data": { + "firebase_app_id": "firebase_app_id_value", + "bundle_id": "bundle_id_value", + }, + "name": "properties/sample1/dataStreams/sample2", + "type_": 1, "display_name": "display_name_value", - "description": "description_value", - "scope": 1, - "disallow_ads_personalization": True, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomDimension( + return_value = resources.DataStream( name="name_value", - parameter_name="parameter_name_value", + type_=resources.DataStream.DataStreamType.WEB_DATA_STREAM, display_name="display_name_value", - description="description_value", - scope=resources.CustomDimension.DimensionScope.EVENT, - disallow_ads_personalization=True, + web_stream_data=resources.DataStream.WebStreamData( + measurement_id="measurement_id_value" + ), ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = resources.DataStream.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_custom_dimension(request) + response = client.update_data_stream(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomDimension) + assert isinstance(response, resources.DataStream) assert response.name == "name_value" - assert response.parameter_name == "parameter_name_value" + assert response.type_ == resources.DataStream.DataStreamType.WEB_DATA_STREAM 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_rest_required_fields( - request_type=analytics_admin.CreateCustomDimensionRequest, +def test_update_data_stream_rest_required_fields( + request_type=analytics_admin.UpdateDataStreamRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -39974,21 +47677,19 @@ def test_create_custom_dimension_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_custom_dimension._get_unset_required_fields(jsonified_request) + ).update_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_custom_dimension._get_unset_required_fields(jsonified_request) + ).update_data_stream._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39997,7 +47698,7 @@ def test_create_custom_dimension_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.CustomDimension() + return_value = resources.DataStream() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -40009,7 +47710,7 @@ def test_create_custom_dimension_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "patch", "query_params": pb_request, } transcode_result["body"] = pb_request @@ -40018,38 +47719,30 @@ def test_create_custom_dimension_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = resources.DataStream.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_custom_dimension(request) + response = client.update_data_stream(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_custom_dimension_rest_unset_required_fields(): +def test_update_data_stream_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_custom_dimension._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "customDimension", - ) - ) - ) + unset_fields = transport.update_data_stream._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_custom_dimension_rest_interceptors(null_interceptor): +def test_update_data_stream_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -40062,14 +47755,14 @@ def test_create_custom_dimension_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_data_stream" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_data_stream" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateCustomDimensionRequest.pb( - analytics_admin.CreateCustomDimensionRequest() + pb_message = analytics_admin.UpdateDataStreamRequest.pb( + analytics_admin.UpdateDataStreamRequest() ) transcode.return_value = { "method": "post", @@ -40081,19 +47774,17 @@ def test_create_custom_dimension_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.CustomDimension.to_json( - resources.CustomDimension() - ) + req.return_value._content = resources.DataStream.to_json(resources.DataStream()) - request = analytics_admin.CreateCustomDimensionRequest() + request = analytics_admin.UpdateDataStreamRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomDimension() + post.return_value = resources.DataStream() - client.create_custom_dimension( + client.update_data_stream( request, metadata=[ ("key", "val"), @@ -40105,8 +47796,8 @@ def test_create_custom_dimension_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_custom_dimension_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateCustomDimensionRequest +def test_update_data_stream_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateDataStreamRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40114,14 +47805,26 @@ def test_create_custom_dimension_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["custom_dimension"] = { - "name": "name_value", - "parameter_name": "parameter_name_value", + request_init = {"data_stream": {"name": "properties/sample1/dataStreams/sample2"}} + request_init["data_stream"] = { + "web_stream_data": { + "measurement_id": "measurement_id_value", + "firebase_app_id": "firebase_app_id_value", + "default_uri": "default_uri_value", + }, + "android_app_stream_data": { + "firebase_app_id": "firebase_app_id_value", + "package_name": "package_name_value", + }, + "ios_app_stream_data": { + "firebase_app_id": "firebase_app_id_value", + "bundle_id": "bundle_id_value", + }, + "name": "properties/sample1/dataStreams/sample2", + "type_": 1, "display_name": "display_name_value", - "description": "description_value", - "scope": 1, - "disallow_ads_personalization": True, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, } request = request_type(**request_init) @@ -40134,10 +47837,10 @@ def test_create_custom_dimension_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_custom_dimension(request) + client.update_data_stream(request) -def test_create_custom_dimension_rest_flattened(): +def test_update_data_stream_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -40146,40 +47849,46 @@ def test_create_custom_dimension_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomDimension() + return_value = resources.DataStream() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = { + "data_stream": {"name": "properties/sample1/dataStreams/sample2"} + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - custom_dimension=resources.CustomDimension(name="name_value"), + data_stream=resources.DataStream( + web_stream_data=resources.DataStream.WebStreamData( + measurement_id="measurement_id_value" + ) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = resources.DataStream.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_custom_dimension(**mock_args) + client.update_data_stream(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/customDimensions" + "%s/v1alpha/{data_stream.name=properties/*/dataStreams/*}" % client.transport._host, args[1], ) -def test_create_custom_dimension_rest_flattened_error(transport: str = "rest"): +def test_update_data_stream_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -40188,14 +47897,18 @@ def test_create_custom_dimension_rest_flattened_error(transport: str = "rest"): # 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"), + client.update_data_stream( + analytics_admin.UpdateDataStreamRequest(), + data_stream=resources.DataStream( + web_stream_data=resources.DataStream.WebStreamData( + measurement_id="measurement_id_value" + ) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_create_custom_dimension_rest_error(): +def test_update_data_stream_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -40204,68 +47917,49 @@ def test_create_custom_dimension_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateCustomDimensionRequest, + analytics_admin.ListDataStreamsRequest, dict, ], ) -def test_update_custom_dimension_rest(request_type): +def test_list_data_streams_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "custom_dimension": {"name": "properties/sample1/customDimensions/sample2"} - } - request_init["custom_dimension"] = { - "name": "properties/sample1/customDimensions/sample2", - "parameter_name": "parameter_name_value", - "display_name": "display_name_value", - "description": "description_value", - "scope": 1, - "disallow_ads_personalization": True, - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - 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, + return_value = analytics_admin.ListDataStreamsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = analytics_admin.ListDataStreamsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_custom_dimension(request) + response = client.list_data_streams(request) # 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 + assert isinstance(response, pagers.ListDataStreamsPager) + assert response.next_page_token == "next_page_token_value" -def test_update_custom_dimension_rest_required_fields( - request_type=analytics_admin.UpdateCustomDimensionRequest, +def test_list_data_streams_rest_required_fields( + request_type=analytics_admin.ListDataStreamsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -40280,19 +47974,28 @@ def test_update_custom_dimension_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_custom_dimension._get_unset_required_fields(jsonified_request) + ).list_data_streams._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_custom_dimension._get_unset_required_fields(jsonified_request) + ).list_data_streams._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40301,7 +48004,7 @@ def test_update_custom_dimension_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.CustomDimension() + return_value = analytics_admin.ListDataStreamsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -40313,39 +48016,46 @@ def test_update_custom_dimension_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = analytics_admin.ListDataStreamsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_custom_dimension(request) + response = client.list_data_streams(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_custom_dimension_rest_unset_required_fields(): +def test_list_data_streams_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_custom_dimension._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) + unset_fields = transport.list_data_streams._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_custom_dimension_rest_interceptors(null_interceptor): +def test_list_data_streams_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -40358,14 +48068,14 @@ def test_update_custom_dimension_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_data_streams" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_data_streams" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateCustomDimensionRequest.pb( - analytics_admin.UpdateCustomDimensionRequest() + pb_message = analytics_admin.ListDataStreamsRequest.pb( + analytics_admin.ListDataStreamsRequest() ) transcode.return_value = { "method": "post", @@ -40377,19 +48087,19 @@ def test_update_custom_dimension_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.CustomDimension.to_json( - resources.CustomDimension() + req.return_value._content = analytics_admin.ListDataStreamsResponse.to_json( + analytics_admin.ListDataStreamsResponse() ) - request = analytics_admin.UpdateCustomDimensionRequest() + request = analytics_admin.ListDataStreamsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomDimension() + post.return_value = analytics_admin.ListDataStreamsResponse() - client.update_custom_dimension( + client.list_data_streams( request, metadata=[ ("key", "val"), @@ -40401,8 +48111,8 @@ def test_update_custom_dimension_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_custom_dimension_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateCustomDimensionRequest +def test_list_data_streams_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListDataStreamsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40410,17 +48120,7 @@ def test_update_custom_dimension_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "custom_dimension": {"name": "properties/sample1/customDimensions/sample2"} - } - request_init["custom_dimension"] = { - "name": "properties/sample1/customDimensions/sample2", - "parameter_name": "parameter_name_value", - "display_name": "display_name_value", - "description": "description_value", - "scope": 1, - "disallow_ads_personalization": True, - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -40432,10 +48132,10 @@ def test_update_custom_dimension_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_custom_dimension(request) + client.list_data_streams(request) -def test_update_custom_dimension_rest_flattened(): +def test_list_data_streams_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -40444,42 +48144,38 @@ def test_update_custom_dimension_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomDimension() + return_value = analytics_admin.ListDataStreamsResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "custom_dimension": {"name": "properties/sample1/customDimensions/sample2"} - } + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - custom_dimension=resources.CustomDimension(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = analytics_admin.ListDataStreamsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_custom_dimension(**mock_args) + client.list_data_streams(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{custom_dimension.name=properties/*/customDimensions/*}" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/dataStreams" % client.transport._host, args[1], ) -def test_update_custom_dimension_rest_flattened_error(transport: str = "rest"): +def test_list_data_streams_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -40488,65 +48184,128 @@ def test_update_custom_dimension_rest_flattened_error(transport: str = "rest"): # 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"]), + client.list_data_streams( + analytics_admin.ListDataStreamsRequest(), + parent="parent_value", ) -def test_update_custom_dimension_rest_error(): +def test_list_data_streams_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListDataStreamsResponse( + data_streams=[ + resources.DataStream(), + resources.DataStream(), + resources.DataStream(), + ], + next_page_token="abc", + ), + analytics_admin.ListDataStreamsResponse( + data_streams=[], + next_page_token="def", + ), + analytics_admin.ListDataStreamsResponse( + data_streams=[ + resources.DataStream(), + ], + next_page_token="ghi", + ), + analytics_admin.ListDataStreamsResponse( + data_streams=[ + resources.DataStream(), + resources.DataStream(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListDataStreamsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1"} + + pager = client.list_data_streams(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.DataStream) for i in results) + + pages = list(client.list_data_streams(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListCustomDimensionsRequest, + analytics_admin.GetDataStreamRequest, dict, ], ) -def test_list_custom_dimensions_rest(request_type): +def test_get_data_stream_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/dataStreams/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListCustomDimensionsResponse( - next_page_token="next_page_token_value", + return_value = resources.DataStream( + name="name_value", + type_=resources.DataStream.DataStreamType.WEB_DATA_STREAM, + display_name="display_name_value", + web_stream_data=resources.DataStream.WebStreamData( + measurement_id="measurement_id_value" + ), ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListCustomDimensionsResponse.pb(return_value) + pb_return_value = resources.DataStream.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_custom_dimensions(request) + response = client.get_data_stream(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomDimensionsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.DataStream) + assert response.name == "name_value" + assert response.type_ == resources.DataStream.DataStreamType.WEB_DATA_STREAM + assert response.display_name == "display_name_value" -def test_list_custom_dimensions_rest_required_fields( - request_type=analytics_admin.ListCustomDimensionsRequest, +def test_get_data_stream_rest_required_fields( + request_type=analytics_admin.GetDataStreamRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -40561,28 +48320,21 @@ def test_list_custom_dimensions_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_custom_dimensions._get_unset_required_fields(jsonified_request) + ).get_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_custom_dimensions._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).get_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40591,7 +48343,7 @@ def test_list_custom_dimensions_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListCustomDimensionsResponse() + return_value = resources.DataStream() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -40611,40 +48363,30 @@ def test_list_custom_dimensions_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListCustomDimensionsResponse.pb( - return_value - ) + pb_return_value = resources.DataStream.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_custom_dimensions(request) + response = client.get_data_stream(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_custom_dimensions_rest_unset_required_fields(): +def test_get_data_stream_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_custom_dimensions._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.get_data_stream._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_custom_dimensions_rest_interceptors(null_interceptor): +def test_get_data_stream_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -40657,14 +48399,14 @@ def test_list_custom_dimensions_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_custom_dimensions" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_data_stream" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_custom_dimensions" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_data_stream" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListCustomDimensionsRequest.pb( - analytics_admin.ListCustomDimensionsRequest() + pb_message = analytics_admin.GetDataStreamRequest.pb( + analytics_admin.GetDataStreamRequest() ) transcode.return_value = { "method": "post", @@ -40676,21 +48418,17 @@ def test_list_custom_dimensions_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.ListCustomDimensionsResponse.to_json( - analytics_admin.ListCustomDimensionsResponse() - ) - ) + req.return_value._content = resources.DataStream.to_json(resources.DataStream()) - request = analytics_admin.ListCustomDimensionsRequest() + request = analytics_admin.GetDataStreamRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListCustomDimensionsResponse() + post.return_value = resources.DataStream() - client.list_custom_dimensions( + client.get_data_stream( request, metadata=[ ("key", "val"), @@ -40702,8 +48440,8 @@ def test_list_custom_dimensions_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_custom_dimensions_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListCustomDimensionsRequest +def test_get_data_stream_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetDataStreamRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40711,7 +48449,7 @@ def test_list_custom_dimensions_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/dataStreams/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -40723,10 +48461,10 @@ def test_list_custom_dimensions_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_custom_dimensions(request) + client.get_data_stream(request) -def test_list_custom_dimensions_rest_flattened(): +def test_get_data_stream_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -40735,39 +48473,38 @@ def test_list_custom_dimensions_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListCustomDimensionsResponse() + return_value = resources.DataStream() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "properties/sample1/dataStreams/sample2"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListCustomDimensionsResponse.pb(return_value) + pb_return_value = resources.DataStream.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_custom_dimensions(**mock_args) + client.get_data_stream(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/customDimensions" - % client.transport._host, + "%s/v1alpha/{name=properties/*/dataStreams/*}" % client.transport._host, args[1], ) -def test_list_custom_dimensions_rest_flattened_error(transport: str = "rest"): +def test_get_data_stream_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -40776,112 +48513,72 @@ def test_list_custom_dimensions_rest_flattened_error(transport: str = "rest"): # 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", + client.get_data_stream( + analytics_admin.GetDataStreamRequest(), + name="name_value", ) -def test_list_custom_dimensions_rest_pager(transport: str = "rest"): +def test_get_data_stream_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListCustomDimensionsResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1"} - - pager = client.list_custom_dimensions(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.CustomDimension) for i in results) - - pages = list(client.list_custom_dimensions(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.ArchiveCustomDimensionRequest, + analytics_admin.GetAudienceRequest, dict, ], ) -def test_archive_custom_dimension_rest(request_type): +def test_get_audience_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customDimensions/sample2"} + request_init = {"name": "properties/sample1/audiences/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = audience.Audience( + name="name_value", + display_name="display_name_value", + description="description_value", + membership_duration_days=2561, + ads_personalization_enabled=True, + exclusion_duration_mode=audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = audience.Audience.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.archive_custom_dimension(request) + response = client.get_audience(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, audience.Audience) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.membership_duration_days == 2561 + assert response.ads_personalization_enabled is True + assert ( + response.exclusion_duration_mode + == audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY + ) -def test_archive_custom_dimension_rest_required_fields( - request_type=analytics_admin.ArchiveCustomDimensionRequest, +def test_get_audience_rest_required_fields( + request_type=analytics_admin.GetAudienceRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -40901,7 +48598,7 @@ def test_archive_custom_dimension_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).archive_custom_dimension._get_unset_required_fields(jsonified_request) + ).get_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -40910,7 +48607,7 @@ def test_archive_custom_dimension_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).archive_custom_dimension._get_unset_required_fields(jsonified_request) + ).get_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -40924,7 +48621,7 @@ def test_archive_custom_dimension_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = audience.Audience() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -40936,37 +48633,38 @@ def test_archive_custom_dimension_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = audience.Audience.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.archive_custom_dimension(request) + response = client.get_audience(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_archive_custom_dimension_rest_unset_required_fields(): +def test_get_audience_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.archive_custom_dimension._get_unset_required_fields({}) + unset_fields = transport.get_audience._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_archive_custom_dimension_rest_interceptors(null_interceptor): +def test_get_audience_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -40979,11 +48677,14 @@ def test_archive_custom_dimension_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_archive_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_audience" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_audience" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.ArchiveCustomDimensionRequest.pb( - analytics_admin.ArchiveCustomDimensionRequest() + post.assert_not_called() + pb_message = analytics_admin.GetAudienceRequest.pb( + analytics_admin.GetAudienceRequest() ) transcode.return_value = { "method": "post", @@ -40995,15 +48696,17 @@ def test_archive_custom_dimension_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = audience.Audience.to_json(audience.Audience()) - request = analytics_admin.ArchiveCustomDimensionRequest() + request = analytics_admin.GetAudienceRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = audience.Audience() - client.archive_custom_dimension( + client.get_audience( request, metadata=[ ("key", "val"), @@ -41012,10 +48715,11 @@ def test_archive_custom_dimension_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_archive_custom_dimension_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ArchiveCustomDimensionRequest +def test_get_audience_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetAudienceRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41023,7 +48727,7 @@ def test_archive_custom_dimension_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customDimensions/sample2"} + request_init = {"name": "properties/sample1/audiences/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -41035,10 +48739,10 @@ def test_archive_custom_dimension_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.archive_custom_dimension(request) + client.get_audience(request) -def test_archive_custom_dimension_rest_flattened(): +def test_get_audience_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41047,10 +48751,10 @@ def test_archive_custom_dimension_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = audience.Audience() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/customDimensions/sample2"} + sample_request = {"name": "properties/sample1/audiences/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -41061,24 +48765,24 @@ def test_archive_custom_dimension_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = audience.Audience.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.archive_custom_dimension(**mock_args) + client.get_audience(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/customDimensions/*}:archive" - % client.transport._host, + "%s/v1alpha/{name=properties/*/audiences/*}" % client.transport._host, args[1], ) -def test_archive_custom_dimension_rest_flattened_error(transport: str = "rest"): +def test_get_audience_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -41087,13 +48791,13 @@ def test_archive_custom_dimension_rest_flattened_error(transport: str = "rest"): # 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(), + client.get_audience( + analytics_admin.GetAudienceRequest(), name="name_value", ) -def test_archive_custom_dimension_rest_error(): +def test_get_audience_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -41102,59 +48806,49 @@ def test_archive_custom_dimension_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetCustomDimensionRequest, + analytics_admin.ListAudiencesRequest, dict, ], ) -def test_get_custom_dimension_rest(request_type): +def test_list_audiences_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customDimensions/sample2"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - 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, + return_value = analytics_admin.ListAudiencesResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = analytics_admin.ListAudiencesResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_custom_dimension(request) + response = client.list_audiences(request) # 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 + assert isinstance(response, pagers.ListAudiencesPager) + assert response.next_page_token == "next_page_token_value" -def test_get_custom_dimension_rest_required_fields( - request_type=analytics_admin.GetCustomDimensionRequest, +def test_list_audiences_rest_required_fields( + request_type=analytics_admin.ListAudiencesRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -41169,21 +48863,28 @@ def test_get_custom_dimension_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_custom_dimension._get_unset_required_fields(jsonified_request) + ).list_audiences._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_custom_dimension._get_unset_required_fields(jsonified_request) + ).list_audiences._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41192,7 +48893,7 @@ def test_get_custom_dimension_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.CustomDimension() + return_value = analytics_admin.ListAudiencesResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -41212,30 +48913,38 @@ def test_get_custom_dimension_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = analytics_admin.ListAudiencesResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_custom_dimension(request) + response = client.list_audiences(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_custom_dimension_rest_unset_required_fields(): +def test_list_audiences_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_custom_dimension._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.list_audiences._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_custom_dimension_rest_interceptors(null_interceptor): +def test_list_audiences_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -41248,14 +48957,14 @@ def test_get_custom_dimension_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_audiences" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_audiences" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetCustomDimensionRequest.pb( - analytics_admin.GetCustomDimensionRequest() + pb_message = analytics_admin.ListAudiencesRequest.pb( + analytics_admin.ListAudiencesRequest() ) transcode.return_value = { "method": "post", @@ -41267,19 +48976,19 @@ def test_get_custom_dimension_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.CustomDimension.to_json( - resources.CustomDimension() + req.return_value._content = analytics_admin.ListAudiencesResponse.to_json( + analytics_admin.ListAudiencesResponse() ) - request = analytics_admin.GetCustomDimensionRequest() + request = analytics_admin.ListAudiencesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomDimension() + post.return_value = analytics_admin.ListAudiencesResponse() - client.get_custom_dimension( + client.list_audiences( request, metadata=[ ("key", "val"), @@ -41291,8 +49000,8 @@ def test_get_custom_dimension_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_custom_dimension_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetCustomDimensionRequest +def test_list_audiences_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListAudiencesRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41300,7 +49009,7 @@ def test_get_custom_dimension_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customDimensions/sample2"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -41312,10 +49021,10 @@ def test_get_custom_dimension_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_custom_dimension(request) + client.list_audiences(request) -def test_get_custom_dimension_rest_flattened(): +def test_list_audiences_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41324,39 +49033,38 @@ def test_get_custom_dimension_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomDimension() + return_value = analytics_admin.ListAudiencesResponse() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/customDimensions/sample2"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.pb(return_value) + pb_return_value = analytics_admin.ListAudiencesResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_custom_dimension(**mock_args) + client.list_audiences(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/customDimensions/*}" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/audiences" % client.transport._host, args[1], ) -def test_get_custom_dimension_rest_flattened_error(transport: str = "rest"): +def test_list_audiences_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -41365,26 +49073,83 @@ def test_get_custom_dimension_rest_flattened_error(transport: str = "rest"): # 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", + client.list_audiences( + analytics_admin.ListAudiencesRequest(), + parent="parent_value", ) -def test_get_custom_dimension_rest_error(): +def test_list_audiences_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListAudiencesResponse( + audiences=[ + audience.Audience(), + audience.Audience(), + audience.Audience(), + ], + next_page_token="abc", + ), + analytics_admin.ListAudiencesResponse( + audiences=[], + next_page_token="def", + ), + analytics_admin.ListAudiencesResponse( + audiences=[ + audience.Audience(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAudiencesResponse( + audiences=[ + audience.Audience(), + audience.Audience(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListAudiencesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1"} + + pager = client.list_audiences(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, audience.Audience) for i in results) + + pages = list(client.list_audiences(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateCustomMetricRequest, + analytics_admin.CreateAudienceRequest, dict, ], ) -def test_create_custom_metric_rest(request_type): +def test_create_audience_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41392,57 +49157,105 @@ def test_create_custom_metric_rest(request_type): # send a request that will satisfy transcoding request_init = {"parent": "properties/sample1"} - request_init["custom_metric"] = { + request_init["audience"] = { "name": "name_value", - "parameter_name": "parameter_name_value", "display_name": "display_name_value", "description": "description_value", - "measurement_unit": 1, - "scope": 1, - "restricted_metric_type": [1], + "membership_duration_days": 2561, + "ads_personalization_enabled": True, + "event_trigger": {"event_name": "event_name_value", "log_condition": 1}, + "exclusion_duration_mode": 1, + "filter_clauses": [ + { + "simple_filter": { + "scope": 1, + "filter_expression": { + "and_group": {"filter_expressions": {}}, + "or_group": {}, + "not_expression": {}, + "dimension_or_metric_filter": { + "string_filter": { + "match_type": 1, + "value": "value_value", + "case_sensitive": True, + }, + "in_list_filter": { + "values": ["values_value1", "values_value2"], + "case_sensitive": True, + }, + "numeric_filter": { + "operation": 1, + "value": { + "int64_value": 1073, + "double_value": 0.12710000000000002, + }, + }, + "between_filter": {"from_value": {}, "to_value": {}}, + "field_name": "field_name_value", + "at_any_point_in_time": True, + "in_any_n_day_period": 1994, + }, + "event_filter": { + "event_name": "event_name_value", + "event_parameter_filter_expression": {}, + }, + }, + }, + "sequence_filter": { + "scope": 1, + "sequence_maximum_duration": {"seconds": 751, "nanos": 543}, + "sequence_steps": [ + { + "scope": 1, + "immediately_follows": True, + "constraint_duration": {}, + "filter_expression": {}, + } + ], + }, + "clause_type": 1, + } + ], } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomMetric( + return_value = gaa_audience.Audience( 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, - restricted_metric_type=[ - resources.CustomMetric.RestrictedMetricType.COST_DATA - ], + membership_duration_days=2561, + ads_personalization_enabled=True, + exclusion_duration_mode=gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = gaa_audience.Audience.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_custom_metric(request) + response = client.create_audience(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) + assert isinstance(response, gaa_audience.Audience) 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 - assert response.restricted_metric_type == [ - resources.CustomMetric.RestrictedMetricType.COST_DATA - ] + assert response.membership_duration_days == 2561 + assert response.ads_personalization_enabled is True + assert ( + response.exclusion_duration_mode + == gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY + ) -def test_create_custom_metric_rest_required_fields( - request_type=analytics_admin.CreateCustomMetricRequest, +def test_create_audience_rest_required_fields( + request_type=analytics_admin.CreateAudienceRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -41462,7 +49275,7 @@ def test_create_custom_metric_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_custom_metric._get_unset_required_fields(jsonified_request) + ).create_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -41471,7 +49284,7 @@ def test_create_custom_metric_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_custom_metric._get_unset_required_fields(jsonified_request) + ).create_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -41485,7 +49298,7 @@ def test_create_custom_metric_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.CustomMetric() + return_value = gaa_audience.Audience() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -41506,38 +49319,38 @@ def test_create_custom_metric_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = gaa_audience.Audience.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_custom_metric(request) + response = client.create_audience(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_custom_metric_rest_unset_required_fields(): +def test_create_audience_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_custom_metric._get_unset_required_fields({}) + unset_fields = transport.create_audience._get_unset_required_fields({}) assert set(unset_fields) == ( set(()) & set( ( "parent", - "customMetric", + "audience", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_custom_metric_rest_interceptors(null_interceptor): +def test_create_audience_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -41550,14 +49363,14 @@ def test_create_custom_metric_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_audience" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_audience" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateCustomMetricRequest.pb( - analytics_admin.CreateCustomMetricRequest() + pb_message = analytics_admin.CreateAudienceRequest.pb( + analytics_admin.CreateAudienceRequest() ) transcode.return_value = { "method": "post", @@ -41569,19 +49382,19 @@ def test_create_custom_metric_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.CustomMetric.to_json( - resources.CustomMetric() + req.return_value._content = gaa_audience.Audience.to_json( + gaa_audience.Audience() ) - request = analytics_admin.CreateCustomMetricRequest() + request = analytics_admin.CreateAudienceRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomMetric() + post.return_value = gaa_audience.Audience() - client.create_custom_metric( + client.create_audience( request, metadata=[ ("key", "val"), @@ -41593,8 +49406,8 @@ def test_create_custom_metric_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_custom_metric_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateCustomMetricRequest +def test_create_audience_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateAudienceRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41603,14 +49416,65 @@ def test_create_custom_metric_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "properties/sample1"} - request_init["custom_metric"] = { + request_init["audience"] = { "name": "name_value", - "parameter_name": "parameter_name_value", "display_name": "display_name_value", "description": "description_value", - "measurement_unit": 1, - "scope": 1, - "restricted_metric_type": [1], + "membership_duration_days": 2561, + "ads_personalization_enabled": True, + "event_trigger": {"event_name": "event_name_value", "log_condition": 1}, + "exclusion_duration_mode": 1, + "filter_clauses": [ + { + "simple_filter": { + "scope": 1, + "filter_expression": { + "and_group": {"filter_expressions": {}}, + "or_group": {}, + "not_expression": {}, + "dimension_or_metric_filter": { + "string_filter": { + "match_type": 1, + "value": "value_value", + "case_sensitive": True, + }, + "in_list_filter": { + "values": ["values_value1", "values_value2"], + "case_sensitive": True, + }, + "numeric_filter": { + "operation": 1, + "value": { + "int64_value": 1073, + "double_value": 0.12710000000000002, + }, + }, + "between_filter": {"from_value": {}, "to_value": {}}, + "field_name": "field_name_value", + "at_any_point_in_time": True, + "in_any_n_day_period": 1994, + }, + "event_filter": { + "event_name": "event_name_value", + "event_parameter_filter_expression": {}, + }, + }, + }, + "sequence_filter": { + "scope": 1, + "sequence_maximum_duration": {"seconds": 751, "nanos": 543}, + "sequence_steps": [ + { + "scope": 1, + "immediately_follows": True, + "constraint_duration": {}, + "filter_expression": {}, + } + ], + }, + "clause_type": 1, + } + ], } request = request_type(**request_init) @@ -41623,10 +49487,10 @@ def test_create_custom_metric_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_custom_metric(request) + client.create_audience(request) -def test_create_custom_metric_rest_flattened(): +def test_create_audience_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41635,7 +49499,7 @@ def test_create_custom_metric_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomMetric() + return_value = gaa_audience.Audience() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -41643,31 +49507,31 @@ def test_create_custom_metric_rest_flattened(): # get truthy value for each flattened field mock_args = dict( parent="parent_value", - custom_metric=resources.CustomMetric(name="name_value"), + audience=gaa_audience.Audience(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = gaa_audience.Audience.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_custom_metric(**mock_args) + client.create_audience(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/customMetrics" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/audiences" % client.transport._host, args[1], ) -def test_create_custom_metric_rest_flattened_error(transport: str = "rest"): +def test_create_audience_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -41676,14 +49540,14 @@ def test_create_custom_metric_rest_flattened_error(transport: str = "rest"): # 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(), + client.create_audience( + analytics_admin.CreateAudienceRequest(), parent="parent_value", - custom_metric=resources.CustomMetric(name="name_value"), + audience=gaa_audience.Audience(name="name_value"), ) -def test_create_custom_metric_rest_error(): +def test_create_audience_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -41692,71 +49556,117 @@ def test_create_custom_metric_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateCustomMetricRequest, + analytics_admin.UpdateAudienceRequest, dict, ], ) -def test_update_custom_metric_rest(request_type): +def test_update_audience_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} - } - request_init["custom_metric"] = { - "name": "properties/sample1/customMetrics/sample2", - "parameter_name": "parameter_name_value", + request_init = {"audience": {"name": "properties/sample1/audiences/sample2"}} + request_init["audience"] = { + "name": "properties/sample1/audiences/sample2", "display_name": "display_name_value", "description": "description_value", - "measurement_unit": 1, - "scope": 1, - "restricted_metric_type": [1], + "membership_duration_days": 2561, + "ads_personalization_enabled": True, + "event_trigger": {"event_name": "event_name_value", "log_condition": 1}, + "exclusion_duration_mode": 1, + "filter_clauses": [ + { + "simple_filter": { + "scope": 1, + "filter_expression": { + "and_group": {"filter_expressions": {}}, + "or_group": {}, + "not_expression": {}, + "dimension_or_metric_filter": { + "string_filter": { + "match_type": 1, + "value": "value_value", + "case_sensitive": True, + }, + "in_list_filter": { + "values": ["values_value1", "values_value2"], + "case_sensitive": True, + }, + "numeric_filter": { + "operation": 1, + "value": { + "int64_value": 1073, + "double_value": 0.12710000000000002, + }, + }, + "between_filter": {"from_value": {}, "to_value": {}}, + "field_name": "field_name_value", + "at_any_point_in_time": True, + "in_any_n_day_period": 1994, + }, + "event_filter": { + "event_name": "event_name_value", + "event_parameter_filter_expression": {}, + }, + }, + }, + "sequence_filter": { + "scope": 1, + "sequence_maximum_duration": {"seconds": 751, "nanos": 543}, + "sequence_steps": [ + { + "scope": 1, + "immediately_follows": True, + "constraint_duration": {}, + "filter_expression": {}, + } + ], + }, + "clause_type": 1, + } + ], } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomMetric( + return_value = gaa_audience.Audience( 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, - restricted_metric_type=[ - resources.CustomMetric.RestrictedMetricType.COST_DATA - ], + membership_duration_days=2561, + ads_personalization_enabled=True, + exclusion_duration_mode=gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = gaa_audience.Audience.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_custom_metric(request) + response = client.update_audience(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) + assert isinstance(response, gaa_audience.Audience) 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 - assert response.restricted_metric_type == [ - resources.CustomMetric.RestrictedMetricType.COST_DATA - ] + assert response.membership_duration_days == 2561 + assert response.ads_personalization_enabled is True + assert ( + response.exclusion_duration_mode + == gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY + ) -def test_update_custom_metric_rest_required_fields( - request_type=analytics_admin.UpdateCustomMetricRequest, +def test_update_audience_rest_required_fields( + request_type=analytics_admin.UpdateAudienceRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -41775,14 +49685,14 @@ def test_update_custom_metric_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_custom_metric._get_unset_required_fields(jsonified_request) + ).update_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_custom_metric._get_unset_required_fields(jsonified_request) + ).update_audience._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) @@ -41796,7 +49706,7 @@ def test_update_custom_metric_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.CustomMetric() + return_value = gaa_audience.Audience() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -41817,30 +49727,38 @@ def test_update_custom_metric_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = gaa_audience.Audience.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_custom_metric(request) + response = client.update_audience(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_custom_metric_rest_unset_required_fields(): +def test_update_audience_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_custom_metric._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) + unset_fields = transport.update_audience._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "audience", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_custom_metric_rest_interceptors(null_interceptor): +def test_update_audience_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -41853,14 +49771,14 @@ def test_update_custom_metric_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_audience" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_audience" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateCustomMetricRequest.pb( - analytics_admin.UpdateCustomMetricRequest() + pb_message = analytics_admin.UpdateAudienceRequest.pb( + analytics_admin.UpdateAudienceRequest() ) transcode.return_value = { "method": "post", @@ -41872,19 +49790,19 @@ def test_update_custom_metric_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.CustomMetric.to_json( - resources.CustomMetric() + req.return_value._content = gaa_audience.Audience.to_json( + gaa_audience.Audience() ) - request = analytics_admin.UpdateCustomMetricRequest() + request = analytics_admin.UpdateAudienceRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomMetric() + post.return_value = gaa_audience.Audience() - client.update_custom_metric( + client.update_audience( request, metadata=[ ("key", "val"), @@ -41896,8 +49814,8 @@ def test_update_custom_metric_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_custom_metric_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateCustomMetricRequest +def test_update_audience_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateAudienceRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41905,17 +49823,66 @@ def test_update_custom_metric_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} - } - request_init["custom_metric"] = { - "name": "properties/sample1/customMetrics/sample2", - "parameter_name": "parameter_name_value", + request_init = {"audience": {"name": "properties/sample1/audiences/sample2"}} + request_init["audience"] = { + "name": "properties/sample1/audiences/sample2", "display_name": "display_name_value", "description": "description_value", - "measurement_unit": 1, - "scope": 1, - "restricted_metric_type": [1], + "membership_duration_days": 2561, + "ads_personalization_enabled": True, + "event_trigger": {"event_name": "event_name_value", "log_condition": 1}, + "exclusion_duration_mode": 1, + "filter_clauses": [ + { + "simple_filter": { + "scope": 1, + "filter_expression": { + "and_group": {"filter_expressions": {}}, + "or_group": {}, + "not_expression": {}, + "dimension_or_metric_filter": { + "string_filter": { + "match_type": 1, + "value": "value_value", + "case_sensitive": True, + }, + "in_list_filter": { + "values": ["values_value1", "values_value2"], + "case_sensitive": True, + }, + "numeric_filter": { + "operation": 1, + "value": { + "int64_value": 1073, + "double_value": 0.12710000000000002, + }, + }, + "between_filter": {"from_value": {}, "to_value": {}}, + "field_name": "field_name_value", + "at_any_point_in_time": True, + "in_any_n_day_period": 1994, + }, + "event_filter": { + "event_name": "event_name_value", + "event_parameter_filter_expression": {}, + }, + }, + }, + "sequence_filter": { + "scope": 1, + "sequence_maximum_duration": {"seconds": 751, "nanos": 543}, + "sequence_steps": [ + { + "scope": 1, + "immediately_follows": True, + "constraint_duration": {}, + "filter_expression": {}, + } + ], + }, + "clause_type": 1, + } + ], } request = request_type(**request_init) @@ -41928,10 +49895,10 @@ def test_update_custom_metric_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_custom_metric(request) + client.update_audience(request) -def test_update_custom_metric_rest_flattened(): +def test_update_audience_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41940,16 +49907,14 @@ def test_update_custom_metric_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomMetric() + return_value = gaa_audience.Audience() # get arguments that satisfy an http rule for this method - sample_request = { - "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} - } + sample_request = {"audience": {"name": "properties/sample1/audiences/sample2"}} # get truthy value for each flattened field mock_args = dict( - custom_metric=resources.CustomMetric(name="name_value"), + audience=gaa_audience.Audience(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) @@ -41957,25 +49922,25 @@ def test_update_custom_metric_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = gaa_audience.Audience.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_custom_metric(**mock_args) + client.update_audience(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{custom_metric.name=properties/*/customMetrics/*}" + "%s/v1alpha/{audience.name=properties/*/audiences/*}" % client.transport._host, args[1], ) -def test_update_custom_metric_rest_flattened_error(transport: str = "rest"): +def test_update_audience_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -41984,14 +49949,14 @@ def test_update_custom_metric_rest_flattened_error(transport: str = "rest"): # 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"), + client.update_audience( + analytics_admin.UpdateAudienceRequest(), + audience=gaa_audience.Audience(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_update_custom_metric_rest_error(): +def test_update_audience_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -42000,49 +49965,45 @@ def test_update_custom_metric_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListCustomMetricsRequest, + analytics_admin.ArchiveAudienceRequest, dict, ], ) -def test_list_custom_metrics_rest(request_type): +def test_archive_audience_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/audiences/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListCustomMetricsResponse( - next_page_token="next_page_token_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListCustomMetricsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_custom_metrics(request) + response = client.archive_audience(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomMetricsPager) - assert response.next_page_token == "next_page_token_value" + assert response is None -def test_list_custom_metrics_rest_required_fields( - request_type=analytics_admin.ListCustomMetricsRequest, +def test_archive_audience_rest_required_fields( + request_type=analytics_admin.ArchiveAudienceRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -42057,28 +50018,21 @@ def test_list_custom_metrics_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_custom_metrics._get_unset_required_fields(jsonified_request) + ).archive_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_custom_metrics._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).archive_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42087,7 +50041,7 @@ def test_list_custom_metrics_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListCustomMetricsResponse() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -42099,46 +50053,37 @@ def test_list_custom_metrics_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = analytics_admin.ListCustomMetricsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_custom_metrics(request) + response = client.archive_audience(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_custom_metrics_rest_unset_required_fields(): +def test_archive_audience_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_custom_metrics._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.archive_audience._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_custom_metrics_rest_interceptors(null_interceptor): +def test_archive_audience_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -42151,14 +50096,11 @@ def test_list_custom_metrics_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_custom_metrics" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_custom_metrics" + transports.AnalyticsAdminServiceRestInterceptor, "pre_archive_audience" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.ListCustomMetricsRequest.pb( - analytics_admin.ListCustomMetricsRequest() + pb_message = analytics_admin.ArchiveAudienceRequest.pb( + analytics_admin.ArchiveAudienceRequest() ) transcode.return_value = { "method": "post", @@ -42170,19 +50112,15 @@ def test_list_custom_metrics_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ListCustomMetricsResponse.to_json( - analytics_admin.ListCustomMetricsResponse() - ) - request = analytics_admin.ListCustomMetricsRequest() + request = analytics_admin.ArchiveAudienceRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListCustomMetricsResponse() - client.list_custom_metrics( + client.archive_audience( request, metadata=[ ("key", "val"), @@ -42191,11 +50129,10 @@ def test_list_custom_metrics_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_list_custom_metrics_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListCustomMetricsRequest +def test_archive_audience_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ArchiveAudienceRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42203,7 +50140,7 @@ def test_list_custom_metrics_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/audiences/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -42215,164 +50152,60 @@ def test_list_custom_metrics_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_custom_metrics(request) - - -def test_list_custom_metrics_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListCustomMetricsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = analytics_admin.ListCustomMetricsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_custom_metrics(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/customMetrics" % client.transport._host, - args[1], - ) - - -def test_list_custom_metrics_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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", - ) + client.archive_audience(request) -def test_list_custom_metrics_rest_pager(transport: str = "rest"): +def test_archive_audience_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListCustomMetricsResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1"} - - pager = client.list_custom_metrics(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.CustomMetric) for i in results) - - pages = list(client.list_custom_metrics(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.ArchiveCustomMetricRequest, + analytics_admin.GetSearchAds360LinkRequest, dict, ], ) -def test_archive_custom_metric_rest(request_type): +def test_get_search_ads360_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customMetrics/sample2"} + request_init = {"name": "properties/sample1/searchAds360Links/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.SearchAds360Link( + name="name_value", + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.SearchAds360Link.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.archive_custom_metric(request) + response = client.get_search_ads360_link(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.SearchAds360Link) + assert response.name == "name_value" + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" -def test_archive_custom_metric_rest_required_fields( - request_type=analytics_admin.ArchiveCustomMetricRequest, +def test_get_search_ads360_link_rest_required_fields( + request_type=analytics_admin.GetSearchAds360LinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -42392,7 +50225,7 @@ def test_archive_custom_metric_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).archive_custom_metric._get_unset_required_fields(jsonified_request) + ).get_search_ads360_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -42401,7 +50234,7 @@ def test_archive_custom_metric_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).archive_custom_metric._get_unset_required_fields(jsonified_request) + ).get_search_ads360_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -42415,7 +50248,7 @@ def test_archive_custom_metric_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.SearchAds360Link() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -42427,37 +50260,38 @@ def test_archive_custom_metric_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = resources.SearchAds360Link.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.archive_custom_metric(request) + response = client.get_search_ads360_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_archive_custom_metric_rest_unset_required_fields(): +def test_get_search_ads360_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.archive_custom_metric._get_unset_required_fields({}) + unset_fields = transport.get_search_ads360_link._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_archive_custom_metric_rest_interceptors(null_interceptor): +def test_get_search_ads360_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -42470,11 +50304,14 @@ def test_archive_custom_metric_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_archive_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_search_ads360_link" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_search_ads360_link" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.ArchiveCustomMetricRequest.pb( - analytics_admin.ArchiveCustomMetricRequest() + post.assert_not_called() + pb_message = analytics_admin.GetSearchAds360LinkRequest.pb( + analytics_admin.GetSearchAds360LinkRequest() ) transcode.return_value = { "method": "post", @@ -42486,15 +50323,19 @@ def test_archive_custom_metric_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.SearchAds360Link.to_json( + resources.SearchAds360Link() + ) - request = analytics_admin.ArchiveCustomMetricRequest() + request = analytics_admin.GetSearchAds360LinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.SearchAds360Link() - client.archive_custom_metric( + client.get_search_ads360_link( request, metadata=[ ("key", "val"), @@ -42503,10 +50344,11 @@ def test_archive_custom_metric_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_archive_custom_metric_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ArchiveCustomMetricRequest +def test_get_search_ads360_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetSearchAds360LinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42514,7 +50356,7 @@ def test_archive_custom_metric_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customMetrics/sample2"} + request_init = {"name": "properties/sample1/searchAds360Links/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -42526,10 +50368,10 @@ def test_archive_custom_metric_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.archive_custom_metric(request) + client.get_search_ads360_link(request) -def test_archive_custom_metric_rest_flattened(): +def test_get_search_ads360_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -42538,10 +50380,10 @@ def test_archive_custom_metric_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.SearchAds360Link() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/customMetrics/sample2"} + sample_request = {"name": "properties/sample1/searchAds360Links/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -42552,24 +50394,25 @@ def test_archive_custom_metric_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.SearchAds360Link.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.archive_custom_metric(**mock_args) + client.get_search_ads360_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/customMetrics/*}:archive" + "%s/v1alpha/{name=properties/*/searchAds360Links/*}" % client.transport._host, args[1], ) -def test_archive_custom_metric_rest_flattened_error(transport: str = "rest"): +def test_get_search_ads360_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -42578,13 +50421,13 @@ def test_archive_custom_metric_rest_flattened_error(transport: str = "rest"): # 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(), + client.get_search_ads360_link( + analytics_admin.GetSearchAds360LinkRequest(), name="name_value", ) -def test_archive_custom_metric_rest_error(): +def test_get_search_ads360_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -42593,65 +50436,49 @@ def test_archive_custom_metric_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetCustomMetricRequest, + analytics_admin.ListSearchAds360LinksRequest, dict, ], ) -def test_get_custom_metric_rest(request_type): +def test_list_search_ads360_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customMetrics/sample2"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - 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, - restricted_metric_type=[ - resources.CustomMetric.RestrictedMetricType.COST_DATA - ], + return_value = analytics_admin.ListSearchAds360LinksResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = analytics_admin.ListSearchAds360LinksResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_custom_metric(request) + response = client.list_search_ads360_links(request) # 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 - assert response.restricted_metric_type == [ - resources.CustomMetric.RestrictedMetricType.COST_DATA - ] + assert isinstance(response, pagers.ListSearchAds360LinksPager) + assert response.next_page_token == "next_page_token_value" -def test_get_custom_metric_rest_required_fields( - request_type=analytics_admin.GetCustomMetricRequest, +def test_list_search_ads360_links_rest_required_fields( + request_type=analytics_admin.ListSearchAds360LinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -42666,21 +50493,28 @@ def test_get_custom_metric_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_custom_metric._get_unset_required_fields(jsonified_request) + ).list_search_ads360_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_custom_metric._get_unset_required_fields(jsonified_request) + ).list_search_ads360_links._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42689,7 +50523,7 @@ def test_get_custom_metric_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.CustomMetric() + return_value = analytics_admin.ListSearchAds360LinksResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -42709,30 +50543,40 @@ def test_get_custom_metric_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = analytics_admin.ListSearchAds360LinksResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_custom_metric(request) + response = client.list_search_ads360_links(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_custom_metric_rest_unset_required_fields(): +def test_list_search_ads360_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_custom_metric._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.list_search_ads360_links._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_custom_metric_rest_interceptors(null_interceptor): +def test_list_search_ads360_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -42745,14 +50589,14 @@ def test_get_custom_metric_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_search_ads360_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_search_ads360_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetCustomMetricRequest.pb( - analytics_admin.GetCustomMetricRequest() + pb_message = analytics_admin.ListSearchAds360LinksRequest.pb( + analytics_admin.ListSearchAds360LinksRequest() ) transcode.return_value = { "method": "post", @@ -42764,19 +50608,21 @@ def test_get_custom_metric_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.CustomMetric.to_json( - resources.CustomMetric() + req.return_value._content = ( + analytics_admin.ListSearchAds360LinksResponse.to_json( + analytics_admin.ListSearchAds360LinksResponse() + ) ) - request = analytics_admin.GetCustomMetricRequest() + request = analytics_admin.ListSearchAds360LinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomMetric() + post.return_value = analytics_admin.ListSearchAds360LinksResponse() - client.get_custom_metric( + client.list_search_ads360_links( request, metadata=[ ("key", "val"), @@ -42788,8 +50634,8 @@ def test_get_custom_metric_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_custom_metric_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetCustomMetricRequest +def test_list_search_ads360_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListSearchAds360LinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42797,7 +50643,7 @@ def test_get_custom_metric_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customMetrics/sample2"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -42809,10 +50655,10 @@ def test_get_custom_metric_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_custom_metric(request) + client.list_search_ads360_links(request) -def test_get_custom_metric_rest_flattened(): +def test_list_search_ads360_links_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -42821,38 +50667,39 @@ def test_get_custom_metric_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.CustomMetric() + return_value = analytics_admin.ListSearchAds360LinksResponse() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/customMetrics/sample2"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.pb(return_value) + pb_return_value = analytics_admin.ListSearchAds360LinksResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_custom_metric(**mock_args) + client.list_search_ads360_links(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/customMetrics/*}" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/searchAds360Links" + % client.transport._host, args[1], ) -def test_get_custom_metric_rest_flattened_error(transport: str = "rest"): +def test_list_search_ads360_links_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -42861,71 +50708,134 @@ def test_get_custom_metric_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_custom_metric( - analytics_admin.GetCustomMetricRequest(), - name="name_value", + client.list_search_ads360_links( + analytics_admin.ListSearchAds360LinksRequest(), + parent="parent_value", ) -def test_get_custom_metric_rest_error(): +def test_list_search_ads360_links_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListSearchAds360LinksResponse( + search_ads_360_links=[ + resources.SearchAds360Link(), + resources.SearchAds360Link(), + resources.SearchAds360Link(), + ], + next_page_token="abc", + ), + analytics_admin.ListSearchAds360LinksResponse( + search_ads_360_links=[], + next_page_token="def", + ), + analytics_admin.ListSearchAds360LinksResponse( + search_ads_360_links=[ + resources.SearchAds360Link(), + ], + next_page_token="ghi", + ), + analytics_admin.ListSearchAds360LinksResponse( + search_ads_360_links=[ + resources.SearchAds360Link(), + resources.SearchAds360Link(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListSearchAds360LinksResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1"} + + pager = client.list_search_ads360_links(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.SearchAds360Link) for i in results) + + pages = list(client.list_search_ads360_links(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDataRetentionSettingsRequest, + analytics_admin.CreateSearchAds360LinkRequest, dict, ], ) -def test_get_data_retention_settings_rest(request_type): +def test_create_search_ads360_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/dataRetentionSettings"} + request_init = {"parent": "properties/sample1"} + request_init["search_ads_360_link"] = { + "name": "name_value", + "advertiser_id": "advertiser_id_value", + "campaign_data_sharing_enabled": {"value": True}, + "cost_data_sharing_enabled": {}, + "advertiser_display_name": "advertiser_display_name_value", + "ads_personalization_enabled": {}, + "site_stats_sharing_enabled": {}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataRetentionSettings( + return_value = resources.SearchAds360Link( name="name_value", - event_data_retention=resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS, - reset_user_data_on_new_activity=True, + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataRetentionSettings.pb(return_value) + pb_return_value = resources.SearchAds360Link.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_data_retention_settings(request) + response = client.create_search_ads360_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataRetentionSettings) + assert isinstance(response, resources.SearchAds360Link) assert response.name == "name_value" - assert ( - response.event_data_retention - == resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS - ) - assert response.reset_user_data_on_new_activity is True + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" -def test_get_data_retention_settings_rest_required_fields( - request_type=analytics_admin.GetDataRetentionSettingsRequest, +def test_create_search_ads360_link_rest_required_fields( + request_type=analytics_admin.CreateSearchAds360LinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -42940,21 +50850,21 @@ def test_get_data_retention_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_data_retention_settings._get_unset_required_fields(jsonified_request) + ).create_search_ads360_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_data_retention_settings._get_unset_required_fields(jsonified_request) + ).create_search_ads360_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42963,7 +50873,7 @@ def test_get_data_retention_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DataRetentionSettings() + return_value = resources.SearchAds360Link() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -42975,38 +50885,47 @@ def test_get_data_retention_settings_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataRetentionSettings.pb(return_value) + pb_return_value = resources.SearchAds360Link.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_data_retention_settings(request) + response = client.create_search_ads360_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_data_retention_settings_rest_unset_required_fields(): +def test_create_search_ads360_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_data_retention_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.create_search_ads360_link._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "searchAds360Link", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_data_retention_settings_rest_interceptors(null_interceptor): +def test_create_search_ads360_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -43020,15 +50939,14 @@ def test_get_data_retention_settings_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_get_data_retention_settings", + "post_create_search_ads360_link", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_data_retention_settings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_search_ads360_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetDataRetentionSettingsRequest.pb( - analytics_admin.GetDataRetentionSettingsRequest() + pb_message = analytics_admin.CreateSearchAds360LinkRequest.pb( + analytics_admin.CreateSearchAds360LinkRequest() ) transcode.return_value = { "method": "post", @@ -43040,19 +50958,19 @@ def test_get_data_retention_settings_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DataRetentionSettings.to_json( - resources.DataRetentionSettings() + req.return_value._content = resources.SearchAds360Link.to_json( + resources.SearchAds360Link() ) - request = analytics_admin.GetDataRetentionSettingsRequest() + request = analytics_admin.CreateSearchAds360LinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataRetentionSettings() + post.return_value = resources.SearchAds360Link() - client.get_data_retention_settings( + client.create_search_ads360_link( request, metadata=[ ("key", "val"), @@ -43064,9 +50982,8 @@ def test_get_data_retention_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_data_retention_settings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.GetDataRetentionSettingsRequest, +def test_create_search_ads360_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateSearchAds360LinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43074,7 +50991,16 @@ def test_get_data_retention_settings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/dataRetentionSettings"} + request_init = {"parent": "properties/sample1"} + request_init["search_ads_360_link"] = { + "name": "name_value", + "advertiser_id": "advertiser_id_value", + "campaign_data_sharing_enabled": {"value": True}, + "cost_data_sharing_enabled": {}, + "advertiser_display_name": "advertiser_display_name_value", + "ads_personalization_enabled": {}, + "site_stats_sharing_enabled": {}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -43086,10 +51012,10 @@ def test_get_data_retention_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_data_retention_settings(request) + client.create_search_ads360_link(request) -def test_get_data_retention_settings_rest_flattened(): +def test_create_search_ads360_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -43098,39 +51024,40 @@ def test_get_data_retention_settings_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataRetentionSettings() + return_value = resources.SearchAds360Link() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/dataRetentionSettings"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", + search_ads_360_link=resources.SearchAds360Link(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataRetentionSettings.pb(return_value) + pb_return_value = resources.SearchAds360Link.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_data_retention_settings(**mock_args) + client.create_search_ads360_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/dataRetentionSettings}" + "%s/v1alpha/{parent=properties/*}/searchAds360Links" % client.transport._host, args[1], ) -def test_get_data_retention_settings_rest_flattened_error(transport: str = "rest"): +def test_create_search_ads360_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -43139,13 +51066,14 @@ def test_get_data_retention_settings_rest_flattened_error(transport: str = "rest # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_data_retention_settings( - analytics_admin.GetDataRetentionSettingsRequest(), - name="name_value", + client.create_search_ads360_link( + analytics_admin.CreateSearchAds360LinkRequest(), + parent="parent_value", + search_ads_360_link=resources.SearchAds360Link(name="name_value"), ) -def test_get_data_retention_settings_rest_error(): +def test_create_search_ads360_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -43154,62 +51082,45 @@ def test_get_data_retention_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateDataRetentionSettingsRequest, + analytics_admin.DeleteSearchAds360LinkRequest, dict, ], ) -def test_update_data_retention_settings_rest(request_type): +def test_delete_search_ads360_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "data_retention_settings": {"name": "properties/sample1/dataRetentionSettings"} - } - request_init["data_retention_settings"] = { - "name": "properties/sample1/dataRetentionSettings", - "event_data_retention": 1, - "reset_user_data_on_new_activity": True, - } + request_init = {"name": "properties/sample1/searchAds360Links/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataRetentionSettings( - name="name_value", - event_data_retention=resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS, - reset_user_data_on_new_activity=True, - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataRetentionSettings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_data_retention_settings(request) + response = client.delete_search_ads360_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataRetentionSettings) - assert response.name == "name_value" - assert ( - response.event_data_retention - == resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS - ) - assert response.reset_user_data_on_new_activity is True + assert response is None -def test_update_data_retention_settings_rest_required_fields( - request_type=analytics_admin.UpdateDataRetentionSettingsRequest, +def test_delete_search_ads360_link_rest_required_fields( + request_type=analytics_admin.DeleteSearchAds360LinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -43224,19 +51135,21 @@ def test_update_data_retention_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_data_retention_settings._get_unset_required_fields(jsonified_request) + ).delete_search_ads360_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_data_retention_settings._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + ).delete_search_ads360_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43245,7 +51158,7 @@ def test_update_data_retention_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DataRetentionSettings() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -43257,49 +51170,36 @@ def test_update_data_retention_settings_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "delete", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.DataRetentionSettings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_data_retention_settings(request) + response = client.delete_search_ads360_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_data_retention_settings_rest_unset_required_fields(): +def test_delete_search_ads360_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_data_retention_settings._get_unset_required_fields( - {} - ) - assert set(unset_fields) == ( - set(("updateMask",)) - & set( - ( - "dataRetentionSettings", - "updateMask", - ) - ) - ) + unset_fields = transport.delete_search_ads360_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_data_retention_settings_rest_interceptors(null_interceptor): +def test_delete_search_ads360_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -43312,16 +51212,11 @@ def test_update_data_retention_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_update_data_retention_settings", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_data_retention_settings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_search_ads360_link" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.UpdateDataRetentionSettingsRequest.pb( - analytics_admin.UpdateDataRetentionSettingsRequest() + pb_message = analytics_admin.DeleteSearchAds360LinkRequest.pb( + analytics_admin.DeleteSearchAds360LinkRequest() ) transcode.return_value = { "method": "post", @@ -43333,19 +51228,15 @@ def test_update_data_retention_settings_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DataRetentionSettings.to_json( - resources.DataRetentionSettings() - ) - request = analytics_admin.UpdateDataRetentionSettingsRequest() + request = analytics_admin.DeleteSearchAds360LinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataRetentionSettings() - client.update_data_retention_settings( + client.delete_search_ads360_link( request, metadata=[ ("key", "val"), @@ -43354,12 +51245,10 @@ def test_update_data_retention_settings_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_update_data_retention_settings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.UpdateDataRetentionSettingsRequest, +def test_delete_search_ads360_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteSearchAds360LinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43367,14 +51256,7 @@ def test_update_data_retention_settings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "data_retention_settings": {"name": "properties/sample1/dataRetentionSettings"} - } - request_init["data_retention_settings"] = { - "name": "properties/sample1/dataRetentionSettings", - "event_data_retention": 1, - "reset_user_data_on_new_activity": True, - } + request_init = {"name": "properties/sample1/searchAds360Links/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -43386,10 +51268,10 @@ def test_update_data_retention_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_data_retention_settings(request) + client.delete_search_ads360_link(request) -def test_update_data_retention_settings_rest_flattened(): +def test_delete_search_ads360_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -43398,44 +51280,38 @@ def test_update_data_retention_settings_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataRetentionSettings() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = { - "data_retention_settings": { - "name": "properties/sample1/dataRetentionSettings" - } - } + sample_request = {"name": "properties/sample1/searchAds360Links/sample2"} # get truthy value for each flattened field mock_args = dict( - data_retention_settings=resources.DataRetentionSettings(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataRetentionSettings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_data_retention_settings(**mock_args) + client.delete_search_ads360_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{data_retention_settings.name=properties/*/dataRetentionSettings}" + "%s/v1alpha/{name=properties/*/searchAds360Links/*}" % client.transport._host, args[1], ) -def test_update_data_retention_settings_rest_flattened_error(transport: str = "rest"): +def test_delete_search_ads360_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -43444,14 +51320,13 @@ def test_update_data_retention_settings_rest_flattened_error(transport: str = "r # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_data_retention_settings( - analytics_admin.UpdateDataRetentionSettingsRequest(), - data_retention_settings=resources.DataRetentionSettings(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.delete_search_ads360_link( + analytics_admin.DeleteSearchAds360LinkRequest(), + name="name_value", ) -def test_update_data_retention_settings_rest_error(): +def test_delete_search_ads360_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -43460,76 +51335,63 @@ def test_update_data_retention_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateDataStreamRequest, + analytics_admin.UpdateSearchAds360LinkRequest, dict, ], ) -def test_create_data_stream_rest(request_type): +def test_update_search_ads360_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["data_stream"] = { - "web_stream_data": { - "measurement_id": "measurement_id_value", - "firebase_app_id": "firebase_app_id_value", - "default_uri": "default_uri_value", - }, - "android_app_stream_data": { - "firebase_app_id": "firebase_app_id_value", - "package_name": "package_name_value", - }, - "ios_app_stream_data": { - "firebase_app_id": "firebase_app_id_value", - "bundle_id": "bundle_id_value", - }, - "name": "name_value", - "type_": 1, - "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, + request_init = { + "search_ads_360_link": {"name": "properties/sample1/searchAds360Links/sample2"} + } + request_init["search_ads_360_link"] = { + "name": "properties/sample1/searchAds360Links/sample2", + "advertiser_id": "advertiser_id_value", + "campaign_data_sharing_enabled": {"value": True}, + "cost_data_sharing_enabled": {}, + "advertiser_display_name": "advertiser_display_name_value", + "ads_personalization_enabled": {}, + "site_stats_sharing_enabled": {}, } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataStream( + return_value = resources.SearchAds360Link( name="name_value", - type_=resources.DataStream.DataStreamType.WEB_DATA_STREAM, - display_name="display_name_value", - web_stream_data=resources.DataStream.WebStreamData( - measurement_id="measurement_id_value" - ), + advertiser_id="advertiser_id_value", + advertiser_display_name="advertiser_display_name_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.SearchAds360Link.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_data_stream(request) + response = client.update_search_ads360_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataStream) + assert isinstance(response, resources.SearchAds360Link) assert response.name == "name_value" - assert response.type_ == resources.DataStream.DataStreamType.WEB_DATA_STREAM - assert response.display_name == "display_name_value" + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" -def test_create_data_stream_rest_required_fields( - request_type=analytics_admin.CreateDataStreamRequest, +def test_update_search_ads360_link_rest_required_fields( + request_type=analytics_admin.UpdateSearchAds360LinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -43544,21 +51406,19 @@ def test_create_data_stream_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_data_stream._get_unset_required_fields(jsonified_request) + ).update_search_ads360_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_data_stream._get_unset_required_fields(jsonified_request) + ).update_search_ads360_link._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43567,7 +51427,7 @@ def test_create_data_stream_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DataStream() + return_value = resources.SearchAds360Link() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -43579,7 +51439,7 @@ def test_create_data_stream_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "patch", "query_params": pb_request, } transcode_result["body"] = pb_request @@ -43588,38 +51448,30 @@ def test_create_data_stream_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.SearchAds360Link.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_data_stream(request) + response = client.update_search_ads360_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params - - -def test_create_data_stream_rest_unset_required_fields(): - transport = transports.AnalyticsAdminServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.create_data_stream._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "dataStream", - ) - ) + + +def test_update_search_ads360_link_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials ) + unset_fields = transport.update_search_ads360_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) + @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_data_stream_rest_interceptors(null_interceptor): +def test_update_search_ads360_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -43632,14 +51484,15 @@ def test_create_data_stream_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, + "post_update_search_ads360_link", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_search_ads360_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateDataStreamRequest.pb( - analytics_admin.CreateDataStreamRequest() + pb_message = analytics_admin.UpdateSearchAds360LinkRequest.pb( + analytics_admin.UpdateSearchAds360LinkRequest() ) transcode.return_value = { "method": "post", @@ -43651,17 +51504,19 @@ def test_create_data_stream_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DataStream.to_json(resources.DataStream()) + req.return_value._content = resources.SearchAds360Link.to_json( + resources.SearchAds360Link() + ) - request = analytics_admin.CreateDataStreamRequest() + request = analytics_admin.UpdateSearchAds360LinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataStream() + post.return_value = resources.SearchAds360Link() - client.create_data_stream( + client.update_search_ads360_link( request, metadata=[ ("key", "val"), @@ -43673,8 +51528,8 @@ def test_create_data_stream_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_data_stream_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateDataStreamRequest +def test_update_search_ads360_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateSearchAds360LinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43682,26 +51537,17 @@ def test_create_data_stream_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["data_stream"] = { - "web_stream_data": { - "measurement_id": "measurement_id_value", - "firebase_app_id": "firebase_app_id_value", - "default_uri": "default_uri_value", - }, - "android_app_stream_data": { - "firebase_app_id": "firebase_app_id_value", - "package_name": "package_name_value", - }, - "ios_app_stream_data": { - "firebase_app_id": "firebase_app_id_value", - "bundle_id": "bundle_id_value", - }, - "name": "name_value", - "type_": 1, - "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, + request_init = { + "search_ads_360_link": {"name": "properties/sample1/searchAds360Links/sample2"} + } + request_init["search_ads_360_link"] = { + "name": "properties/sample1/searchAds360Links/sample2", + "advertiser_id": "advertiser_id_value", + "campaign_data_sharing_enabled": {"value": True}, + "cost_data_sharing_enabled": {}, + "advertiser_display_name": "advertiser_display_name_value", + "ads_personalization_enabled": {}, + "site_stats_sharing_enabled": {}, } request = request_type(**request_init) @@ -43714,10 +51560,10 @@ def test_create_data_stream_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_data_stream(request) + client.update_search_ads360_link(request) -def test_create_data_stream_rest_flattened(): +def test_update_search_ads360_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -43726,43 +51572,44 @@ def test_create_data_stream_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataStream() + return_value = resources.SearchAds360Link() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = { + "search_ads_360_link": { + "name": "properties/sample1/searchAds360Links/sample2" + } + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - data_stream=resources.DataStream( - web_stream_data=resources.DataStream.WebStreamData( - measurement_id="measurement_id_value" - ) - ), + search_ads_360_link=resources.SearchAds360Link(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.SearchAds360Link.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_data_stream(**mock_args) + client.update_search_ads360_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/dataStreams" % client.transport._host, + "%s/v1alpha/{search_ads_360_link.name=properties/*/searchAds360Links/*}" + % client.transport._host, args[1], ) -def test_create_data_stream_rest_flattened_error(transport: str = "rest"): +def test_update_search_ads360_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -43771,18 +51618,14 @@ def test_create_data_stream_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_data_stream( - analytics_admin.CreateDataStreamRequest(), - parent="parent_value", - data_stream=resources.DataStream( - web_stream_data=resources.DataStream.WebStreamData( - measurement_id="measurement_id_value" - ) - ), + client.update_search_ads360_link( + analytics_admin.UpdateSearchAds360LinkRequest(), + search_ads_360_link=resources.SearchAds360Link(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_create_data_stream_rest_error(): +def test_update_search_ads360_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -43791,40 +51634,59 @@ def test_create_data_stream_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteDataStreamRequest, + analytics_admin.GetAttributionSettingsRequest, dict, ], ) -def test_delete_data_stream_rest(request_type): +def test_get_attribution_settings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/dataStreams/sample2"} + request_init = {"name": "properties/sample1/attributionSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.AttributionSettings( + name="name_value", + acquisition_conversion_event_lookback_window=resources.AttributionSettings.AcquisitionConversionEventLookbackWindow.ACQUISITION_CONVERSION_EVENT_LOOKBACK_WINDOW_7_DAYS, + other_conversion_event_lookback_window=resources.AttributionSettings.OtherConversionEventLookbackWindow.OTHER_CONVERSION_EVENT_LOOKBACK_WINDOW_30_DAYS, + reporting_attribution_model=resources.AttributionSettings.ReportingAttributionModel.CROSS_CHANNEL_DATA_DRIVEN, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.AttributionSettings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_data_stream(request) + response = client.get_attribution_settings(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.AttributionSettings) + assert response.name == "name_value" + assert ( + response.acquisition_conversion_event_lookback_window + == resources.AttributionSettings.AcquisitionConversionEventLookbackWindow.ACQUISITION_CONVERSION_EVENT_LOOKBACK_WINDOW_7_DAYS + ) + assert ( + response.other_conversion_event_lookback_window + == resources.AttributionSettings.OtherConversionEventLookbackWindow.OTHER_CONVERSION_EVENT_LOOKBACK_WINDOW_30_DAYS + ) + assert ( + response.reporting_attribution_model + == resources.AttributionSettings.ReportingAttributionModel.CROSS_CHANNEL_DATA_DRIVEN + ) -def test_delete_data_stream_rest_required_fields( - request_type=analytics_admin.DeleteDataStreamRequest, +def test_get_attribution_settings_rest_required_fields( + request_type=analytics_admin.GetAttributionSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -43844,7 +51706,7 @@ def test_delete_data_stream_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_data_stream._get_unset_required_fields(jsonified_request) + ).get_attribution_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -43853,7 +51715,7 @@ def test_delete_data_stream_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_data_stream._get_unset_required_fields(jsonified_request) + ).get_attribution_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -43867,7 +51729,7 @@ def test_delete_data_stream_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.AttributionSettings() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -43879,36 +51741,38 @@ def test_delete_data_stream_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "get", "query_params": pb_request, } transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = resources.AttributionSettings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_data_stream(request) + response = client.get_attribution_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_data_stream_rest_unset_required_fields(): +def test_get_attribution_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_data_stream._get_unset_required_fields({}) + unset_fields = transport.get_attribution_settings._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_data_stream_rest_interceptors(null_interceptor): +def test_get_attribution_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -43921,11 +51785,14 @@ def test_delete_data_stream_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_attribution_settings" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_attribution_settings" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteDataStreamRequest.pb( - analytics_admin.DeleteDataStreamRequest() + post.assert_not_called() + pb_message = analytics_admin.GetAttributionSettingsRequest.pb( + analytics_admin.GetAttributionSettingsRequest() ) transcode.return_value = { "method": "post", @@ -43937,15 +51804,19 @@ def test_delete_data_stream_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.AttributionSettings.to_json( + resources.AttributionSettings() + ) - request = analytics_admin.DeleteDataStreamRequest() + request = analytics_admin.GetAttributionSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.AttributionSettings() - client.delete_data_stream( + client.get_attribution_settings( request, metadata=[ ("key", "val"), @@ -43954,10 +51825,11 @@ def test_delete_data_stream_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_data_stream_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteDataStreamRequest +def test_get_attribution_settings_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetAttributionSettingsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43965,7 +51837,7 @@ def test_delete_data_stream_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/dataStreams/sample2"} + request_init = {"name": "properties/sample1/attributionSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -43977,10 +51849,10 @@ def test_delete_data_stream_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_data_stream(request) + client.get_attribution_settings(request) -def test_delete_data_stream_rest_flattened(): +def test_get_attribution_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -43989,10 +51861,10 @@ def test_delete_data_stream_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.AttributionSettings() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/dataStreams/sample2"} + sample_request = {"name": "properties/sample1/attributionSettings"} # get truthy value for each flattened field mock_args = dict( @@ -44003,23 +51875,25 @@ def test_delete_data_stream_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.AttributionSettings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_data_stream(**mock_args) + client.get_attribution_settings(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/dataStreams/*}" % client.transport._host, + "%s/v1alpha/{name=properties/*/attributionSettings}" + % client.transport._host, args[1], ) -def test_delete_data_stream_rest_flattened_error(transport: str = "rest"): +def test_get_attribution_settings_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -44028,13 +51902,13 @@ def test_delete_data_stream_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_data_stream( - analytics_admin.DeleteDataStreamRequest(), + client.get_attribution_settings( + analytics_admin.GetAttributionSettingsRequest(), name="name_value", ) -def test_delete_data_stream_rest_error(): +def test_get_attribution_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -44043,71 +51917,67 @@ def test_delete_data_stream_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateDataStreamRequest, + analytics_admin.UpdateAttributionSettingsRequest, dict, ], ) -def test_update_data_stream_rest(request_type): +def test_update_attribution_settings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"data_stream": {"name": "properties/sample1/dataStreams/sample2"}} - request_init["data_stream"] = { - "web_stream_data": { - "measurement_id": "measurement_id_value", - "firebase_app_id": "firebase_app_id_value", - "default_uri": "default_uri_value", - }, - "android_app_stream_data": { - "firebase_app_id": "firebase_app_id_value", - "package_name": "package_name_value", - }, - "ios_app_stream_data": { - "firebase_app_id": "firebase_app_id_value", - "bundle_id": "bundle_id_value", - }, - "name": "properties/sample1/dataStreams/sample2", - "type_": 1, - "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, + request_init = { + "attribution_settings": {"name": "properties/sample1/attributionSettings"} + } + request_init["attribution_settings"] = { + "name": "properties/sample1/attributionSettings", + "acquisition_conversion_event_lookback_window": 1, + "other_conversion_event_lookback_window": 1, + "reporting_attribution_model": 1, } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataStream( + return_value = resources.AttributionSettings( name="name_value", - type_=resources.DataStream.DataStreamType.WEB_DATA_STREAM, - display_name="display_name_value", - web_stream_data=resources.DataStream.WebStreamData( - measurement_id="measurement_id_value" - ), + acquisition_conversion_event_lookback_window=resources.AttributionSettings.AcquisitionConversionEventLookbackWindow.ACQUISITION_CONVERSION_EVENT_LOOKBACK_WINDOW_7_DAYS, + other_conversion_event_lookback_window=resources.AttributionSettings.OtherConversionEventLookbackWindow.OTHER_CONVERSION_EVENT_LOOKBACK_WINDOW_30_DAYS, + reporting_attribution_model=resources.AttributionSettings.ReportingAttributionModel.CROSS_CHANNEL_DATA_DRIVEN, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.AttributionSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_data_stream(request) + response = client.update_attribution_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataStream) + assert isinstance(response, resources.AttributionSettings) assert response.name == "name_value" - assert response.type_ == resources.DataStream.DataStreamType.WEB_DATA_STREAM - assert response.display_name == "display_name_value" + assert ( + response.acquisition_conversion_event_lookback_window + == resources.AttributionSettings.AcquisitionConversionEventLookbackWindow.ACQUISITION_CONVERSION_EVENT_LOOKBACK_WINDOW_7_DAYS + ) + assert ( + response.other_conversion_event_lookback_window + == resources.AttributionSettings.OtherConversionEventLookbackWindow.OTHER_CONVERSION_EVENT_LOOKBACK_WINDOW_30_DAYS + ) + assert ( + response.reporting_attribution_model + == resources.AttributionSettings.ReportingAttributionModel.CROSS_CHANNEL_DATA_DRIVEN + ) -def test_update_data_stream_rest_required_fields( - request_type=analytics_admin.UpdateDataStreamRequest, +def test_update_attribution_settings_rest_required_fields( + request_type=analytics_admin.UpdateAttributionSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -44126,14 +51996,14 @@ def test_update_data_stream_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_data_stream._get_unset_required_fields(jsonified_request) + ).update_attribution_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_data_stream._get_unset_required_fields(jsonified_request) + ).update_attribution_settings._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) @@ -44147,7 +52017,7 @@ def test_update_data_stream_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DataStream() + return_value = resources.AttributionSettings() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -44168,30 +52038,38 @@ def test_update_data_stream_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.AttributionSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_data_stream(request) + response = client.update_attribution_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_data_stream_rest_unset_required_fields(): +def test_update_attribution_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_data_stream._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) + unset_fields = transport.update_attribution_settings._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "attributionSettings", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_data_stream_rest_interceptors(null_interceptor): +def test_update_attribution_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -44204,14 +52082,16 @@ def test_update_data_stream_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, + "post_update_attribution_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_attribution_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateDataStreamRequest.pb( - analytics_admin.UpdateDataStreamRequest() + pb_message = analytics_admin.UpdateAttributionSettingsRequest.pb( + analytics_admin.UpdateAttributionSettingsRequest() ) transcode.return_value = { "method": "post", @@ -44223,17 +52103,19 @@ def test_update_data_stream_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DataStream.to_json(resources.DataStream()) + req.return_value._content = resources.AttributionSettings.to_json( + resources.AttributionSettings() + ) - request = analytics_admin.UpdateDataStreamRequest() + request = analytics_admin.UpdateAttributionSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataStream() + post.return_value = resources.AttributionSettings() - client.update_data_stream( + client.update_attribution_settings( request, metadata=[ ("key", "val"), @@ -44245,8 +52127,9 @@ def test_update_data_stream_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_data_stream_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateDataStreamRequest +def test_update_attribution_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.UpdateAttributionSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -44254,26 +52137,14 @@ def test_update_data_stream_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"data_stream": {"name": "properties/sample1/dataStreams/sample2"}} - request_init["data_stream"] = { - "web_stream_data": { - "measurement_id": "measurement_id_value", - "firebase_app_id": "firebase_app_id_value", - "default_uri": "default_uri_value", - }, - "android_app_stream_data": { - "firebase_app_id": "firebase_app_id_value", - "package_name": "package_name_value", - }, - "ios_app_stream_data": { - "firebase_app_id": "firebase_app_id_value", - "bundle_id": "bundle_id_value", - }, - "name": "properties/sample1/dataStreams/sample2", - "type_": 1, - "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, + request_init = { + "attribution_settings": {"name": "properties/sample1/attributionSettings"} + } + request_init["attribution_settings"] = { + "name": "properties/sample1/attributionSettings", + "acquisition_conversion_event_lookback_window": 1, + "other_conversion_event_lookback_window": 1, + "reporting_attribution_model": 1, } request = request_type(**request_init) @@ -44286,10 +52157,10 @@ def test_update_data_stream_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_data_stream(request) + client.update_attribution_settings(request) -def test_update_data_stream_rest_flattened(): +def test_update_attribution_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -44298,20 +52169,16 @@ def test_update_data_stream_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataStream() + return_value = resources.AttributionSettings() # get arguments that satisfy an http rule for this method sample_request = { - "data_stream": {"name": "properties/sample1/dataStreams/sample2"} + "attribution_settings": {"name": "properties/sample1/attributionSettings"} } # get truthy value for each flattened field mock_args = dict( - data_stream=resources.DataStream( - web_stream_data=resources.DataStream.WebStreamData( - measurement_id="measurement_id_value" - ) - ), + attribution_settings=resources.AttributionSettings(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) @@ -44319,25 +52186,25 @@ def test_update_data_stream_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.AttributionSettings.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_data_stream(**mock_args) + client.update_attribution_settings(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{data_stream.name=properties/*/dataStreams/*}" + "%s/v1alpha/{attribution_settings.name=properties/*/attributionSettings}" % client.transport._host, args[1], ) -def test_update_data_stream_rest_flattened_error(transport: str = "rest"): +def test_update_attribution_settings_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -44346,18 +52213,14 @@ def test_update_data_stream_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_data_stream( - analytics_admin.UpdateDataStreamRequest(), - data_stream=resources.DataStream( - web_stream_data=resources.DataStream.WebStreamData( - measurement_id="measurement_id_value" - ) - ), + client.update_attribution_settings( + analytics_admin.UpdateAttributionSettingsRequest(), + attribution_settings=resources.AttributionSettings(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_update_data_stream_rest_error(): +def test_update_attribution_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -44366,145 +52229,44 @@ def test_update_data_stream_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListDataStreamsRequest, + analytics_admin.RunAccessReportRequest, dict, ], ) -def test_list_data_streams_rest(request_type): +def test_run_access_report_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"entity": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListDataStreamsResponse( - next_page_token="next_page_token_value", + return_value = analytics_admin.RunAccessReportResponse( + row_count=992, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListDataStreamsResponse.pb(return_value) + pb_return_value = analytics_admin.RunAccessReportResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_data_streams(request) + response = client.run_access_report(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDataStreamsPager) - assert response.next_page_token == "next_page_token_value" - - -def test_list_data_streams_rest_required_fields( - request_type=analytics_admin.ListDataStreamsRequest, -): - transport_class = transports.AnalyticsAdminServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False, - ) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_data_streams._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_data_streams._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListDataStreamsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = analytics_admin.ListDataStreamsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.list_data_streams(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_list_data_streams_rest_unset_required_fields(): - transport = transports.AnalyticsAdminServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.list_data_streams._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + assert isinstance(response, analytics_admin.RunAccessReportResponse) + assert response.row_count == 992 @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_data_streams_rest_interceptors(null_interceptor): +def test_run_access_report_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -44517,14 +52279,14 @@ def test_list_data_streams_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_data_streams" + transports.AnalyticsAdminServiceRestInterceptor, "post_run_access_report" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_data_streams" + transports.AnalyticsAdminServiceRestInterceptor, "pre_run_access_report" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListDataStreamsRequest.pb( - analytics_admin.ListDataStreamsRequest() + pb_message = analytics_admin.RunAccessReportRequest.pb( + analytics_admin.RunAccessReportRequest() ) transcode.return_value = { "method": "post", @@ -44536,19 +52298,19 @@ def test_list_data_streams_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ListDataStreamsResponse.to_json( - analytics_admin.ListDataStreamsResponse() + req.return_value._content = analytics_admin.RunAccessReportResponse.to_json( + analytics_admin.RunAccessReportResponse() ) - request = analytics_admin.ListDataStreamsRequest() + request = analytics_admin.RunAccessReportRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListDataStreamsResponse() + post.return_value = analytics_admin.RunAccessReportResponse() - client.list_data_streams( + client.run_access_report( request, metadata=[ ("key", "val"), @@ -44560,8 +52322,8 @@ def test_list_data_streams_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_data_streams_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListDataStreamsRequest +def test_run_access_report_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.RunAccessReportRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -44569,7 +52331,7 @@ def test_list_data_streams_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"entity": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -44581,180 +52343,69 @@ def test_list_data_streams_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_data_streams(request) - - -def test_list_data_streams_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListDataStreamsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = analytics_admin.ListDataStreamsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_data_streams(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/dataStreams" % client.transport._host, - args[1], - ) - - -def test_list_data_streams_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_data_streams( - analytics_admin.ListDataStreamsRequest(), - parent="parent_value", - ) + client.run_access_report(request) -def test_list_data_streams_rest_pager(transport: str = "rest"): +def test_run_access_report_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListDataStreamsResponse( - data_streams=[ - resources.DataStream(), - resources.DataStream(), - resources.DataStream(), - ], - next_page_token="abc", - ), - analytics_admin.ListDataStreamsResponse( - data_streams=[], - next_page_token="def", - ), - analytics_admin.ListDataStreamsResponse( - data_streams=[ - resources.DataStream(), - ], - next_page_token="ghi", - ), - analytics_admin.ListDataStreamsResponse( - data_streams=[ - resources.DataStream(), - resources.DataStream(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListDataStreamsResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1"} - - pager = client.list_data_streams(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.DataStream) for i in results) - - pages = list(client.list_data_streams(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDataStreamRequest, + analytics_admin.CreateAccessBindingRequest, dict, ], ) -def test_get_data_stream_rest(request_type): +def test_create_access_binding_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/dataStreams/sample2"} + request_init = {"parent": "accounts/sample1"} + request_init["access_binding"] = { + "user": "user_value", + "name": "name_value", + "roles": ["roles_value1", "roles_value2"], + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataStream( + return_value = resources.AccessBinding( name="name_value", - type_=resources.DataStream.DataStreamType.WEB_DATA_STREAM, - display_name="display_name_value", - web_stream_data=resources.DataStream.WebStreamData( - measurement_id="measurement_id_value" - ), + roles=["roles_value"], + user="user_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_data_stream(request) + response = client.create_access_binding(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataStream) + assert isinstance(response, resources.AccessBinding) assert response.name == "name_value" - assert response.type_ == resources.DataStream.DataStreamType.WEB_DATA_STREAM - assert response.display_name == "display_name_value" + assert response.roles == ["roles_value"] -def test_get_data_stream_rest_required_fields( - request_type=analytics_admin.GetDataStreamRequest, +def test_create_access_binding_rest_required_fields( + request_type=analytics_admin.CreateAccessBindingRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -44769,21 +52420,21 @@ def test_get_data_stream_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_data_stream._get_unset_required_fields(jsonified_request) + ).create_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_data_stream._get_unset_required_fields(jsonified_request) + ).create_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -44792,7 +52443,7 @@ def test_get_data_stream_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.DataStream() + return_value = resources.AccessBinding() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -44804,38 +52455,47 @@ def test_get_data_stream_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_data_stream(request) + response = client.create_access_binding(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_data_stream_rest_unset_required_fields(): +def test_create_access_binding_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_data_stream._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.create_access_binding._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "accessBinding", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_data_stream_rest_interceptors(null_interceptor): +def test_create_access_binding_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -44848,14 +52508,14 @@ def test_get_data_stream_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_access_binding" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_access_binding" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetDataStreamRequest.pb( - analytics_admin.GetDataStreamRequest() + pb_message = analytics_admin.CreateAccessBindingRequest.pb( + analytics_admin.CreateAccessBindingRequest() ) transcode.return_value = { "method": "post", @@ -44867,17 +52527,19 @@ def test_get_data_stream_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.DataStream.to_json(resources.DataStream()) + req.return_value._content = resources.AccessBinding.to_json( + resources.AccessBinding() + ) - request = analytics_admin.GetDataStreamRequest() + request = analytics_admin.CreateAccessBindingRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataStream() + post.return_value = resources.AccessBinding() - client.get_data_stream( + client.create_access_binding( request, metadata=[ ("key", "val"), @@ -44889,8 +52551,8 @@ def test_get_data_stream_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_data_stream_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetDataStreamRequest +def test_create_access_binding_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateAccessBindingRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -44898,7 +52560,12 @@ def test_get_data_stream_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/dataStreams/sample2"} + request_init = {"parent": "accounts/sample1"} + request_init["access_binding"] = { + "user": "user_value", + "name": "name_value", + "roles": ["roles_value1", "roles_value2"], + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -44910,10 +52577,10 @@ def test_get_data_stream_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_data_stream(request) + client.create_access_binding(request) -def test_get_data_stream_rest_flattened(): +def test_create_access_binding_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -44922,38 +52589,39 @@ def test_get_data_stream_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.DataStream() + return_value = resources.AccessBinding() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/dataStreams/sample2"} + sample_request = {"parent": "accounts/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", + access_binding=resources.AccessBinding(user="user_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataStream.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_data_stream(**mock_args) + client.create_access_binding(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/dataStreams/*}" % client.transport._host, + "%s/v1alpha/{parent=accounts/*}/accessBindings" % client.transport._host, args[1], ) -def test_get_data_stream_rest_flattened_error(transport: str = "rest"): +def test_create_access_binding_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -44962,13 +52630,14 @@ def test_get_data_stream_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_data_stream( - analytics_admin.GetDataStreamRequest(), - name="name_value", + client.create_access_binding( + analytics_admin.CreateAccessBindingRequest(), + parent="parent_value", + access_binding=resources.AccessBinding(user="user_value"), ) -def test_get_data_stream_rest_error(): +def test_create_access_binding_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -44977,57 +52646,47 @@ def test_get_data_stream_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetAudienceRequest, + analytics_admin.GetAccessBindingRequest, dict, ], ) -def test_get_audience_rest(request_type): +def test_get_access_binding_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/audiences/sample2"} + request_init = {"name": "accounts/sample1/accessBindings/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = audience.Audience( + return_value = resources.AccessBinding( name="name_value", - display_name="display_name_value", - description="description_value", - membership_duration_days=2561, - ads_personalization_enabled=True, - exclusion_duration_mode=audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY, + roles=["roles_value"], + user="user_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = audience.Audience.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_audience(request) + response = client.get_access_binding(request) # Establish that the response is the type that we expect. - assert isinstance(response, audience.Audience) + assert isinstance(response, resources.AccessBinding) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.membership_duration_days == 2561 - assert response.ads_personalization_enabled is True - assert ( - response.exclusion_duration_mode - == audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY - ) + assert response.roles == ["roles_value"] -def test_get_audience_rest_required_fields( - request_type=analytics_admin.GetAudienceRequest, +def test_get_access_binding_rest_required_fields( + request_type=analytics_admin.GetAccessBindingRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -45047,7 +52706,7 @@ def test_get_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_audience._get_unset_required_fields(jsonified_request) + ).get_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -45056,7 +52715,7 @@ def test_get_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_audience._get_unset_required_fields(jsonified_request) + ).get_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -45070,7 +52729,7 @@ def test_get_audience_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = audience.Audience() + return_value = resources.AccessBinding() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -45090,30 +52749,30 @@ def test_get_audience_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = audience.Audience.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_audience(request) + response = client.get_access_binding(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_audience_rest_unset_required_fields(): +def test_get_access_binding_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_audience._get_unset_required_fields({}) + unset_fields = transport.get_access_binding._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_audience_rest_interceptors(null_interceptor): +def test_get_access_binding_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -45126,14 +52785,14 @@ def test_get_audience_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_audience" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_access_binding" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_audience" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_access_binding" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetAudienceRequest.pb( - analytics_admin.GetAudienceRequest() + pb_message = analytics_admin.GetAccessBindingRequest.pb( + analytics_admin.GetAccessBindingRequest() ) transcode.return_value = { "method": "post", @@ -45145,17 +52804,19 @@ def test_get_audience_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = audience.Audience.to_json(audience.Audience()) + req.return_value._content = resources.AccessBinding.to_json( + resources.AccessBinding() + ) - request = analytics_admin.GetAudienceRequest() + request = analytics_admin.GetAccessBindingRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = audience.Audience() + post.return_value = resources.AccessBinding() - client.get_audience( + client.get_access_binding( request, metadata=[ ("key", "val"), @@ -45167,8 +52828,8 @@ def test_get_audience_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_audience_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetAudienceRequest +def test_get_access_binding_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetAccessBindingRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45176,7 +52837,7 @@ def test_get_audience_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/audiences/sample2"} + request_init = {"name": "accounts/sample1/accessBindings/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -45188,10 +52849,10 @@ def test_get_audience_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_audience(request) + client.get_access_binding(request) -def test_get_audience_rest_flattened(): +def test_get_access_binding_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -45200,10 +52861,10 @@ def test_get_audience_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = audience.Audience() + return_value = resources.AccessBinding() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/audiences/sample2"} + sample_request = {"name": "accounts/sample1/accessBindings/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -45214,24 +52875,24 @@ def test_get_audience_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = audience.Audience.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_audience(**mock_args) + client.get_access_binding(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/audiences/*}" % client.transport._host, + "%s/v1alpha/{name=accounts/*/accessBindings/*}" % client.transport._host, args[1], ) -def test_get_audience_rest_flattened_error(transport: str = "rest"): +def test_get_access_binding_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -45240,13 +52901,13 @@ def test_get_audience_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_audience( - analytics_admin.GetAudienceRequest(), + client.get_access_binding( + analytics_admin.GetAccessBindingRequest(), name="name_value", ) -def test_get_audience_rest_error(): +def test_get_access_binding_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -45255,49 +52916,58 @@ def test_get_audience_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListAudiencesRequest, + analytics_admin.UpdateAccessBindingRequest, dict, ], ) -def test_list_audiences_rest(request_type): +def test_update_access_binding_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = { + "access_binding": {"name": "accounts/sample1/accessBindings/sample2"} + } + request_init["access_binding"] = { + "user": "user_value", + "name": "accounts/sample1/accessBindings/sample2", + "roles": ["roles_value1", "roles_value2"], + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListAudiencesResponse( - next_page_token="next_page_token_value", + return_value = resources.AccessBinding( + name="name_value", + roles=["roles_value"], + user="user_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListAudiencesResponse.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_audiences(request) + response = client.update_access_binding(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAudiencesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.AccessBinding) + assert response.name == "name_value" + assert response.roles == ["roles_value"] -def test_list_audiences_rest_required_fields( - request_type=analytics_admin.ListAudiencesRequest, +def test_update_access_binding_rest_required_fields( + request_type=analytics_admin.UpdateAccessBindingRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -45312,28 +52982,17 @@ def test_list_audiences_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_audiences._get_unset_required_fields(jsonified_request) + ).update_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_audiences._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).update_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45342,7 +53001,7 @@ def test_list_audiences_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListAudiencesResponse() + return_value = resources.AccessBinding() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -45354,46 +53013,39 @@ def test_list_audiences_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListAudiencesResponse.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_audiences(request) + response = client.update_access_binding(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_audiences_rest_unset_required_fields(): +def test_update_access_binding_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_audiences._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.update_access_binding._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("accessBinding",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_audiences_rest_interceptors(null_interceptor): +def test_update_access_binding_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -45406,14 +53058,14 @@ def test_list_audiences_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_audiences" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_access_binding" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_audiences" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_access_binding" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListAudiencesRequest.pb( - analytics_admin.ListAudiencesRequest() + pb_message = analytics_admin.UpdateAccessBindingRequest.pb( + analytics_admin.UpdateAccessBindingRequest() ) transcode.return_value = { "method": "post", @@ -45425,19 +53077,19 @@ def test_list_audiences_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.ListAudiencesResponse.to_json( - analytics_admin.ListAudiencesResponse() + req.return_value._content = resources.AccessBinding.to_json( + resources.AccessBinding() ) - request = analytics_admin.ListAudiencesRequest() + request = analytics_admin.UpdateAccessBindingRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListAudiencesResponse() + post.return_value = resources.AccessBinding() - client.list_audiences( + client.update_access_binding( request, metadata=[ ("key", "val"), @@ -45449,8 +53101,8 @@ def test_list_audiences_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_audiences_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListAudiencesRequest +def test_update_access_binding_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateAccessBindingRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45458,7 +53110,14 @@ def test_list_audiences_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = { + "access_binding": {"name": "accounts/sample1/accessBindings/sample2"} + } + request_init["access_binding"] = { + "user": "user_value", + "name": "accounts/sample1/accessBindings/sample2", + "roles": ["roles_value1", "roles_value2"], + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -45470,10 +53129,10 @@ def test_list_audiences_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_audiences(request) + client.update_access_binding(request) -def test_list_audiences_rest_flattened(): +def test_update_access_binding_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -45482,38 +53141,41 @@ def test_list_audiences_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListAudiencesResponse() + return_value = resources.AccessBinding() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = { + "access_binding": {"name": "accounts/sample1/accessBindings/sample2"} + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", + access_binding=resources.AccessBinding(user="user_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListAudiencesResponse.pb(return_value) + pb_return_value = resources.AccessBinding.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_audiences(**mock_args) + client.update_access_binding(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/audiences" % client.transport._host, + "%s/v1alpha/{access_binding.name=accounts/*/accessBindings/*}" + % client.transport._host, args[1], ) -def test_list_audiences_rest_flattened_error(transport: str = "rest"): +def test_update_access_binding_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -45522,194 +53184,60 @@ def test_list_audiences_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_audiences( - analytics_admin.ListAudiencesRequest(), - parent="parent_value", + client.update_access_binding( + analytics_admin.UpdateAccessBindingRequest(), + access_binding=resources.AccessBinding(user="user_value"), ) -def test_list_audiences_rest_pager(transport: str = "rest"): +def test_update_access_binding_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListAudiencesResponse( - audiences=[ - audience.Audience(), - audience.Audience(), - audience.Audience(), - ], - next_page_token="abc", - ), - analytics_admin.ListAudiencesResponse( - audiences=[], - next_page_token="def", - ), - analytics_admin.ListAudiencesResponse( - audiences=[ - audience.Audience(), - ], - next_page_token="ghi", - ), - analytics_admin.ListAudiencesResponse( - audiences=[ - audience.Audience(), - audience.Audience(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListAudiencesResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1"} - - pager = client.list_audiences(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, audience.Audience) for i in results) - - pages = list(client.list_audiences(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateAudienceRequest, + analytics_admin.DeleteAccessBindingRequest, dict, ], ) -def test_create_audience_rest(request_type): +def test_delete_access_binding_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["audience"] = { - "name": "name_value", - "display_name": "display_name_value", - "description": "description_value", - "membership_duration_days": 2561, - "ads_personalization_enabled": True, - "event_trigger": {"event_name": "event_name_value", "log_condition": 1}, - "exclusion_duration_mode": 1, - "filter_clauses": [ - { - "simple_filter": { - "scope": 1, - "filter_expression": { - "and_group": {"filter_expressions": {}}, - "or_group": {}, - "not_expression": {}, - "dimension_or_metric_filter": { - "string_filter": { - "match_type": 1, - "value": "value_value", - "case_sensitive": True, - }, - "in_list_filter": { - "values": ["values_value1", "values_value2"], - "case_sensitive": True, - }, - "numeric_filter": { - "operation": 1, - "value": { - "int64_value": 1073, - "double_value": 0.12710000000000002, - }, - }, - "between_filter": {"from_value": {}, "to_value": {}}, - "field_name": "field_name_value", - "at_any_point_in_time": True, - "in_any_n_day_period": 1994, - }, - "event_filter": { - "event_name": "event_name_value", - "event_parameter_filter_expression": {}, - }, - }, - }, - "sequence_filter": { - "scope": 1, - "sequence_maximum_duration": {"seconds": 751, "nanos": 543}, - "sequence_steps": [ - { - "scope": 1, - "immediately_follows": True, - "constraint_duration": {}, - "filter_expression": {}, - } - ], - }, - "clause_type": 1, - } - ], - } + request_init = {"name": "accounts/sample1/accessBindings/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gaa_audience.Audience( - name="name_value", - display_name="display_name_value", - description="description_value", - membership_duration_days=2561, - ads_personalization_enabled=True, - exclusion_duration_mode=gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY, - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_audience.Audience.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_audience(request) + response = client.delete_access_binding(request) # Establish that the response is the type that we expect. - assert isinstance(response, gaa_audience.Audience) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.membership_duration_days == 2561 - assert response.ads_personalization_enabled is True - assert ( - response.exclusion_duration_mode - == gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY - ) + assert response is None -def test_create_audience_rest_required_fields( - request_type=analytics_admin.CreateAudienceRequest, +def test_delete_access_binding_rest_required_fields( + request_type=analytics_admin.DeleteAccessBindingRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -45724,21 +53252,21 @@ def test_create_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_audience._get_unset_required_fields(jsonified_request) + ).delete_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_audience._get_unset_required_fields(jsonified_request) + ).delete_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45747,7 +53275,7 @@ def test_create_audience_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = gaa_audience.Audience() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -45759,47 +53287,36 @@ def test_create_audience_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "delete", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - pb_return_value = gaa_audience.Audience.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_audience(request) + response = client.delete_access_binding(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_audience_rest_unset_required_fields(): +def test_delete_access_binding_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_audience._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "audience", - ) - ) - ) + unset_fields = transport.delete_access_binding._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_audience_rest_interceptors(null_interceptor): +def test_delete_access_binding_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -45812,14 +53329,11 @@ def test_create_audience_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_audience" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_audience" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_access_binding" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreateAudienceRequest.pb( - analytics_admin.CreateAudienceRequest() + pb_message = analytics_admin.DeleteAccessBindingRequest.pb( + analytics_admin.DeleteAccessBindingRequest() ) transcode.return_value = { "method": "post", @@ -45831,19 +53345,15 @@ def test_create_audience_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = gaa_audience.Audience.to_json( - gaa_audience.Audience() - ) - request = analytics_admin.CreateAudienceRequest() + request = analytics_admin.DeleteAccessBindingRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gaa_audience.Audience() - client.create_audience( + client.delete_access_binding( request, metadata=[ ("key", "val"), @@ -45852,11 +53362,10 @@ def test_create_audience_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_audience_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateAudienceRequest +def test_delete_access_binding_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteAccessBindingRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45864,67 +53373,7 @@ def test_create_audience_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["audience"] = { - "name": "name_value", - "display_name": "display_name_value", - "description": "description_value", - "membership_duration_days": 2561, - "ads_personalization_enabled": True, - "event_trigger": {"event_name": "event_name_value", "log_condition": 1}, - "exclusion_duration_mode": 1, - "filter_clauses": [ - { - "simple_filter": { - "scope": 1, - "filter_expression": { - "and_group": {"filter_expressions": {}}, - "or_group": {}, - "not_expression": {}, - "dimension_or_metric_filter": { - "string_filter": { - "match_type": 1, - "value": "value_value", - "case_sensitive": True, - }, - "in_list_filter": { - "values": ["values_value1", "values_value2"], - "case_sensitive": True, - }, - "numeric_filter": { - "operation": 1, - "value": { - "int64_value": 1073, - "double_value": 0.12710000000000002, - }, - }, - "between_filter": {"from_value": {}, "to_value": {}}, - "field_name": "field_name_value", - "at_any_point_in_time": True, - "in_any_n_day_period": 1994, - }, - "event_filter": { - "event_name": "event_name_value", - "event_parameter_filter_expression": {}, - }, - }, - }, - "sequence_filter": { - "scope": 1, - "sequence_maximum_duration": {"seconds": 751, "nanos": 543}, - "sequence_steps": [ - { - "scope": 1, - "immediately_follows": True, - "constraint_duration": {}, - "filter_expression": {}, - } - ], - }, - "clause_type": 1, - } - ], - } + request_init = {"name": "accounts/sample1/accessBindings/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -45936,10 +53385,10 @@ def test_create_audience_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_audience(request) + client.delete_access_binding(request) -def test_create_audience_rest_flattened(): +def test_delete_access_binding_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -45948,39 +53397,37 @@ def test_create_audience_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gaa_audience.Audience() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "accounts/sample1/accessBindings/sample2"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - audience=gaa_audience.Audience(name="name_value"), + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_audience.Audience.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_audience(**mock_args) + client.delete_access_binding(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/audiences" % client.transport._host, + "%s/v1alpha/{name=accounts/*/accessBindings/*}" % client.transport._host, args[1], ) -def test_create_audience_rest_flattened_error(transport: str = "rest"): +def test_delete_access_binding_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -45989,14 +53436,13 @@ def test_create_audience_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_audience( - analytics_admin.CreateAudienceRequest(), - parent="parent_value", - audience=gaa_audience.Audience(name="name_value"), + client.delete_access_binding( + analytics_admin.DeleteAccessBindingRequest(), + name="name_value", ) -def test_create_audience_rest_error(): +def test_delete_access_binding_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -46005,121 +53451,49 @@ def test_create_audience_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateAudienceRequest, + analytics_admin.ListAccessBindingsRequest, dict, ], ) -def test_update_audience_rest(request_type): +def test_list_access_bindings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"audience": {"name": "properties/sample1/audiences/sample2"}} - request_init["audience"] = { - "name": "properties/sample1/audiences/sample2", - "display_name": "display_name_value", - "description": "description_value", - "membership_duration_days": 2561, - "ads_personalization_enabled": True, - "event_trigger": {"event_name": "event_name_value", "log_condition": 1}, - "exclusion_duration_mode": 1, - "filter_clauses": [ - { - "simple_filter": { - "scope": 1, - "filter_expression": { - "and_group": {"filter_expressions": {}}, - "or_group": {}, - "not_expression": {}, - "dimension_or_metric_filter": { - "string_filter": { - "match_type": 1, - "value": "value_value", - "case_sensitive": True, - }, - "in_list_filter": { - "values": ["values_value1", "values_value2"], - "case_sensitive": True, - }, - "numeric_filter": { - "operation": 1, - "value": { - "int64_value": 1073, - "double_value": 0.12710000000000002, - }, - }, - "between_filter": {"from_value": {}, "to_value": {}}, - "field_name": "field_name_value", - "at_any_point_in_time": True, - "in_any_n_day_period": 1994, - }, - "event_filter": { - "event_name": "event_name_value", - "event_parameter_filter_expression": {}, - }, - }, - }, - "sequence_filter": { - "scope": 1, - "sequence_maximum_duration": {"seconds": 751, "nanos": 543}, - "sequence_steps": [ - { - "scope": 1, - "immediately_follows": True, - "constraint_duration": {}, - "filter_expression": {}, - } - ], - }, - "clause_type": 1, - } - ], - } + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gaa_audience.Audience( - name="name_value", - display_name="display_name_value", - description="description_value", - membership_duration_days=2561, - ads_personalization_enabled=True, - exclusion_duration_mode=gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY, + return_value = analytics_admin.ListAccessBindingsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_audience.Audience.pb(return_value) + pb_return_value = analytics_admin.ListAccessBindingsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_audience(request) + response = client.list_access_bindings(request) # Establish that the response is the type that we expect. - assert isinstance(response, gaa_audience.Audience) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.membership_duration_days == 2561 - assert response.ads_personalization_enabled is True - assert ( - response.exclusion_duration_mode - == gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY - ) + assert isinstance(response, pagers.ListAccessBindingsPager) + assert response.next_page_token == "next_page_token_value" -def test_update_audience_rest_required_fields( - request_type=analytics_admin.UpdateAudienceRequest, +def test_list_access_bindings_rest_required_fields( + request_type=analytics_admin.ListAccessBindingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -46134,19 +53508,28 @@ def test_update_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_audience._get_unset_required_fields(jsonified_request) + ).list_access_bindings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_audience._get_unset_required_fields(jsonified_request) + ).list_access_bindings._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46155,7 +53538,7 @@ def test_update_audience_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = gaa_audience.Audience() + return_value = analytics_admin.ListAccessBindingsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -46167,47 +53550,48 @@ def test_update_audience_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_audience.Audience.pb(return_value) + pb_return_value = analytics_admin.ListAccessBindingsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_audience(request) + response = client.list_access_bindings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_audience_rest_unset_required_fields(): +def test_list_access_bindings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_audience._get_unset_required_fields({}) + unset_fields = transport.list_access_bindings._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("updateMask",)) - & set( + set( ( - "audience", - "updateMask", + "pageSize", + "pageToken", ) ) + & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_audience_rest_interceptors(null_interceptor): +def test_list_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -46220,14 +53604,14 @@ def test_update_audience_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_audience" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_access_bindings" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_audience" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_access_bindings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateAudienceRequest.pb( - analytics_admin.UpdateAudienceRequest() + pb_message = analytics_admin.ListAccessBindingsRequest.pb( + analytics_admin.ListAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -46239,19 +53623,19 @@ def test_update_audience_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = gaa_audience.Audience.to_json( - gaa_audience.Audience() + req.return_value._content = analytics_admin.ListAccessBindingsResponse.to_json( + analytics_admin.ListAccessBindingsResponse() ) - request = analytics_admin.UpdateAudienceRequest() + request = analytics_admin.ListAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gaa_audience.Audience() + post.return_value = analytics_admin.ListAccessBindingsResponse() - client.update_audience( + client.list_access_bindings( request, metadata=[ ("key", "val"), @@ -46263,8 +53647,8 @@ def test_update_audience_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_audience_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateAudienceRequest +def test_list_access_bindings_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListAccessBindingsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46272,67 +53656,7 @@ def test_update_audience_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"audience": {"name": "properties/sample1/audiences/sample2"}} - request_init["audience"] = { - "name": "properties/sample1/audiences/sample2", - "display_name": "display_name_value", - "description": "description_value", - "membership_duration_days": 2561, - "ads_personalization_enabled": True, - "event_trigger": {"event_name": "event_name_value", "log_condition": 1}, - "exclusion_duration_mode": 1, - "filter_clauses": [ - { - "simple_filter": { - "scope": 1, - "filter_expression": { - "and_group": {"filter_expressions": {}}, - "or_group": {}, - "not_expression": {}, - "dimension_or_metric_filter": { - "string_filter": { - "match_type": 1, - "value": "value_value", - "case_sensitive": True, - }, - "in_list_filter": { - "values": ["values_value1", "values_value2"], - "case_sensitive": True, - }, - "numeric_filter": { - "operation": 1, - "value": { - "int64_value": 1073, - "double_value": 0.12710000000000002, - }, - }, - "between_filter": {"from_value": {}, "to_value": {}}, - "field_name": "field_name_value", - "at_any_point_in_time": True, - "in_any_n_day_period": 1994, - }, - "event_filter": { - "event_name": "event_name_value", - "event_parameter_filter_expression": {}, - }, - }, - }, - "sequence_filter": { - "scope": 1, - "sequence_maximum_duration": {"seconds": 751, "nanos": 543}, - "sequence_steps": [ - { - "scope": 1, - "immediately_follows": True, - "constraint_duration": {}, - "filter_expression": {}, - } - ], - }, - "clause_type": 1, - } - ], - } + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -46344,10 +53668,10 @@ def test_update_audience_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_audience(request) + client.list_access_bindings(request) -def test_update_audience_rest_flattened(): +def test_list_access_bindings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -46356,40 +53680,38 @@ def test_update_audience_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gaa_audience.Audience() + return_value = analytics_admin.ListAccessBindingsResponse() # get arguments that satisfy an http rule for this method - sample_request = {"audience": {"name": "properties/sample1/audiences/sample2"}} + sample_request = {"parent": "accounts/sample1"} # get truthy value for each flattened field mock_args = dict( - audience=gaa_audience.Audience(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_audience.Audience.pb(return_value) + pb_return_value = analytics_admin.ListAccessBindingsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_audience(**mock_args) + client.list_access_bindings(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{audience.name=properties/*/audiences/*}" - % client.transport._host, + "%s/v1alpha/{parent=accounts/*}/accessBindings" % client.transport._host, args[1], ) -def test_update_audience_rest_flattened_error(transport: str = "rest"): +def test_list_access_bindings_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -46398,61 +53720,120 @@ def test_update_audience_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_audience( - analytics_admin.UpdateAudienceRequest(), - audience=gaa_audience.Audience(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.list_access_bindings( + analytics_admin.ListAccessBindingsRequest(), + parent="parent_value", ) -def test_update_audience_rest_error(): +def test_list_access_bindings_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + resources.AccessBinding(), + ], + next_page_token="abc", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[], + next_page_token="def", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAccessBindingsResponse( + access_bindings=[ + resources.AccessBinding(), + resources.AccessBinding(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListAccessBindingsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "accounts/sample1"} + + pager = client.list_access_bindings(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.AccessBinding) for i in results) + + pages = list(client.list_access_bindings(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.ArchiveAudienceRequest, + analytics_admin.BatchCreateAccessBindingsRequest, dict, ], ) -def test_archive_audience_rest(request_type): +def test_batch_create_access_bindings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/audiences/sample2"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = analytics_admin.BatchCreateAccessBindingsResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = analytics_admin.BatchCreateAccessBindingsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.archive_audience(request) + response = client.batch_create_access_bindings(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, analytics_admin.BatchCreateAccessBindingsResponse) -def test_archive_audience_rest_required_fields( - request_type=analytics_admin.ArchiveAudienceRequest, +def test_batch_create_access_bindings_rest_required_fields( + request_type=analytics_admin.BatchCreateAccessBindingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -46467,21 +53848,21 @@ def test_archive_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).archive_audience._get_unset_required_fields(jsonified_request) + ).batch_create_access_bindings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).archive_audience._get_unset_required_fields(jsonified_request) + ).batch_create_access_bindings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46490,7 +53871,7 @@ def test_archive_audience_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = analytics_admin.BatchCreateAccessBindingsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -46510,29 +53891,41 @@ def test_archive_audience_rest_required_fields( response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = analytics_admin.BatchCreateAccessBindingsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.archive_audience(request) + response = client.batch_create_access_bindings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_archive_audience_rest_unset_required_fields(): +def test_batch_create_access_bindings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.archive_audience._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.batch_create_access_bindings._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "requests", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_archive_audience_rest_interceptors(null_interceptor): +def test_batch_create_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -46545,11 +53938,16 @@ def test_archive_audience_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_archive_audience" + transports.AnalyticsAdminServiceRestInterceptor, + "post_batch_create_access_bindings", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_batch_create_access_bindings", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.ArchiveAudienceRequest.pb( - analytics_admin.ArchiveAudienceRequest() + post.assert_not_called() + pb_message = analytics_admin.BatchCreateAccessBindingsRequest.pb( + analytics_admin.BatchCreateAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -46561,15 +53959,21 @@ def test_archive_audience_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = ( + analytics_admin.BatchCreateAccessBindingsResponse.to_json( + analytics_admin.BatchCreateAccessBindingsResponse() + ) + ) - request = analytics_admin.ArchiveAudienceRequest() + request = analytics_admin.BatchCreateAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = analytics_admin.BatchCreateAccessBindingsResponse() - client.archive_audience( + client.batch_create_access_bindings( request, metadata=[ ("key", "val"), @@ -46578,10 +53982,12 @@ def test_archive_audience_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_archive_audience_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ArchiveAudienceRequest +def test_batch_create_access_bindings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.BatchCreateAccessBindingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46589,7 +53995,7 @@ def test_archive_audience_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/audiences/sample2"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -46601,10 +54007,10 @@ def test_archive_audience_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.archive_audience(request) + client.batch_create_access_bindings(request) -def test_archive_audience_rest_error(): +def test_batch_create_access_bindings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -46613,53 +54019,49 @@ def test_archive_audience_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetSearchAds360LinkRequest, + analytics_admin.BatchGetAccessBindingsRequest, dict, ], ) -def test_get_search_ads360_link_rest(request_type): +def test_batch_get_access_bindings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/searchAds360Links/sample2"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link( - name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", - ) + return_value = analytics_admin.BatchGetAccessBindingsResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.SearchAds360Link.pb(return_value) + pb_return_value = analytics_admin.BatchGetAccessBindingsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_search_ads360_link(request) + response = client.batch_get_access_bindings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.SearchAds360Link) - assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" + assert isinstance(response, analytics_admin.BatchGetAccessBindingsResponse) -def test_get_search_ads360_link_rest_required_fields( - request_type=analytics_admin.GetSearchAds360LinkRequest, +def test_batch_get_access_bindings_rest_required_fields( + request_type=analytics_admin.BatchGetAccessBindingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" + request_init["names"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -46671,24 +54073,32 @@ def test_get_search_ads360_link_rest_required_fields( ) # verify fields with default values are dropped + assert "names" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_search_ads360_link._get_unset_required_fields(jsonified_request) + ).batch_get_access_bindings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + assert "names" in jsonified_request + assert jsonified_request["names"] == request_init["names"] - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" + jsonified_request["names"] = "names_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_search_ads360_link._get_unset_required_fields(jsonified_request) + ).batch_get_access_bindings._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("names",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "names" in jsonified_request + assert jsonified_request["names"] == "names_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46697,7 +54107,7 @@ def test_get_search_ads360_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link() + return_value = analytics_admin.BatchGetAccessBindingsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -46717,30 +54127,46 @@ def test_get_search_ads360_link_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.SearchAds360Link.pb(return_value) + pb_return_value = analytics_admin.BatchGetAccessBindingsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_search_ads360_link(request) + response = client.batch_get_access_bindings(request) - expected_params = [("$alt", "json;enum-encoding=int")] + expected_params = [ + ( + "names", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_search_ads360_link_rest_unset_required_fields(): +def test_batch_get_access_bindings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_search_ads360_link._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.batch_get_access_bindings._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("names",)) + & set( + ( + "parent", + "names", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_search_ads360_link_rest_interceptors(null_interceptor): +def test_batch_get_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -46753,14 +54179,15 @@ def test_get_search_ads360_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_search_ads360_link" + transports.AnalyticsAdminServiceRestInterceptor, + "post_batch_get_access_bindings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_search_ads360_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_get_access_bindings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetSearchAds360LinkRequest.pb( - analytics_admin.GetSearchAds360LinkRequest() + pb_message = analytics_admin.BatchGetAccessBindingsRequest.pb( + analytics_admin.BatchGetAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -46772,19 +54199,21 @@ def test_get_search_ads360_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.SearchAds360Link.to_json( - resources.SearchAds360Link() + req.return_value._content = ( + analytics_admin.BatchGetAccessBindingsResponse.to_json( + analytics_admin.BatchGetAccessBindingsResponse() + ) ) - request = analytics_admin.GetSearchAds360LinkRequest() + request = analytics_admin.BatchGetAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.SearchAds360Link() + post.return_value = analytics_admin.BatchGetAccessBindingsResponse() - client.get_search_ads360_link( + client.batch_get_access_bindings( request, metadata=[ ("key", "val"), @@ -46795,9 +54224,9 @@ def test_get_search_ads360_link_rest_interceptors(null_interceptor): pre.assert_called_once() post.assert_called_once() - -def test_get_search_ads360_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetSearchAds360LinkRequest + +def test_batch_get_access_bindings_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchGetAccessBindingsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46805,7 +54234,7 @@ def test_get_search_ads360_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/searchAds360Links/sample2"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -46817,66 +54246,10 @@ def test_get_search_ads360_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_search_ads360_link(request) - - -def test_get_search_ads360_link_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link() - - # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/searchAds360Links/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.SearchAds360Link.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.get_search_ads360_link(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{name=properties/*/searchAds360Links/*}" - % client.transport._host, - args[1], - ) - - -def test_get_search_ads360_link_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_search_ads360_link( - analytics_admin.GetSearchAds360LinkRequest(), - name="name_value", - ) + client.batch_get_access_bindings(request) -def test_get_search_ads360_link_rest_error(): +def test_batch_get_access_bindings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -46885,44 +54258,43 @@ def test_get_search_ads360_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListSearchAds360LinksRequest, + analytics_admin.BatchUpdateAccessBindingsRequest, dict, ], ) -def test_list_search_ads360_links_rest(request_type): +def test_batch_update_access_bindings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListSearchAds360LinksResponse( - next_page_token="next_page_token_value", - ) + return_value = analytics_admin.BatchUpdateAccessBindingsResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListSearchAds360LinksResponse.pb(return_value) + pb_return_value = analytics_admin.BatchUpdateAccessBindingsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_search_ads360_links(request) + response = client.batch_update_access_bindings(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSearchAds360LinksPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, analytics_admin.BatchUpdateAccessBindingsResponse) -def test_list_search_ads360_links_rest_required_fields( - request_type=analytics_admin.ListSearchAds360LinksRequest, +def test_batch_update_access_bindings_rest_required_fields( + request_type=analytics_admin.BatchUpdateAccessBindingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -46942,7 +54314,7 @@ def test_list_search_ads360_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_search_ads360_links._get_unset_required_fields(jsonified_request) + ).batch_update_access_bindings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -46951,14 +54323,7 @@ def test_list_search_ads360_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_search_ads360_links._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).batch_update_access_bindings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -46972,7 +54337,7 @@ def test_list_search_ads360_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListSearchAds360LinksResponse() + return_value = analytics_admin.BatchUpdateAccessBindingsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -46984,15 +54349,16 @@ def test_list_search_ads360_links_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListSearchAds360LinksResponse.pb( + pb_return_value = analytics_admin.BatchUpdateAccessBindingsResponse.pb( return_value ) json_return_value = json_format.MessageToJson(pb_return_value) @@ -47000,32 +54366,32 @@ def test_list_search_ads360_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_search_ads360_links(request) + response = client.batch_update_access_bindings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_search_ads360_links_rest_unset_required_fields(): +def test_batch_update_access_bindings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_search_ads360_links._get_unset_required_fields({}) + unset_fields = transport.batch_update_access_bindings._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(()) + & set( ( - "pageSize", - "pageToken", + "parent", + "requests", ) ) - & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_search_ads360_links_rest_interceptors(null_interceptor): +def test_batch_update_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -47038,14 +54404,16 @@ def test_list_search_ads360_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_search_ads360_links" + transports.AnalyticsAdminServiceRestInterceptor, + "post_batch_update_access_bindings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_search_ads360_links" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_batch_update_access_bindings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListSearchAds360LinksRequest.pb( - analytics_admin.ListSearchAds360LinksRequest() + pb_message = analytics_admin.BatchUpdateAccessBindingsRequest.pb( + analytics_admin.BatchUpdateAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -47058,20 +54426,20 @@ def test_list_search_ads360_links_rest_interceptors(null_interceptor): req.return_value.status_code = 200 req.return_value.request = PreparedRequest() req.return_value._content = ( - analytics_admin.ListSearchAds360LinksResponse.to_json( - analytics_admin.ListSearchAds360LinksResponse() + analytics_admin.BatchUpdateAccessBindingsResponse.to_json( + analytics_admin.BatchUpdateAccessBindingsResponse() ) ) - request = analytics_admin.ListSearchAds360LinksRequest() + request = analytics_admin.BatchUpdateAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListSearchAds360LinksResponse() + post.return_value = analytics_admin.BatchUpdateAccessBindingsResponse() - client.list_search_ads360_links( + client.batch_update_access_bindings( request, metadata=[ ("key", "val"), @@ -47083,8 +54451,9 @@ def test_list_search_ads360_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_search_ads360_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListSearchAds360LinksRequest +def test_batch_update_access_bindings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.BatchUpdateAccessBindingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47092,7 +54461,7 @@ def test_list_search_ads360_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -47104,182 +54473,52 @@ def test_list_search_ads360_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_search_ads360_links(request) - - -def test_list_search_ads360_links_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListSearchAds360LinksResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = analytics_admin.ListSearchAds360LinksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_search_ads360_links(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/searchAds360Links" - % client.transport._host, - args[1], - ) + client.batch_update_access_bindings(request) -def test_list_search_ads360_links_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_search_ads360_links( - analytics_admin.ListSearchAds360LinksRequest(), - parent="parent_value", - ) - - -def test_list_search_ads360_links_rest_pager(transport: str = "rest"): +def test_batch_update_access_bindings_rest_error(): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - analytics_admin.ListSearchAds360LinksResponse( - search_ads_360_links=[ - resources.SearchAds360Link(), - resources.SearchAds360Link(), - resources.SearchAds360Link(), - ], - next_page_token="abc", - ), - analytics_admin.ListSearchAds360LinksResponse( - search_ads_360_links=[], - next_page_token="def", - ), - analytics_admin.ListSearchAds360LinksResponse( - search_ads_360_links=[ - resources.SearchAds360Link(), - ], - next_page_token="ghi", - ), - analytics_admin.ListSearchAds360LinksResponse( - search_ads_360_links=[ - resources.SearchAds360Link(), - resources.SearchAds360Link(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListSearchAds360LinksResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "properties/sample1"} - - pager = client.list_search_ads360_links(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.SearchAds360Link) for i in results) - - pages = list(client.list_search_ads360_links(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateSearchAds360LinkRequest, + analytics_admin.BatchDeleteAccessBindingsRequest, dict, ], ) -def test_create_search_ads360_link_rest(request_type): +def test_batch_delete_access_bindings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["search_ads_360_link"] = { - "name": "name_value", - "advertiser_id": "advertiser_id_value", - "campaign_data_sharing_enabled": {"value": True}, - "cost_data_sharing_enabled": {}, - "advertiser_display_name": "advertiser_display_name_value", - "ads_personalization_enabled": {}, - "site_stats_sharing_enabled": {}, - } + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link( - name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.SearchAds360Link.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_search_ads360_link(request) + response = client.batch_delete_access_bindings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.SearchAds360Link) - assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" + assert response is None -def test_create_search_ads360_link_rest_required_fields( - request_type=analytics_admin.CreateSearchAds360LinkRequest, +def test_batch_delete_access_bindings_rest_required_fields( + request_type=analytics_admin.BatchDeleteAccessBindingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -47299,7 +54538,7 @@ def test_create_search_ads360_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_search_ads360_link._get_unset_required_fields(jsonified_request) + ).batch_delete_access_bindings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -47308,7 +54547,7 @@ def test_create_search_ads360_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_search_ads360_link._get_unset_required_fields(jsonified_request) + ).batch_delete_access_bindings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -47322,7 +54561,7 @@ def test_create_search_ads360_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -47342,39 +54581,37 @@ def test_create_search_ads360_link_rest_required_fields( response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.SearchAds360Link.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_search_ads360_link(request) + response = client.batch_delete_access_bindings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_search_ads360_link_rest_unset_required_fields(): +def test_batch_delete_access_bindings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_search_ads360_link._get_unset_required_fields({}) + unset_fields = transport.batch_delete_access_bindings._get_unset_required_fields({}) assert set(unset_fields) == ( set(()) & set( ( "parent", - "searchAds360Link", + "requests", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_search_ads360_link_rest_interceptors(null_interceptor): +def test_batch_delete_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -47388,14 +54625,11 @@ def test_create_search_ads360_link_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_create_search_ads360_link", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_search_ads360_link" + "pre_batch_delete_access_bindings", ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreateSearchAds360LinkRequest.pb( - analytics_admin.CreateSearchAds360LinkRequest() + pb_message = analytics_admin.BatchDeleteAccessBindingsRequest.pb( + analytics_admin.BatchDeleteAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -47407,19 +54641,15 @@ def test_create_search_ads360_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.SearchAds360Link.to_json( - resources.SearchAds360Link() - ) - request = analytics_admin.CreateSearchAds360LinkRequest() + request = analytics_admin.BatchDeleteAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.SearchAds360Link() - client.create_search_ads360_link( + client.batch_delete_access_bindings( request, metadata=[ ("key", "val"), @@ -47428,11 +54658,11 @@ def test_create_search_ads360_link_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_search_ads360_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateSearchAds360LinkRequest +def test_batch_delete_access_bindings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.BatchDeleteAccessBindingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47440,16 +54670,7 @@ def test_create_search_ads360_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["search_ads_360_link"] = { - "name": "name_value", - "advertiser_id": "advertiser_id_value", - "campaign_data_sharing_enabled": {"value": True}, - "cost_data_sharing_enabled": {}, - "advertiser_display_name": "advertiser_display_name_value", - "ads_personalization_enabled": {}, - "site_stats_sharing_enabled": {}, - } + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -47461,68 +54682,10 @@ def test_create_search_ads360_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_search_ads360_link(request) - - -def test_create_search_ads360_link_rest_flattened(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - search_ads_360_link=resources.SearchAds360Link(name="name_value"), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.SearchAds360Link.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.create_search_ads360_link(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1alpha/{parent=properties/*}/searchAds360Links" - % client.transport._host, - args[1], - ) - - -def test_create_search_ads360_link_rest_flattened_error(transport: str = "rest"): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_search_ads360_link( - analytics_admin.CreateSearchAds360LinkRequest(), - parent="parent_value", - search_ads_360_link=resources.SearchAds360Link(name="name_value"), - ) + client.batch_delete_access_bindings(request) -def test_create_search_ads360_link_rest_error(): +def test_batch_delete_access_bindings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -47531,40 +54694,52 @@ def test_create_search_ads360_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteSearchAds360LinkRequest, + analytics_admin.GetExpandedDataSetRequest, dict, ], ) -def test_delete_search_ads360_link_rest(request_type): +def test_get_expanded_data_set_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/searchAds360Links/sample2"} + request_init = {"name": "properties/sample1/expandedDataSets/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = expanded_data_set.ExpandedDataSet( + name="name_value", + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = expanded_data_set.ExpandedDataSet.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_search_ads360_link(request) + response = client.get_expanded_data_set(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, expanded_data_set.ExpandedDataSet) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] -def test_delete_search_ads360_link_rest_required_fields( - request_type=analytics_admin.DeleteSearchAds360LinkRequest, +def test_get_expanded_data_set_rest_required_fields( + request_type=analytics_admin.GetExpandedDataSetRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -47584,7 +54759,7 @@ def test_delete_search_ads360_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_search_ads360_link._get_unset_required_fields(jsonified_request) + ).get_expanded_data_set._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -47593,7 +54768,7 @@ def test_delete_search_ads360_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_search_ads360_link._get_unset_required_fields(jsonified_request) + ).get_expanded_data_set._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -47607,7 +54782,7 @@ def test_delete_search_ads360_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = expanded_data_set.ExpandedDataSet() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -47619,36 +54794,38 @@ def test_delete_search_ads360_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "get", "query_params": pb_request, } transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = expanded_data_set.ExpandedDataSet.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_search_ads360_link(request) + response = client.get_expanded_data_set(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_search_ads360_link_rest_unset_required_fields(): +def test_get_expanded_data_set_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_search_ads360_link._get_unset_required_fields({}) + unset_fields = transport.get_expanded_data_set._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_search_ads360_link_rest_interceptors(null_interceptor): +def test_get_expanded_data_set_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -47661,11 +54838,14 @@ def test_delete_search_ads360_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_search_ads360_link" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_expanded_data_set" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_expanded_data_set" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteSearchAds360LinkRequest.pb( - analytics_admin.DeleteSearchAds360LinkRequest() + post.assert_not_called() + pb_message = analytics_admin.GetExpandedDataSetRequest.pb( + analytics_admin.GetExpandedDataSetRequest() ) transcode.return_value = { "method": "post", @@ -47677,15 +54857,19 @@ def test_delete_search_ads360_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = expanded_data_set.ExpandedDataSet.to_json( + expanded_data_set.ExpandedDataSet() + ) - request = analytics_admin.DeleteSearchAds360LinkRequest() + request = analytics_admin.GetExpandedDataSetRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = expanded_data_set.ExpandedDataSet() - client.delete_search_ads360_link( + client.get_expanded_data_set( request, metadata=[ ("key", "val"), @@ -47694,10 +54878,11 @@ def test_delete_search_ads360_link_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_search_ads360_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteSearchAds360LinkRequest +def test_get_expanded_data_set_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetExpandedDataSetRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47705,7 +54890,7 @@ def test_delete_search_ads360_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/searchAds360Links/sample2"} + request_init = {"name": "properties/sample1/expandedDataSets/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -47717,10 +54902,10 @@ def test_delete_search_ads360_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_search_ads360_link(request) + client.get_expanded_data_set(request) -def test_delete_search_ads360_link_rest_flattened(): +def test_get_expanded_data_set_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -47729,10 +54914,10 @@ def test_delete_search_ads360_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = expanded_data_set.ExpandedDataSet() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/searchAds360Links/sample2"} + sample_request = {"name": "properties/sample1/expandedDataSets/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -47743,24 +54928,25 @@ def test_delete_search_ads360_link_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = expanded_data_set.ExpandedDataSet.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_search_ads360_link(**mock_args) + client.get_expanded_data_set(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/searchAds360Links/*}" + "%s/v1alpha/{name=properties/*/expandedDataSets/*}" % client.transport._host, args[1], ) -def test_delete_search_ads360_link_rest_flattened_error(transport: str = "rest"): +def test_get_expanded_data_set_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -47769,13 +54955,13 @@ def test_delete_search_ads360_link_rest_flattened_error(transport: str = "rest") # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_search_ads360_link( - analytics_admin.DeleteSearchAds360LinkRequest(), + client.get_expanded_data_set( + analytics_admin.GetExpandedDataSetRequest(), name="name_value", ) -def test_delete_search_ads360_link_rest_error(): +def test_get_expanded_data_set_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -47784,63 +54970,49 @@ def test_delete_search_ads360_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateSearchAds360LinkRequest, + analytics_admin.ListExpandedDataSetsRequest, dict, ], ) -def test_update_search_ads360_link_rest(request_type): +def test_list_expanded_data_sets_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "search_ads_360_link": {"name": "properties/sample1/searchAds360Links/sample2"} - } - request_init["search_ads_360_link"] = { - "name": "properties/sample1/searchAds360Links/sample2", - "advertiser_id": "advertiser_id_value", - "campaign_data_sharing_enabled": {"value": True}, - "cost_data_sharing_enabled": {}, - "advertiser_display_name": "advertiser_display_name_value", - "ads_personalization_enabled": {}, - "site_stats_sharing_enabled": {}, - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link( - name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", + return_value = analytics_admin.ListExpandedDataSetsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.SearchAds360Link.pb(return_value) + pb_return_value = analytics_admin.ListExpandedDataSetsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_search_ads360_link(request) + response = client.list_expanded_data_sets(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.SearchAds360Link) - assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" + assert isinstance(response, pagers.ListExpandedDataSetsPager) + assert response.next_page_token == "next_page_token_value" -def test_update_search_ads360_link_rest_required_fields( - request_type=analytics_admin.UpdateSearchAds360LinkRequest, +def test_list_expanded_data_sets_rest_required_fields( + request_type=analytics_admin.ListExpandedDataSetsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -47855,19 +55027,28 @@ def test_update_search_ads360_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_search_ads360_link._get_unset_required_fields(jsonified_request) + ).list_expanded_data_sets._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_search_ads360_link._get_unset_required_fields(jsonified_request) + ).list_expanded_data_sets._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47876,7 +55057,7 @@ def test_update_search_ads360_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link() + return_value = analytics_admin.ListExpandedDataSetsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -47888,39 +55069,48 @@ def test_update_search_ads360_link_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.SearchAds360Link.pb(return_value) + pb_return_value = analytics_admin.ListExpandedDataSetsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_search_ads360_link(request) + response = client.list_expanded_data_sets(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_search_ads360_link_rest_unset_required_fields(): +def test_list_expanded_data_sets_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_search_ads360_link._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) + unset_fields = transport.list_expanded_data_sets._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_search_ads360_link_rest_interceptors(null_interceptor): +def test_list_expanded_data_sets_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -47933,15 +55123,14 @@ def test_update_search_ads360_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_update_search_ads360_link", + transports.AnalyticsAdminServiceRestInterceptor, "post_list_expanded_data_sets" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_search_ads360_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_expanded_data_sets" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateSearchAds360LinkRequest.pb( - analytics_admin.UpdateSearchAds360LinkRequest() + pb_message = analytics_admin.ListExpandedDataSetsRequest.pb( + analytics_admin.ListExpandedDataSetsRequest() ) transcode.return_value = { "method": "post", @@ -47953,19 +55142,21 @@ def test_update_search_ads360_link_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.SearchAds360Link.to_json( - resources.SearchAds360Link() + req.return_value._content = ( + analytics_admin.ListExpandedDataSetsResponse.to_json( + analytics_admin.ListExpandedDataSetsResponse() + ) ) - request = analytics_admin.UpdateSearchAds360LinkRequest() + request = analytics_admin.ListExpandedDataSetsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.SearchAds360Link() + post.return_value = analytics_admin.ListExpandedDataSetsResponse() - client.update_search_ads360_link( + client.list_expanded_data_sets( request, metadata=[ ("key", "val"), @@ -47977,8 +55168,8 @@ def test_update_search_ads360_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_search_ads360_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateSearchAds360LinkRequest +def test_list_expanded_data_sets_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListExpandedDataSetsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47986,18 +55177,7 @@ def test_update_search_ads360_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "search_ads_360_link": {"name": "properties/sample1/searchAds360Links/sample2"} - } - request_init["search_ads_360_link"] = { - "name": "properties/sample1/searchAds360Links/sample2", - "advertiser_id": "advertiser_id_value", - "campaign_data_sharing_enabled": {"value": True}, - "cost_data_sharing_enabled": {}, - "advertiser_display_name": "advertiser_display_name_value", - "ads_personalization_enabled": {}, - "site_stats_sharing_enabled": {}, - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -48009,10 +55189,10 @@ def test_update_search_ads360_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_search_ads360_link(request) + client.list_expanded_data_sets(request) -def test_update_search_ads360_link_rest_flattened(): +def test_list_expanded_data_sets_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -48021,44 +55201,39 @@ def test_update_search_ads360_link_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.SearchAds360Link() + return_value = analytics_admin.ListExpandedDataSetsResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "search_ads_360_link": { - "name": "properties/sample1/searchAds360Links/sample2" - } - } + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - search_ads_360_link=resources.SearchAds360Link(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.SearchAds360Link.pb(return_value) + pb_return_value = analytics_admin.ListExpandedDataSetsResponse.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_search_ads360_link(**mock_args) + client.list_expanded_data_sets(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{search_ads_360_link.name=properties/*/searchAds360Links/*}" + "%s/v1alpha/{parent=properties/*}/expandedDataSets" % client.transport._host, args[1], ) -def test_update_search_ads360_link_rest_flattened_error(transport: str = "rest"): +def test_list_expanded_data_sets_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -48067,80 +55242,153 @@ def test_update_search_ads360_link_rest_flattened_error(transport: str = "rest") # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_search_ads360_link( - analytics_admin.UpdateSearchAds360LinkRequest(), - search_ads_360_link=resources.SearchAds360Link(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.list_expanded_data_sets( + analytics_admin.ListExpandedDataSetsRequest(), + parent="parent_value", ) -def test_update_search_ads360_link_rest_error(): +def test_list_expanded_data_sets_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="abc", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[], + next_page_token="def", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + ], + next_page_token="ghi", + ), + analytics_admin.ListExpandedDataSetsResponse( + expanded_data_sets=[ + expanded_data_set.ExpandedDataSet(), + expanded_data_set.ExpandedDataSet(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListExpandedDataSetsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "properties/sample1"} + + pager = client.list_expanded_data_sets(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, expanded_data_set.ExpandedDataSet) for i in results) + + pages = list(client.list_expanded_data_sets(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetAttributionSettingsRequest, + analytics_admin.CreateExpandedDataSetRequest, dict, ], ) -def test_get_attribution_settings_rest(request_type): +def test_create_expanded_data_set_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/attributionSettings"} + request_init = {"parent": "properties/sample1"} + request_init["expanded_data_set"] = { + "name": "name_value", + "display_name": "display_name_value", + "description": "description_value", + "dimension_names": ["dimension_names_value1", "dimension_names_value2"], + "metric_names": ["metric_names_value1", "metric_names_value2"], + "dimension_filter_expression": { + "and_group": {"filter_expressions": {}}, + "not_expression": {}, + "filter": { + "string_filter": { + "match_type": 1, + "value": "value_value", + "case_sensitive": True, + }, + "in_list_filter": { + "values": ["values_value1", "values_value2"], + "case_sensitive": True, + }, + "field_name": "field_name_value", + }, + }, + "data_collection_start_time": {"seconds": 751, "nanos": 543}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.AttributionSettings( + return_value = gaa_expanded_data_set.ExpandedDataSet( name="name_value", - acquisition_conversion_event_lookback_window=resources.AttributionSettings.AcquisitionConversionEventLookbackWindow.ACQUISITION_CONVERSION_EVENT_LOOKBACK_WINDOW_7_DAYS, - other_conversion_event_lookback_window=resources.AttributionSettings.OtherConversionEventLookbackWindow.OTHER_CONVERSION_EVENT_LOOKBACK_WINDOW_30_DAYS, - reporting_attribution_model=resources.AttributionSettings.ReportingAttributionModel.CROSS_CHANNEL_DATA_DRIVEN, + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AttributionSettings.pb(return_value) + pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_attribution_settings(request) + response = client.create_expanded_data_set(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.AttributionSettings) + assert isinstance(response, gaa_expanded_data_set.ExpandedDataSet) assert response.name == "name_value" - assert ( - response.acquisition_conversion_event_lookback_window - == resources.AttributionSettings.AcquisitionConversionEventLookbackWindow.ACQUISITION_CONVERSION_EVENT_LOOKBACK_WINDOW_7_DAYS - ) - assert ( - response.other_conversion_event_lookback_window - == resources.AttributionSettings.OtherConversionEventLookbackWindow.OTHER_CONVERSION_EVENT_LOOKBACK_WINDOW_30_DAYS - ) - assert ( - response.reporting_attribution_model - == resources.AttributionSettings.ReportingAttributionModel.CROSS_CHANNEL_DATA_DRIVEN - ) + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] -def test_get_attribution_settings_rest_required_fields( - request_type=analytics_admin.GetAttributionSettingsRequest, +def test_create_expanded_data_set_rest_required_fields( + request_type=analytics_admin.CreateExpandedDataSetRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -48155,21 +55403,21 @@ def test_get_attribution_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_attribution_settings._get_unset_required_fields(jsonified_request) + ).create_expanded_data_set._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_attribution_settings._get_unset_required_fields(jsonified_request) + ).create_expanded_data_set._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -48178,7 +55426,7 @@ def test_get_attribution_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.AttributionSettings() + return_value = gaa_expanded_data_set.ExpandedDataSet() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -48190,38 +55438,47 @@ def test_get_attribution_settings_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AttributionSettings.pb(return_value) + pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_attribution_settings(request) + response = client.create_expanded_data_set(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_attribution_settings_rest_unset_required_fields(): +def test_create_expanded_data_set_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_attribution_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.create_expanded_data_set._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "expandedDataSet", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_attribution_settings_rest_interceptors(null_interceptor): +def test_create_expanded_data_set_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -48234,14 +55491,14 @@ def test_get_attribution_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_attribution_settings" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_expanded_data_set" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_attribution_settings" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_expanded_data_set" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetAttributionSettingsRequest.pb( - analytics_admin.GetAttributionSettingsRequest() + pb_message = analytics_admin.CreateExpandedDataSetRequest.pb( + analytics_admin.CreateExpandedDataSetRequest() ) transcode.return_value = { "method": "post", @@ -48253,19 +55510,19 @@ def test_get_attribution_settings_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.AttributionSettings.to_json( - resources.AttributionSettings() + req.return_value._content = gaa_expanded_data_set.ExpandedDataSet.to_json( + gaa_expanded_data_set.ExpandedDataSet() ) - request = analytics_admin.GetAttributionSettingsRequest() + request = analytics_admin.CreateExpandedDataSetRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.AttributionSettings() + post.return_value = gaa_expanded_data_set.ExpandedDataSet() - client.get_attribution_settings( + client.create_expanded_data_set( request, metadata=[ ("key", "val"), @@ -48277,8 +55534,8 @@ def test_get_attribution_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_attribution_settings_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetAttributionSettingsRequest +def test_create_expanded_data_set_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateExpandedDataSetRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -48286,7 +55543,31 @@ def test_get_attribution_settings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/attributionSettings"} + request_init = {"parent": "properties/sample1"} + request_init["expanded_data_set"] = { + "name": "name_value", + "display_name": "display_name_value", + "description": "description_value", + "dimension_names": ["dimension_names_value1", "dimension_names_value2"], + "metric_names": ["metric_names_value1", "metric_names_value2"], + "dimension_filter_expression": { + "and_group": {"filter_expressions": {}}, + "not_expression": {}, + "filter": { + "string_filter": { + "match_type": 1, + "value": "value_value", + "case_sensitive": True, + }, + "in_list_filter": { + "values": ["values_value1", "values_value2"], + "case_sensitive": True, + }, + "field_name": "field_name_value", + }, + }, + "data_collection_start_time": {"seconds": 751, "nanos": 543}, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -48298,10 +55579,10 @@ def test_get_attribution_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_attribution_settings(request) + client.create_expanded_data_set(request) -def test_get_attribution_settings_rest_flattened(): +def test_create_expanded_data_set_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -48310,39 +55591,40 @@ def test_get_attribution_settings_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.AttributionSettings() + return_value = gaa_expanded_data_set.ExpandedDataSet() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/attributionSettings"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AttributionSettings.pb(return_value) + pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_attribution_settings(**mock_args) + client.create_expanded_data_set(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{name=properties/*/attributionSettings}" + "%s/v1alpha/{parent=properties/*}/expandedDataSets" % client.transport._host, args[1], ) -def test_get_attribution_settings_rest_flattened_error(transport: str = "rest"): +def test_create_expanded_data_set_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -48351,13 +55633,14 @@ def test_get_attribution_settings_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_attribution_settings( - analytics_admin.GetAttributionSettingsRequest(), - name="name_value", + client.create_expanded_data_set( + analytics_admin.CreateExpandedDataSetRequest(), + parent="parent_value", + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), ) -def test_get_attribution_settings_rest_error(): +def test_create_expanded_data_set_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -48366,11 +55649,11 @@ def test_get_attribution_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateAttributionSettingsRequest, + analytics_admin.UpdateExpandedDataSetRequest, dict, ], ) -def test_update_attribution_settings_rest(request_type): +def test_update_expanded_data_set_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -48378,55 +55661,66 @@ def test_update_attribution_settings_rest(request_type): # send a request that will satisfy transcoding request_init = { - "attribution_settings": {"name": "properties/sample1/attributionSettings"} + "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} } - request_init["attribution_settings"] = { - "name": "properties/sample1/attributionSettings", - "acquisition_conversion_event_lookback_window": 1, - "other_conversion_event_lookback_window": 1, - "reporting_attribution_model": 1, + request_init["expanded_data_set"] = { + "name": "properties/sample1/expandedDataSets/sample2", + "display_name": "display_name_value", + "description": "description_value", + "dimension_names": ["dimension_names_value1", "dimension_names_value2"], + "metric_names": ["metric_names_value1", "metric_names_value2"], + "dimension_filter_expression": { + "and_group": {"filter_expressions": {}}, + "not_expression": {}, + "filter": { + "string_filter": { + "match_type": 1, + "value": "value_value", + "case_sensitive": True, + }, + "in_list_filter": { + "values": ["values_value1", "values_value2"], + "case_sensitive": True, + }, + "field_name": "field_name_value", + }, + }, + "data_collection_start_time": {"seconds": 751, "nanos": 543}, } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.AttributionSettings( + return_value = gaa_expanded_data_set.ExpandedDataSet( name="name_value", - acquisition_conversion_event_lookback_window=resources.AttributionSettings.AcquisitionConversionEventLookbackWindow.ACQUISITION_CONVERSION_EVENT_LOOKBACK_WINDOW_7_DAYS, - other_conversion_event_lookback_window=resources.AttributionSettings.OtherConversionEventLookbackWindow.OTHER_CONVERSION_EVENT_LOOKBACK_WINDOW_30_DAYS, - reporting_attribution_model=resources.AttributionSettings.ReportingAttributionModel.CROSS_CHANNEL_DATA_DRIVEN, + display_name="display_name_value", + description="description_value", + dimension_names=["dimension_names_value"], + metric_names=["metric_names_value"], ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AttributionSettings.pb(return_value) + pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_attribution_settings(request) + response = client.update_expanded_data_set(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.AttributionSettings) + assert isinstance(response, gaa_expanded_data_set.ExpandedDataSet) assert response.name == "name_value" - assert ( - response.acquisition_conversion_event_lookback_window - == resources.AttributionSettings.AcquisitionConversionEventLookbackWindow.ACQUISITION_CONVERSION_EVENT_LOOKBACK_WINDOW_7_DAYS - ) - assert ( - response.other_conversion_event_lookback_window - == resources.AttributionSettings.OtherConversionEventLookbackWindow.OTHER_CONVERSION_EVENT_LOOKBACK_WINDOW_30_DAYS - ) - assert ( - response.reporting_attribution_model - == resources.AttributionSettings.ReportingAttributionModel.CROSS_CHANNEL_DATA_DRIVEN - ) + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.dimension_names == ["dimension_names_value"] + assert response.metric_names == ["metric_names_value"] -def test_update_attribution_settings_rest_required_fields( - request_type=analytics_admin.UpdateAttributionSettingsRequest, +def test_update_expanded_data_set_rest_required_fields( + request_type=analytics_admin.UpdateExpandedDataSetRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -48445,14 +55739,14 @@ def test_update_attribution_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_attribution_settings._get_unset_required_fields(jsonified_request) + ).update_expanded_data_set._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_attribution_settings._get_unset_required_fields(jsonified_request) + ).update_expanded_data_set._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("update_mask",)) jsonified_request.update(unset_fields) @@ -48466,7 +55760,7 @@ def test_update_attribution_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.AttributionSettings() + return_value = gaa_expanded_data_set.ExpandedDataSet() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -48487,30 +55781,30 @@ def test_update_attribution_settings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AttributionSettings.pb(return_value) + pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_attribution_settings(request) + response = client.update_expanded_data_set(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_attribution_settings_rest_unset_required_fields(): +def test_update_expanded_data_set_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_attribution_settings._get_unset_required_fields({}) + unset_fields = transport.update_expanded_data_set._get_unset_required_fields({}) assert set(unset_fields) == ( set(("updateMask",)) & set( ( - "attributionSettings", + "expandedDataSet", "updateMask", ) ) @@ -48518,7 +55812,7 @@ def test_update_attribution_settings_rest_unset_required_fields(): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_attribution_settings_rest_interceptors(null_interceptor): +def test_update_expanded_data_set_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -48531,16 +55825,14 @@ def test_update_attribution_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_update_attribution_settings", + transports.AnalyticsAdminServiceRestInterceptor, "post_update_expanded_data_set" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_attribution_settings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_expanded_data_set" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateAttributionSettingsRequest.pb( - analytics_admin.UpdateAttributionSettingsRequest() + pb_message = analytics_admin.UpdateExpandedDataSetRequest.pb( + analytics_admin.UpdateExpandedDataSetRequest() ) transcode.return_value = { "method": "post", @@ -48552,19 +55844,19 @@ def test_update_attribution_settings_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.AttributionSettings.to_json( - resources.AttributionSettings() + req.return_value._content = gaa_expanded_data_set.ExpandedDataSet.to_json( + gaa_expanded_data_set.ExpandedDataSet() ) - request = analytics_admin.UpdateAttributionSettingsRequest() + request = analytics_admin.UpdateExpandedDataSetRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.AttributionSettings() + post.return_value = gaa_expanded_data_set.ExpandedDataSet() - client.update_attribution_settings( + client.update_expanded_data_set( request, metadata=[ ("key", "val"), @@ -48576,9 +55868,8 @@ def test_update_attribution_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_attribution_settings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.UpdateAttributionSettingsRequest, +def test_update_expanded_data_set_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateExpandedDataSetRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -48587,13 +55878,31 @@ def test_update_attribution_settings_rest_bad_request( # send a request that will satisfy transcoding request_init = { - "attribution_settings": {"name": "properties/sample1/attributionSettings"} + "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} } - request_init["attribution_settings"] = { - "name": "properties/sample1/attributionSettings", - "acquisition_conversion_event_lookback_window": 1, - "other_conversion_event_lookback_window": 1, - "reporting_attribution_model": 1, + request_init["expanded_data_set"] = { + "name": "properties/sample1/expandedDataSets/sample2", + "display_name": "display_name_value", + "description": "description_value", + "dimension_names": ["dimension_names_value1", "dimension_names_value2"], + "metric_names": ["metric_names_value1", "metric_names_value2"], + "dimension_filter_expression": { + "and_group": {"filter_expressions": {}}, + "not_expression": {}, + "filter": { + "string_filter": { + "match_type": 1, + "value": "value_value", + "case_sensitive": True, + }, + "in_list_filter": { + "values": ["values_value1", "values_value2"], + "case_sensitive": True, + }, + "field_name": "field_name_value", + }, + }, + "data_collection_start_time": {"seconds": 751, "nanos": 543}, } request = request_type(**request_init) @@ -48606,10 +55915,10 @@ def test_update_attribution_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_attribution_settings(request) + client.update_expanded_data_set(request) -def test_update_attribution_settings_rest_flattened(): +def test_update_expanded_data_set_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -48618,16 +55927,16 @@ def test_update_attribution_settings_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = resources.AttributionSettings() + return_value = gaa_expanded_data_set.ExpandedDataSet() # get arguments that satisfy an http rule for this method sample_request = { - "attribution_settings": {"name": "properties/sample1/attributionSettings"} + "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} } # get truthy value for each flattened field mock_args = dict( - attribution_settings=resources.AttributionSettings(name="name_value"), + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) @@ -48635,25 +55944,25 @@ def test_update_attribution_settings_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AttributionSettings.pb(return_value) + pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) json_return_value = json_format.MessageToJson(pb_return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_attribution_settings(**mock_args) + client.update_expanded_data_set(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1alpha/{attribution_settings.name=properties/*/attributionSettings}" + "%s/v1alpha/{expanded_data_set.name=properties/*/expandedDataSets/*}" % client.transport._host, args[1], ) -def test_update_attribution_settings_rest_flattened_error(transport: str = "rest"): +def test_update_expanded_data_set_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -48662,14 +55971,14 @@ def test_update_attribution_settings_rest_flattened_error(transport: str = "rest # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_attribution_settings( - analytics_admin.UpdateAttributionSettingsRequest(), - attribution_settings=resources.AttributionSettings(name="name_value"), + client.update_expanded_data_set( + analytics_admin.UpdateExpandedDataSetRequest(), + expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_update_attribution_settings_rest_error(): +def test_update_expanded_data_set_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -48678,44 +55987,124 @@ def test_update_attribution_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.RunAccessReportRequest, + analytics_admin.DeleteExpandedDataSetRequest, dict, ], ) -def test_run_access_report_rest(request_type): +def test_delete_expanded_data_set_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"entity": "properties/sample1"} + request_init = {"name": "properties/sample1/expandedDataSets/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = analytics_admin.RunAccessReportResponse( - row_count=992, - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.RunAccessReportResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.run_access_report(request) + response = client.delete_expanded_data_set(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.RunAccessReportResponse) - assert response.row_count == 992 + assert response is None + + +def test_delete_expanded_data_set_rest_required_fields( + request_type=analytics_admin.DeleteExpandedDataSetRequest, +): + transport_class = transports.AnalyticsAdminServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_expanded_data_set._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_expanded_data_set._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_expanded_data_set(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_expanded_data_set_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_expanded_data_set._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_run_access_report_rest_interceptors(null_interceptor): +def test_delete_expanded_data_set_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -48728,14 +56117,11 @@ def test_run_access_report_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_run_access_report" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_run_access_report" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_expanded_data_set" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.RunAccessReportRequest.pb( - analytics_admin.RunAccessReportRequest() + pb_message = analytics_admin.DeleteExpandedDataSetRequest.pb( + analytics_admin.DeleteExpandedDataSetRequest() ) transcode.return_value = { "method": "post", @@ -48747,19 +56133,15 @@ def test_run_access_report_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = analytics_admin.RunAccessReportResponse.to_json( - analytics_admin.RunAccessReportResponse() - ) - request = analytics_admin.RunAccessReportRequest() + request = analytics_admin.DeleteExpandedDataSetRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.RunAccessReportResponse() - client.run_access_report( + client.delete_expanded_data_set( request, metadata=[ ("key", "val"), @@ -48768,11 +56150,10 @@ def test_run_access_report_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_run_access_report_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.RunAccessReportRequest +def test_delete_expanded_data_set_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteExpandedDataSetRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -48780,7 +56161,7 @@ def test_run_access_report_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"entity": "properties/sample1"} + request_init = {"name": "properties/sample1/expandedDataSets/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -48792,10 +56173,65 @@ def test_run_access_report_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.run_access_report(request) + client.delete_expanded_data_set(request) -def test_run_access_report_rest_error(): +def test_delete_expanded_data_set_rest_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "properties/sample1/expandedDataSets/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_expanded_data_set(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha/{name=properties/*/expandedDataSets/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_expanded_data_set_rest_flattened_error(transport: str = "rest"): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_expanded_data_set( + analytics_admin.DeleteExpandedDataSetRequest(), + name="name_value", + ) + + +def test_delete_expanded_data_set_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -50109,6 +57545,20 @@ def test_analytics_admin_service_base_transport(): "get_attribution_settings", "update_attribution_settings", "run_access_report", + "create_access_binding", + "get_access_binding", + "update_access_binding", + "delete_access_binding", + "list_access_bindings", + "batch_create_access_bindings", + "batch_get_access_bindings", + "batch_update_access_bindings", + "batch_delete_access_bindings", + "get_expanded_data_set", + "list_expanded_data_sets", + "create_expanded_data_set", + "update_expanded_data_set", + "delete_expanded_data_set", "set_automated_ga4_configuration_opt_out", "fetch_automated_ga4_configuration_opt_out", "get_big_query_link", @@ -50667,6 +58117,48 @@ def test_analytics_admin_service_client_transport_session_collision(transport_na session1 = client1.transport.run_access_report._session session2 = client2.transport.run_access_report._session assert session1 != session2 + session1 = client1.transport.create_access_binding._session + session2 = client2.transport.create_access_binding._session + assert session1 != session2 + session1 = client1.transport.get_access_binding._session + session2 = client2.transport.get_access_binding._session + assert session1 != session2 + session1 = client1.transport.update_access_binding._session + session2 = client2.transport.update_access_binding._session + assert session1 != session2 + session1 = client1.transport.delete_access_binding._session + session2 = client2.transport.delete_access_binding._session + assert session1 != session2 + session1 = client1.transport.list_access_bindings._session + session2 = client2.transport.list_access_bindings._session + assert session1 != session2 + session1 = client1.transport.batch_create_access_bindings._session + session2 = client2.transport.batch_create_access_bindings._session + assert session1 != session2 + session1 = client1.transport.batch_get_access_bindings._session + session2 = client2.transport.batch_get_access_bindings._session + assert session1 != session2 + session1 = client1.transport.batch_update_access_bindings._session + session2 = client2.transport.batch_update_access_bindings._session + assert session1 != session2 + session1 = client1.transport.batch_delete_access_bindings._session + session2 = client2.transport.batch_delete_access_bindings._session + assert session1 != session2 + session1 = client1.transport.get_expanded_data_set._session + session2 = client2.transport.get_expanded_data_set._session + assert session1 != session2 + session1 = client1.transport.list_expanded_data_sets._session + session2 = client2.transport.list_expanded_data_sets._session + assert session1 != session2 + session1 = client1.transport.create_expanded_data_set._session + session2 = client2.transport.create_expanded_data_set._session + assert session1 != session2 + session1 = client1.transport.update_expanded_data_set._session + session2 = client2.transport.update_expanded_data_set._session + assert session1 != session2 + session1 = client1.transport.delete_expanded_data_set._session + session2 = client2.transport.delete_expanded_data_set._session + assert session1 != session2 session1 = client1.transport.set_automated_ga4_configuration_opt_out._session session2 = client2.transport.set_automated_ga4_configuration_opt_out._session assert session1 != session2 @@ -50807,8 +58299,31 @@ def test_analytics_admin_service_transport_channel_mtls_with_adc(transport_class assert transport.grpc_channel == mock_grpc_channel -def test_account_path(): +def test_access_binding_path(): account = "squid" + access_binding = "clam" + expected = "accounts/{account}/accessBindings/{access_binding}".format( + account=account, + access_binding=access_binding, + ) + actual = AnalyticsAdminServiceClient.access_binding_path(account, access_binding) + assert expected == actual + + +def test_parse_access_binding_path(): + expected = { + "account": "whelk", + "access_binding": "octopus", + } + path = AnalyticsAdminServiceClient.access_binding_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_access_binding_path(path) + assert expected == actual + + +def test_account_path(): + account = "oyster" expected = "accounts/{account}".format( account=account, ) @@ -50818,7 +58333,7 @@ def test_account_path(): def test_parse_account_path(): expected = { - "account": "clam", + "account": "nudibranch", } path = AnalyticsAdminServiceClient.account_path(**expected) @@ -50828,7 +58343,7 @@ def test_parse_account_path(): def test_account_summary_path(): - account_summary = "whelk" + account_summary = "cuttlefish" expected = "accountSummaries/{account_summary}".format( account_summary=account_summary, ) @@ -50838,7 +58353,7 @@ def test_account_summary_path(): def test_parse_account_summary_path(): expected = { - "account_summary": "octopus", + "account_summary": "mussel", } path = AnalyticsAdminServiceClient.account_summary_path(**expected) @@ -50848,7 +58363,7 @@ def test_parse_account_summary_path(): def test_attribution_settings_path(): - property = "oyster" + property = "winkle" expected = "properties/{property}/attributionSettings".format( property=property, ) @@ -50858,7 +58373,7 @@ def test_attribution_settings_path(): def test_parse_attribution_settings_path(): expected = { - "property": "nudibranch", + "property": "nautilus", } path = AnalyticsAdminServiceClient.attribution_settings_path(**expected) @@ -50868,8 +58383,8 @@ def test_parse_attribution_settings_path(): def test_audience_path(): - property = "cuttlefish" - audience = "mussel" + property = "scallop" + audience = "abalone" expected = "properties/{property}/audiences/{audience}".format( property=property, audience=audience, @@ -50880,8 +58395,8 @@ def test_audience_path(): def test_parse_audience_path(): expected = { - "property": "winkle", - "audience": "nautilus", + "property": "squid", + "audience": "clam", } path = AnalyticsAdminServiceClient.audience_path(**expected) @@ -50891,8 +58406,8 @@ def test_parse_audience_path(): def test_big_query_link_path(): - property = "scallop" - bigquery_link = "abalone" + property = "whelk" + bigquery_link = "octopus" expected = "properties/{property}/bigQueryLinks/{bigquery_link}".format( property=property, bigquery_link=bigquery_link, @@ -50903,8 +58418,8 @@ def test_big_query_link_path(): def test_parse_big_query_link_path(): expected = { - "property": "squid", - "bigquery_link": "clam", + "property": "oyster", + "bigquery_link": "nudibranch", } path = AnalyticsAdminServiceClient.big_query_link_path(**expected) @@ -50914,8 +58429,8 @@ def test_parse_big_query_link_path(): def test_conversion_event_path(): - property = "whelk" - conversion_event = "octopus" + property = "cuttlefish" + conversion_event = "mussel" expected = "properties/{property}/conversionEvents/{conversion_event}".format( property=property, conversion_event=conversion_event, @@ -50928,8 +58443,8 @@ def test_conversion_event_path(): def test_parse_conversion_event_path(): expected = { - "property": "oyster", - "conversion_event": "nudibranch", + "property": "winkle", + "conversion_event": "nautilus", } path = AnalyticsAdminServiceClient.conversion_event_path(**expected) @@ -50939,8 +58454,8 @@ def test_parse_conversion_event_path(): def test_custom_dimension_path(): - property = "cuttlefish" - custom_dimension = "mussel" + property = "scallop" + custom_dimension = "abalone" expected = "properties/{property}/customDimensions/{custom_dimension}".format( property=property, custom_dimension=custom_dimension, @@ -50953,8 +58468,8 @@ def test_custom_dimension_path(): def test_parse_custom_dimension_path(): expected = { - "property": "winkle", - "custom_dimension": "nautilus", + "property": "squid", + "custom_dimension": "clam", } path = AnalyticsAdminServiceClient.custom_dimension_path(**expected) @@ -50964,8 +58479,8 @@ def test_parse_custom_dimension_path(): def test_custom_metric_path(): - property = "scallop" - custom_metric = "abalone" + property = "whelk" + custom_metric = "octopus" expected = "properties/{property}/customMetrics/{custom_metric}".format( property=property, custom_metric=custom_metric, @@ -50976,8 +58491,8 @@ def test_custom_metric_path(): def test_parse_custom_metric_path(): expected = { - "property": "squid", - "custom_metric": "clam", + "property": "oyster", + "custom_metric": "nudibranch", } path = AnalyticsAdminServiceClient.custom_metric_path(**expected) @@ -50987,7 +58502,7 @@ def test_parse_custom_metric_path(): def test_data_retention_settings_path(): - property = "whelk" + property = "cuttlefish" expected = "properties/{property}/dataRetentionSettings".format( property=property, ) @@ -50997,7 +58512,7 @@ def test_data_retention_settings_path(): def test_parse_data_retention_settings_path(): expected = { - "property": "octopus", + "property": "mussel", } path = AnalyticsAdminServiceClient.data_retention_settings_path(**expected) @@ -51007,7 +58522,7 @@ def test_parse_data_retention_settings_path(): def test_data_sharing_settings_path(): - account = "oyster" + account = "winkle" expected = "accounts/{account}/dataSharingSettings".format( account=account, ) @@ -51017,7 +58532,7 @@ def test_data_sharing_settings_path(): def test_parse_data_sharing_settings_path(): expected = { - "account": "nudibranch", + "account": "nautilus", } path = AnalyticsAdminServiceClient.data_sharing_settings_path(**expected) @@ -51027,8 +58542,8 @@ def test_parse_data_sharing_settings_path(): def test_data_stream_path(): - property = "cuttlefish" - data_stream = "mussel" + property = "scallop" + data_stream = "abalone" expected = "properties/{property}/dataStreams/{data_stream}".format( property=property, data_stream=data_stream, @@ -51039,8 +58554,8 @@ def test_data_stream_path(): def test_parse_data_stream_path(): expected = { - "property": "winkle", - "data_stream": "nautilus", + "property": "squid", + "data_stream": "clam", } path = AnalyticsAdminServiceClient.data_stream_path(**expected) @@ -51050,8 +58565,8 @@ def test_parse_data_stream_path(): def test_display_video360_advertiser_link_path(): - property = "scallop" - display_video_360_advertiser_link = "abalone" + property = "whelk" + display_video_360_advertiser_link = "octopus" expected = "properties/{property}/displayVideo360AdvertiserLinks/{display_video_360_advertiser_link}".format( property=property, display_video_360_advertiser_link=display_video_360_advertiser_link, @@ -51064,8 +58579,8 @@ def test_display_video360_advertiser_link_path(): def test_parse_display_video360_advertiser_link_path(): expected = { - "property": "squid", - "display_video_360_advertiser_link": "clam", + "property": "oyster", + "display_video_360_advertiser_link": "nudibranch", } path = AnalyticsAdminServiceClient.display_video360_advertiser_link_path(**expected) @@ -51077,8 +58592,8 @@ def test_parse_display_video360_advertiser_link_path(): def test_display_video360_advertiser_link_proposal_path(): - property = "whelk" - display_video_360_advertiser_link_proposal = "octopus" + property = "cuttlefish" + display_video_360_advertiser_link_proposal = "mussel" expected = "properties/{property}/displayVideo360AdvertiserLinkProposals/{display_video_360_advertiser_link_proposal}".format( property=property, display_video_360_advertiser_link_proposal=display_video_360_advertiser_link_proposal, @@ -51091,8 +58606,8 @@ def test_display_video360_advertiser_link_proposal_path(): def test_parse_display_video360_advertiser_link_proposal_path(): expected = { - "property": "oyster", - "display_video_360_advertiser_link_proposal": "nudibranch", + "property": "winkle", + "display_video_360_advertiser_link_proposal": "nautilus", } path = AnalyticsAdminServiceClient.display_video360_advertiser_link_proposal_path( **expected @@ -51106,8 +58621,8 @@ def test_parse_display_video360_advertiser_link_proposal_path(): def test_expanded_data_set_path(): - property = "cuttlefish" - expanded_data_set = "mussel" + property = "scallop" + expanded_data_set = "abalone" expected = "properties/{property}/expandedDataSets/{expanded_data_set}".format( property=property, expanded_data_set=expanded_data_set, @@ -51120,8 +58635,8 @@ def test_expanded_data_set_path(): def test_parse_expanded_data_set_path(): expected = { - "property": "winkle", - "expanded_data_set": "nautilus", + "property": "squid", + "expanded_data_set": "clam", } path = AnalyticsAdminServiceClient.expanded_data_set_path(**expected) @@ -51131,8 +58646,8 @@ def test_parse_expanded_data_set_path(): def test_firebase_link_path(): - property = "scallop" - firebase_link = "abalone" + property = "whelk" + firebase_link = "octopus" expected = "properties/{property}/firebaseLinks/{firebase_link}".format( property=property, firebase_link=firebase_link, @@ -51143,8 +58658,8 @@ def test_firebase_link_path(): def test_parse_firebase_link_path(): expected = { - "property": "squid", - "firebase_link": "clam", + "property": "oyster", + "firebase_link": "nudibranch", } path = AnalyticsAdminServiceClient.firebase_link_path(**expected) @@ -51154,8 +58669,8 @@ def test_parse_firebase_link_path(): def test_global_site_tag_path(): - property = "whelk" - data_stream = "octopus" + property = "cuttlefish" + data_stream = "mussel" expected = "properties/{property}/dataStreams/{data_stream}/globalSiteTag".format( property=property, data_stream=data_stream, @@ -51166,8 +58681,8 @@ def test_global_site_tag_path(): def test_parse_global_site_tag_path(): expected = { - "property": "oyster", - "data_stream": "nudibranch", + "property": "winkle", + "data_stream": "nautilus", } path = AnalyticsAdminServiceClient.global_site_tag_path(**expected) @@ -51177,8 +58692,8 @@ def test_parse_global_site_tag_path(): def test_google_ads_link_path(): - property = "cuttlefish" - google_ads_link = "mussel" + property = "scallop" + google_ads_link = "abalone" expected = "properties/{property}/googleAdsLinks/{google_ads_link}".format( property=property, google_ads_link=google_ads_link, @@ -51189,8 +58704,8 @@ def test_google_ads_link_path(): def test_parse_google_ads_link_path(): expected = { - "property": "winkle", - "google_ads_link": "nautilus", + "property": "squid", + "google_ads_link": "clam", } path = AnalyticsAdminServiceClient.google_ads_link_path(**expected) @@ -51200,7 +58715,7 @@ def test_parse_google_ads_link_path(): def test_google_signals_settings_path(): - property = "scallop" + property = "whelk" expected = "properties/{property}/googleSignalsSettings".format( property=property, ) @@ -51210,7 +58725,7 @@ def test_google_signals_settings_path(): def test_parse_google_signals_settings_path(): expected = { - "property": "abalone", + "property": "octopus", } path = AnalyticsAdminServiceClient.google_signals_settings_path(**expected) @@ -51220,9 +58735,9 @@ def test_parse_google_signals_settings_path(): def test_measurement_protocol_secret_path(): - property = "squid" - data_stream = "clam" - measurement_protocol_secret = "whelk" + property = "oyster" + data_stream = "nudibranch" + measurement_protocol_secret = "cuttlefish" expected = "properties/{property}/dataStreams/{data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}".format( property=property, data_stream=data_stream, @@ -51236,9 +58751,9 @@ def test_measurement_protocol_secret_path(): def test_parse_measurement_protocol_secret_path(): expected = { - "property": "octopus", - "data_stream": "oyster", - "measurement_protocol_secret": "nudibranch", + "property": "mussel", + "data_stream": "winkle", + "measurement_protocol_secret": "nautilus", } path = AnalyticsAdminServiceClient.measurement_protocol_secret_path(**expected) @@ -51248,7 +58763,7 @@ def test_parse_measurement_protocol_secret_path(): def test_property_path(): - property = "cuttlefish" + property = "scallop" expected = "properties/{property}".format( property=property, ) @@ -51258,7 +58773,7 @@ def test_property_path(): def test_parse_property_path(): expected = { - "property": "mussel", + "property": "abalone", } path = AnalyticsAdminServiceClient.property_path(**expected) @@ -51268,8 +58783,8 @@ def test_parse_property_path(): def test_search_ads360_link_path(): - property = "winkle" - search_ads_360_link = "nautilus" + property = "squid" + search_ads_360_link = "clam" expected = "properties/{property}/searchAds360Links/{search_ads_360_link}".format( property=property, search_ads_360_link=search_ads_360_link, @@ -51282,8 +58797,8 @@ def test_search_ads360_link_path(): def test_parse_search_ads360_link_path(): expected = { - "property": "scallop", - "search_ads_360_link": "abalone", + "property": "whelk", + "search_ads_360_link": "octopus", } path = AnalyticsAdminServiceClient.search_ads360_link_path(**expected) @@ -51293,8 +58808,8 @@ def test_parse_search_ads360_link_path(): def test_user_link_path(): - account = "squid" - user_link = "clam" + account = "oyster" + user_link = "nudibranch" expected = "accounts/{account}/userLinks/{user_link}".format( account=account, user_link=user_link, @@ -51305,8 +58820,8 @@ def test_user_link_path(): def test_parse_user_link_path(): expected = { - "account": "whelk", - "user_link": "octopus", + "account": "cuttlefish", + "user_link": "mussel", } path = AnalyticsAdminServiceClient.user_link_path(**expected) @@ -51316,7 +58831,7 @@ def test_parse_user_link_path(): def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "winkle" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -51326,7 +58841,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "nautilus", } path = AnalyticsAdminServiceClient.common_billing_account_path(**expected) @@ -51336,7 +58851,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "scallop" expected = "folders/{folder}".format( folder=folder, ) @@ -51346,7 +58861,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "abalone", } path = AnalyticsAdminServiceClient.common_folder_path(**expected) @@ -51356,7 +58871,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "squid" expected = "organizations/{organization}".format( organization=organization, ) @@ -51366,7 +58881,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "clam", } path = AnalyticsAdminServiceClient.common_organization_path(**expected) @@ -51376,7 +58891,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "whelk" expected = "projects/{project}".format( project=project, ) @@ -51386,7 +58901,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "octopus", } path = AnalyticsAdminServiceClient.common_project_path(**expected) @@ -51396,8 +58911,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "oyster" + location = "nudibranch" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -51408,8 +58923,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "cuttlefish", + "location": "mussel", } path = AnalyticsAdminServiceClient.common_location_path(**expected)