diff --git a/google/analytics/admin/__init__.py b/google/analytics/admin/__init__.py index 8ad74f7c..a9e1a4b7 100644 --- a/google/analytics/admin/__init__.py +++ b/google/analytics/admin/__init__.py @@ -71,6 +71,7 @@ BatchUpdateUserLinksResponse, CancelDisplayVideo360AdvertiserLinkProposalRequest, CreateAccessBindingRequest, + CreateAdSenseLinkRequest, CreateAudienceRequest, CreateChannelGroupRequest, CreateConnectedSiteTagRequest, @@ -81,6 +82,7 @@ CreateDataStreamRequest, CreateDisplayVideo360AdvertiserLinkProposalRequest, CreateDisplayVideo360AdvertiserLinkRequest, + CreateEventCreateRuleRequest, CreateExpandedDataSetRequest, CreateFirebaseLinkRequest, CreateGoogleAdsLinkRequest, @@ -90,12 +92,14 @@ CreateUserLinkRequest, DeleteAccessBindingRequest, DeleteAccountRequest, + DeleteAdSenseLinkRequest, DeleteChannelGroupRequest, DeleteConnectedSiteTagRequest, DeleteConversionEventRequest, DeleteDataStreamRequest, DeleteDisplayVideo360AdvertiserLinkProposalRequest, DeleteDisplayVideo360AdvertiserLinkRequest, + DeleteEventCreateRuleRequest, DeleteExpandedDataSetRequest, DeleteFirebaseLinkRequest, DeleteGoogleAdsLinkRequest, @@ -109,6 +113,7 @@ FetchConnectedGa4PropertyResponse, GetAccessBindingRequest, GetAccountRequest, + GetAdSenseLinkRequest, GetAttributionSettingsRequest, GetAudienceRequest, GetBigQueryLinkRequest, @@ -122,6 +127,7 @@ GetDisplayVideo360AdvertiserLinkProposalRequest, GetDisplayVideo360AdvertiserLinkRequest, GetEnhancedMeasurementSettingsRequest, + GetEventCreateRuleRequest, GetExpandedDataSetRequest, GetGlobalSiteTagRequest, GetGoogleSignalsSettingsRequest, @@ -135,6 +141,8 @@ ListAccountsResponse, ListAccountSummariesRequest, ListAccountSummariesResponse, + ListAdSenseLinksRequest, + ListAdSenseLinksResponse, ListAudiencesRequest, ListAudiencesResponse, ListBigQueryLinksRequest, @@ -155,6 +163,8 @@ ListDisplayVideo360AdvertiserLinkProposalsResponse, ListDisplayVideo360AdvertiserLinksRequest, ListDisplayVideo360AdvertiserLinksResponse, + ListEventCreateRulesRequest, + ListEventCreateRulesResponse, ListExpandedDataSetsRequest, ListExpandedDataSetsResponse, ListFirebaseLinksRequest, @@ -188,6 +198,7 @@ UpdateDataStreamRequest, UpdateDisplayVideo360AdvertiserLinkRequest, UpdateEnhancedMeasurementSettingsRequest, + UpdateEventCreateRuleRequest, UpdateExpandedDataSetRequest, UpdateGoogleAdsLinkRequest, UpdateGoogleSignalsSettingsRequest, @@ -215,6 +226,11 @@ ChannelGroupFilterExpressionList, GroupingRule, ) +from google.analytics.admin_v1alpha.types.event_create_and_edit import ( + EventCreateRule, + MatchingCondition, + ParameterMutation, +) from google.analytics.admin_v1alpha.types.expanded_data_set import ( ExpandedDataSet, ExpandedDataSetFilter, @@ -227,6 +243,7 @@ AccountSummary, ActionType, ActorType, + AdSenseLink, AttributionSettings, AuditUserLink, BigQueryLink, @@ -309,6 +326,7 @@ "BatchUpdateUserLinksResponse", "CancelDisplayVideo360AdvertiserLinkProposalRequest", "CreateAccessBindingRequest", + "CreateAdSenseLinkRequest", "CreateAudienceRequest", "CreateChannelGroupRequest", "CreateConnectedSiteTagRequest", @@ -319,6 +337,7 @@ "CreateDataStreamRequest", "CreateDisplayVideo360AdvertiserLinkProposalRequest", "CreateDisplayVideo360AdvertiserLinkRequest", + "CreateEventCreateRuleRequest", "CreateExpandedDataSetRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", @@ -328,12 +347,14 @@ "CreateUserLinkRequest", "DeleteAccessBindingRequest", "DeleteAccountRequest", + "DeleteAdSenseLinkRequest", "DeleteChannelGroupRequest", "DeleteConnectedSiteTagRequest", "DeleteConversionEventRequest", "DeleteDataStreamRequest", "DeleteDisplayVideo360AdvertiserLinkProposalRequest", "DeleteDisplayVideo360AdvertiserLinkRequest", + "DeleteEventCreateRuleRequest", "DeleteExpandedDataSetRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", @@ -347,6 +368,7 @@ "FetchConnectedGa4PropertyResponse", "GetAccessBindingRequest", "GetAccountRequest", + "GetAdSenseLinkRequest", "GetAttributionSettingsRequest", "GetAudienceRequest", "GetBigQueryLinkRequest", @@ -360,6 +382,7 @@ "GetDisplayVideo360AdvertiserLinkProposalRequest", "GetDisplayVideo360AdvertiserLinkRequest", "GetEnhancedMeasurementSettingsRequest", + "GetEventCreateRuleRequest", "GetExpandedDataSetRequest", "GetGlobalSiteTagRequest", "GetGoogleSignalsSettingsRequest", @@ -373,6 +396,8 @@ "ListAccountsResponse", "ListAccountSummariesRequest", "ListAccountSummariesResponse", + "ListAdSenseLinksRequest", + "ListAdSenseLinksResponse", "ListAudiencesRequest", "ListAudiencesResponse", "ListBigQueryLinksRequest", @@ -393,6 +418,8 @@ "ListDisplayVideo360AdvertiserLinkProposalsResponse", "ListDisplayVideo360AdvertiserLinksRequest", "ListDisplayVideo360AdvertiserLinksResponse", + "ListEventCreateRulesRequest", + "ListEventCreateRulesResponse", "ListExpandedDataSetsRequest", "ListExpandedDataSetsResponse", "ListFirebaseLinksRequest", @@ -426,6 +453,7 @@ "UpdateDataStreamRequest", "UpdateDisplayVideo360AdvertiserLinkRequest", "UpdateEnhancedMeasurementSettingsRequest", + "UpdateEventCreateRuleRequest", "UpdateExpandedDataSetRequest", "UpdateGoogleAdsLinkRequest", "UpdateGoogleSignalsSettingsRequest", @@ -448,6 +476,9 @@ "ChannelGroupFilterExpression", "ChannelGroupFilterExpressionList", "GroupingRule", + "EventCreateRule", + "MatchingCondition", + "ParameterMutation", "ExpandedDataSet", "ExpandedDataSetFilter", "ExpandedDataSetFilterExpression", @@ -455,6 +486,7 @@ "AccessBinding", "Account", "AccountSummary", + "AdSenseLink", "AttributionSettings", "AuditUserLink", "BigQueryLink", diff --git a/google/analytics/admin_v1alpha/__init__.py b/google/analytics/admin_v1alpha/__init__.py index 72181f29..a6d0df3e 100644 --- a/google/analytics/admin_v1alpha/__init__.py +++ b/google/analytics/admin_v1alpha/__init__.py @@ -69,6 +69,7 @@ BatchUpdateUserLinksResponse, CancelDisplayVideo360AdvertiserLinkProposalRequest, CreateAccessBindingRequest, + CreateAdSenseLinkRequest, CreateAudienceRequest, CreateChannelGroupRequest, CreateConnectedSiteTagRequest, @@ -79,6 +80,7 @@ CreateDataStreamRequest, CreateDisplayVideo360AdvertiserLinkProposalRequest, CreateDisplayVideo360AdvertiserLinkRequest, + CreateEventCreateRuleRequest, CreateExpandedDataSetRequest, CreateFirebaseLinkRequest, CreateGoogleAdsLinkRequest, @@ -88,12 +90,14 @@ CreateUserLinkRequest, DeleteAccessBindingRequest, DeleteAccountRequest, + DeleteAdSenseLinkRequest, DeleteChannelGroupRequest, DeleteConnectedSiteTagRequest, DeleteConversionEventRequest, DeleteDataStreamRequest, DeleteDisplayVideo360AdvertiserLinkProposalRequest, DeleteDisplayVideo360AdvertiserLinkRequest, + DeleteEventCreateRuleRequest, DeleteExpandedDataSetRequest, DeleteFirebaseLinkRequest, DeleteGoogleAdsLinkRequest, @@ -107,6 +111,7 @@ FetchConnectedGa4PropertyResponse, GetAccessBindingRequest, GetAccountRequest, + GetAdSenseLinkRequest, GetAttributionSettingsRequest, GetAudienceRequest, GetBigQueryLinkRequest, @@ -120,6 +125,7 @@ GetDisplayVideo360AdvertiserLinkProposalRequest, GetDisplayVideo360AdvertiserLinkRequest, GetEnhancedMeasurementSettingsRequest, + GetEventCreateRuleRequest, GetExpandedDataSetRequest, GetGlobalSiteTagRequest, GetGoogleSignalsSettingsRequest, @@ -133,6 +139,8 @@ ListAccountsResponse, ListAccountSummariesRequest, ListAccountSummariesResponse, + ListAdSenseLinksRequest, + ListAdSenseLinksResponse, ListAudiencesRequest, ListAudiencesResponse, ListBigQueryLinksRequest, @@ -153,6 +161,8 @@ ListDisplayVideo360AdvertiserLinkProposalsResponse, ListDisplayVideo360AdvertiserLinksRequest, ListDisplayVideo360AdvertiserLinksResponse, + ListEventCreateRulesRequest, + ListEventCreateRulesResponse, ListExpandedDataSetsRequest, ListExpandedDataSetsResponse, ListFirebaseLinksRequest, @@ -186,6 +196,7 @@ UpdateDataStreamRequest, UpdateDisplayVideo360AdvertiserLinkRequest, UpdateEnhancedMeasurementSettingsRequest, + UpdateEventCreateRuleRequest, UpdateExpandedDataSetRequest, UpdateGoogleAdsLinkRequest, UpdateGoogleSignalsSettingsRequest, @@ -213,6 +224,11 @@ ChannelGroupFilterExpressionList, GroupingRule, ) +from .types.event_create_and_edit import ( + EventCreateRule, + MatchingCondition, + ParameterMutation, +) from .types.expanded_data_set import ( ExpandedDataSet, ExpandedDataSetFilter, @@ -225,6 +241,7 @@ AccountSummary, ActionType, ActorType, + AdSenseLink, AttributionSettings, AuditUserLink, BigQueryLink, @@ -287,6 +304,7 @@ "AcknowledgeUserDataCollectionResponse", "ActionType", "ActorType", + "AdSenseLink", "AnalyticsAdminServiceClient", "ApproveDisplayVideo360AdvertiserLinkProposalRequest", "ApproveDisplayVideo360AdvertiserLinkProposalResponse", @@ -333,6 +351,7 @@ "ConnectedSiteTag", "ConversionEvent", "CreateAccessBindingRequest", + "CreateAdSenseLinkRequest", "CreateAudienceRequest", "CreateChannelGroupRequest", "CreateConnectedSiteTagRequest", @@ -343,6 +362,7 @@ "CreateDataStreamRequest", "CreateDisplayVideo360AdvertiserLinkProposalRequest", "CreateDisplayVideo360AdvertiserLinkRequest", + "CreateEventCreateRuleRequest", "CreateExpandedDataSetRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", @@ -357,12 +377,14 @@ "DataStream", "DeleteAccessBindingRequest", "DeleteAccountRequest", + "DeleteAdSenseLinkRequest", "DeleteChannelGroupRequest", "DeleteConnectedSiteTagRequest", "DeleteConversionEventRequest", "DeleteDataStreamRequest", "DeleteDisplayVideo360AdvertiserLinkProposalRequest", "DeleteDisplayVideo360AdvertiserLinkRequest", + "DeleteEventCreateRuleRequest", "DeleteExpandedDataSetRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", @@ -373,6 +395,7 @@ "DisplayVideo360AdvertiserLink", "DisplayVideo360AdvertiserLinkProposal", "EnhancedMeasurementSettings", + "EventCreateRule", "ExpandedDataSet", "ExpandedDataSetFilter", "ExpandedDataSetFilterExpression", @@ -384,6 +407,7 @@ "FirebaseLink", "GetAccessBindingRequest", "GetAccountRequest", + "GetAdSenseLinkRequest", "GetAttributionSettingsRequest", "GetAudienceRequest", "GetBigQueryLinkRequest", @@ -397,6 +421,7 @@ "GetDisplayVideo360AdvertiserLinkProposalRequest", "GetDisplayVideo360AdvertiserLinkRequest", "GetEnhancedMeasurementSettingsRequest", + "GetEventCreateRuleRequest", "GetExpandedDataSetRequest", "GetGlobalSiteTagRequest", "GetGoogleSignalsSettingsRequest", @@ -420,6 +445,8 @@ "ListAccountSummariesResponse", "ListAccountsRequest", "ListAccountsResponse", + "ListAdSenseLinksRequest", + "ListAdSenseLinksResponse", "ListAudiencesRequest", "ListAudiencesResponse", "ListBigQueryLinksRequest", @@ -440,6 +467,8 @@ "ListDisplayVideo360AdvertiserLinkProposalsResponse", "ListDisplayVideo360AdvertiserLinksRequest", "ListDisplayVideo360AdvertiserLinksResponse", + "ListEventCreateRulesRequest", + "ListEventCreateRulesResponse", "ListExpandedDataSetsRequest", "ListExpandedDataSetsResponse", "ListFirebaseLinksRequest", @@ -454,8 +483,10 @@ "ListSearchAds360LinksResponse", "ListUserLinksRequest", "ListUserLinksResponse", + "MatchingCondition", "MeasurementProtocolSecret", "NumericValue", + "ParameterMutation", "Property", "PropertySummary", "PropertyType", @@ -480,6 +511,7 @@ "UpdateDataStreamRequest", "UpdateDisplayVideo360AdvertiserLinkRequest", "UpdateEnhancedMeasurementSettingsRequest", + "UpdateEventCreateRuleRequest", "UpdateExpandedDataSetRequest", "UpdateGoogleAdsLinkRequest", "UpdateGoogleSignalsSettingsRequest", diff --git a/google/analytics/admin_v1alpha/gapic_metadata.json b/google/analytics/admin_v1alpha/gapic_metadata.json index 74dde513..bcad6ca9 100644 --- a/google/analytics/admin_v1alpha/gapic_metadata.json +++ b/google/analytics/admin_v1alpha/gapic_metadata.json @@ -90,6 +90,11 @@ "create_access_binding" ] }, + "CreateAdSenseLink": { + "methods": [ + "create_ad_sense_link" + ] + }, "CreateAudience": { "methods": [ "create_audience" @@ -135,6 +140,11 @@ "create_display_video360_advertiser_link_proposal" ] }, + "CreateEventCreateRule": { + "methods": [ + "create_event_create_rule" + ] + }, "CreateExpandedDataSet": { "methods": [ "create_expanded_data_set" @@ -180,6 +190,11 @@ "delete_account" ] }, + "DeleteAdSenseLink": { + "methods": [ + "delete_ad_sense_link" + ] + }, "DeleteChannelGroup": { "methods": [ "delete_channel_group" @@ -210,6 +225,11 @@ "delete_display_video360_advertiser_link_proposal" ] }, + "DeleteEventCreateRule": { + "methods": [ + "delete_event_create_rule" + ] + }, "DeleteExpandedDataSet": { "methods": [ "delete_expanded_data_set" @@ -265,6 +285,11 @@ "get_account" ] }, + "GetAdSenseLink": { + "methods": [ + "get_ad_sense_link" + ] + }, "GetAttributionSettings": { "methods": [ "get_attribution_settings" @@ -330,6 +355,11 @@ "get_enhanced_measurement_settings" ] }, + "GetEventCreateRule": { + "methods": [ + "get_event_create_rule" + ] + }, "GetExpandedDataSet": { "methods": [ "get_expanded_data_set" @@ -380,6 +410,11 @@ "list_accounts" ] }, + "ListAdSenseLinks": { + "methods": [ + "list_ad_sense_links" + ] + }, "ListAudiences": { "methods": [ "list_audiences" @@ -430,6 +465,11 @@ "list_display_video360_advertiser_links" ] }, + "ListEventCreateRules": { + "methods": [ + "list_event_create_rules" + ] + }, "ListExpandedDataSets": { "methods": [ "list_expanded_data_sets" @@ -540,6 +580,11 @@ "update_enhanced_measurement_settings" ] }, + "UpdateEventCreateRule": { + "methods": [ + "update_event_create_rule" + ] + }, "UpdateExpandedDataSet": { "methods": [ "update_expanded_data_set" @@ -660,6 +705,11 @@ "create_access_binding" ] }, + "CreateAdSenseLink": { + "methods": [ + "create_ad_sense_link" + ] + }, "CreateAudience": { "methods": [ "create_audience" @@ -705,6 +755,11 @@ "create_display_video360_advertiser_link_proposal" ] }, + "CreateEventCreateRule": { + "methods": [ + "create_event_create_rule" + ] + }, "CreateExpandedDataSet": { "methods": [ "create_expanded_data_set" @@ -750,6 +805,11 @@ "delete_account" ] }, + "DeleteAdSenseLink": { + "methods": [ + "delete_ad_sense_link" + ] + }, "DeleteChannelGroup": { "methods": [ "delete_channel_group" @@ -780,6 +840,11 @@ "delete_display_video360_advertiser_link_proposal" ] }, + "DeleteEventCreateRule": { + "methods": [ + "delete_event_create_rule" + ] + }, "DeleteExpandedDataSet": { "methods": [ "delete_expanded_data_set" @@ -835,6 +900,11 @@ "get_account" ] }, + "GetAdSenseLink": { + "methods": [ + "get_ad_sense_link" + ] + }, "GetAttributionSettings": { "methods": [ "get_attribution_settings" @@ -900,6 +970,11 @@ "get_enhanced_measurement_settings" ] }, + "GetEventCreateRule": { + "methods": [ + "get_event_create_rule" + ] + }, "GetExpandedDataSet": { "methods": [ "get_expanded_data_set" @@ -950,6 +1025,11 @@ "list_accounts" ] }, + "ListAdSenseLinks": { + "methods": [ + "list_ad_sense_links" + ] + }, "ListAudiences": { "methods": [ "list_audiences" @@ -1000,6 +1080,11 @@ "list_display_video360_advertiser_links" ] }, + "ListEventCreateRules": { + "methods": [ + "list_event_create_rules" + ] + }, "ListExpandedDataSets": { "methods": [ "list_expanded_data_sets" @@ -1110,6 +1195,11 @@ "update_enhanced_measurement_settings" ] }, + "UpdateEventCreateRule": { + "methods": [ + "update_event_create_rule" + ] + }, "UpdateExpandedDataSet": { "methods": [ "update_expanded_data_set" @@ -1230,6 +1320,11 @@ "create_access_binding" ] }, + "CreateAdSenseLink": { + "methods": [ + "create_ad_sense_link" + ] + }, "CreateAudience": { "methods": [ "create_audience" @@ -1275,6 +1370,11 @@ "create_display_video360_advertiser_link_proposal" ] }, + "CreateEventCreateRule": { + "methods": [ + "create_event_create_rule" + ] + }, "CreateExpandedDataSet": { "methods": [ "create_expanded_data_set" @@ -1320,6 +1420,11 @@ "delete_account" ] }, + "DeleteAdSenseLink": { + "methods": [ + "delete_ad_sense_link" + ] + }, "DeleteChannelGroup": { "methods": [ "delete_channel_group" @@ -1350,6 +1455,11 @@ "delete_display_video360_advertiser_link_proposal" ] }, + "DeleteEventCreateRule": { + "methods": [ + "delete_event_create_rule" + ] + }, "DeleteExpandedDataSet": { "methods": [ "delete_expanded_data_set" @@ -1405,6 +1515,11 @@ "get_account" ] }, + "GetAdSenseLink": { + "methods": [ + "get_ad_sense_link" + ] + }, "GetAttributionSettings": { "methods": [ "get_attribution_settings" @@ -1470,6 +1585,11 @@ "get_enhanced_measurement_settings" ] }, + "GetEventCreateRule": { + "methods": [ + "get_event_create_rule" + ] + }, "GetExpandedDataSet": { "methods": [ "get_expanded_data_set" @@ -1520,6 +1640,11 @@ "list_accounts" ] }, + "ListAdSenseLinks": { + "methods": [ + "list_ad_sense_links" + ] + }, "ListAudiences": { "methods": [ "list_audiences" @@ -1570,6 +1695,11 @@ "list_display_video360_advertiser_links" ] }, + "ListEventCreateRules": { + "methods": [ + "list_event_create_rules" + ] + }, "ListExpandedDataSets": { "methods": [ "list_expanded_data_sets" @@ -1680,6 +1810,11 @@ "update_enhanced_measurement_settings" ] }, + "UpdateEventCreateRule": { + "methods": [ + "update_event_create_rule" + ] + }, "UpdateExpandedDataSet": { "methods": [ "update_expanded_data_set" 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 bd9e550d..67513a9c 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 @@ -55,6 +55,7 @@ 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 channel_group +from google.analytics.admin_v1alpha.types import event_create_and_edit from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources @@ -83,6 +84,10 @@ class AnalyticsAdminServiceAsyncClient: parse_account_summary_path = staticmethod( AnalyticsAdminServiceClient.parse_account_summary_path ) + ad_sense_link_path = staticmethod(AnalyticsAdminServiceClient.ad_sense_link_path) + parse_ad_sense_link_path = staticmethod( + AnalyticsAdminServiceClient.parse_ad_sense_link_path + ) attribution_settings_path = staticmethod( AnalyticsAdminServiceClient.attribution_settings_path ) @@ -149,6 +154,12 @@ class AnalyticsAdminServiceAsyncClient: parse_enhanced_measurement_settings_path = staticmethod( AnalyticsAdminServiceClient.parse_enhanced_measurement_settings_path ) + event_create_rule_path = staticmethod( + AnalyticsAdminServiceClient.event_create_rule_path + ) + parse_event_create_rule_path = staticmethod( + AnalyticsAdminServiceClient.parse_event_create_rule_path + ) expanded_data_set_path = staticmethod( AnalyticsAdminServiceClient.expanded_data_set_path ) @@ -12225,6 +12236,1027 @@ async def sample_fetch_connected_ga4_property(): # Done; return the response. return response + async def get_ad_sense_link( + self, + request: Optional[Union[analytics_admin.GetAdSenseLinkRequest, 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.AdSenseLink: + r"""Looks up a single AdSenseLink. + + .. 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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetAdSenseLinkRequest( + name="name_value", + ) + + # Make the request + response = await client.get_ad_sense_link(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.GetAdSenseLinkRequest, dict]]): + The request object. Request message to be passed to + GetAdSenseLink method. + name (:class:`str`): + Required. Unique identifier for the + AdSense Link requested. Format: + properties/{propertyId}/adSenseLinks/{linkId} + Example: + properties/1234/adSenseLinks/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.AdSenseLink: + A link between a GA4 Property and an + AdSense for Content ad client. + + """ + # 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.GetAdSenseLinkRequest(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_ad_sense_link, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_ad_sense_link( + self, + request: Optional[Union[analytics_admin.CreateAdSenseLinkRequest, dict]] = None, + *, + parent: Optional[str] = None, + adsense_link: Optional[resources.AdSenseLink] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AdSenseLink: + r"""Creates an AdSenseLink. + + .. 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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.CreateAdSenseLinkRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_ad_sense_link(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.CreateAdSenseLinkRequest, dict]]): + The request object. Request message to be passed to + CreateAdSenseLink method. + parent (:class:`str`): + Required. The property for which to + create an AdSense Link. Format: + properties/{propertyId} Example: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + adsense_link (:class:`google.analytics.admin_v1alpha.types.AdSenseLink`): + Required. The AdSense Link to create + This corresponds to the ``adsense_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AdSenseLink: + A link between a GA4 Property and an + AdSense for Content ad client. + + """ + # 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, adsense_link]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = analytics_admin.CreateAdSenseLinkRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if adsense_link is not None: + request.adsense_link = adsense_link + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_ad_sense_link, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_ad_sense_link( + self, + request: Optional[Union[analytics_admin.DeleteAdSenseLinkRequest, 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 AdSenseLink. + + .. 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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteAdSenseLinkRequest( + name="name_value", + ) + + # Make the request + await client.delete_ad_sense_link(request=request) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.DeleteAdSenseLinkRequest, dict]]): + The request object. Request message to be passed to + DeleteAdSenseLink method. + name (:class:`str`): + Required. Unique identifier for the + AdSense Link to be deleted. Format: + properties/{propertyId}/adSenseLinks/{linkId} + Example: + properties/1234/adSenseLinks/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.DeleteAdSenseLinkRequest(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_ad_sense_link, + 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_ad_sense_links( + self, + request: Optional[Union[analytics_admin.ListAdSenseLinksRequest, 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.ListAdSenseLinksAsyncPager: + r"""Lists AdSenseLinks 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_ad_sense_links(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListAdSenseLinksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_ad_sense_links(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.ListAdSenseLinksRequest, dict]]): + The request object. Request message to be passed to + ListAdSenseLinks method. + parent (:class:`str`): + Required. Resource name of the parent + property. Format: + properties/{propertyId} + Example: properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAdSenseLinksAsyncPager: + Response message for ListAdSenseLinks + method. + 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.ListAdSenseLinksRequest(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_ad_sense_links, + 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.ListAdSenseLinksAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_event_create_rule( + self, + request: Optional[ + Union[analytics_admin.GetEventCreateRuleRequest, 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]] = (), + ) -> event_create_and_edit.EventCreateRule: + r"""Lookup for a single EventCreateRule. + + .. 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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetEventCreateRuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_event_create_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.GetEventCreateRuleRequest, dict]]): + The request object. Request message for + GetEventCreateRule RPC. + name (:class:`str`): + Required. The name of the + EventCreateRule to get. Example format: + properties/123/dataStreams/456/eventCreateRules/789 + + 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.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + # 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.GetEventCreateRuleRequest(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_event_create_rule, + 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_event_create_rules( + self, + request: Optional[ + Union[analytics_admin.ListEventCreateRulesRequest, 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.ListEventCreateRulesAsyncPager: + r"""Lists EventCreateRules on a web data stream. + + .. 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_event_create_rules(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListEventCreateRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_event_create_rules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.ListEventCreateRulesRequest, dict]]): + The request object. Request message for + ListEventCreateRules RPC. + parent (:class:`str`): + Required. Example format: + properties/123/dataStreams/456 + + 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.ListEventCreateRulesAsyncPager: + Response message for + ListEventCreateRules 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.ListEventCreateRulesRequest(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_event_create_rules, + 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.ListEventCreateRulesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_event_create_rule( + self, + request: Optional[ + Union[analytics_admin.CreateEventCreateRuleRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + event_create_rule: Optional[event_create_and_edit.EventCreateRule] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> event_create_and_edit.EventCreateRule: + r"""Creates an EventCreateRule. + + .. 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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + event_create_rule = admin_v1alpha.EventCreateRule() + event_create_rule.destination_event = "destination_event_value" + event_create_rule.event_conditions.field = "field_value" + event_create_rule.event_conditions.comparison_type = "REGULAR_EXPRESSION_CASE_INSENSITIVE" + event_create_rule.event_conditions.value = "value_value" + + request = admin_v1alpha.CreateEventCreateRuleRequest( + parent="parent_value", + event_create_rule=event_create_rule, + ) + + # Make the request + response = await client.create_event_create_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.CreateEventCreateRuleRequest, dict]]): + The request object. Request message for + CreateEventCreateRule RPC. + parent (:class:`str`): + Required. Example format: + properties/123/dataStreams/456 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + event_create_rule (:class:`google.analytics.admin_v1alpha.types.EventCreateRule`): + Required. The EventCreateRule to + create. + + This corresponds to the ``event_create_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout 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.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + # 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, event_create_rule]) + if request is 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.CreateEventCreateRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if event_create_rule is not None: + request.event_create_rule = event_create_rule + + # 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_event_create_rule, + 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_event_create_rule( + self, + request: Optional[ + Union[analytics_admin.UpdateEventCreateRuleRequest, dict] + ] = None, + *, + event_create_rule: Optional[event_create_and_edit.EventCreateRule] = 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]] = (), + ) -> event_create_and_edit.EventCreateRule: + r"""Updates an EventCreateRule. + + .. 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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + event_create_rule = admin_v1alpha.EventCreateRule() + event_create_rule.destination_event = "destination_event_value" + event_create_rule.event_conditions.field = "field_value" + event_create_rule.event_conditions.comparison_type = "REGULAR_EXPRESSION_CASE_INSENSITIVE" + event_create_rule.event_conditions.value = "value_value" + + request = admin_v1alpha.UpdateEventCreateRuleRequest( + event_create_rule=event_create_rule, + ) + + # Make the request + response = await client.update_event_create_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.UpdateEventCreateRuleRequest, dict]]): + The request object. Request message for + UpdateEventCreateRule RPC. + event_create_rule (:class:`google.analytics.admin_v1alpha.types.EventCreateRule`): + Required. The EventCreateRule to update. The resource's + ``name`` field is used to identify the EventCreateRule + to be updated. + + This corresponds to the ``event_create_rule`` 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.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + # 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([event_create_rule, 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.UpdateEventCreateRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if event_create_rule is not None: + request.event_create_rule = event_create_rule + 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_event_create_rule, + 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( + (("event_create_rule.name", request.event_create_rule.name),) + ), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_event_create_rule( + self, + request: Optional[ + Union[analytics_admin.DeleteEventCreateRuleRequest, 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 EventCreateRule. + + .. 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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteEventCreateRuleRequest( + name="name_value", + ) + + # Make the request + await client.delete_event_create_rule(request=request) + + Args: + request (Optional[Union[google.analytics.admin_v1alpha.types.DeleteEventCreateRuleRequest, dict]]): + The request object. Request message for + DeleteEventCreateRule RPC. + name (:class:`str`): + Required. Example format: + properties/123/dataStreams/456/eventCreateRules/789 + + 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.DeleteEventCreateRuleRequest(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_event_create_rule, + 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 __aenter__(self): return self 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 0af3e184..e1add1ca 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py @@ -59,6 +59,7 @@ 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 channel_group +from google.analytics.admin_v1alpha.types import event_create_and_edit from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources @@ -239,6 +240,25 @@ def parse_account_summary_path(path: str) -> Dict[str, str]: m = re.match(r"^accountSummaries/(?P.+?)$", path) return m.groupdict() if m else {} + @staticmethod + def ad_sense_link_path( + property: str, + adsense_link: str, + ) -> str: + """Returns a fully-qualified ad_sense_link string.""" + return "properties/{property}/adSenseLinks/{adsense_link}".format( + property=property, + adsense_link=adsense_link, + ) + + @staticmethod + def parse_ad_sense_link_path(path: str) -> Dict[str, str]: + """Parses a ad_sense_link path into its component segments.""" + m = re.match( + r"^properties/(?P.+?)/adSenseLinks/(?P.+?)$", path + ) + return m.groupdict() if m else {} + @staticmethod def attribution_settings_path( property: str, @@ -481,6 +501,28 @@ def parse_enhanced_measurement_settings_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def event_create_rule_path( + property: str, + data_stream: str, + event_create_rule: str, + ) -> str: + """Returns a fully-qualified event_create_rule string.""" + return "properties/{property}/dataStreams/{data_stream}/eventCreateRules/{event_create_rule}".format( + property=property, + data_stream=data_stream, + event_create_rule=event_create_rule, + ) + + @staticmethod + def parse_event_create_rule_path(path: str) -> Dict[str, str]: + """Parses a event_create_rule path into its component segments.""" + m = re.match( + r"^properties/(?P.+?)/dataStreams/(?P.+?)/eventCreateRules/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def expanded_data_set_path( property: str, @@ -12923,6 +12965,1027 @@ def sample_fetch_connected_ga4_property(): # Done; return the response. return response + def get_ad_sense_link( + self, + request: Optional[Union[analytics_admin.GetAdSenseLinkRequest, 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.AdSenseLink: + r"""Looks up a single AdSenseLink. + + .. 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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetAdSenseLinkRequest( + name="name_value", + ) + + # Make the request + response = client.get_ad_sense_link(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.GetAdSenseLinkRequest, dict]): + The request object. Request message to be passed to + GetAdSenseLink method. + name (str): + Required. Unique identifier for the + AdSense Link requested. Format: + properties/{propertyId}/adSenseLinks/{linkId} + Example: + properties/1234/adSenseLinks/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.AdSenseLink: + A link between a GA4 Property and an + AdSense for Content ad client. + + """ + # 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.GetAdSenseLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetAdSenseLinkRequest): + request = analytics_admin.GetAdSenseLinkRequest(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_ad_sense_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_ad_sense_link( + self, + request: Optional[Union[analytics_admin.CreateAdSenseLinkRequest, dict]] = None, + *, + parent: Optional[str] = None, + adsense_link: Optional[resources.AdSenseLink] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AdSenseLink: + r"""Creates an AdSenseLink. + + .. 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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.CreateAdSenseLinkRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_ad_sense_link(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.CreateAdSenseLinkRequest, dict]): + The request object. Request message to be passed to + CreateAdSenseLink method. + parent (str): + Required. The property for which to + create an AdSense Link. Format: + properties/{propertyId} Example: + properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + adsense_link (google.analytics.admin_v1alpha.types.AdSenseLink): + Required. The AdSense Link to create + This corresponds to the ``adsense_link`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.types.AdSenseLink: + A link between a GA4 Property and an + AdSense for Content ad client. + + """ + # 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, adsense_link]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a analytics_admin.CreateAdSenseLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateAdSenseLinkRequest): + request = analytics_admin.CreateAdSenseLinkRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if adsense_link is not None: + request.adsense_link = adsense_link + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_ad_sense_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_ad_sense_link( + self, + request: Optional[Union[analytics_admin.DeleteAdSenseLinkRequest, 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 AdSenseLink. + + .. 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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteAdSenseLinkRequest( + name="name_value", + ) + + # Make the request + client.delete_ad_sense_link(request=request) + + Args: + request (Union[google.analytics.admin_v1alpha.types.DeleteAdSenseLinkRequest, dict]): + The request object. Request message to be passed to + DeleteAdSenseLink method. + name (str): + Required. Unique identifier for the + AdSense Link to be deleted. Format: + properties/{propertyId}/adSenseLinks/{linkId} + Example: + properties/1234/adSenseLinks/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.DeleteAdSenseLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteAdSenseLinkRequest): + request = analytics_admin.DeleteAdSenseLinkRequest(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_ad_sense_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def list_ad_sense_links( + self, + request: Optional[Union[analytics_admin.ListAdSenseLinksRequest, 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.ListAdSenseLinksPager: + r"""Lists AdSenseLinks 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_ad_sense_links(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListAdSenseLinksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_ad_sense_links(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.ListAdSenseLinksRequest, dict]): + The request object. Request message to be passed to + ListAdSenseLinks method. + parent (str): + Required. Resource name of the parent + property. Format: + properties/{propertyId} + Example: properties/1234 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAdSenseLinksPager: + Response message for ListAdSenseLinks + method. + 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.ListAdSenseLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListAdSenseLinksRequest): + request = analytics_admin.ListAdSenseLinksRequest(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_ad_sense_links] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListAdSenseLinksPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_event_create_rule( + self, + request: Optional[ + Union[analytics_admin.GetEventCreateRuleRequest, 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]] = (), + ) -> event_create_and_edit.EventCreateRule: + r"""Lookup for a single EventCreateRule. + + .. 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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetEventCreateRuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_event_create_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.GetEventCreateRuleRequest, dict]): + The request object. Request message for + GetEventCreateRule RPC. + name (str): + Required. The name of the + EventCreateRule to get. Example format: + properties/123/dataStreams/456/eventCreateRules/789 + + 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.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + # 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.GetEventCreateRuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.GetEventCreateRuleRequest): + request = analytics_admin.GetEventCreateRuleRequest(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_event_create_rule] + + # 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_event_create_rules( + self, + request: Optional[ + Union[analytics_admin.ListEventCreateRulesRequest, 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.ListEventCreateRulesPager: + r"""Lists EventCreateRules on a web data stream. + + .. 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_event_create_rules(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListEventCreateRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_event_create_rules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.ListEventCreateRulesRequest, dict]): + The request object. Request message for + ListEventCreateRules RPC. + parent (str): + Required. Example format: + properties/123/dataStreams/456 + + 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.ListEventCreateRulesPager: + Response message for + ListEventCreateRules 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.ListEventCreateRulesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.ListEventCreateRulesRequest): + request = analytics_admin.ListEventCreateRulesRequest(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_event_create_rules] + + # 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.ListEventCreateRulesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_event_create_rule( + self, + request: Optional[ + Union[analytics_admin.CreateEventCreateRuleRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + event_create_rule: Optional[event_create_and_edit.EventCreateRule] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> event_create_and_edit.EventCreateRule: + r"""Creates an EventCreateRule. + + .. 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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + event_create_rule = admin_v1alpha.EventCreateRule() + event_create_rule.destination_event = "destination_event_value" + event_create_rule.event_conditions.field = "field_value" + event_create_rule.event_conditions.comparison_type = "REGULAR_EXPRESSION_CASE_INSENSITIVE" + event_create_rule.event_conditions.value = "value_value" + + request = admin_v1alpha.CreateEventCreateRuleRequest( + parent="parent_value", + event_create_rule=event_create_rule, + ) + + # Make the request + response = client.create_event_create_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.CreateEventCreateRuleRequest, dict]): + The request object. Request message for + CreateEventCreateRule RPC. + parent (str): + Required. Example format: + properties/123/dataStreams/456 + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + event_create_rule (google.analytics.admin_v1alpha.types.EventCreateRule): + Required. The EventCreateRule to + create. + + This corresponds to the ``event_create_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout 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.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + # 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, event_create_rule]) + if request is 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.CreateEventCreateRuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.CreateEventCreateRuleRequest): + request = analytics_admin.CreateEventCreateRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if event_create_rule is not None: + request.event_create_rule = event_create_rule + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_event_create_rule] + + # 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_event_create_rule( + self, + request: Optional[ + Union[analytics_admin.UpdateEventCreateRuleRequest, dict] + ] = None, + *, + event_create_rule: Optional[event_create_and_edit.EventCreateRule] = 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]] = (), + ) -> event_create_and_edit.EventCreateRule: + r"""Updates an EventCreateRule. + + .. 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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + event_create_rule = admin_v1alpha.EventCreateRule() + event_create_rule.destination_event = "destination_event_value" + event_create_rule.event_conditions.field = "field_value" + event_create_rule.event_conditions.comparison_type = "REGULAR_EXPRESSION_CASE_INSENSITIVE" + event_create_rule.event_conditions.value = "value_value" + + request = admin_v1alpha.UpdateEventCreateRuleRequest( + event_create_rule=event_create_rule, + ) + + # Make the request + response = client.update_event_create_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.analytics.admin_v1alpha.types.UpdateEventCreateRuleRequest, dict]): + The request object. Request message for + UpdateEventCreateRule RPC. + event_create_rule (google.analytics.admin_v1alpha.types.EventCreateRule): + Required. The EventCreateRule to update. The resource's + ``name`` field is used to identify the EventCreateRule + to be updated. + + This corresponds to the ``event_create_rule`` 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.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + # 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([event_create_rule, 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.UpdateEventCreateRuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.UpdateEventCreateRuleRequest): + request = analytics_admin.UpdateEventCreateRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if event_create_rule is not None: + request.event_create_rule = event_create_rule + 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_event_create_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("event_create_rule.name", request.event_create_rule.name),) + ), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_event_create_rule( + self, + request: Optional[ + Union[analytics_admin.DeleteEventCreateRuleRequest, 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 EventCreateRule. + + .. 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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteEventCreateRuleRequest( + name="name_value", + ) + + # Make the request + client.delete_event_create_rule(request=request) + + Args: + request (Union[google.analytics.admin_v1alpha.types.DeleteEventCreateRuleRequest, dict]): + The request object. Request message for + DeleteEventCreateRule RPC. + name (str): + Required. Example format: + properties/123/dataStreams/456/eventCreateRules/789 + + 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.DeleteEventCreateRuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, analytics_admin.DeleteEventCreateRuleRequest): + request = analytics_admin.DeleteEventCreateRuleRequest(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_event_create_rule] + + # 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 __enter__(self) -> "AnalyticsAdminServiceClient": return self 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 937de198..fe36424d 100644 --- a/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py +++ b/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py @@ -28,6 +28,7 @@ analytics_admin, audience, channel_group, + event_create_and_edit, expanded_data_set, resources, ) @@ -2768,3 +2769,261 @@ async def async_generator(): def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAdSenseLinksPager: + """A pager for iterating through ``list_ad_sense_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAdSenseLinksResponse` object, and + provides an ``__iter__`` method to iterate through its + ``adsense_links`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAdSenseLinks`` requests and continue to iterate + through the ``adsense_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAdSenseLinksResponse` + 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.ListAdSenseLinksResponse], + request: analytics_admin.ListAdSenseLinksRequest, + response: analytics_admin.ListAdSenseLinksResponse, + *, + 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.ListAdSenseLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAdSenseLinksResponse): + 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.ListAdSenseLinksRequest(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.ListAdSenseLinksResponse]: + 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.AdSenseLink]: + for page in self.pages: + yield from page.adsense_links + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAdSenseLinksAsyncPager: + """A pager for iterating through ``list_ad_sense_links`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListAdSenseLinksResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``adsense_links`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAdSenseLinks`` requests and continue to iterate + through the ``adsense_links`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListAdSenseLinksResponse` + 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.ListAdSenseLinksResponse]], + request: analytics_admin.ListAdSenseLinksRequest, + response: analytics_admin.ListAdSenseLinksResponse, + *, + 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.ListAdSenseLinksRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListAdSenseLinksResponse): + 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.ListAdSenseLinksRequest(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.ListAdSenseLinksResponse]: + 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.AdSenseLink]: + async def async_generator(): + async for page in self.pages: + for response in page.adsense_links: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListEventCreateRulesPager: + """A pager for iterating through ``list_event_create_rules`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListEventCreateRulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``event_create_rules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListEventCreateRules`` requests and continue to iterate + through the ``event_create_rules`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListEventCreateRulesResponse` + 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.ListEventCreateRulesResponse], + request: analytics_admin.ListEventCreateRulesRequest, + response: analytics_admin.ListEventCreateRulesResponse, + *, + 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.ListEventCreateRulesRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListEventCreateRulesResponse): + 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.ListEventCreateRulesRequest(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.ListEventCreateRulesResponse]: + 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[event_create_and_edit.EventCreateRule]: + for page in self.pages: + yield from page.event_create_rules + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListEventCreateRulesAsyncPager: + """A pager for iterating through ``list_event_create_rules`` requests. + + This class thinly wraps an initial + :class:`google.analytics.admin_v1alpha.types.ListEventCreateRulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``event_create_rules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListEventCreateRules`` requests and continue to iterate + through the ``event_create_rules`` field on the + corresponding responses. + + All the usual :class:`google.analytics.admin_v1alpha.types.ListEventCreateRulesResponse` + 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.ListEventCreateRulesResponse]], + request: analytics_admin.ListEventCreateRulesRequest, + response: analytics_admin.ListEventCreateRulesResponse, + *, + 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.ListEventCreateRulesRequest): + The initial request object. + response (google.analytics.admin_v1alpha.types.ListEventCreateRulesResponse): + 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.ListEventCreateRulesRequest(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.ListEventCreateRulesResponse]: + 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[event_create_and_edit.EventCreateRule]: + async def async_generator(): + async for page in self.pages: + for response in page.event_create_rules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) 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 7d162b90..1fe29679 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 @@ -34,6 +34,7 @@ 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 channel_group +from google.analytics.admin_v1alpha.types import event_create_and_edit from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources @@ -702,6 +703,51 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.get_ad_sense_link: gapic_v1.method.wrap_method( + self.get_ad_sense_link, + default_timeout=None, + client_info=client_info, + ), + self.create_ad_sense_link: gapic_v1.method.wrap_method( + self.create_ad_sense_link, + default_timeout=None, + client_info=client_info, + ), + self.delete_ad_sense_link: gapic_v1.method.wrap_method( + self.delete_ad_sense_link, + default_timeout=None, + client_info=client_info, + ), + self.list_ad_sense_links: gapic_v1.method.wrap_method( + self.list_ad_sense_links, + default_timeout=None, + client_info=client_info, + ), + self.get_event_create_rule: gapic_v1.method.wrap_method( + self.get_event_create_rule, + default_timeout=None, + client_info=client_info, + ), + self.list_event_create_rules: gapic_v1.method.wrap_method( + self.list_event_create_rules, + default_timeout=None, + client_info=client_info, + ), + self.create_event_create_rule: gapic_v1.method.wrap_method( + self.create_event_create_rule, + default_timeout=None, + client_info=client_info, + ), + self.update_event_create_rule: gapic_v1.method.wrap_method( + self.update_event_create_rule, + default_timeout=None, + client_info=client_info, + ), + self.delete_event_create_rule: gapic_v1.method.wrap_method( + self.delete_event_create_rule, + default_timeout=None, + client_info=client_info, + ), } def close(self): @@ -1896,6 +1942,102 @@ def fetch_connected_ga4_property( ]: raise NotImplementedError() + @property + def get_ad_sense_link( + self, + ) -> Callable[ + [analytics_admin.GetAdSenseLinkRequest], + Union[resources.AdSenseLink, Awaitable[resources.AdSenseLink]], + ]: + raise NotImplementedError() + + @property + def create_ad_sense_link( + self, + ) -> Callable[ + [analytics_admin.CreateAdSenseLinkRequest], + Union[resources.AdSenseLink, Awaitable[resources.AdSenseLink]], + ]: + raise NotImplementedError() + + @property + def delete_ad_sense_link( + self, + ) -> Callable[ + [analytics_admin.DeleteAdSenseLinkRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def list_ad_sense_links( + self, + ) -> Callable[ + [analytics_admin.ListAdSenseLinksRequest], + Union[ + analytics_admin.ListAdSenseLinksResponse, + Awaitable[analytics_admin.ListAdSenseLinksResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.GetEventCreateRuleRequest], + Union[ + event_create_and_edit.EventCreateRule, + Awaitable[event_create_and_edit.EventCreateRule], + ], + ]: + raise NotImplementedError() + + @property + def list_event_create_rules( + self, + ) -> Callable[ + [analytics_admin.ListEventCreateRulesRequest], + Union[ + analytics_admin.ListEventCreateRulesResponse, + Awaitable[analytics_admin.ListEventCreateRulesResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.CreateEventCreateRuleRequest], + Union[ + event_create_and_edit.EventCreateRule, + Awaitable[event_create_and_edit.EventCreateRule], + ], + ]: + raise NotImplementedError() + + @property + def update_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.UpdateEventCreateRuleRequest], + Union[ + event_create_and_edit.EventCreateRule, + Awaitable[event_create_and_edit.EventCreateRule], + ], + ]: + raise NotImplementedError() + + @property + def delete_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.DeleteEventCreateRuleRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() 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 79b45759..fa0a6779 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 @@ -31,6 +31,7 @@ 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 channel_group +from google.analytics.admin_v1alpha.types import event_create_and_edit from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources @@ -3573,6 +3574,255 @@ def fetch_connected_ga4_property( ) return self._stubs["fetch_connected_ga4_property"] + @property + def get_ad_sense_link( + self, + ) -> Callable[[analytics_admin.GetAdSenseLinkRequest], resources.AdSenseLink]: + r"""Return a callable for the get ad sense link method over gRPC. + + Looks up a single AdSenseLink. + + Returns: + Callable[[~.GetAdSenseLinkRequest], + ~.AdSenseLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ad_sense_link" not in self._stubs: + self._stubs["get_ad_sense_link"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAdSenseLink", + request_serializer=analytics_admin.GetAdSenseLinkRequest.serialize, + response_deserializer=resources.AdSenseLink.deserialize, + ) + return self._stubs["get_ad_sense_link"] + + @property + def create_ad_sense_link( + self, + ) -> Callable[[analytics_admin.CreateAdSenseLinkRequest], resources.AdSenseLink]: + r"""Return a callable for the create ad sense link method over gRPC. + + Creates an AdSenseLink. + + Returns: + Callable[[~.CreateAdSenseLinkRequest], + ~.AdSenseLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ad_sense_link" not in self._stubs: + self._stubs["create_ad_sense_link"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAdSenseLink", + request_serializer=analytics_admin.CreateAdSenseLinkRequest.serialize, + response_deserializer=resources.AdSenseLink.deserialize, + ) + return self._stubs["create_ad_sense_link"] + + @property + def delete_ad_sense_link( + self, + ) -> Callable[[analytics_admin.DeleteAdSenseLinkRequest], empty_pb2.Empty]: + r"""Return a callable for the delete ad sense link method over gRPC. + + Deletes an AdSenseLink. + + Returns: + Callable[[~.DeleteAdSenseLinkRequest], + ~.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_ad_sense_link" not in self._stubs: + self._stubs["delete_ad_sense_link"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAdSenseLink", + request_serializer=analytics_admin.DeleteAdSenseLinkRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_ad_sense_link"] + + @property + def list_ad_sense_links( + self, + ) -> Callable[ + [analytics_admin.ListAdSenseLinksRequest], + analytics_admin.ListAdSenseLinksResponse, + ]: + r"""Return a callable for the list ad sense links method over gRPC. + + Lists AdSenseLinks on a property. + + Returns: + Callable[[~.ListAdSenseLinksRequest], + ~.ListAdSenseLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ad_sense_links" not in self._stubs: + self._stubs["list_ad_sense_links"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAdSenseLinks", + request_serializer=analytics_admin.ListAdSenseLinksRequest.serialize, + response_deserializer=analytics_admin.ListAdSenseLinksResponse.deserialize, + ) + return self._stubs["list_ad_sense_links"] + + @property + def get_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.GetEventCreateRuleRequest], + event_create_and_edit.EventCreateRule, + ]: + r"""Return a callable for the get event create rule method over gRPC. + + Lookup for a single EventCreateRule. + + Returns: + Callable[[~.GetEventCreateRuleRequest], + ~.EventCreateRule]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_event_create_rule" not in self._stubs: + self._stubs["get_event_create_rule"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEventCreateRule", + request_serializer=analytics_admin.GetEventCreateRuleRequest.serialize, + response_deserializer=event_create_and_edit.EventCreateRule.deserialize, + ) + return self._stubs["get_event_create_rule"] + + @property + def list_event_create_rules( + self, + ) -> Callable[ + [analytics_admin.ListEventCreateRulesRequest], + analytics_admin.ListEventCreateRulesResponse, + ]: + r"""Return a callable for the list event create rules method over gRPC. + + Lists EventCreateRules on a web data stream. + + Returns: + Callable[[~.ListEventCreateRulesRequest], + ~.ListEventCreateRulesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_event_create_rules" not in self._stubs: + self._stubs["list_event_create_rules"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListEventCreateRules", + request_serializer=analytics_admin.ListEventCreateRulesRequest.serialize, + response_deserializer=analytics_admin.ListEventCreateRulesResponse.deserialize, + ) + return self._stubs["list_event_create_rules"] + + @property + def create_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.CreateEventCreateRuleRequest], + event_create_and_edit.EventCreateRule, + ]: + r"""Return a callable for the create event create rule method over gRPC. + + Creates an EventCreateRule. + + Returns: + Callable[[~.CreateEventCreateRuleRequest], + ~.EventCreateRule]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_event_create_rule" not in self._stubs: + self._stubs["create_event_create_rule"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateEventCreateRule", + request_serializer=analytics_admin.CreateEventCreateRuleRequest.serialize, + response_deserializer=event_create_and_edit.EventCreateRule.deserialize, + ) + return self._stubs["create_event_create_rule"] + + @property + def update_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.UpdateEventCreateRuleRequest], + event_create_and_edit.EventCreateRule, + ]: + r"""Return a callable for the update event create rule method over gRPC. + + Updates an EventCreateRule. + + Returns: + Callable[[~.UpdateEventCreateRuleRequest], + ~.EventCreateRule]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_event_create_rule" not in self._stubs: + self._stubs["update_event_create_rule"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEventCreateRule", + request_serializer=analytics_admin.UpdateEventCreateRuleRequest.serialize, + response_deserializer=event_create_and_edit.EventCreateRule.deserialize, + ) + return self._stubs["update_event_create_rule"] + + @property + def delete_event_create_rule( + self, + ) -> Callable[[analytics_admin.DeleteEventCreateRuleRequest], empty_pb2.Empty]: + r"""Return a callable for the delete event create rule method over gRPC. + + Deletes an EventCreateRule. + + Returns: + Callable[[~.DeleteEventCreateRuleRequest], + ~.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_event_create_rule" not in self._stubs: + self._stubs["delete_event_create_rule"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteEventCreateRule", + request_serializer=analytics_admin.DeleteEventCreateRuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_event_create_rule"] + def close(self): self.grpc_channel.close() 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 68c5da92..ae8b9a16 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 @@ -31,6 +31,7 @@ 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 channel_group +from google.analytics.admin_v1alpha.types import event_create_and_edit from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources @@ -3658,6 +3659,263 @@ def fetch_connected_ga4_property( ) return self._stubs["fetch_connected_ga4_property"] + @property + def get_ad_sense_link( + self, + ) -> Callable[ + [analytics_admin.GetAdSenseLinkRequest], Awaitable[resources.AdSenseLink] + ]: + r"""Return a callable for the get ad sense link method over gRPC. + + Looks up a single AdSenseLink. + + Returns: + Callable[[~.GetAdSenseLinkRequest], + Awaitable[~.AdSenseLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ad_sense_link" not in self._stubs: + self._stubs["get_ad_sense_link"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAdSenseLink", + request_serializer=analytics_admin.GetAdSenseLinkRequest.serialize, + response_deserializer=resources.AdSenseLink.deserialize, + ) + return self._stubs["get_ad_sense_link"] + + @property + def create_ad_sense_link( + self, + ) -> Callable[ + [analytics_admin.CreateAdSenseLinkRequest], Awaitable[resources.AdSenseLink] + ]: + r"""Return a callable for the create ad sense link method over gRPC. + + Creates an AdSenseLink. + + Returns: + Callable[[~.CreateAdSenseLinkRequest], + Awaitable[~.AdSenseLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ad_sense_link" not in self._stubs: + self._stubs["create_ad_sense_link"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAdSenseLink", + request_serializer=analytics_admin.CreateAdSenseLinkRequest.serialize, + response_deserializer=resources.AdSenseLink.deserialize, + ) + return self._stubs["create_ad_sense_link"] + + @property + def delete_ad_sense_link( + self, + ) -> Callable[ + [analytics_admin.DeleteAdSenseLinkRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete ad sense link method over gRPC. + + Deletes an AdSenseLink. + + Returns: + Callable[[~.DeleteAdSenseLinkRequest], + 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_ad_sense_link" not in self._stubs: + self._stubs["delete_ad_sense_link"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAdSenseLink", + request_serializer=analytics_admin.DeleteAdSenseLinkRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_ad_sense_link"] + + @property + def list_ad_sense_links( + self, + ) -> Callable[ + [analytics_admin.ListAdSenseLinksRequest], + Awaitable[analytics_admin.ListAdSenseLinksResponse], + ]: + r"""Return a callable for the list ad sense links method over gRPC. + + Lists AdSenseLinks on a property. + + Returns: + Callable[[~.ListAdSenseLinksRequest], + Awaitable[~.ListAdSenseLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_ad_sense_links" not in self._stubs: + self._stubs["list_ad_sense_links"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAdSenseLinks", + request_serializer=analytics_admin.ListAdSenseLinksRequest.serialize, + response_deserializer=analytics_admin.ListAdSenseLinksResponse.deserialize, + ) + return self._stubs["list_ad_sense_links"] + + @property + def get_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.GetEventCreateRuleRequest], + Awaitable[event_create_and_edit.EventCreateRule], + ]: + r"""Return a callable for the get event create rule method over gRPC. + + Lookup for a single EventCreateRule. + + Returns: + Callable[[~.GetEventCreateRuleRequest], + Awaitable[~.EventCreateRule]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_event_create_rule" not in self._stubs: + self._stubs["get_event_create_rule"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEventCreateRule", + request_serializer=analytics_admin.GetEventCreateRuleRequest.serialize, + response_deserializer=event_create_and_edit.EventCreateRule.deserialize, + ) + return self._stubs["get_event_create_rule"] + + @property + def list_event_create_rules( + self, + ) -> Callable[ + [analytics_admin.ListEventCreateRulesRequest], + Awaitable[analytics_admin.ListEventCreateRulesResponse], + ]: + r"""Return a callable for the list event create rules method over gRPC. + + Lists EventCreateRules on a web data stream. + + Returns: + Callable[[~.ListEventCreateRulesRequest], + Awaitable[~.ListEventCreateRulesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_event_create_rules" not in self._stubs: + self._stubs["list_event_create_rules"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListEventCreateRules", + request_serializer=analytics_admin.ListEventCreateRulesRequest.serialize, + response_deserializer=analytics_admin.ListEventCreateRulesResponse.deserialize, + ) + return self._stubs["list_event_create_rules"] + + @property + def create_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.CreateEventCreateRuleRequest], + Awaitable[event_create_and_edit.EventCreateRule], + ]: + r"""Return a callable for the create event create rule method over gRPC. + + Creates an EventCreateRule. + + Returns: + Callable[[~.CreateEventCreateRuleRequest], + Awaitable[~.EventCreateRule]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_event_create_rule" not in self._stubs: + self._stubs["create_event_create_rule"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateEventCreateRule", + request_serializer=analytics_admin.CreateEventCreateRuleRequest.serialize, + response_deserializer=event_create_and_edit.EventCreateRule.deserialize, + ) + return self._stubs["create_event_create_rule"] + + @property + def update_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.UpdateEventCreateRuleRequest], + Awaitable[event_create_and_edit.EventCreateRule], + ]: + r"""Return a callable for the update event create rule method over gRPC. + + Updates an EventCreateRule. + + Returns: + Callable[[~.UpdateEventCreateRuleRequest], + Awaitable[~.EventCreateRule]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_event_create_rule" not in self._stubs: + self._stubs["update_event_create_rule"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEventCreateRule", + request_serializer=analytics_admin.UpdateEventCreateRuleRequest.serialize, + response_deserializer=event_create_and_edit.EventCreateRule.deserialize, + ) + return self._stubs["update_event_create_rule"] + + @property + def delete_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.DeleteEventCreateRuleRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete event create rule method over gRPC. + + Deletes an EventCreateRule. + + Returns: + Callable[[~.DeleteEventCreateRuleRequest], + 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_event_create_rule" not in self._stubs: + self._stubs["delete_event_create_rule"] = self.grpc_channel.unary_unary( + "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteEventCreateRule", + request_serializer=analytics_admin.DeleteEventCreateRuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_event_create_rule"] + def close(self): return self.grpc_channel.close() 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 5e6d5d31..092ee1ae 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 @@ -46,6 +46,7 @@ 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 channel_group +from google.analytics.admin_v1alpha.types import event_create_and_edit from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources @@ -182,6 +183,14 @@ def post_create_access_binding(self, response): logging.log(f"Received response: {response}") return response + def pre_create_ad_sense_link(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_ad_sense_link(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 @@ -254,6 +263,14 @@ def post_create_display_video360_advertiser_link_proposal(self, response): logging.log(f"Received response: {response}") return response + def pre_create_event_create_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_event_create_rule(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 @@ -318,6 +335,10 @@ def pre_delete_account(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata + def pre_delete_ad_sense_link(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + def pre_delete_channel_group(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -342,6 +363,10 @@ def pre_delete_display_video360_advertiser_link_proposal(self, request, metadata logging.log(f"Received request: {request}") return request, metadata + def pre_delete_event_create_rule(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 @@ -406,6 +431,14 @@ def post_get_account(self, response): logging.log(f"Received response: {response}") return response + def pre_get_ad_sense_link(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_ad_sense_link(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_attribution_settings(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -510,6 +543,14 @@ def post_get_enhanced_measurement_settings(self, response): logging.log(f"Received response: {response}") return response + def pre_get_event_create_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_event_create_rule(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 @@ -590,6 +631,14 @@ def post_list_account_summaries(self, response): logging.log(f"Received response: {response}") return response + def pre_list_ad_sense_links(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_ad_sense_links(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_audiences(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -670,6 +719,14 @@ def post_list_display_video360_advertiser_links(self, response): logging.log(f"Received response: {response}") return response + def pre_list_event_create_rules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_event_create_rules(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 @@ -846,6 +903,14 @@ def post_update_enhanced_measurement_settings(self, response): logging.log(f"Received response: {response}") return response + def pre_update_event_create_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_event_create_rule(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 @@ -1240,6 +1305,29 @@ def post_create_access_binding( """ return response + def pre_create_ad_sense_link( + self, + request: analytics_admin.CreateAdSenseLinkRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.CreateAdSenseLinkRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_ad_sense_link + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_create_ad_sense_link( + self, response: resources.AdSenseLink + ) -> resources.AdSenseLink: + """Post-rpc interceptor for create_ad_sense_link + + 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, @@ -1455,6 +1543,29 @@ def post_create_display_video360_advertiser_link_proposal( """ return response + def pre_create_event_create_rule( + self, + request: analytics_admin.CreateEventCreateRuleRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.CreateEventCreateRuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_event_create_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_create_event_create_rule( + self, response: event_create_and_edit.EventCreateRule + ) -> event_create_and_edit.EventCreateRule: + """Post-rpc interceptor for create_event_create_rule + + 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_expanded_data_set( self, request: analytics_admin.CreateExpandedDataSetRequest, @@ -1641,6 +1752,18 @@ def pre_delete_account( """ return request, metadata + def pre_delete_ad_sense_link( + self, + request: analytics_admin.DeleteAdSenseLinkRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.DeleteAdSenseLinkRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_ad_sense_link + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + def pre_delete_channel_group( self, request: analytics_admin.DeleteChannelGroupRequest, @@ -1721,6 +1844,18 @@ def pre_delete_display_video360_advertiser_link_proposal( """ return request, metadata + def pre_delete_event_create_rule( + self, + request: analytics_admin.DeleteEventCreateRuleRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.DeleteEventCreateRuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_event_create_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + def pre_delete_expanded_data_set( self, request: analytics_admin.DeleteExpandedDataSetRequest, @@ -1914,6 +2049,29 @@ def post_get_account(self, response: resources.Account) -> resources.Account: """ return response + def pre_get_ad_sense_link( + self, + request: analytics_admin.GetAdSenseLinkRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.GetAdSenseLinkRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_ad_sense_link + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_get_ad_sense_link( + self, response: resources.AdSenseLink + ) -> resources.AdSenseLink: + """Post-rpc interceptor for get_ad_sense_link + + 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_attribution_settings( self, request: analytics_admin.GetAttributionSettingsRequest, @@ -2225,6 +2383,29 @@ def post_get_enhanced_measurement_settings( """ return response + def pre_get_event_create_rule( + self, + request: analytics_admin.GetEventCreateRuleRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.GetEventCreateRuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_event_create_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_get_event_create_rule( + self, response: event_create_and_edit.EventCreateRule + ) -> event_create_and_edit.EventCreateRule: + """Post-rpc interceptor for get_event_create_rule + + 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_expanded_data_set( self, request: analytics_admin.GetExpandedDataSetRequest, @@ -2455,6 +2636,29 @@ def post_list_account_summaries( """ return response + def pre_list_ad_sense_links( + self, + request: analytics_admin.ListAdSenseLinksRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.ListAdSenseLinksRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_ad_sense_links + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_list_ad_sense_links( + self, response: analytics_admin.ListAdSenseLinksResponse + ) -> analytics_admin.ListAdSenseLinksResponse: + """Post-rpc interceptor for list_ad_sense_links + + 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_audiences( self, request: analytics_admin.ListAudiencesRequest, @@ -2692,6 +2896,29 @@ def post_list_display_video360_advertiser_links( """ return response + def pre_list_event_create_rules( + self, + request: analytics_admin.ListEventCreateRulesRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.ListEventCreateRulesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_event_create_rules + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_list_event_create_rules( + self, response: analytics_admin.ListEventCreateRulesResponse + ) -> analytics_admin.ListEventCreateRulesResponse: + """Post-rpc interceptor for list_event_create_rules + + 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_expanded_data_sets( self, request: analytics_admin.ListExpandedDataSetsRequest, @@ -3215,6 +3442,29 @@ def post_update_enhanced_measurement_settings( """ return response + def pre_update_event_create_rule( + self, + request: analytics_admin.UpdateEventCreateRuleRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[analytics_admin.UpdateEventCreateRuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_event_create_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the AnalyticsAdminService server. + """ + return request, metadata + + def post_update_event_create_rule( + self, response: event_create_and_edit.EventCreateRule + ) -> event_create_and_edit.EventCreateRule: + """Post-rpc interceptor for update_event_create_rule + + 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_expanded_data_set( self, request: analytics_admin.UpdateExpandedDataSetRequest, @@ -5084,6 +5334,106 @@ def __call__( resp = self._interceptor.post_create_access_binding(resp) return resp + class _CreateAdSenseLink(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("CreateAdSenseLink") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @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.CreateAdSenseLinkRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AdSenseLink: + r"""Call the create ad sense link method over HTTP. + + Args: + request (~.analytics_admin.CreateAdSenseLinkRequest): + The request object. Request message to be passed to + CreateAdSenseLink method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + 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.AdSenseLink: + A link between a GA4 Property and an + AdSense for Content ad client. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha/{parent=properties/*}/adSenseLinks", + "body": "adsense_link", + }, + ] + request, metadata = self._interceptor.pre_create_ad_sense_link( + request, metadata + ) + pb_request = analytics_admin.CreateAdSenseLinkRequest.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.AdSenseLink() + pb_resp = resources.AdSenseLink.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_ad_sense_link(resp) + return resp + class _CreateAudience(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("CreateAudience") @@ -6004,9 +6354,9 @@ def __call__( ) return resp - class _CreateExpandedDataSet(AnalyticsAdminServiceRestStub): + class _CreateEventCreateRule(AnalyticsAdminServiceRestStub): def __hash__(self): - return hash("CreateExpandedDataSet") + return hash("CreateEventCreateRule") __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @@ -6020,13 +6370,124 @@ def _get_unset_required_fields(cls, message_dict): def __call__( self, - request: analytics_admin.CreateExpandedDataSetRequest, + request: analytics_admin.CreateEventCreateRuleRequest, *, 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. + ) -> event_create_and_edit.EventCreateRule: + r"""Call the create event create rule method over HTTP. + + Args: + request (~.analytics_admin.CreateEventCreateRuleRequest): + The request object. Request message for + CreateEventCreateRule 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: + ~.event_create_and_edit.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha/{parent=properties/*/dataStreams/*}/eventCreateRules", + "body": "event_create_rule", + }, + ] + request, metadata = self._interceptor.pre_create_event_create_rule( + request, metadata + ) + pb_request = analytics_admin.CreateEventCreateRuleRequest.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 = event_create_and_edit.EventCreateRule() + pb_resp = event_create_and_edit.EventCreateRule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event_create_rule(resp) + return resp + + class _CreateExpandedDataSet(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("CreateExpandedDataSet") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @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): @@ -6880,6 +7341,83 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) + class _DeleteAdSenseLink(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("DeleteAdSenseLink") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @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.DeleteAdSenseLinkRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete ad sense link method over HTTP. + + Args: + request (~.analytics_admin.DeleteAdSenseLinkRequest): + The request object. Request message to be passed to + DeleteAdSenseLink method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be 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/*/adSenseLinks/*}", + }, + ] + request, metadata = self._interceptor.pre_delete_ad_sense_link( + request, metadata + ) + pb_request = analytics_admin.DeleteAdSenseLinkRequest.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 _DeleteChannelGroup(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("DeleteChannelGroup") @@ -7355,6 +7893,83 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) + class _DeleteEventCreateRule(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("DeleteEventCreateRule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @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.DeleteEventCreateRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete event create rule method over HTTP. + + Args: + request (~.analytics_admin.DeleteEventCreateRuleRequest): + The request object. Request message for + DeleteEventCreateRule 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/*/dataStreams/*/eventCreateRules/*}", + }, + ] + request, metadata = self._interceptor.pre_delete_event_create_rule( + request, metadata + ) + pb_request = analytics_admin.DeleteEventCreateRuleRequest.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 _DeleteExpandedDataSet(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("DeleteExpandedDataSet") @@ -8305,6 +8920,97 @@ def __call__( resp = self._interceptor.post_get_account(resp) return resp + class _GetAdSenseLink(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("GetAdSenseLink") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @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.GetAdSenseLinkRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.AdSenseLink: + r"""Call the get ad sense link method over HTTP. + + Args: + request (~.analytics_admin.GetAdSenseLinkRequest): + The request object. Request message to be passed to + GetAdSenseLink method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + 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.AdSenseLink: + A link between a GA4 Property and an + AdSense for Content ad client. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/{name=properties/*/adSenseLinks/*}", + }, + ] + request, metadata = self._interceptor.pre_get_ad_sense_link( + request, metadata + ) + pb_request = analytics_admin.GetAdSenseLinkRequest.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.AdSenseLink() + pb_resp = resources.AdSenseLink.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_ad_sense_link(resp) + return resp + class _GetAttributionSettings(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("GetAttributionSettings") @@ -9511,6 +10217,108 @@ def __call__( resp = self._interceptor.post_get_enhanced_measurement_settings(resp) return resp + class _GetEventCreateRule(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("GetEventCreateRule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @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.GetEventCreateRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> event_create_and_edit.EventCreateRule: + r"""Call the get event create rule method over HTTP. + + Args: + request (~.analytics_admin.GetEventCreateRuleRequest): + The request object. Request message for + GetEventCreateRule 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: + ~.event_create_and_edit.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/{name=properties/*/dataStreams/*/eventCreateRules/*}", + }, + ] + request, metadata = self._interceptor.pre_get_event_create_rule( + request, metadata + ) + pb_request = analytics_admin.GetEventCreateRuleRequest.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 = event_create_and_edit.EventCreateRule() + pb_resp = event_create_and_edit.EventCreateRule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event_create_rule(resp) + return resp + class _GetExpandedDataSet(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("GetExpandedDataSet") @@ -10280,8 +11088,88 @@ def __call__( "uri": "/v1alpha/accounts", }, ] - request, metadata = self._interceptor.pre_list_accounts(request, metadata) - pb_request = analytics_admin.ListAccountsRequest.pb(request) + request, metadata = self._interceptor.pre_list_accounts(request, metadata) + pb_request = analytics_admin.ListAccountsRequest.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["$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.ListAccountsResponse() + pb_resp = analytics_admin.ListAccountsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_accounts(resp) + return resp + + class _ListAccountSummaries(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("ListAccountSummaries") + + def __call__( + self, + request: analytics_admin.ListAccountSummariesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.ListAccountSummariesResponse: + r"""Call the list account summaries method over HTTP. + + Args: + request (~.analytics_admin.ListAccountSummariesRequest): + The request object. Request message for + ListAccountSummaries RPC. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.analytics_admin.ListAccountSummariesResponse: + Response message for + ListAccountSummaries RPC. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/accountSummaries", + }, + ] + request, metadata = self._interceptor.pre_list_account_summaries( + request, metadata + ) + pb_request = analytics_admin.ListAccountSummariesRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) uri = transcoded_request["uri"] @@ -10314,31 +11202,41 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = analytics_admin.ListAccountsResponse() - pb_resp = analytics_admin.ListAccountsResponse.pb(resp) + resp = analytics_admin.ListAccountSummariesResponse() + pb_resp = analytics_admin.ListAccountSummariesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_accounts(resp) + resp = self._interceptor.post_list_account_summaries(resp) return resp - class _ListAccountSummaries(AnalyticsAdminServiceRestStub): + class _ListAdSenseLinks(AnalyticsAdminServiceRestStub): def __hash__(self): - return hash("ListAccountSummaries") + return hash("ListAdSenseLinks") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @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.ListAccountSummariesRequest, + request: analytics_admin.ListAdSenseLinksRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> analytics_admin.ListAccountSummariesResponse: - r"""Call the list account summaries method over HTTP. + ) -> analytics_admin.ListAdSenseLinksResponse: + r"""Call the list ad sense links method over HTTP. Args: - request (~.analytics_admin.ListAccountSummariesRequest): - The request object. Request message for - ListAccountSummaries RPC. + request (~.analytics_admin.ListAdSenseLinksRequest): + The request object. Request message to be passed to + ListAdSenseLinks method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -10346,22 +11244,22 @@ def __call__( sent along with the request as metadata. Returns: - ~.analytics_admin.ListAccountSummariesResponse: - Response message for - ListAccountSummaries RPC. + ~.analytics_admin.ListAdSenseLinksResponse: + Response message for ListAdSenseLinks + method. """ http_options: List[Dict[str, str]] = [ { "method": "get", - "uri": "/v1alpha/accountSummaries", + "uri": "/v1alpha/{parent=properties/*}/adSenseLinks", }, ] - request, metadata = self._interceptor.pre_list_account_summaries( + request, metadata = self._interceptor.pre_list_ad_sense_links( request, metadata ) - pb_request = analytics_admin.ListAccountSummariesRequest.pb(request) + pb_request = analytics_admin.ListAdSenseLinksRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) uri = transcoded_request["uri"] @@ -10375,6 +11273,7 @@ def __call__( use_integers_for_enums=True, ) ) + query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" @@ -10394,11 +11293,11 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = analytics_admin.ListAccountSummariesResponse() - pb_resp = analytics_admin.ListAccountSummariesResponse.pb(resp) + resp = analytics_admin.ListAdSenseLinksResponse() + pb_resp = analytics_admin.ListAdSenseLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_account_summaries(resp) + resp = self._interceptor.post_list_ad_sense_links(resp) return resp class _ListAudiences(AnalyticsAdminServiceRestStub): @@ -11333,6 +12232,97 @@ def __call__( resp = self._interceptor.post_list_display_video360_advertiser_links(resp) return resp + class _ListEventCreateRules(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("ListEventCreateRules") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @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.ListEventCreateRulesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> analytics_admin.ListEventCreateRulesResponse: + r"""Call the list event create rules method over HTTP. + + Args: + request (~.analytics_admin.ListEventCreateRulesRequest): + The request object. Request message for + ListEventCreateRules 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.ListEventCreateRulesResponse: + Response message for + ListEventCreateRules RPC. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha/{parent=properties/*/dataStreams/*}/eventCreateRules", + }, + ] + request, metadata = self._interceptor.pre_list_event_create_rules( + request, metadata + ) + pb_request = analytics_admin.ListEventCreateRulesRequest.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.ListEventCreateRulesResponse() + pb_resp = analytics_admin.ListEventCreateRulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_event_create_rules(resp) + return resp + class _ListExpandedDataSets(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("ListExpandedDataSets") @@ -13503,6 +14493,119 @@ def __call__( resp = self._interceptor.post_update_enhanced_measurement_settings(resp) return resp + class _UpdateEventCreateRule(AnalyticsAdminServiceRestStub): + def __hash__(self): + return hash("UpdateEventCreateRule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "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.UpdateEventCreateRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> event_create_and_edit.EventCreateRule: + r"""Call the update event create rule method over HTTP. + + Args: + request (~.analytics_admin.UpdateEventCreateRuleRequest): + The request object. Request message for + UpdateEventCreateRule 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: + ~.event_create_and_edit.EventCreateRule: + An Event Create Rule defines + conditions that will trigger the + creation of an entirely new event based + upon matched criteria of a source event. + Additional mutations of the parameters + from the source event can be defined. + Unlike Event Edit rules, Event Creation + Rules have no defined order. They will + all be run independently. + + Event Edit and Event Create rules can't + be used to modify an event created from + an Event Create rule. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1alpha/{event_create_rule.name=properties/*/dataStreams/*/eventCreateRules/*}", + "body": "event_create_rule", + }, + ] + request, metadata = self._interceptor.pre_update_event_create_rule( + request, metadata + ) + pb_request = analytics_admin.UpdateEventCreateRuleRequest.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 = event_create_and_edit.EventCreateRule() + pb_resp = event_create_and_edit.EventCreateRule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_event_create_rule(resp) + return resp + class _UpdateExpandedDataSet(AnalyticsAdminServiceRestStub): def __hash__(self): return hash("UpdateExpandedDataSet") @@ -14383,6 +15486,14 @@ def create_access_binding( # In C++ this would require a dynamic_cast return self._CreateAccessBinding(self._session, self._host, self._interceptor) # type: ignore + @property + def create_ad_sense_link( + self, + ) -> Callable[[analytics_admin.CreateAdSenseLinkRequest], resources.AdSenseLink]: + # 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._CreateAdSenseLink(self._session, self._host, self._interceptor) # type: ignore + @property def create_audience( self, @@ -14470,6 +15581,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_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.CreateEventCreateRuleRequest], + event_create_and_edit.EventCreateRule, + ]: + # 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._CreateEventCreateRule(self._session, self._host, self._interceptor) # type: ignore + @property def create_expanded_data_set( self, @@ -14552,6 +15674,14 @@ def delete_account( # In C++ this would require a dynamic_cast return self._DeleteAccount(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_ad_sense_link( + self, + ) -> Callable[[analytics_admin.DeleteAdSenseLinkRequest], 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._DeleteAdSenseLink(self._session, self._host, self._interceptor) # type: ignore + @property def delete_channel_group( self, @@ -14605,6 +15735,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_event_create_rule( + self, + ) -> Callable[[analytics_admin.DeleteEventCreateRuleRequest], 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._DeleteEventCreateRule(self._session, self._host, self._interceptor) # type: ignore + @property def delete_expanded_data_set( self, @@ -14701,6 +15839,14 @@ def get_account( # In C++ this would require a dynamic_cast return self._GetAccount(self._session, self._host, self._interceptor) # type: ignore + @property + def get_ad_sense_link( + self, + ) -> Callable[[analytics_admin.GetAdSenseLinkRequest], resources.AdSenseLink]: + # 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._GetAdSenseLink(self._session, self._host, self._interceptor) # type: ignore + @property def get_attribution_settings( self, @@ -14825,6 +15971,17 @@ def get_enhanced_measurement_settings( # In C++ this would require a dynamic_cast return self._GetEnhancedMeasurementSettings(self._session, self._host, self._interceptor) # type: ignore + @property + def get_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.GetEventCreateRuleRequest], + event_create_and_edit.EventCreateRule, + ]: + # 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._GetEventCreateRule(self._session, self._host, self._interceptor) # type: ignore + @property def get_expanded_data_set( self, @@ -14923,6 +16080,17 @@ def list_account_summaries( # In C++ this would require a dynamic_cast return self._ListAccountSummaries(self._session, self._host, self._interceptor) # type: ignore + @property + def list_ad_sense_links( + self, + ) -> Callable[ + [analytics_admin.ListAdSenseLinksRequest], + analytics_admin.ListAdSenseLinksResponse, + ]: + # 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._ListAdSenseLinks(self._session, self._host, self._interceptor) # type: ignore + @property def list_audiences( self, @@ -15032,6 +16200,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_event_create_rules( + self, + ) -> Callable[ + [analytics_admin.ListEventCreateRulesRequest], + analytics_admin.ListEventCreateRulesResponse, + ]: + # 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._ListEventCreateRules(self._session, self._host, self._interceptor) # type: ignore + @property def list_expanded_data_sets( self, @@ -15257,6 +16436,17 @@ def update_enhanced_measurement_settings( # In C++ this would require a dynamic_cast return self._UpdateEnhancedMeasurementSettings(self._session, self._host, self._interceptor) # type: ignore + @property + def update_event_create_rule( + self, + ) -> Callable[ + [analytics_admin.UpdateEventCreateRuleRequest], + event_create_and_edit.EventCreateRule, + ]: + # 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._UpdateEventCreateRule(self._session, self._host, self._interceptor) # type: ignore + @property def update_expanded_data_set( self, diff --git a/google/analytics/admin_v1alpha/types/__init__.py b/google/analytics/admin_v1alpha/types/__init__.py index 36704c64..5ae55df5 100644 --- a/google/analytics/admin_v1alpha/types/__init__.py +++ b/google/analytics/admin_v1alpha/types/__init__.py @@ -60,6 +60,7 @@ BatchUpdateUserLinksResponse, CancelDisplayVideo360AdvertiserLinkProposalRequest, CreateAccessBindingRequest, + CreateAdSenseLinkRequest, CreateAudienceRequest, CreateChannelGroupRequest, CreateConnectedSiteTagRequest, @@ -70,6 +71,7 @@ CreateDataStreamRequest, CreateDisplayVideo360AdvertiserLinkProposalRequest, CreateDisplayVideo360AdvertiserLinkRequest, + CreateEventCreateRuleRequest, CreateExpandedDataSetRequest, CreateFirebaseLinkRequest, CreateGoogleAdsLinkRequest, @@ -79,12 +81,14 @@ CreateUserLinkRequest, DeleteAccessBindingRequest, DeleteAccountRequest, + DeleteAdSenseLinkRequest, DeleteChannelGroupRequest, DeleteConnectedSiteTagRequest, DeleteConversionEventRequest, DeleteDataStreamRequest, DeleteDisplayVideo360AdvertiserLinkProposalRequest, DeleteDisplayVideo360AdvertiserLinkRequest, + DeleteEventCreateRuleRequest, DeleteExpandedDataSetRequest, DeleteFirebaseLinkRequest, DeleteGoogleAdsLinkRequest, @@ -98,6 +102,7 @@ FetchConnectedGa4PropertyResponse, GetAccessBindingRequest, GetAccountRequest, + GetAdSenseLinkRequest, GetAttributionSettingsRequest, GetAudienceRequest, GetBigQueryLinkRequest, @@ -111,6 +116,7 @@ GetDisplayVideo360AdvertiserLinkProposalRequest, GetDisplayVideo360AdvertiserLinkRequest, GetEnhancedMeasurementSettingsRequest, + GetEventCreateRuleRequest, GetExpandedDataSetRequest, GetGlobalSiteTagRequest, GetGoogleSignalsSettingsRequest, @@ -124,6 +130,8 @@ ListAccountsResponse, ListAccountSummariesRequest, ListAccountSummariesResponse, + ListAdSenseLinksRequest, + ListAdSenseLinksResponse, ListAudiencesRequest, ListAudiencesResponse, ListBigQueryLinksRequest, @@ -144,6 +152,8 @@ ListDisplayVideo360AdvertiserLinkProposalsResponse, ListDisplayVideo360AdvertiserLinksRequest, ListDisplayVideo360AdvertiserLinksResponse, + ListEventCreateRulesRequest, + ListEventCreateRulesResponse, ListExpandedDataSetsRequest, ListExpandedDataSetsResponse, ListFirebaseLinksRequest, @@ -177,6 +187,7 @@ UpdateDataStreamRequest, UpdateDisplayVideo360AdvertiserLinkRequest, UpdateEnhancedMeasurementSettingsRequest, + UpdateEventCreateRuleRequest, UpdateExpandedDataSetRequest, UpdateGoogleAdsLinkRequest, UpdateGoogleSignalsSettingsRequest, @@ -204,6 +215,7 @@ ChannelGroupFilterExpressionList, GroupingRule, ) +from .event_create_and_edit import EventCreateRule, MatchingCondition, ParameterMutation from .expanded_data_set import ( ExpandedDataSet, ExpandedDataSetFilter, @@ -216,6 +228,7 @@ AccountSummary, ActionType, ActorType, + AdSenseLink, AttributionSettings, AuditUserLink, BigQueryLink, @@ -296,6 +309,7 @@ "BatchUpdateUserLinksResponse", "CancelDisplayVideo360AdvertiserLinkProposalRequest", "CreateAccessBindingRequest", + "CreateAdSenseLinkRequest", "CreateAudienceRequest", "CreateChannelGroupRequest", "CreateConnectedSiteTagRequest", @@ -306,6 +320,7 @@ "CreateDataStreamRequest", "CreateDisplayVideo360AdvertiserLinkProposalRequest", "CreateDisplayVideo360AdvertiserLinkRequest", + "CreateEventCreateRuleRequest", "CreateExpandedDataSetRequest", "CreateFirebaseLinkRequest", "CreateGoogleAdsLinkRequest", @@ -315,12 +330,14 @@ "CreateUserLinkRequest", "DeleteAccessBindingRequest", "DeleteAccountRequest", + "DeleteAdSenseLinkRequest", "DeleteChannelGroupRequest", "DeleteConnectedSiteTagRequest", "DeleteConversionEventRequest", "DeleteDataStreamRequest", "DeleteDisplayVideo360AdvertiserLinkProposalRequest", "DeleteDisplayVideo360AdvertiserLinkRequest", + "DeleteEventCreateRuleRequest", "DeleteExpandedDataSetRequest", "DeleteFirebaseLinkRequest", "DeleteGoogleAdsLinkRequest", @@ -334,6 +351,7 @@ "FetchConnectedGa4PropertyResponse", "GetAccessBindingRequest", "GetAccountRequest", + "GetAdSenseLinkRequest", "GetAttributionSettingsRequest", "GetAudienceRequest", "GetBigQueryLinkRequest", @@ -347,6 +365,7 @@ "GetDisplayVideo360AdvertiserLinkProposalRequest", "GetDisplayVideo360AdvertiserLinkRequest", "GetEnhancedMeasurementSettingsRequest", + "GetEventCreateRuleRequest", "GetExpandedDataSetRequest", "GetGlobalSiteTagRequest", "GetGoogleSignalsSettingsRequest", @@ -360,6 +379,8 @@ "ListAccountsResponse", "ListAccountSummariesRequest", "ListAccountSummariesResponse", + "ListAdSenseLinksRequest", + "ListAdSenseLinksResponse", "ListAudiencesRequest", "ListAudiencesResponse", "ListBigQueryLinksRequest", @@ -380,6 +401,8 @@ "ListDisplayVideo360AdvertiserLinkProposalsResponse", "ListDisplayVideo360AdvertiserLinksRequest", "ListDisplayVideo360AdvertiserLinksResponse", + "ListEventCreateRulesRequest", + "ListEventCreateRulesResponse", "ListExpandedDataSetsRequest", "ListExpandedDataSetsResponse", "ListFirebaseLinksRequest", @@ -413,6 +436,7 @@ "UpdateDataStreamRequest", "UpdateDisplayVideo360AdvertiserLinkRequest", "UpdateEnhancedMeasurementSettingsRequest", + "UpdateEventCreateRuleRequest", "UpdateExpandedDataSetRequest", "UpdateGoogleAdsLinkRequest", "UpdateGoogleSignalsSettingsRequest", @@ -435,6 +459,9 @@ "ChannelGroupFilterExpression", "ChannelGroupFilterExpressionList", "GroupingRule", + "EventCreateRule", + "MatchingCondition", + "ParameterMutation", "ExpandedDataSet", "ExpandedDataSetFilter", "ExpandedDataSetFilterExpression", @@ -442,6 +469,7 @@ "AccessBinding", "Account", "AccountSummary", + "AdSenseLink", "AttributionSettings", "AuditUserLink", "BigQueryLink", diff --git a/google/analytics/admin_v1alpha/types/analytics_admin.py b/google/analytics/admin_v1alpha/types/analytics_admin.py index cad3cbd5..00121be1 100644 --- a/google/analytics/admin_v1alpha/types/analytics_admin.py +++ b/google/analytics/admin_v1alpha/types/analytics_admin.py @@ -27,6 +27,7 @@ ) 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 event_create_and_edit from google.analytics.admin_v1alpha.types import resources __protobuf__ = proto.module( @@ -179,8 +180,19 @@ "DeleteConnectedSiteTagRequest", "ListConnectedSiteTagsRequest", "ListConnectedSiteTagsResponse", + "CreateAdSenseLinkRequest", + "GetAdSenseLinkRequest", + "DeleteAdSenseLinkRequest", + "ListAdSenseLinksRequest", + "ListAdSenseLinksResponse", "FetchConnectedGa4PropertyRequest", "FetchConnectedGa4PropertyResponse", + "CreateEventCreateRuleRequest", + "UpdateEventCreateRuleRequest", + "DeleteEventCreateRuleRequest", + "GetEventCreateRuleRequest", + "ListEventCreateRulesRequest", + "ListEventCreateRulesResponse", }, ) @@ -3830,6 +3842,126 @@ class ListConnectedSiteTagsResponse(proto.Message): ) +class CreateAdSenseLinkRequest(proto.Message): + r"""Request message to be passed to CreateAdSenseLink method. + + Attributes: + parent (str): + Required. The property for which to create an + AdSense Link. Format: properties/{propertyId} + Example: properties/1234 + adsense_link (google.analytics.admin_v1alpha.types.AdSenseLink): + Required. The AdSense Link to create + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + adsense_link: resources.AdSenseLink = proto.Field( + proto.MESSAGE, + number=2, + message=resources.AdSenseLink, + ) + + +class GetAdSenseLinkRequest(proto.Message): + r"""Request message to be passed to GetAdSenseLink method. + + Attributes: + name (str): + Required. Unique identifier for the AdSense + Link requested. Format: + properties/{propertyId}/adSenseLinks/{linkId} + Example: properties/1234/adSenseLinks/5678 + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteAdSenseLinkRequest(proto.Message): + r"""Request message to be passed to DeleteAdSenseLink method. + + Attributes: + name (str): + Required. Unique identifier for the AdSense + Link to be deleted. Format: + properties/{propertyId}/adSenseLinks/{linkId} + Example: properties/1234/adSenseLinks/5678 + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListAdSenseLinksRequest(proto.Message): + r"""Request message to be passed to ListAdSenseLinks method. + + Attributes: + parent (str): + Required. Resource name of the parent + property. Format: properties/{propertyId} + Example: 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 ``ListAdSenseLinks`` + call. Provide this to retrieve the subsequent page. + + When paginating, all other parameters provided to + ``ListAdSenseLinks`` 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 ListAdSenseLinksResponse(proto.Message): + r"""Response message for ListAdSenseLinks method. + + Attributes: + adsense_links (MutableSequence[google.analytics.admin_v1alpha.types.AdSenseLink]): + List of AdSenseLinks. + 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 + + adsense_links: MutableSequence[resources.AdSenseLink] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.AdSenseLink, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + class FetchConnectedGa4PropertyRequest(proto.Message): r"""Request for looking up GA4 property connected to a UA property. @@ -3866,4 +3998,150 @@ class FetchConnectedGa4PropertyResponse(proto.Message): ) +class CreateEventCreateRuleRequest(proto.Message): + r"""Request message for CreateEventCreateRule RPC. + + Attributes: + parent (str): + Required. Example format: + properties/123/dataStreams/456 + event_create_rule (google.analytics.admin_v1alpha.types.EventCreateRule): + Required. The EventCreateRule to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + event_create_rule: event_create_and_edit.EventCreateRule = proto.Field( + proto.MESSAGE, + number=2, + message=event_create_and_edit.EventCreateRule, + ) + + +class UpdateEventCreateRuleRequest(proto.Message): + r"""Request message for UpdateEventCreateRule RPC. + + Attributes: + event_create_rule (google.analytics.admin_v1alpha.types.EventCreateRule): + Required. The EventCreateRule to update. The resource's + ``name`` field is used to identify the EventCreateRule 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. + """ + + event_create_rule: event_create_and_edit.EventCreateRule = proto.Field( + proto.MESSAGE, + number=1, + message=event_create_and_edit.EventCreateRule, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteEventCreateRuleRequest(proto.Message): + r"""Request message for DeleteEventCreateRule RPC. + + Attributes: + name (str): + Required. Example format: + properties/123/dataStreams/456/eventCreateRules/789 + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class GetEventCreateRuleRequest(proto.Message): + r"""Request message for GetEventCreateRule RPC. + + Attributes: + name (str): + Required. The name of the EventCreateRule to + get. Example format: + properties/123/dataStreams/456/eventCreateRules/789 + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListEventCreateRulesRequest(proto.Message): + r"""Request message for ListEventCreateRules RPC. + + Attributes: + parent (str): + Required. Example format: + properties/123/dataStreams/456 + 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 + ``ListEventCreateRules`` call. Provide this to retrieve the + subsequent page. + + When paginating, all other parameters provided to + ``ListEventCreateRules`` 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 ListEventCreateRulesResponse(proto.Message): + r"""Response message for ListEventCreateRules RPC. + + Attributes: + event_create_rules (MutableSequence[google.analytics.admin_v1alpha.types.EventCreateRule]): + List of EventCreateRules. 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 + + event_create_rules: MutableSequence[ + event_create_and_edit.EventCreateRule + ] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=event_create_and_edit.EventCreateRule, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/analytics/admin_v1alpha/types/audience.py b/google/analytics/admin_v1alpha/types/audience.py index f4313d73..b5dbb201 100644 --- a/google/analytics/admin_v1alpha/types/audience.py +++ b/google/analytics/admin_v1alpha/types/audience.py @@ -92,8 +92,13 @@ class AudienceDimensionOrMetricFilter(proto.Message): This field is a member of `oneof`_ ``one_filter``. field_name (str): - Required. Immutable. The dimension name or - metric name to filter. + Required. Immutable. The dimension name or metric name to + filter. If the field name refers to a custom dimension or + metric, a scope prefix will be added to the front of the + custom dimensions or metric name. For more on scope prefixes + or custom dimensions/metrics, reference the [Google + Analytics Data API documentation] + (https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#custom_dimensions). at_any_point_in_time (bool): Optional. Indicates whether this filter needs dynamic evaluation or not. If set to true, users join the Audience @@ -107,8 +112,8 @@ class AudienceDimensionOrMetricFilter(proto.Message): in_any_n_day_period (int): Optional. If set, specifies the time window for which to evaluate data in number of days. If not set, then audience - data is evaluated against lifetime data (i.e., infinite time - window). + data is evaluated against lifetime data (For example, + infinite time window). For example, if set to 1 day, only the current day's data is evaluated. The reference point is the current day when @@ -348,8 +353,8 @@ class AudienceEventFilter(proto.Message): Optional. If specified, this filter matches events that match both the single event name and the parameter filter expressions. AudienceEventFilter inside the parameter filter - expression cannot be set (i.e., nested event filters are not - supported). This should be a single and_group of + expression cannot be set (For example, nested event filters + are not supported). This should be a single and_group of dimension_or_metric_filter or not_expression; ANDs of ORs are not supported. Also, if it includes a filter for "eventCount", only that one will be considered; all the @@ -391,7 +396,7 @@ class AudienceFilterExpression(proto.Message): This field is a member of `oneof`_ ``expr``. not_expression (google.analytics.admin_v1alpha.types.AudienceFilterExpression): - A filter expression to be NOT'ed (i.e., inverted, + A filter expression to be NOT'ed (For example, inverted, complemented). It can only include a dimension_or_metric_filter. This cannot be set on the top level AudienceFilterExpression. @@ -520,8 +525,8 @@ class AudienceSequenceStep(proto.Message): step. constraint_duration (google.protobuf.duration_pb2.Duration): Optional. When set, this step must be satisfied within the - constraint_duration of the previous step (i.e., t[i] - - t[i-1] <= constraint_duration). If not set, there is no + constraint_duration of the previous step (For example, t[i] + - t[i-1] <= constraint_duration). If not set, there is no duration requirement (the duration is effectively unlimited). It is ignored for the first step. filter_expression (google.analytics.admin_v1alpha.types.AudienceFilterExpression): @@ -569,9 +574,10 @@ class AudienceSequenceStep(proto.Message): class AudienceFilterClause(proto.Message): r"""A clause for defining either a simple or sequence filter. A - filter can be inclusive (i.e., users satisfying the filter - clause are included in the Audience) or exclusive (i.e., users - satisfying the filter clause are excluded from the Audience). + filter can be inclusive (For example, users satisfying the + filter clause are included in the Audience) or exclusive (For + example, users satisfying the filter clause are excluded from + the Audience). This message has `oneof`_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. diff --git a/google/analytics/admin_v1alpha/types/event_create_and_edit.py b/google/analytics/admin_v1alpha/types/event_create_and_edit.py new file mode 100644 index 00000000..f95957c7 --- /dev/null +++ b/google/analytics/admin_v1alpha/types/event_create_and_edit.py @@ -0,0 +1,231 @@ +# -*- 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. +# +from __future__ import annotations + +from typing import MutableMapping, MutableSequence + +import proto # type: ignore + +__protobuf__ = proto.module( + package="google.analytics.admin.v1alpha", + manifest={ + "ParameterMutation", + "EventCreateRule", + "MatchingCondition", + }, +) + + +class ParameterMutation(proto.Message): + r"""Defines an event parameter to mutate. + + Attributes: + parameter (str): + Required. The name of the parameter to mutate. This value + must: + + - be less than 40 characters. + - be unique across across all mutations within the rule + - consist only of letters, digits or \_ (underscores) For + event edit rules, the name may also be set to + 'event_name' to modify the event_name in place. + parameter_value (str): + Required. The value mutation to perform. + + - Must be less than 100 characters. + - To specify a constant value for the param, use the + value's string. + - To copy value from another parameter, use syntax like + "[[other_parameter]]" For more details, see this `help + center + article `__. + """ + + parameter: str = proto.Field( + proto.STRING, + number=1, + ) + parameter_value: str = proto.Field( + proto.STRING, + number=2, + ) + + +class EventCreateRule(proto.Message): + r"""An Event Create Rule defines conditions that will trigger the + creation of an entirely new event based upon matched criteria of + a source event. Additional mutations of the parameters from the + source event can be defined. + Unlike Event Edit rules, Event Creation Rules have no defined + order. They will all be run independently. + + Event Edit and Event Create rules can't be used to modify an + event created from an Event Create rule. + + Attributes: + name (str): + Output only. Resource name for this EventCreateRule + resource. Format: + properties/{property}/dataStreams/{data_stream}/eventCreateRules/{event_create_rule} + destination_event (str): + Required. The name of the new event to be created. + + This value must: + + - be less than 40 characters + - consist only of letters, digits or \_ (underscores) + - start with a letter + event_conditions (MutableSequence[google.analytics.admin_v1alpha.types.MatchingCondition]): + Required. Must have at least one condition, + and can have up to 10 max. Conditions on the + source event must match for this rule to be + applied. + source_copy_parameters (bool): + If true, the source parameters are copied to + the new event. If false, or unset, all + non-internal parameters are not copied from the + source event. Parameter mutations are applied + after the parameters have been copied. + parameter_mutations (MutableSequence[google.analytics.admin_v1alpha.types.ParameterMutation]): + Parameter mutations define parameter behavior + on the new event, and are applied in order. + A maximum of 20 mutations can be applied. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + destination_event: str = proto.Field( + proto.STRING, + number=2, + ) + event_conditions: MutableSequence["MatchingCondition"] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="MatchingCondition", + ) + source_copy_parameters: bool = proto.Field( + proto.BOOL, + number=4, + ) + parameter_mutations: MutableSequence["ParameterMutation"] = proto.RepeatedField( + proto.MESSAGE, + number=5, + message="ParameterMutation", + ) + + +class MatchingCondition(proto.Message): + r"""Defines a condition for when an Event Edit or Event Creation + rule applies to an event. + + Attributes: + field (str): + Required. The name of the field that is compared against for + the condition. If 'event_name' is specified this condition + will apply to the name of the event. Otherwise the condition + will apply to a parameter with the specified name. + + This value cannot contain spaces. + comparison_type (google.analytics.admin_v1alpha.types.MatchingCondition.ComparisonType): + Required. The type of comparison to be + applied to the value. + value (str): + Required. The value being compared against + for this condition. The runtime implementation + may perform type coercion of this value to + evaluate this condition based on the type of the + parameter value. + negated (bool): + Whether or not the result of the comparison should be + negated. For example, if ``negated`` is true, then 'equals' + comparisons would function as 'not equals'. + """ + + class ComparisonType(proto.Enum): + r"""Comparison type for matching condition + + Values: + COMPARISON_TYPE_UNSPECIFIED (0): + Unknown + EQUALS (1): + Equals, case sensitive + EQUALS_CASE_INSENSITIVE (2): + Equals, case insensitive + CONTAINS (3): + Contains, case sensitive + CONTAINS_CASE_INSENSITIVE (4): + Contains, case insensitive + STARTS_WITH (5): + Starts with, case sensitive + STARTS_WITH_CASE_INSENSITIVE (6): + Starts with, case insensitive + ENDS_WITH (7): + Ends with, case sensitive + ENDS_WITH_CASE_INSENSITIVE (8): + Ends with, case insensitive + GREATER_THAN (9): + Greater than + GREATER_THAN_OR_EQUAL (10): + Greater than or equal + LESS_THAN (11): + Less than + LESS_THAN_OR_EQUAL (12): + Less than or equal + REGULAR_EXPRESSION (13): + regular expression. Only supported for web + streams. + REGULAR_EXPRESSION_CASE_INSENSITIVE (14): + regular expression, case insensitive. Only + supported for web streams. + """ + COMPARISON_TYPE_UNSPECIFIED = 0 + EQUALS = 1 + EQUALS_CASE_INSENSITIVE = 2 + CONTAINS = 3 + CONTAINS_CASE_INSENSITIVE = 4 + STARTS_WITH = 5 + STARTS_WITH_CASE_INSENSITIVE = 6 + ENDS_WITH = 7 + ENDS_WITH_CASE_INSENSITIVE = 8 + GREATER_THAN = 9 + GREATER_THAN_OR_EQUAL = 10 + LESS_THAN = 11 + LESS_THAN_OR_EQUAL = 12 + REGULAR_EXPRESSION = 13 + REGULAR_EXPRESSION_CASE_INSENSITIVE = 14 + + field: str = proto.Field( + proto.STRING, + number=1, + ) + comparison_type: ComparisonType = proto.Field( + proto.ENUM, + number=2, + enum=ComparisonType, + ) + value: str = proto.Field( + proto.STRING, + number=3, + ) + negated: bool = proto.Field( + proto.BOOL, + number=4, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/analytics/admin_v1alpha/types/resources.py b/google/analytics/admin_v1alpha/types/resources.py index 05d4153c..b6eddac4 100644 --- a/google/analytics/admin_v1alpha/types/resources.py +++ b/google/analytics/admin_v1alpha/types/resources.py @@ -25,6 +25,8 @@ from google.analytics.admin_v1alpha.types import ( expanded_data_set as gaa_expanded_data_set, ) +from google.analytics.admin_v1alpha.types import audience as gaa_audience +from google.analytics.admin_v1alpha.types import event_create_and_edit __protobuf__ = proto.module( package="google.analytics.admin.v1alpha", @@ -67,6 +69,7 @@ "BigQueryLink", "EnhancedMeasurementSettings", "ConnectedSiteTag", + "AdSenseLink", }, ) @@ -261,6 +264,12 @@ class ChangeHistoryResourceType(proto.Enum): ChannelGroup resource ENHANCED_MEASUREMENT_SETTINGS (24): EnhancedMeasurementSettings resource + ADSENSE_LINK (27): + AdSenseLink resource + AUDIENCE (28): + Audience resource + EVENT_CREATE_RULE (29): + EventCreateRule resource """ CHANGE_HISTORY_RESOURCE_TYPE_UNSPECIFIED = 0 ACCOUNT = 1 @@ -281,6 +290,9 @@ class ChangeHistoryResourceType(proto.Enum): EXPANDED_DATA_SET = 21 CHANNEL_GROUP = 22 ENHANCED_MEASUREMENT_SETTINGS = 24 + ADSENSE_LINK = 27 + AUDIENCE = 28 + EVENT_CREATE_RULE = 29 class GoogleSignalsState(proto.Enum): @@ -1339,6 +1351,21 @@ class ChangeHistoryResource(proto.Message): A snapshot of EnhancedMeasurementSettings resource in change history. + This field is a member of `oneof`_ ``resource``. + adsense_link (google.analytics.admin_v1alpha.types.AdSenseLink): + A snapshot of an AdSenseLink resource in + change history. + + This field is a member of `oneof`_ ``resource``. + audience (google.analytics.admin_v1alpha.types.Audience): + A snapshot of an Audience resource in change + history. + + This field is a member of `oneof`_ ``resource``. + event_create_rule (google.analytics.admin_v1alpha.types.EventCreateRule): + A snapshot of an EventCreateRule resource in + change history. + This field is a member of `oneof`_ ``resource``. """ @@ -1458,6 +1485,24 @@ class ChangeHistoryResource(proto.Message): oneof="resource", message="EnhancedMeasurementSettings", ) + adsense_link: "AdSenseLink" = proto.Field( + proto.MESSAGE, + number=27, + oneof="resource", + message="AdSenseLink", + ) + audience: gaa_audience.Audience = proto.Field( + proto.MESSAGE, + number=28, + oneof="resource", + message=gaa_audience.Audience, + ) + event_create_rule: event_create_and_edit.EventCreateRule = proto.Field( + proto.MESSAGE, + number=29, + oneof="resource", + message=event_create_and_edit.EventCreateRule, + ) resource: str = proto.Field( proto.STRING, @@ -2508,4 +2553,30 @@ class ConnectedSiteTag(proto.Message): ) +class AdSenseLink(proto.Message): + r"""A link between a GA4 Property and an AdSense for Content ad + client. + + Attributes: + name (str): + Output only. The resource name for this + AdSense Link resource. Format: + properties/{propertyId}/adSenseLinks/{linkId} + Example: properties/1234/adSenseLinks/6789 + ad_client_code (str): + Immutable. The AdSense ad client code that + the GA4 property is linked to. Example format: + "ca-pub-1234567890". + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + ad_client_code: str = proto.Field( + proto.STRING, + number=2, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_ad_sense_link_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_ad_sense_link_async.py new file mode 100644 index 00000000..82c0f923 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_ad_sense_link_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 CreateAdSenseLink +# 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_CreateAdSenseLink_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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.CreateAdSenseLinkRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_ad_sense_link(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAdSenseLink_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_ad_sense_link_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_ad_sense_link_sync.py new file mode 100644 index 00000000..4176133f --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_ad_sense_link_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 CreateAdSenseLink +# 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_CreateAdSenseLink_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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.CreateAdSenseLinkRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_ad_sense_link(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAdSenseLink_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_async.py new file mode 100644 index 00000000..a86bb522 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_async.py @@ -0,0 +1,59 @@ +# -*- 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 CreateEventCreateRule +# 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_CreateEventCreateRule_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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + event_create_rule = admin_v1alpha.EventCreateRule() + event_create_rule.destination_event = "destination_event_value" + event_create_rule.event_conditions.field = "field_value" + event_create_rule.event_conditions.comparison_type = "REGULAR_EXPRESSION_CASE_INSENSITIVE" + event_create_rule.event_conditions.value = "value_value" + + request = admin_v1alpha.CreateEventCreateRuleRequest( + parent="parent_value", + event_create_rule=event_create_rule, + ) + + # Make the request + response = await client.create_event_create_rule(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateEventCreateRule_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_sync.py new file mode 100644 index 00000000..f878fe1e --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_sync.py @@ -0,0 +1,59 @@ +# -*- 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 CreateEventCreateRule +# 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_CreateEventCreateRule_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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + event_create_rule = admin_v1alpha.EventCreateRule() + event_create_rule.destination_event = "destination_event_value" + event_create_rule.event_conditions.field = "field_value" + event_create_rule.event_conditions.comparison_type = "REGULAR_EXPRESSION_CASE_INSENSITIVE" + event_create_rule.event_conditions.value = "value_value" + + request = admin_v1alpha.CreateEventCreateRuleRequest( + parent="parent_value", + event_create_rule=event_create_rule, + ) + + # Make the request + response = client.create_event_create_rule(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateEventCreateRule_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_async.py new file mode 100644 index 00000000..0eee17f5 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_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 DeleteAdSenseLink +# 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_DeleteAdSenseLink_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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteAdSenseLinkRequest( + name="name_value", + ) + + # Make the request + await client.delete_ad_sense_link(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAdSenseLink_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_sync.py new file mode 100644 index 00000000..cd243c9e --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_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 DeleteAdSenseLink +# 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_DeleteAdSenseLink_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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteAdSenseLinkRequest( + name="name_value", + ) + + # Make the request + client.delete_ad_sense_link(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAdSenseLink_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_event_create_rule_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_event_create_rule_async.py new file mode 100644 index 00000000..a7082623 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_event_create_rule_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 DeleteEventCreateRule +# 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_DeleteEventCreateRule_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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteEventCreateRuleRequest( + name="name_value", + ) + + # Make the request + await client.delete_event_create_rule(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteEventCreateRule_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_event_create_rule_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_event_create_rule_sync.py new file mode 100644 index 00000000..79a9ac7f --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_delete_event_create_rule_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 DeleteEventCreateRule +# 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_DeleteEventCreateRule_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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.DeleteEventCreateRuleRequest( + name="name_value", + ) + + # Make the request + client.delete_event_create_rule(request=request) + + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteEventCreateRule_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_async.py new file mode 100644 index 00000000..c6287532 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_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 GetAdSenseLink +# 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_GetAdSenseLink_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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetAdSenseLinkRequest( + name="name_value", + ) + + # Make the request + response = await client.get_ad_sense_link(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAdSenseLink_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_sync.py new file mode 100644 index 00000000..cc2c8f7d --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_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 GetAdSenseLink +# 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_GetAdSenseLink_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_ad_sense_link(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetAdSenseLinkRequest( + name="name_value", + ) + + # Make the request + response = client.get_ad_sense_link(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAdSenseLink_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_async.py new file mode 100644 index 00000000..714a7d32 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_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 GetEventCreateRule +# 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_GetEventCreateRule_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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetEventCreateRuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_event_create_rule(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetEventCreateRule_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_sync.py new file mode 100644 index 00000000..a34d1179 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_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 GetEventCreateRule +# 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_GetEventCreateRule_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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.GetEventCreateRuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_event_create_rule(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetEventCreateRule_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_async.py new file mode 100644 index 00000000..c4818547 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_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 ListAdSenseLinks +# 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_ListAdSenseLinks_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_ad_sense_links(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListAdSenseLinksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_ad_sense_links(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAdSenseLinks_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_sync.py new file mode 100644 index 00000000..e533bc02 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_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 ListAdSenseLinks +# 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_ListAdSenseLinks_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_ad_sense_links(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListAdSenseLinksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_ad_sense_links(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAdSenseLinks_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_event_create_rules_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_event_create_rules_async.py new file mode 100644 index 00000000..3cd851ab --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_event_create_rules_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 ListEventCreateRules +# 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_ListEventCreateRules_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_event_create_rules(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListEventCreateRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_event_create_rules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListEventCreateRules_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_event_create_rules_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_event_create_rules_sync.py new file mode 100644 index 00000000..0a397a67 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_list_event_create_rules_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 ListEventCreateRules +# 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_ListEventCreateRules_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_event_create_rules(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + request = admin_v1alpha.ListEventCreateRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_event_create_rules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListEventCreateRules_sync] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_event_create_rule_async.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_event_create_rule_async.py new file mode 100644 index 00000000..026e8e51 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_event_create_rule_async.py @@ -0,0 +1,58 @@ +# -*- 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 UpdateEventCreateRule +# 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_UpdateEventCreateRule_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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceAsyncClient() + + # Initialize request argument(s) + event_create_rule = admin_v1alpha.EventCreateRule() + event_create_rule.destination_event = "destination_event_value" + event_create_rule.event_conditions.field = "field_value" + event_create_rule.event_conditions.comparison_type = "REGULAR_EXPRESSION_CASE_INSENSITIVE" + event_create_rule.event_conditions.value = "value_value" + + request = admin_v1alpha.UpdateEventCreateRuleRequest( + event_create_rule=event_create_rule, + ) + + # Make the request + response = await client.update_event_create_rule(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateEventCreateRule_async] diff --git a/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_event_create_rule_sync.py b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_event_create_rule_sync.py new file mode 100644 index 00000000..555ef5c1 --- /dev/null +++ b/samples/generated_samples/analyticsadmin_v1alpha_generated_analytics_admin_service_update_event_create_rule_sync.py @@ -0,0 +1,58 @@ +# -*- 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 UpdateEventCreateRule +# 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_UpdateEventCreateRule_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_event_create_rule(): + # Create a client + client = admin_v1alpha.AnalyticsAdminServiceClient() + + # Initialize request argument(s) + event_create_rule = admin_v1alpha.EventCreateRule() + event_create_rule.destination_event = "destination_event_value" + event_create_rule.event_conditions.field = "field_value" + event_create_rule.event_conditions.comparison_type = "REGULAR_EXPRESSION_CASE_INSENSITIVE" + event_create_rule.event_conditions.value = "value_value" + + request = admin_v1alpha.UpdateEventCreateRuleRequest( + event_create_rule=event_create_rule, + ) + + # Make the request + response = client.update_event_create_rule(request=request) + + # Handle the response + print(response) + +# [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateEventCreateRule_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 411386c0..3313b473 100644 --- a/samples/generated_samples/snippet_metadata_google.analytics.admin.v1alpha.json +++ b/samples/generated_samples/snippet_metadata_google.analytics.admin.v1alpha.json @@ -2461,6 +2461,175 @@ ], "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_access_binding_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_ad_sense_link", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateAdSenseLink", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateAdSenseLink" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateAdSenseLinkRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "adsense_link", + "type": "google.analytics.admin_v1alpha.types.AdSenseLink" + }, + { + "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.AdSenseLink", + "shortName": "create_ad_sense_link" + }, + "description": "Sample for CreateAdSenseLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_ad_sense_link_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAdSenseLink_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_ad_sense_link_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_ad_sense_link", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateAdSenseLink", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateAdSenseLink" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateAdSenseLinkRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "adsense_link", + "type": "google.analytics.admin_v1alpha.types.AdSenseLink" + }, + { + "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.AdSenseLink", + "shortName": "create_ad_sense_link" + }, + "description": "Sample for CreateAdSenseLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_ad_sense_link_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateAdSenseLink_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_ad_sense_link_sync.py" + }, { "canonical": true, "clientMethod": { @@ -3974,27 +4143,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_expanded_data_set", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_event_create_rule", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateExpandedDataSet", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateEventCreateRule", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateExpandedDataSet" + "shortName": "CreateEventCreateRule" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateExpandedDataSetRequest" + "type": "google.analytics.admin_v1alpha.types.CreateEventCreateRuleRequest" }, { "name": "parent", "type": "str" }, { - "name": "expanded_data_set", - "type": "google.analytics.admin_v1alpha.types.ExpandedDataSet" + "name": "event_create_rule", + "type": "google.analytics.admin_v1alpha.types.EventCreateRule" }, { "name": "retry", @@ -4009,22 +4178,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", - "shortName": "create_expanded_data_set" + "resultType": "google.analytics.admin_v1alpha.types.EventCreateRule", + "shortName": "create_event_create_rule" }, - "description": "Sample for CreateExpandedDataSet", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_async.py", + "description": "Sample for CreateEventCreateRule", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateEventCreateRule_async", "segments": [ { - "end": 55, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 58, "start": 27, "type": "SHORT" }, @@ -4034,22 +4203,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 52, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 50, + "end": 55, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_async.py" }, { "canonical": true, @@ -4058,27 +4227,27 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_expanded_data_set", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_event_create_rule", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateExpandedDataSet", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateEventCreateRule", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateExpandedDataSet" + "shortName": "CreateEventCreateRule" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateExpandedDataSetRequest" + "type": "google.analytics.admin_v1alpha.types.CreateEventCreateRuleRequest" }, { "name": "parent", "type": "str" }, { - "name": "expanded_data_set", - "type": "google.analytics.admin_v1alpha.types.ExpandedDataSet" + "name": "event_create_rule", + "type": "google.analytics.admin_v1alpha.types.EventCreateRule" }, { "name": "retry", @@ -4093,22 +4262,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", - "shortName": "create_expanded_data_set" + "resultType": "google.analytics.admin_v1alpha.types.EventCreateRule", + "shortName": "create_event_create_rule" }, - "description": "Sample for CreateExpandedDataSet", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_sync.py", + "description": "Sample for CreateEventCreateRule", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateEventCreateRule_sync", "segments": [ { - "end": 55, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 58, "start": 27, "type": "SHORT" }, @@ -4118,22 +4287,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 52, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 50, + "end": 55, + "start": 53, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_expanded_data_set_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_event_create_rule_sync.py" }, { "canonical": true, @@ -4143,27 +4312,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_expanded_data_set", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateFirebaseLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateExpandedDataSet", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateFirebaseLink" + "shortName": "CreateExpandedDataSet" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest" + "type": "google.analytics.admin_v1alpha.types.CreateExpandedDataSetRequest" }, { "name": "parent", "type": "str" }, { - "name": "firebase_link", - "type": "google.analytics.admin_v1alpha.types.FirebaseLink" + "name": "expanded_data_set", + "type": "google.analytics.admin_v1alpha.types.ExpandedDataSet" }, { "name": "retry", @@ -4178,22 +4347,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.FirebaseLink", - "shortName": "create_firebase_link" + "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", + "shortName": "create_expanded_data_set" }, - "description": "Sample for CreateFirebaseLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_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_CreateFirebaseLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_async", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -4203,22 +4372,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_expanded_data_set_async.py" }, { "canonical": true, @@ -4227,27 +4396,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_expanded_data_set", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateFirebaseLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateExpandedDataSet", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "CreateFirebaseLink" + "shortName": "CreateExpandedDataSet" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest" + "type": "google.analytics.admin_v1alpha.types.CreateExpandedDataSetRequest" }, { "name": "parent", "type": "str" }, { - "name": "firebase_link", - "type": "google.analytics.admin_v1alpha.types.FirebaseLink" + "name": "expanded_data_set", + "type": "google.analytics.admin_v1alpha.types.ExpandedDataSet" }, { "name": "retry", @@ -4262,14 +4431,183 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.FirebaseLink", - "shortName": "create_firebase_link" + "resultType": "google.analytics.admin_v1alpha.types.ExpandedDataSet", + "shortName": "create_expanded_data_set" }, - "description": "Sample for CreateFirebaseLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_create_firebase_link_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_CreateFirebaseLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateExpandedDataSet_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_expanded_data_set_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.create_firebase_link", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateFirebaseLink", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateFirebaseLink" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "firebase_link", + "type": "google.analytics.admin_v1alpha.types.FirebaseLink" + }, + { + "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.FirebaseLink", + "shortName": "create_firebase_link" + }, + "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_CreateFirebaseLink_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_firebase_link_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_firebase_link", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.CreateFirebaseLink", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "CreateFirebaseLink" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.CreateFirebaseLinkRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "firebase_link", + "type": "google.analytics.admin_v1alpha.types.FirebaseLink" + }, + { + "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.FirebaseLink", + "shortName": "create_firebase_link" + }, + "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_CreateFirebaseLink_sync", "segments": [ { "end": 51, @@ -5459,19 +5797,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_channel_group", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_ad_sense_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteChannelGroup", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteAdSenseLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteChannelGroup" + "shortName": "DeleteAdSenseLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteChannelGroupRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteAdSenseLinkRequest" }, { "name": "name", @@ -5490,13 +5828,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_channel_group" + "shortName": "delete_ad_sense_link" }, - "description": "Sample for DeleteChannelGroup", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_channel_group_async.py", + "description": "Sample for DeleteAdSenseLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteChannelGroup_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAdSenseLink_async", "segments": [ { "end": 49, @@ -5527,7 +5865,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_channel_group_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_async.py" }, { "canonical": true, @@ -5536,19 +5874,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_channel_group", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_ad_sense_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteChannelGroup", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteAdSenseLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteChannelGroup" + "shortName": "DeleteAdSenseLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteChannelGroupRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteAdSenseLinkRequest" }, { "name": "name", @@ -5567,13 +5905,13 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_channel_group" + "shortName": "delete_ad_sense_link" }, - "description": "Sample for DeleteChannelGroup", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_channel_group_sync.py", + "description": "Sample for DeleteAdSenseLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteChannelGroup_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteAdSenseLink_sync", "segments": [ { "end": 49, @@ -5604,7 +5942,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_channel_group_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_ad_sense_link_sync.py" }, { "canonical": true, @@ -5614,19 +5952,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_connected_site_tag", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_channel_group", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConnectedSiteTag", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteChannelGroup", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteConnectedSiteTag" + "shortName": "DeleteChannelGroup" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteConnectedSiteTagRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteChannelGroupRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -5641,21 +5983,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_connected_site_tag" + "shortName": "delete_channel_group" }, - "description": "Sample for DeleteConnectedSiteTag", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_connected_site_tag_async.py", + "description": "Sample for DeleteChannelGroup", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_channel_group_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteConnectedSiteTag_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteChannelGroup_async", "segments": [ { - "end": 48, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 49, "start": 27, "type": "SHORT" }, @@ -5665,20 +6007,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 45, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_connected_site_tag_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_channel_group_async.py" }, { "canonical": true, @@ -5687,19 +6029,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_connected_site_tag", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_channel_group", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConnectedSiteTag", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteChannelGroup", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "DeleteConnectedSiteTag" + "shortName": "DeleteChannelGroup" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.DeleteConnectedSiteTagRequest" + "type": "google.analytics.admin_v1alpha.types.DeleteChannelGroupRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -5714,21 +6060,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_connected_site_tag" + "shortName": "delete_channel_group" }, - "description": "Sample for DeleteConnectedSiteTag", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_connected_site_tag_sync.py", + "description": "Sample for DeleteChannelGroup", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_channel_group_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteConnectedSiteTag_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteChannelGroup_sync", "segments": [ { - "end": 48, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 49, "start": 27, "type": "SHORT" }, @@ -5738,20 +6084,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 45, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 49, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_connected_site_tag_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_channel_group_sync.py" }, { "canonical": true, @@ -5761,9 +6107,156 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_conversion_event", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_connected_site_tag", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConversionEvent", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConnectedSiteTag", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "DeleteConnectedSiteTag" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.DeleteConnectedSiteTagRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_connected_site_tag" + }, + "description": "Sample for DeleteConnectedSiteTag", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_connected_site_tag_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteConnectedSiteTag_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_connected_site_tag_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_connected_site_tag", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConnectedSiteTag", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "DeleteConnectedSiteTag" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.DeleteConnectedSiteTagRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_connected_site_tag" + }, + "description": "Sample for DeleteConnectedSiteTag", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_connected_site_tag_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteConnectedSiteTag_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_connected_site_tag_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.delete_conversion_event", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteConversionEvent", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" @@ -6373,6 +6866,161 @@ ], "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_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.delete_event_create_rule", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteEventCreateRule", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "DeleteEventCreateRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.DeleteEventCreateRuleRequest" + }, + { + "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_event_create_rule" + }, + "description": "Sample for DeleteEventCreateRule", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_event_create_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteEventCreateRule_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_event_create_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_event_create_rule", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.DeleteEventCreateRule", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "DeleteEventCreateRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.DeleteEventCreateRuleRequest" + }, + { + "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_event_create_rule" + }, + "description": "Sample for DeleteEventCreateRule", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_delete_event_create_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteEventCreateRule_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_event_create_rule_sync.py" + }, { "canonical": true, "clientMethod": { @@ -7652,14 +8300,171 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.FetchConnectedGa4PropertyResponse", - "shortName": "fetch_connected_ga4_property" + "resultType": "google.analytics.admin_v1alpha.types.FetchConnectedGa4PropertyResponse", + "shortName": "fetch_connected_ga4_property" + }, + "description": "Sample for FetchConnectedGa4Property", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_connected_ga4_property_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_FetchConnectedGa4Property_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_fetch_connected_ga4_property_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.fetch_connected_ga4_property", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.FetchConnectedGa4Property", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "FetchConnectedGa4Property" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.FetchConnectedGa4PropertyRequest" + }, + { + "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.FetchConnectedGa4PropertyResponse", + "shortName": "fetch_connected_ga4_property" + }, + "description": "Sample for FetchConnectedGa4Property", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_connected_ga4_property_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_FetchConnectedGa4Property_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_fetch_connected_ga4_property_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_access_binding", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccessBinding", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "GetAccessBinding" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.GetAccessBindingRequest" + }, + { + "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.AccessBinding", + "shortName": "get_access_binding" }, - "description": "Sample for FetchConnectedGa4Property", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_connected_ga4_property_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_FetchConnectedGa4Property_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_async", "segments": [ { "end": 51, @@ -7692,7 +8497,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_connected_ga4_property_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_async.py" }, { "canonical": true, @@ -7701,19 +8506,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.fetch_connected_ga4_property", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_access_binding", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.FetchConnectedGa4Property", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccessBinding", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "FetchConnectedGa4Property" + "shortName": "GetAccessBinding" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.FetchConnectedGa4PropertyRequest" + "type": "google.analytics.admin_v1alpha.types.GetAccessBindingRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -7728,14 +8537,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.FetchConnectedGa4PropertyResponse", - "shortName": "fetch_connected_ga4_property" + "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", + "shortName": "get_access_binding" }, - "description": "Sample for FetchConnectedGa4Property", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_connected_ga4_property_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_FetchConnectedGa4Property_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_sync", "segments": [ { "end": 51, @@ -7768,7 +8577,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_fetch_connected_ga4_property_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_sync.py" }, { "canonical": true, @@ -7778,19 +8587,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_access_binding", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_account", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccessBinding", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccount", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetAccessBinding" + "shortName": "GetAccount" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetAccessBindingRequest" + "type": "google.analytics.admin_v1alpha.types.GetAccountRequest" }, { "name": "name", @@ -7809,14 +8618,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", - "shortName": "get_access_binding" + "resultType": "google.analytics.admin_v1alpha.types.Account", + "shortName": "get_account" }, - "description": "Sample for GetAccessBinding", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_async.py", + "description": "Sample for GetAccount", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_account_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccount_async", "segments": [ { "end": 51, @@ -7849,7 +8658,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_account_async.py" }, { "canonical": true, @@ -7858,19 +8667,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_access_binding", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_account", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccessBinding", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccount", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetAccessBinding" + "shortName": "GetAccount" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetAccessBindingRequest" + "type": "google.analytics.admin_v1alpha.types.GetAccountRequest" }, { "name": "name", @@ -7889,14 +8698,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.AccessBinding", - "shortName": "get_access_binding" + "resultType": "google.analytics.admin_v1alpha.types.Account", + "shortName": "get_account" }, - "description": "Sample for GetAccessBinding", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_sync.py", + "description": "Sample for GetAccount", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_account_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccessBinding_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccount_sync", "segments": [ { "end": 51, @@ -7929,7 +8738,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_access_binding_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_account_sync.py" }, { "canonical": true, @@ -7939,19 +8748,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_account", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_ad_sense_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccount", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAdSenseLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetAccount" + "shortName": "GetAdSenseLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetAccountRequest" + "type": "google.analytics.admin_v1alpha.types.GetAdSenseLinkRequest" }, { "name": "name", @@ -7970,14 +8779,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.Account", - "shortName": "get_account" + "resultType": "google.analytics.admin_v1alpha.types.AdSenseLink", + "shortName": "get_ad_sense_link" }, - "description": "Sample for GetAccount", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_account_async.py", + "description": "Sample for GetAdSenseLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccount_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAdSenseLink_async", "segments": [ { "end": 51, @@ -8010,7 +8819,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_account_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_async.py" }, { "canonical": true, @@ -8019,19 +8828,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_account", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_ad_sense_link", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAccount", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetAdSenseLink", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetAccount" + "shortName": "GetAdSenseLink" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetAccountRequest" + "type": "google.analytics.admin_v1alpha.types.GetAdSenseLinkRequest" }, { "name": "name", @@ -8050,14 +8859,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.Account", - "shortName": "get_account" + "resultType": "google.analytics.admin_v1alpha.types.AdSenseLink", + "shortName": "get_ad_sense_link" }, - "description": "Sample for GetAccount", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_account_sync.py", + "description": "Sample for GetAdSenseLink", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAccount_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetAdSenseLink_sync", "segments": [ { "end": 51, @@ -8090,7 +8899,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_account_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_ad_sense_link_sync.py" }, { "canonical": true, @@ -9700,7 +10509,168 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_data_stream_sync.py" + "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.GetDisplayVideo360AdvertiserLinkProposalRequest" + }, + { + "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.DisplayVideo360AdvertiserLinkProposal", + "shortName": "get_display_video360_advertiser_link_proposal" + }, + "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_GetDisplayVideo360AdvertiserLinkProposal_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_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.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.GetDisplayVideo360AdvertiserLinkProposalRequest" + }, + { + "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.DisplayVideo360AdvertiserLinkProposal", + "shortName": "get_display_video360_advertiser_link_proposal" + }, + "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_GetDisplayVideo360AdvertiserLinkProposal_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_display_video360_advertiser_link_proposal_sync.py" }, { "canonical": true, @@ -9710,19 +10680,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", @@ -9741,14 +10711,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, @@ -9781,7 +10751,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, @@ -9790,19 +10760,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", @@ -9821,14 +10791,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, @@ -9861,7 +10831,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, @@ -9871,19 +10841,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_enhanced_measurement_settings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetEnhancedMeasurementSettings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetDisplayVideo360AdvertiserLink" + "shortName": "GetEnhancedMeasurementSettings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest" }, { "name": "name", @@ -9902,14 +10872,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.EnhancedMeasurementSettings", + "shortName": "get_enhanced_measurement_settings" }, - "description": "Sample for GetDisplayVideo360AdvertiserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_async.py", + "description": "Sample for GetEnhancedMeasurementSettings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_enhanced_measurement_settings_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLink_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetEnhancedMeasurementSettings_async", "segments": [ { "end": 51, @@ -9942,7 +10912,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_enhanced_measurement_settings_async.py" }, { "canonical": true, @@ -9951,19 +10921,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_enhanced_measurement_settings", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetDisplayVideo360AdvertiserLink", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetEnhancedMeasurementSettings", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetDisplayVideo360AdvertiserLink" + "shortName": "GetEnhancedMeasurementSettings" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetDisplayVideo360AdvertiserLinkRequest" + "type": "google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest" }, { "name": "name", @@ -9982,14 +10952,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.EnhancedMeasurementSettings", + "shortName": "get_enhanced_measurement_settings" }, - "description": "Sample for GetDisplayVideo360AdvertiserLink", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_display_video360_advertiser_link_sync.py", + "description": "Sample for GetEnhancedMeasurementSettings", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_enhanced_measurement_settings_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetDisplayVideo360AdvertiserLink_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetEnhancedMeasurementSettings_sync", "segments": [ { "end": 51, @@ -10022,7 +10992,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_enhanced_measurement_settings_sync.py" }, { "canonical": true, @@ -10032,19 +11002,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_enhanced_measurement_settings", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.get_event_create_rule", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetEnhancedMeasurementSettings", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetEventCreateRule", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetEnhancedMeasurementSettings" + "shortName": "GetEventCreateRule" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest" + "type": "google.analytics.admin_v1alpha.types.GetEventCreateRuleRequest" }, { "name": "name", @@ -10063,14 +11033,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings", - "shortName": "get_enhanced_measurement_settings" + "resultType": "google.analytics.admin_v1alpha.types.EventCreateRule", + "shortName": "get_event_create_rule" }, - "description": "Sample for GetEnhancedMeasurementSettings", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_enhanced_measurement_settings_async.py", + "description": "Sample for GetEventCreateRule", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetEnhancedMeasurementSettings_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetEventCreateRule_async", "segments": [ { "end": 51, @@ -10103,7 +11073,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_enhanced_measurement_settings_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_async.py" }, { "canonical": true, @@ -10112,19 +11082,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_enhanced_measurement_settings", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_event_create_rule", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetEnhancedMeasurementSettings", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.GetEventCreateRule", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "GetEnhancedMeasurementSettings" + "shortName": "GetEventCreateRule" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.GetEnhancedMeasurementSettingsRequest" + "type": "google.analytics.admin_v1alpha.types.GetEventCreateRuleRequest" }, { "name": "name", @@ -10143,14 +11113,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings", - "shortName": "get_enhanced_measurement_settings" + "resultType": "google.analytics.admin_v1alpha.types.EventCreateRule", + "shortName": "get_event_create_rule" }, - "description": "Sample for GetEnhancedMeasurementSettings", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_enhanced_measurement_settings_sync.py", + "description": "Sample for GetEventCreateRule", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetEnhancedMeasurementSettings_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetEventCreateRule_sync", "segments": [ { "end": 51, @@ -10183,7 +11153,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_enhanced_measurement_settings_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_get_event_create_rule_sync.py" }, { "canonical": true, @@ -11471,7 +12441,160 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_access_bindings_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_account_summaries", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccountSummaries", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "ListAccountSummaries" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.ListAccountSummariesRequest" + }, + { + "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.ListAccountSummariesAsyncPager", + "shortName": "list_account_summaries" + }, + "description": "Sample for ListAccountSummaries", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_account_summaries_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccountSummaries_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_account_summaries_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_account_summaries", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccountSummaries", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "ListAccountSummaries" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.ListAccountSummariesRequest" + }, + { + "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.ListAccountSummariesPager", + "shortName": "list_account_summaries" + }, + "description": "Sample for ListAccountSummaries", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_account_summaries_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccountSummaries_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_account_summaries_sync.py" }, { "canonical": true, @@ -11481,19 +12604,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_account_summaries", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_accounts", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccountSummaries", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccounts", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListAccountSummaries" + "shortName": "ListAccounts" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListAccountSummariesRequest" + "type": "google.analytics.admin_v1alpha.types.ListAccountsRequest" }, { "name": "retry", @@ -11508,14 +12631,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountSummariesAsyncPager", - "shortName": "list_account_summaries" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsAsyncPager", + "shortName": "list_accounts" }, - "description": "Sample for ListAccountSummaries", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_account_summaries_async.py", + "description": "Sample for ListAccounts", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_accounts_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccountSummaries_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccounts_async", "segments": [ { "end": 51, @@ -11548,7 +12671,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_account_summaries_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_accounts_async.py" }, { "canonical": true, @@ -11557,19 +12680,19 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_account_summaries", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_accounts", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccountSummaries", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccounts", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListAccountSummaries" + "shortName": "ListAccounts" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListAccountSummariesRequest" + "type": "google.analytics.admin_v1alpha.types.ListAccountsRequest" }, { "name": "retry", @@ -11584,14 +12707,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountSummariesPager", - "shortName": "list_account_summaries" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsPager", + "shortName": "list_accounts" }, - "description": "Sample for ListAccountSummaries", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_account_summaries_sync.py", + "description": "Sample for ListAccounts", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_accounts_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccountSummaries_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccounts_sync", "segments": [ { "end": 51, @@ -11624,7 +12747,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_account_summaries_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_accounts_sync.py" }, { "canonical": true, @@ -11634,19 +12757,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", "shortName": "AnalyticsAdminServiceAsyncClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_accounts", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.list_ad_sense_links", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccounts", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAdSenseLinks", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListAccounts" + "shortName": "ListAdSenseLinks" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListAccountsRequest" + "type": "google.analytics.admin_v1alpha.types.ListAdSenseLinksRequest" + }, + { + "name": "parent", + "type": "str" }, { "name": "retry", @@ -11661,22 +12788,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsAsyncPager", - "shortName": "list_accounts" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAdSenseLinksAsyncPager", + "shortName": "list_ad_sense_links" }, - "description": "Sample for ListAccounts", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_accounts_async.py", + "description": "Sample for ListAdSenseLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccounts_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAdSenseLinks_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -11686,22 +12813,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 48, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_accounts_async.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_async.py" }, { "canonical": true, @@ -11710,19 +12837,23 @@ "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", "shortName": "AnalyticsAdminServiceClient" }, - "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_accounts", + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_ad_sense_links", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAccounts", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListAdSenseLinks", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListAccounts" + "shortName": "ListAdSenseLinks" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListAccountsRequest" + "type": "google.analytics.admin_v1alpha.types.ListAdSenseLinksRequest" + }, + { + "name": "parent", + "type": "str" }, { "name": "retry", @@ -11737,22 +12868,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsPager", - "shortName": "list_accounts" + "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAdSenseLinksPager", + "shortName": "list_ad_sense_links" }, - "description": "Sample for ListAccounts", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_accounts_sync.py", + "description": "Sample for ListAdSenseLinks", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAccounts_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListAdSenseLinks_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -11762,22 +12893,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 48, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_accounts_sync.py" + "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_ad_sense_links_sync.py" }, { "canonical": true, @@ -12859,11 +13990,172 @@ "resultType": "google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomMetricsPager", "shortName": "list_custom_metrics" }, - "description": "Sample for ListCustomMetrics", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_custom_metrics_sync.py", + "description": "Sample for ListCustomMetrics", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_custom_metrics_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "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_ListCustomMetrics_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDataStreams_sync", "segments": [ { "end": 52, @@ -12896,7 +14188,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, @@ -12906,19 +14198,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", @@ -12937,14 +14229,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, @@ -12977,7 +14269,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, @@ -12986,19 +14278,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", @@ -13017,14 +14309,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, @@ -13057,7 +14349,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, @@ -13067,19 +14359,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", @@ -13098,14 +14390,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, @@ -13138,7 +14430,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, @@ -13147,19 +14439,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", @@ -13178,14 +14470,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, @@ -13218,7 +14510,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, @@ -13228,19 +14520,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_event_create_rules", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListEventCreateRules", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListDisplayVideo360AdvertiserLinks" + "shortName": "ListEventCreateRules" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.ListEventCreateRulesRequest" }, { "name": "parent", @@ -13259,14 +14551,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.ListEventCreateRulesAsyncPager", + "shortName": "list_event_create_rules" }, - "description": "Sample for ListDisplayVideo360AdvertiserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_async.py", + "description": "Sample for ListEventCreateRules", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_event_create_rules_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinks_async", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListEventCreateRules_async", "segments": [ { "end": 52, @@ -13299,7 +14591,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_event_create_rules_async.py" }, { "canonical": true, @@ -13308,19 +14600,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_event_create_rules", "method": { - "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListDisplayVideo360AdvertiserLinks", + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.ListEventCreateRules", "service": { "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", "shortName": "AnalyticsAdminService" }, - "shortName": "ListDisplayVideo360AdvertiserLinks" + "shortName": "ListEventCreateRules" }, "parameters": [ { "name": "request", - "type": "google.analytics.admin_v1alpha.types.ListDisplayVideo360AdvertiserLinksRequest" + "type": "google.analytics.admin_v1alpha.types.ListEventCreateRulesRequest" }, { "name": "parent", @@ -13339,14 +14631,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.ListEventCreateRulesPager", + "shortName": "list_event_create_rules" }, - "description": "Sample for ListDisplayVideo360AdvertiserLinks", - "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_display_video360_advertiser_links_sync.py", + "description": "Sample for ListEventCreateRules", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_list_event_create_rules_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListDisplayVideo360AdvertiserLinks_sync", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_ListEventCreateRules_sync", "segments": [ { "end": 52, @@ -13379,7 +14671,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_event_create_rules_sync.py" }, { "canonical": true, @@ -16963,6 +18255,175 @@ ], "title": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_enhanced_measurement_settings_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient", + "shortName": "AnalyticsAdminServiceAsyncClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient.update_event_create_rule", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.UpdateEventCreateRule", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "UpdateEventCreateRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.UpdateEventCreateRuleRequest" + }, + { + "name": "event_create_rule", + "type": "google.analytics.admin_v1alpha.types.EventCreateRule" + }, + { + "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.EventCreateRule", + "shortName": "update_event_create_rule" + }, + "description": "Sample for UpdateEventCreateRule", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_event_create_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateEventCreateRule_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_update_event_create_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient", + "shortName": "AnalyticsAdminServiceClient" + }, + "fullName": "google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_event_create_rule", + "method": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService.UpdateEventCreateRule", + "service": { + "fullName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "shortName": "AnalyticsAdminService" + }, + "shortName": "UpdateEventCreateRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.analytics.admin_v1alpha.types.UpdateEventCreateRuleRequest" + }, + { + "name": "event_create_rule", + "type": "google.analytics.admin_v1alpha.types.EventCreateRule" + }, + { + "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.EventCreateRule", + "shortName": "update_event_create_rule" + }, + "description": "Sample for UpdateEventCreateRule", + "file": "analyticsadmin_v1alpha_generated_analytics_admin_service_update_event_create_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "analyticsadmin_v1alpha_generated_AnalyticsAdminService_UpdateEventCreateRule_sync", + "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_update_event_create_rule_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/scripts/fixup_admin_v1alpha_keywords.py b/scripts/fixup_admin_v1alpha_keywords.py index 5b04d7ab..bf1b9217 100644 --- a/scripts/fixup_admin_v1alpha_keywords.py +++ b/scripts/fixup_admin_v1alpha_keywords.py @@ -55,6 +55,7 @@ class adminCallTransformer(cst.CSTTransformer): 'batch_update_user_links': ('parent', 'requests', ), 'cancel_display_video360_advertiser_link_proposal': ('name', ), 'create_access_binding': ('parent', 'access_binding', ), + 'create_ad_sense_link': ('parent', 'adsense_link', ), 'create_audience': ('parent', 'audience', ), 'create_channel_group': ('parent', 'channel_group', ), 'create_connected_site_tag': ('connected_site_tag', 'property', ), @@ -64,6 +65,7 @@ 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_event_create_rule': ('parent', 'event_create_rule', ), 'create_expanded_data_set': ('parent', 'expanded_data_set', ), 'create_firebase_link': ('parent', 'firebase_link', ), 'create_google_ads_link': ('parent', 'google_ads_link', ), @@ -73,12 +75,14 @@ class adminCallTransformer(cst.CSTTransformer): 'create_user_link': ('parent', 'user_link', 'notify_new_user', ), 'delete_access_binding': ('name', ), 'delete_account': ('name', ), + 'delete_ad_sense_link': ('name', ), 'delete_channel_group': ('name', ), 'delete_connected_site_tag': ('property', 'tag_id', ), 'delete_conversion_event': ('name', ), 'delete_data_stream': ('name', ), 'delete_display_video360_advertiser_link': ('name', ), 'delete_display_video360_advertiser_link_proposal': ('name', ), + 'delete_event_create_rule': ('name', ), 'delete_expanded_data_set': ('name', ), 'delete_firebase_link': ('name', ), 'delete_google_ads_link': ('name', ), @@ -90,6 +94,7 @@ class adminCallTransformer(cst.CSTTransformer): 'fetch_connected_ga4_property': ('property', ), 'get_access_binding': ('name', ), 'get_account': ('name', ), + 'get_ad_sense_link': ('name', ), 'get_attribution_settings': ('name', ), 'get_audience': ('name', ), 'get_big_query_link': ('name', ), @@ -103,6 +108,7 @@ class adminCallTransformer(cst.CSTTransformer): 'get_display_video360_advertiser_link': ('name', ), 'get_display_video360_advertiser_link_proposal': ('name', ), 'get_enhanced_measurement_settings': ('name', ), + 'get_event_create_rule': ('name', ), 'get_expanded_data_set': ('name', ), 'get_global_site_tag': ('name', ), 'get_google_signals_settings': ('name', ), @@ -113,6 +119,7 @@ class adminCallTransformer(cst.CSTTransformer): 'list_access_bindings': ('parent', 'page_size', 'page_token', ), 'list_accounts': ('page_size', 'page_token', 'show_deleted', ), 'list_account_summaries': ('page_size', 'page_token', ), + 'list_ad_sense_links': ('parent', 'page_size', 'page_token', ), 'list_audiences': ('parent', 'page_size', 'page_token', ), 'list_big_query_links': ('parent', 'page_size', 'page_token', ), 'list_channel_groups': ('parent', 'page_size', 'page_token', ), @@ -123,6 +130,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_event_create_rules': ('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', ), @@ -145,6 +153,7 @@ class adminCallTransformer(cst.CSTTransformer): 'update_data_stream': ('update_mask', 'data_stream', ), 'update_display_video360_advertiser_link': ('update_mask', 'display_video_360_advertiser_link', ), 'update_enhanced_measurement_settings': ('enhanced_measurement_settings', 'update_mask', ), + 'update_event_create_rule': ('event_create_rule', 'update_mask', ), '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', ), 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 d5f36a15..b3b5dc3f 100644 --- a/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +++ b/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py @@ -60,6 +60,7 @@ 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 channel_group +from google.analytics.admin_v1alpha.types import event_create_and_edit from google.analytics.admin_v1alpha.types import expanded_data_set from google.analytics.admin_v1alpha.types import resources @@ -30775,6 +30776,2662 @@ async def test_fetch_connected_ga4_property_async_from_dict(): await test_fetch_connected_ga4_property_async(request_type=dict) +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.GetAdSenseLinkRequest, + dict, + ], +) +def test_get_ad_sense_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_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AdSenseLink( + name="name_value", + ad_client_code="ad_client_code_value", + ) + response = client.get_ad_sense_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.GetAdSenseLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.AdSenseLink) + assert response.name == "name_value" + assert response.ad_client_code == "ad_client_code_value" + + +def test_get_ad_sense_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_ad_sense_link), "__call__" + ) as call: + client.get_ad_sense_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetAdSenseLinkRequest() + + +@pytest.mark.asyncio +async def test_get_ad_sense_link_async( + transport: str = "grpc_asyncio", request_type=analytics_admin.GetAdSenseLinkRequest +): + 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_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AdSenseLink( + name="name_value", + ad_client_code="ad_client_code_value", + ) + ) + response = await client.get_ad_sense_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.GetAdSenseLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.AdSenseLink) + assert response.name == "name_value" + assert response.ad_client_code == "ad_client_code_value" + + +@pytest.mark.asyncio +async def test_get_ad_sense_link_async_from_dict(): + await test_get_ad_sense_link_async(request_type=dict) + + +def test_get_ad_sense_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.GetAdSenseLinkRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ad_sense_link), "__call__" + ) as call: + call.return_value = resources.AdSenseLink() + client.get_ad_sense_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_ad_sense_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.GetAdSenseLinkRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ad_sense_link), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AdSenseLink() + ) + await client.get_ad_sense_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_ad_sense_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_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AdSenseLink() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_ad_sense_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_ad_sense_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_ad_sense_link( + analytics_admin.GetAdSenseLinkRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_ad_sense_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_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AdSenseLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AdSenseLink() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_ad_sense_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_ad_sense_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_ad_sense_link( + analytics_admin.GetAdSenseLinkRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.CreateAdSenseLinkRequest, + dict, + ], +) +def test_create_ad_sense_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.create_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AdSenseLink( + name="name_value", + ad_client_code="ad_client_code_value", + ) + response = client.create_ad_sense_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.CreateAdSenseLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.AdSenseLink) + assert response.name == "name_value" + assert response.ad_client_code == "ad_client_code_value" + + +def test_create_ad_sense_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ad_sense_link), "__call__" + ) as call: + client.create_ad_sense_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateAdSenseLinkRequest() + + +@pytest.mark.asyncio +async def test_create_ad_sense_link_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateAdSenseLinkRequest, +): + 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_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AdSenseLink( + name="name_value", + ad_client_code="ad_client_code_value", + ) + ) + response = await client.create_ad_sense_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.CreateAdSenseLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.AdSenseLink) + assert response.name == "name_value" + assert response.ad_client_code == "ad_client_code_value" + + +@pytest.mark.asyncio +async def test_create_ad_sense_link_async_from_dict(): + await test_create_ad_sense_link_async(request_type=dict) + + +def test_create_ad_sense_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.CreateAdSenseLinkRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ad_sense_link), "__call__" + ) as call: + call.return_value = resources.AdSenseLink() + client.create_ad_sense_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_ad_sense_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.CreateAdSenseLinkRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ad_sense_link), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AdSenseLink() + ) + await client.create_ad_sense_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_ad_sense_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AdSenseLink() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_ad_sense_link( + parent="parent_value", + adsense_link=resources.AdSenseLink(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].adsense_link + mock_val = resources.AdSenseLink(name="name_value") + assert arg == mock_val + + +def test_create_ad_sense_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_ad_sense_link( + analytics_admin.CreateAdSenseLinkRequest(), + parent="parent_value", + adsense_link=resources.AdSenseLink(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_ad_sense_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.AdSenseLink() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.AdSenseLink() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_ad_sense_link( + parent="parent_value", + adsense_link=resources.AdSenseLink(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].adsense_link + mock_val = resources.AdSenseLink(name="name_value") + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_ad_sense_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_ad_sense_link( + analytics_admin.CreateAdSenseLinkRequest(), + parent="parent_value", + adsense_link=resources.AdSenseLink(name="name_value"), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.DeleteAdSenseLinkRequest, + dict, + ], +) +def test_delete_ad_sense_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.delete_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_ad_sense_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.DeleteAdSenseLinkRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_ad_sense_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ad_sense_link), "__call__" + ) as call: + client.delete_ad_sense_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteAdSenseLinkRequest() + + +@pytest.mark.asyncio +async def test_delete_ad_sense_link_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteAdSenseLinkRequest, +): + 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_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_ad_sense_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.DeleteAdSenseLinkRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_ad_sense_link_async_from_dict(): + await test_delete_ad_sense_link_async(request_type=dict) + + +def test_delete_ad_sense_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.DeleteAdSenseLinkRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ad_sense_link), "__call__" + ) as call: + call.return_value = None + client.delete_ad_sense_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_ad_sense_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.DeleteAdSenseLinkRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ad_sense_link), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_ad_sense_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_ad_sense_link_flattened(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_ad_sense_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_delete_ad_sense_link_flattened_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_ad_sense_link( + analytics_admin.DeleteAdSenseLinkRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_ad_sense_link_flattened_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ad_sense_link), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_ad_sense_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_delete_ad_sense_link_flattened_error_async(): + client = AnalyticsAdminServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_ad_sense_link( + analytics_admin.DeleteAdSenseLinkRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListAdSenseLinksRequest, + dict, + ], +) +def test_list_ad_sense_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_ad_sense_links), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAdSenseLinksResponse( + next_page_token="next_page_token_value", + ) + response = client.list_ad_sense_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.ListAdSenseLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAdSenseLinksPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_ad_sense_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_ad_sense_links), "__call__" + ) as call: + client.list_ad_sense_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListAdSenseLinksRequest() + + +@pytest.mark.asyncio +async def test_list_ad_sense_links_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListAdSenseLinksRequest, +): + 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_ad_sense_links), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListAdSenseLinksResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_ad_sense_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.ListAdSenseLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAdSenseLinksAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_ad_sense_links_async_from_dict(): + await test_list_ad_sense_links_async(request_type=dict) + + +def test_list_ad_sense_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.ListAdSenseLinksRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ad_sense_links), "__call__" + ) as call: + call.return_value = analytics_admin.ListAdSenseLinksResponse() + client.list_ad_sense_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_ad_sense_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.ListAdSenseLinksRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ad_sense_links), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListAdSenseLinksResponse() + ) + await client.list_ad_sense_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_ad_sense_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_ad_sense_links), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAdSenseLinksResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_ad_sense_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_ad_sense_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_ad_sense_links( + analytics_admin.ListAdSenseLinksRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_ad_sense_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_ad_sense_links), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListAdSenseLinksResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListAdSenseLinksResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_ad_sense_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_ad_sense_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_ad_sense_links( + analytics_admin.ListAdSenseLinksRequest(), + parent="parent_value", + ) + + +def test_list_ad_sense_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_ad_sense_links), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + resources.AdSenseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[], + next_page_token="def", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_ad_sense_links(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.AdSenseLink) for i in results) + + +def test_list_ad_sense_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_ad_sense_links), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + resources.AdSenseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[], + next_page_token="def", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + ], + ), + RuntimeError, + ) + pages = list(client.list_ad_sense_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_ad_sense_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_ad_sense_links), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + resources.AdSenseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[], + next_page_token="def", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_ad_sense_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.AdSenseLink) for i in responses) + + +@pytest.mark.asyncio +async def test_list_ad_sense_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_ad_sense_links), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + resources.AdSenseLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[], + next_page_token="def", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_ad_sense_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.GetEventCreateRuleRequest, + dict, + ], +) +def test_get_event_create_rule(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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule( + name="name_value", + destination_event="destination_event_value", + source_copy_parameters=True, + ) + response = client.get_event_create_rule(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.GetEventCreateRuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event_create_and_edit.EventCreateRule) + assert response.name == "name_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True + + +def test_get_event_create_rule_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_event_create_rule), "__call__" + ) as call: + client.get_event_create_rule() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.GetEventCreateRuleRequest() + + +@pytest.mark.asyncio +async def test_get_event_create_rule_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.GetEventCreateRuleRequest, +): + 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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule( + name="name_value", + destination_event="destination_event_value", + source_copy_parameters=True, + ) + ) + response = await client.get_event_create_rule(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.GetEventCreateRuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event_create_and_edit.EventCreateRule) + assert response.name == "name_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True + + +@pytest.mark.asyncio +async def test_get_event_create_rule_async_from_dict(): + await test_get_event_create_rule_async(request_type=dict) + + +def test_get_event_create_rule_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.GetEventCreateRuleRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_event_create_rule), "__call__" + ) as call: + call.return_value = event_create_and_edit.EventCreateRule() + client.get_event_create_rule(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_event_create_rule_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.GetEventCreateRuleRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_event_create_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule() + ) + await client.get_event_create_rule(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_event_create_rule_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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_event_create_rule( + 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_event_create_rule_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_event_create_rule( + analytics_admin.GetEventCreateRuleRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_event_create_rule_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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_event_create_rule( + 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_event_create_rule_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_event_create_rule( + analytics_admin.GetEventCreateRuleRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListEventCreateRulesRequest, + dict, + ], +) +def test_list_event_create_rules(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_event_create_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListEventCreateRulesResponse( + next_page_token="next_page_token_value", + ) + response = client.list_event_create_rules(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.ListEventCreateRulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEventCreateRulesPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_event_create_rules_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_event_create_rules), "__call__" + ) as call: + client.list_event_create_rules() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.ListEventCreateRulesRequest() + + +@pytest.mark.asyncio +async def test_list_event_create_rules_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.ListEventCreateRulesRequest, +): + 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_event_create_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListEventCreateRulesResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_event_create_rules(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.ListEventCreateRulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEventCreateRulesAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_event_create_rules_async_from_dict(): + await test_list_event_create_rules_async(request_type=dict) + + +def test_list_event_create_rules_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.ListEventCreateRulesRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_event_create_rules), "__call__" + ) as call: + call.return_value = analytics_admin.ListEventCreateRulesResponse() + client.list_event_create_rules(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_event_create_rules_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.ListEventCreateRulesRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_event_create_rules), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListEventCreateRulesResponse() + ) + await client.list_event_create_rules(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_event_create_rules_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_event_create_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListEventCreateRulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_event_create_rules( + 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_event_create_rules_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_event_create_rules( + analytics_admin.ListEventCreateRulesRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_event_create_rules_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_event_create_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = analytics_admin.ListEventCreateRulesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + analytics_admin.ListEventCreateRulesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_event_create_rules( + 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_event_create_rules_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_event_create_rules( + analytics_admin.ListEventCreateRulesRequest(), + parent="parent_value", + ) + + +def test_list_event_create_rules_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_event_create_rules), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + next_page_token="abc", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[], + next_page_token="def", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + ], + next_page_token="ghi", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_event_create_rules(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all( + isinstance(i, event_create_and_edit.EventCreateRule) for i in results + ) + + +def test_list_event_create_rules_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_event_create_rules), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + next_page_token="abc", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[], + next_page_token="def", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + ], + next_page_token="ghi", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_event_create_rules(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_event_create_rules_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_event_create_rules), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + next_page_token="abc", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[], + next_page_token="def", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + ], + next_page_token="ghi", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_event_create_rules( + 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, event_create_and_edit.EventCreateRule) for i in responses + ) + + +@pytest.mark.asyncio +async def test_list_event_create_rules_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_event_create_rules), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + next_page_token="abc", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[], + next_page_token="def", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + ], + next_page_token="ghi", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_event_create_rules(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.CreateEventCreateRuleRequest, + dict, + ], +) +def test_create_event_create_rule(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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule( + name="name_value", + destination_event="destination_event_value", + source_copy_parameters=True, + ) + response = client.create_event_create_rule(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.CreateEventCreateRuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event_create_and_edit.EventCreateRule) + assert response.name == "name_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True + + +def test_create_event_create_rule_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_event_create_rule), "__call__" + ) as call: + client.create_event_create_rule() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.CreateEventCreateRuleRequest() + + +@pytest.mark.asyncio +async def test_create_event_create_rule_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.CreateEventCreateRuleRequest, +): + 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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule( + name="name_value", + destination_event="destination_event_value", + source_copy_parameters=True, + ) + ) + response = await client.create_event_create_rule(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.CreateEventCreateRuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event_create_and_edit.EventCreateRule) + assert response.name == "name_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True + + +@pytest.mark.asyncio +async def test_create_event_create_rule_async_from_dict(): + await test_create_event_create_rule_async(request_type=dict) + + +def test_create_event_create_rule_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.CreateEventCreateRuleRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_event_create_rule), "__call__" + ) as call: + call.return_value = event_create_and_edit.EventCreateRule() + client.create_event_create_rule(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_event_create_rule_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.CreateEventCreateRuleRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_event_create_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule() + ) + await client.create_event_create_rule(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_event_create_rule_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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_event_create_rule( + parent="parent_value", + event_create_rule=event_create_and_edit.EventCreateRule(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].event_create_rule + mock_val = event_create_and_edit.EventCreateRule(name="name_value") + assert arg == mock_val + + +def test_create_event_create_rule_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_event_create_rule( + analytics_admin.CreateEventCreateRuleRequest(), + parent="parent_value", + event_create_rule=event_create_and_edit.EventCreateRule(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_event_create_rule_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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_event_create_rule( + parent="parent_value", + event_create_rule=event_create_and_edit.EventCreateRule(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].event_create_rule + mock_val = event_create_and_edit.EventCreateRule(name="name_value") + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_event_create_rule_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_event_create_rule( + analytics_admin.CreateEventCreateRuleRequest(), + parent="parent_value", + event_create_rule=event_create_and_edit.EventCreateRule(name="name_value"), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.UpdateEventCreateRuleRequest, + dict, + ], +) +def test_update_event_create_rule(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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule( + name="name_value", + destination_event="destination_event_value", + source_copy_parameters=True, + ) + response = client.update_event_create_rule(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.UpdateEventCreateRuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event_create_and_edit.EventCreateRule) + assert response.name == "name_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True + + +def test_update_event_create_rule_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_event_create_rule), "__call__" + ) as call: + client.update_event_create_rule() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.UpdateEventCreateRuleRequest() + + +@pytest.mark.asyncio +async def test_update_event_create_rule_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.UpdateEventCreateRuleRequest, +): + 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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule( + name="name_value", + destination_event="destination_event_value", + source_copy_parameters=True, + ) + ) + response = await client.update_event_create_rule(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.UpdateEventCreateRuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, event_create_and_edit.EventCreateRule) + assert response.name == "name_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True + + +@pytest.mark.asyncio +async def test_update_event_create_rule_async_from_dict(): + await test_update_event_create_rule_async(request_type=dict) + + +def test_update_event_create_rule_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.UpdateEventCreateRuleRequest() + + request.event_create_rule.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_event_create_rule), "__call__" + ) as call: + call.return_value = event_create_and_edit.EventCreateRule() + client.update_event_create_rule(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", + "event_create_rule.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_event_create_rule_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.UpdateEventCreateRuleRequest() + + request.event_create_rule.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_event_create_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule() + ) + await client.update_event_create_rule(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", + "event_create_rule.name=name_value", + ) in kw["metadata"] + + +def test_update_event_create_rule_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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_event_create_rule( + event_create_rule=event_create_and_edit.EventCreateRule(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].event_create_rule + mock_val = event_create_and_edit.EventCreateRule(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_event_create_rule_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_event_create_rule( + analytics_admin.UpdateEventCreateRuleRequest(), + event_create_rule=event_create_and_edit.EventCreateRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_event_create_rule_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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = event_create_and_edit.EventCreateRule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + event_create_and_edit.EventCreateRule() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_event_create_rule( + event_create_rule=event_create_and_edit.EventCreateRule(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].event_create_rule + mock_val = event_create_and_edit.EventCreateRule(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_event_create_rule_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_event_create_rule( + analytics_admin.UpdateEventCreateRuleRequest(), + event_create_rule=event_create_and_edit.EventCreateRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.DeleteEventCreateRuleRequest, + dict, + ], +) +def test_delete_event_create_rule(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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_event_create_rule(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.DeleteEventCreateRuleRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_event_create_rule_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_event_create_rule), "__call__" + ) as call: + client.delete_event_create_rule() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == analytics_admin.DeleteEventCreateRuleRequest() + + +@pytest.mark.asyncio +async def test_delete_event_create_rule_async( + transport: str = "grpc_asyncio", + request_type=analytics_admin.DeleteEventCreateRuleRequest, +): + 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_event_create_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_event_create_rule(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.DeleteEventCreateRuleRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_event_create_rule_async_from_dict(): + await test_delete_event_create_rule_async(request_type=dict) + + +def test_delete_event_create_rule_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.DeleteEventCreateRuleRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_event_create_rule), "__call__" + ) as call: + call.return_value = None + client.delete_event_create_rule(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_event_create_rule_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.DeleteEventCreateRuleRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_event_create_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_event_create_rule(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_event_create_rule_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_event_create_rule), "__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_event_create_rule( + 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_event_create_rule_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_event_create_rule( + analytics_admin.DeleteEventCreateRuleRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_event_create_rule_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_event_create_rule), "__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_event_create_rule( + 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_event_create_rule_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_event_create_rule( + analytics_admin.DeleteEventCreateRuleRequest(), + name="name_value", + ) + + @pytest.mark.parametrize( "request_type", [ @@ -30782,51 +33439,1965 @@ async def test_fetch_connected_ga4_property_async_from_dict(): dict, ], ) -def test_get_account_rest(request_type): +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 = {"name": "accounts/sample1"} + 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.Account( + return_value = resources.Property( name="name_value", + property_type=resources.PropertyType.PROPERTY_TYPE_ORDINARY, + parent="parent_value", display_name="display_name_value", - region_code="region_code_value", - deleted=True, + 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.Account.pb(return_value) + 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_account(request) + response = client.create_property(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Account) + 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.region_code == "region_code_value" - assert response.deleted is True + 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_account_rest_required_fields( - request_type=analytics_admin.GetAccountRequest, +def test_create_property_rest_required_fields( + request_type=analytics_admin.CreatePropertyRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -30841,21 +35412,17 @@ def test_get_account_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_account._get_unset_required_fields(jsonified_request) + ).create_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_account._get_unset_required_fields(jsonified_request) + ).create_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(), @@ -30864,7 +35431,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.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 @@ -30876,38 +35443,39 @@ 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.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_account(request) + 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_get_account_rest_unset_required_fields(): +def test_create_property_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_property._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("property",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_account_rest_interceptors(null_interceptor): +def test_create_property_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30920,14 +35488,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_property" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_account" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_property" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetAccountRequest.pb( - analytics_admin.GetAccountRequest() + pb_message = analytics_admin.CreatePropertyRequest.pb( + analytics_admin.CreatePropertyRequest() ) transcode.return_value = { "method": "post", @@ -30939,17 +35507,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.Property.to_json(resources.Property()) - request = analytics_admin.GetAccountRequest() + request = analytics_admin.CreatePropertyRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Account() + post.return_value = resources.Property() - client.get_account( + client.create_property( request, metadata=[ ("key", "val"), @@ -30961,8 +35529,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_property_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreatePropertyRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -30970,7 +35538,22 @@ def test_get_account_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1"} + 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. @@ -30982,10 +35565,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_property(request) -def test_get_account_rest_flattened(): +def test_create_property_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -30994,37 +35577,37 @@ 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.Property() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1"} + sample_request = {} # get truthy value for each flattened field mock_args = dict( - name="name_value", + 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.Account.pb(return_value) + 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_account(**mock_args) + 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/{name=accounts/*}" % client.transport._host, args[1] + "%s/v1alpha/properties" % client.transport._host, args[1] ) -def test_get_account_rest_flattened_error(transport: str = "rest"): +def test_create_property_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -31033,13 +35616,13 @@ 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_property( + analytics_admin.CreatePropertyRequest(), + property=resources.Property(name="name_value"), ) -def test_get_account_rest_error(): +def test_create_property_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -31048,44 +35631,146 @@ def test_get_account_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListAccountsRequest, + analytics_admin.DeletePropertyRequest, dict, ], ) -def test_list_accounts_rest(request_type): +def test_delete_property_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {} + 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 = analytics_admin.ListAccountsResponse( - next_page_token="next_page_token_value", + 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 = analytics_admin.ListAccountsResponse.pb(return_value) + 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.list_accounts(request) + response = client.delete_property(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, 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_list_accounts_rest_interceptors(null_interceptor): +def test_delete_property_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31098,14 +35783,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_delete_property" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_accounts" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_property" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListAccountsRequest.pb( - analytics_admin.ListAccountsRequest() + pb_message = analytics_admin.DeletePropertyRequest.pb( + analytics_admin.DeletePropertyRequest() ) transcode.return_value = { "method": "post", @@ -31117,19 +35802,17 @@ 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 = resources.Property.to_json(resources.Property()) - request = analytics_admin.ListAccountsRequest() + request = analytics_admin.DeletePropertyRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListAccountsResponse() + post.return_value = resources.Property() - client.list_accounts( + client.delete_property( request, metadata=[ ("key", "val"), @@ -31141,8 +35824,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_delete_property_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeletePropertyRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31150,126 +35833,157 @@ def test_list_accounts_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + 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 - ): + # 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 = 400 - response_value.request = Request() + 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.list_accounts(request) + client.delete_property(**mock_args) -def test_list_accounts_rest_pager(transport: str = "rest"): + # 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, ) - # 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 + # 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", ) - 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 +def test_delete_property_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteAccountRequest, + analytics_admin.UpdatePropertyRequest, dict, ], ) -def test_delete_account_rest(request_type): +def test_update_property_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 = {"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 = None + 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 - json_return_value = "" + 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_account(request) + response = client.update_property(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, resources.Property) + assert response.name == "name_value" + assert response.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_account_rest_required_fields( - request_type=analytics_admin.DeleteAccountRequest, +def test_update_property_rest_required_fields( + request_type=analytics_admin.UpdatePropertyRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -31284,21 +35998,19 @@ def test_delete_account_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_account._get_unset_required_fields(jsonified_request) + ).update_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_account._get_unset_required_fields(jsonified_request) + ).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 - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31307,7 +36019,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.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 @@ -31319,36 +36031,47 @@ 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.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_account(request) + 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_delete_account_rest_unset_required_fields(): +def test_update_property_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_property._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "property", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_account_rest_interceptors(null_interceptor): +def test_update_property_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31361,11 +36084,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_property" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_property" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteAccountRequest.pb( - analytics_admin.DeleteAccountRequest() + post.assert_not_called() + pb_message = analytics_admin.UpdatePropertyRequest.pb( + analytics_admin.UpdatePropertyRequest() ) transcode.return_value = { "method": "post", @@ -31377,15 +36103,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.Property.to_json(resources.Property()) - request = analytics_admin.DeleteAccountRequest() + request = analytics_admin.UpdatePropertyRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.Property() - client.delete_account( + client.update_property( request, metadata=[ ("key", "val"), @@ -31394,10 +36122,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_property_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdatePropertyRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31405,7 +36134,22 @@ def test_delete_account_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1"} + 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. @@ -31417,10 +36161,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_property(request) -def test_delete_account_rest_flattened(): +def test_update_property_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -31429,36 +36173,38 @@ 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.Property() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1"} + sample_request = {"property": {"name": "properties/sample1"}} # get truthy value for each flattened field mock_args = dict( - name="name_value", + 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 - json_return_value = "" + 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_account(**mock_args) + 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/{name=accounts/*}" % client.transport._host, args[1] + "%s/v1alpha/{property.name=properties/*}" % client.transport._host, args[1] ) -def test_delete_account_rest_flattened_error(transport: str = "rest"): +def test_update_property_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -31467,13 +36213,14 @@ 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_property( + analytics_admin.UpdatePropertyRequest(), + property=resources.Property(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_delete_account_rest_error(): +def test_update_property_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -31482,62 +36229,53 @@ def test_delete_account_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateAccountRequest, + analytics_admin.GetUserLinkRequest, dict, ], ) -def test_update_account_rest(request_type): +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 = {"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 = {"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.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.update_account(request) + response = client.get_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_update_account_rest_required_fields( - request_type=analytics_admin.UpdateAccountRequest, +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( @@ -31552,19 +36290,21 @@ def test_update_account_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_account._get_unset_required_fields(jsonified_request) + ).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() - ).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",)) + ).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(), @@ -31573,7 +36313,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 = 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 @@ -31585,47 +36325,38 @@ def test_update_account_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.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.update_account(request) + 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_update_account_rest_unset_required_fields(): +def test_get_user_link_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", - ) - ) - ) + 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_update_account_rest_interceptors(null_interceptor): +def test_get_user_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31638,14 +36369,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_get_user_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_account" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_user_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateAccountRequest.pb( - analytics_admin.UpdateAccountRequest() + pb_message = analytics_admin.GetUserLinkRequest.pb( + analytics_admin.GetUserLinkRequest() ) transcode.return_value = { "method": "post", @@ -31657,17 +36388,17 @@ 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 = resources.UserLink.to_json(resources.UserLink()) - request = analytics_admin.UpdateAccountRequest() + request = analytics_admin.GetUserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Account() + post.return_value = resources.UserLink() - client.update_account( + client.get_user_link( request, metadata=[ ("key", "val"), @@ -31679,8 +36410,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_get_user_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetUserLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31688,15 +36419,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 = {"name": "accounts/sample1/userLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -31708,10 +36431,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) + client.get_user_link(request) -def test_update_account_rest_flattened(): +def test_get_user_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -31720,38 +36443,37 @@ def test_update_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 = {"account": {"name": "accounts/sample1"}} + sample_request = {"name": "accounts/sample1/userLinks/sample2"} # 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"]), + 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.update_account(**mock_args) + 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/{account.name=accounts/*}" % client.transport._host, args[1] + "%s/v1alpha/{name=accounts/*/userLinks/*}" % client.transport._host, args[1] ) -def test_update_account_rest_flattened_error(transport: str = "rest"): +def test_get_user_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -31760,14 +36482,13 @@ def test_update_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.update_account( - analytics_admin.UpdateAccountRequest(), - account=resources.Account(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_user_link( + analytics_admin.GetUserLinkRequest(), + name="name_value", ) -def test_update_account_rest_error(): +def test_get_user_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -31776,46 +36497,150 @@ def test_update_account_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ProvisionAccountTicketRequest, + analytics_admin.BatchGetUserLinksRequest, dict, ], ) -def test_provision_account_ticket_rest(request_type): +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 = {} + 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.ProvisionAccountTicketResponse( - account_ticket_id="account_ticket_id_value", - ) + 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.ProvisionAccountTicketResponse.pb( - return_value - ) + 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.provision_account_ticket(request) + response = client.batch_get_user_links(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 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_provision_account_ticket_rest_interceptors(null_interceptor): +def test_batch_get_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31828,14 +36653,14 @@ def test_provision_account_ticket_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_provision_account_ticket" + transports.AnalyticsAdminServiceRestInterceptor, "post_batch_get_user_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_provision_account_ticket" + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_get_user_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ProvisionAccountTicketRequest.pb( - analytics_admin.ProvisionAccountTicketRequest() + pb_message = analytics_admin.BatchGetUserLinksRequest.pb( + analytics_admin.BatchGetUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -31847,21 +36672,19 @@ def test_provision_account_ticket_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.ProvisionAccountTicketResponse.to_json( - analytics_admin.ProvisionAccountTicketResponse() - ) + req.return_value._content = analytics_admin.BatchGetUserLinksResponse.to_json( + analytics_admin.BatchGetUserLinksResponse() ) - request = analytics_admin.ProvisionAccountTicketRequest() + request = analytics_admin.BatchGetUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ProvisionAccountTicketResponse() + post.return_value = analytics_admin.BatchGetUserLinksResponse() - client.provision_account_ticket( + client.batch_get_user_links( request, metadata=[ ("key", "val"), @@ -31873,8 +36696,8 @@ def test_provision_account_ticket_rest_interceptors(null_interceptor): post.assert_called_once() -def test_provision_account_ticket_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ProvisionAccountTicketRequest +def test_batch_get_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchGetUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31882,7 +36705,7 @@ def test_provision_account_ticket_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. @@ -31894,10 +36717,10 @@ def test_provision_account_ticket_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.provision_account_ticket(request) + client.batch_get_user_links(request) -def test_provision_account_ticket_rest_error(): +def test_batch_get_user_links_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -31906,44 +36729,145 @@ def test_provision_account_ticket_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListAccountSummariesRequest, + analytics_admin.ListUserLinksRequest, dict, ], ) -def test_list_account_summaries_rest(request_type): +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 = {} + 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.ListAccountSummariesResponse( + 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.ListAccountSummariesResponse.pb(return_value) + 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_account_summaries(request) + response = client.list_user_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAccountSummariesPager) + 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_account_summaries_rest_interceptors(null_interceptor): +def test_list_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -31956,14 +36880,14 @@ 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" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_user_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_account_summaries" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_user_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListAccountSummariesRequest.pb( - analytics_admin.ListAccountSummariesRequest() + pb_message = analytics_admin.ListUserLinksRequest.pb( + analytics_admin.ListUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -31975,21 +36899,19 @@ 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() - ) + req.return_value._content = analytics_admin.ListUserLinksResponse.to_json( + analytics_admin.ListUserLinksResponse() ) - request = analytics_admin.ListAccountSummariesRequest() + request = analytics_admin.ListUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListAccountSummariesResponse() + post.return_value = analytics_admin.ListUserLinksResponse() - client.list_account_summaries( + client.list_user_links( request, metadata=[ ("key", "val"), @@ -32001,8 +36923,8 @@ def test_list_account_summaries_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_account_summaries_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListAccountSummariesRequest +def test_list_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32010,7 +36932,7 @@ def test_list_account_summaries_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. @@ -32022,10 +36944,64 @@ 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.list_user_links(request) -def test_list_account_summaries_rest_pager(transport: str = "rest"): +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, @@ -32037,28 +37013,28 @@ def test_list_account_summaries_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.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), - resources.AccountSummary(), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), + resources.UserLink(), ], next_page_token="abc", ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[], + analytics_admin.ListUserLinksResponse( + user_links=[], next_page_token="def", ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), ], next_page_token="ghi", ), - analytics_admin.ListAccountSummariesResponse( - account_summaries=[ - resources.AccountSummary(), - resources.AccountSummary(), + analytics_admin.ListUserLinksResponse( + user_links=[ + resources.UserLink(), + resources.UserLink(), ], ), ) @@ -32067,7 +37043,7 @@ def test_list_account_summaries_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.ListAccountSummariesResponse.to_json(x) for x in response + 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): @@ -32075,15 +37051,15 @@ def test_list_account_summaries_rest_pager(transport: str = "rest"): return_val.status_code = 200 req.side_effect = return_values - sample_request = {} + sample_request = {"parent": "accounts/sample1"} - pager = client.list_account_summaries(request=sample_request) + pager = client.list_user_links(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.AccountSummary) for i in results) + assert all(isinstance(i, resources.UserLink) for i in results) - pages = list(client.list_account_summaries(request=sample_request).pages) + 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 @@ -32091,65 +37067,49 @@ def test_list_account_summaries_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetPropertyRequest, + analytics_admin.AuditUserLinksRequest, dict, ], ) -def test_get_property_rest(request_type): +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 = {"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 = 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 = resources.Property.pb(return_value) + 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.get_property(request) + response = client.audit_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 isinstance(response, pagers.AuditUserLinksPager) + assert response.next_page_token == "next_page_token_value" -def test_get_property_rest_required_fields( - request_type=analytics_admin.GetPropertyRequest, +def test_audit_user_links_rest_required_fields( + request_type=analytics_admin.AuditUserLinksRequest, ): 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( @@ -32164,21 +37124,21 @@ def test_get_property_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_property._get_unset_required_fields(jsonified_request) + ).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["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_property._get_unset_required_fields(jsonified_request) + ).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 "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(), @@ -32187,7 +37147,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 = 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 @@ -32199,38 +37159,39 @@ 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) + 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.get_property(request) + 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_get_property_rest_unset_required_fields(): +def test_audit_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.audit_user_links._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_property_rest_interceptors(null_interceptor): +def test_audit_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32243,14 +37204,14 @@ 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" + transports.AnalyticsAdminServiceRestInterceptor, "post_audit_user_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_property" + transports.AnalyticsAdminServiceRestInterceptor, "pre_audit_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.AuditUserLinksRequest.pb( + analytics_admin.AuditUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -32262,17 +37223,19 @@ 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()) + req.return_value._content = analytics_admin.AuditUserLinksResponse.to_json( + analytics_admin.AuditUserLinksResponse() + ) - request = analytics_admin.GetPropertyRequest() + request = analytics_admin.AuditUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Property() + post.return_value = analytics_admin.AuditUserLinksResponse() - client.get_property( + client.audit_user_links( request, metadata=[ ("key", "val"), @@ -32284,8 +37247,8 @@ def test_get_property_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_property_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetPropertyRequest +def test_audit_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.AuditUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32293,7 +37256,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. @@ -32305,115 +37268,127 @@ 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) + client.audit_user_links(request) -def test_get_property_rest_flattened(): +def test_audit_user_links_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 = 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", + 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.AuditUserLinksResponse( + user_links=[], + next_page_token="def", + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + ], + next_page_token="ghi", + ), + analytics_admin.AuditUserLinksResponse( + user_links=[ + resources.AuditUserLink(), + resources.AuditUserLink(), + ], + ), ) - 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) + # 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/*}" % client.transport._host, args[1] + # 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"} -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", - ) + 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) -def test_get_property_rest_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) + 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 @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListPropertiesRequest, + analytics_admin.CreateUserLinkRequest, dict, ], ) -def test_list_properties_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 = {} + 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 = analytics_admin.ListPropertiesResponse( - next_page_token="next_page_token_value", + 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 = analytics_admin.ListPropertiesResponse.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.list_properties(request) + response = client.create_user_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.UserLink) + assert response.name == "name_value" + assert response.email_address == "email_address_value" + assert response.direct_roles == ["direct_roles_value"] -def test_list_properties_rest_required_fields( - request_type=analytics_admin.ListPropertiesRequest, +def test_create_user_link_rest_required_fields( + request_type=analytics_admin.CreateUserLinkRequest, ): 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( @@ -32425,36 +37400,26 @@ 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_user_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) + ).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( - ( - "filter", - "page_size", - "page_token", - "show_deleted", - ) - ) + 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 "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(), @@ -32463,7 +37428,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.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 @@ -32475,54 +37440,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.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.list_properties(request) + response = client.create_user_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_user_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_user_link._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(("notifyNewUser",)) + & set( ( - "filter", - "pageSize", - "pageToken", - "showDeleted", + "parent", + "userLink", ) ) - & set(("filter",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_properties_rest_interceptors(null_interceptor): +def test_create_user_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32535,14 +37493,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_user_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_properties" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_user_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListPropertiesRequest.pb( - analytics_admin.ListPropertiesRequest() + pb_message = analytics_admin.CreateUserLinkRequest.pb( + analytics_admin.CreateUserLinkRequest() ) transcode.return_value = { "method": "post", @@ -32554,19 +37512,17 @@ 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.UserLink.to_json(resources.UserLink()) - request = analytics_admin.ListPropertiesRequest() + request = analytics_admin.CreateUserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListPropertiesResponse() + post.return_value = resources.UserLink() - client.list_properties( + client.create_user_link( request, metadata=[ ("key", "val"), @@ -32578,8 +37534,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_user_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateUserLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32587,7 +37543,12 @@ def test_list_properties_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + 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. @@ -32599,148 +37560,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_user_link(request) -def test_list_properties_rest_pager(transport: str = "rest"): +def test_create_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.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.UserLink() + + # 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", + user_link=resources.UserLink(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.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.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/{parent=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_properties(request=sample_request) +def test_create_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.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_user_link( + analytics_admin.CreateUserLinkRequest(), + parent="parent_value", + user_link=resources.UserLink(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_user_link_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreatePropertyRequest, + analytics_admin.BatchCreateUserLinksRequest, dict, ], ) -def test_create_property_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["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 = {"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 = analytics_admin.BatchCreateUserLinksResponse() # 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.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.create_property(request) + response = client.batch_create_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 isinstance(response, analytics_admin.BatchCreateUserLinksResponse) -def test_create_property_rest_required_fields( - request_type=analytics_admin.CreatePropertyRequest, +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( @@ -32755,17 +37682,21 @@ def test_create_property_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_property._get_unset_required_fields(jsonified_request) + ).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() - ).create_property._get_unset_required_fields(jsonified_request) + ).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(), @@ -32774,7 +37705,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 = 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 @@ -32795,30 +37726,40 @@ def test_create_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.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.create_property(request) + 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_create_property_rest_unset_required_fields(): +def test_batch_create_user_links_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.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_create_property_rest_interceptors(null_interceptor): +def test_batch_create_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -32831,14 +37772,14 @@ 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" + transports.AnalyticsAdminServiceRestInterceptor, "post_batch_create_user_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_property" + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_create_user_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreatePropertyRequest.pb( - analytics_admin.CreatePropertyRequest() + pb_message = analytics_admin.BatchCreateUserLinksRequest.pb( + analytics_admin.BatchCreateUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -32850,17 +37791,21 @@ 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()) + req.return_value._content = ( + analytics_admin.BatchCreateUserLinksResponse.to_json( + analytics_admin.BatchCreateUserLinksResponse() + ) + ) - request = analytics_admin.CreatePropertyRequest() + request = analytics_admin.BatchCreateUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Property() + post.return_value = analytics_admin.BatchCreateUserLinksResponse() - client.create_property( + client.batch_create_user_links( request, metadata=[ ("key", "val"), @@ -32872,8 +37817,8 @@ def test_create_property_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_property_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreatePropertyRequest +def test_batch_create_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchCreateUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -32881,22 +37826,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 = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -32908,64 +37838,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) - - -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"), - ) + client.batch_create_user_links(request) -def test_create_property_rest_error(): +def test_batch_create_user_links_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -32974,65 +37850,57 @@ def test_create_property_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeletePropertyRequest, + analytics_admin.UpdateUserLinkRequest, dict, ], ) -def test_delete_property_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": "properties/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 = resources.Property( + return_value = resources.UserLink( 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", + 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.Property.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.delete_property(request) + response = client.update_user_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.Property) + assert isinstance(response, resources.UserLink) 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.email_address == "email_address_value" + assert response.direct_roles == ["direct_roles_value"] -def test_delete_property_rest_required_fields( - request_type=analytics_admin.DeletePropertyRequest, +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( @@ -33047,21 +37915,17 @@ def test_delete_property_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_property._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_property._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(), @@ -33070,7 +37934,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 = 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 @@ -33082,38 +37946,39 @@ def test_delete_property_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 - pb_return_value = resources.Property.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.delete_property(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_property_rest_unset_required_fields(): +def test_update_user_link_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.update_user_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("userLink",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_property_rest_interceptors(null_interceptor): +def test_update_user_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -33126,14 +37991,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_update_user_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_property" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_user_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.DeletePropertyRequest.pb( - analytics_admin.DeletePropertyRequest() + pb_message = analytics_admin.UpdateUserLinkRequest.pb( + analytics_admin.UpdateUserLinkRequest() ) transcode.return_value = { "method": "post", @@ -33145,17 +38010,17 @@ 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 = resources.UserLink.to_json(resources.UserLink()) - request = analytics_admin.DeletePropertyRequest() + request = analytics_admin.UpdateUserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Property() + post.return_value = resources.UserLink() - client.delete_property( + client.update_user_link( request, metadata=[ ("key", "val"), @@ -33167,8 +38032,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_update_user_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateUserLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -33176,7 +38041,12 @@ def test_delete_property_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/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. @@ -33188,10 +38058,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.update_user_link(request) -def test_delete_property_rest_flattened(): +def test_update_user_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33200,37 +38070,39 @@ 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 = resources.UserLink() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/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 - pb_return_value = resources.Property.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.delete_property(**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=properties/*}" % client.transport._host, args[1] + "%s/v1alpha/{user_link.name=accounts/*/userLinks/*}" + % client.transport._host, + args[1], ) -def test_delete_property_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, @@ -33239,13 +38111,13 @@ 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.update_user_link( + analytics_admin.UpdateUserLinkRequest(), + user_link=resources.UserLink(name="name_value"), ) -def test_delete_property_rest_error(): +def test_update_user_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -33254,79 +38126,46 @@ def test_delete_property_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdatePropertyRequest, + analytics_admin.BatchUpdateUserLinksRequest, dict, ], ) -def test_update_property_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 = {"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 = {"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 = analytics_admin.BatchUpdateUserLinksResponse() # 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.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_property(request) + response = client.batch_update_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 isinstance(response, analytics_admin.BatchUpdateUserLinksResponse) -def test_update_property_rest_required_fields( - request_type=analytics_admin.UpdatePropertyRequest, +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( @@ -33341,19 +38180,21 @@ def test_update_property_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_property._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_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",)) + ).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(), @@ -33362,7 +38203,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 = 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 @@ -33374,7 +38215,7 @@ def test_update_property_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 @@ -33383,38 +38224,40 @@ def test_update_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.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_property(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_property_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_property._get_unset_required_fields({}) + unset_fields = transport.batch_update_user_links._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("updateMask",)) + set(()) & set( ( - "property", - "updateMask", + "parent", + "requests", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_property_rest_interceptors(null_interceptor): +def test_batch_update_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -33427,14 +38270,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_batch_update_user_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_property" + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_update_user_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdatePropertyRequest.pb( - analytics_admin.UpdatePropertyRequest() + pb_message = analytics_admin.BatchUpdateUserLinksRequest.pb( + analytics_admin.BatchUpdateUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -33446,17 +38289,21 @@ 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 = ( + analytics_admin.BatchUpdateUserLinksResponse.to_json( + analytics_admin.BatchUpdateUserLinksResponse() + ) + ) - request = analytics_admin.UpdatePropertyRequest() + request = analytics_admin.BatchUpdateUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.Property() + post.return_value = analytics_admin.BatchUpdateUserLinksResponse() - client.update_property( + client.batch_update_user_links( request, metadata=[ ("key", "val"), @@ -33468,8 +38315,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_batch_update_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchUpdateUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -33477,22 +38324,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 = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -33504,66 +38336,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) - - -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"]), - ) + client.batch_update_user_links(request) -def test_update_property_rest_error(): +def test_batch_update_user_links_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -33572,11 +38348,11 @@ def test_update_property_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetUserLinkRequest, + analytics_admin.DeleteUserLinkRequest, dict, ], ) -def test_get_user_link_rest(request_type): +def test_delete_user_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33589,31 +38365,23 @@ def test_get_user_link_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 = resources.UserLink( - name="name_value", - email_address="email_address_value", - direct_roles=["direct_roles_value"], - ) + return_value = None # 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) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_user_link(request) + response = client.delete_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"] + assert response is None -def test_get_user_link_rest_required_fields( - request_type=analytics_admin.GetUserLinkRequest, +def test_delete_user_link_rest_required_fields( + request_type=analytics_admin.DeleteUserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -33633,7 +38401,7 @@ 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) + ).delete_user_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -33642,7 +38410,7 @@ 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) + ).delete_user_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -33656,7 +38424,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 = 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 @@ -33668,38 +38436,36 @@ def test_get_user_link_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.UserLink.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_user_link(request) + response = client.delete_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(): +def test_delete_user_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_user_link._get_unset_required_fields({}) + 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_get_user_link_rest_interceptors(null_interceptor): +def test_delete_user_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -33712,14 +38478,11 @@ 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" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_user_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_user_link" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.GetUserLinkRequest.pb( - analytics_admin.GetUserLinkRequest() + pb_message = analytics_admin.DeleteUserLinkRequest.pb( + analytics_admin.DeleteUserLinkRequest() ) transcode.return_value = { "method": "post", @@ -33731,17 +38494,15 @@ 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()) - request = analytics_admin.GetUserLinkRequest() + request = analytics_admin.DeleteUserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.UserLink() - client.get_user_link( + client.delete_user_link( request, metadata=[ ("key", "val"), @@ -33750,11 +38511,10 @@ def test_get_user_link_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_get_user_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetUserLinkRequest +def test_delete_user_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteUserLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -33774,10 +38534,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.delete_user_link(request) -def test_get_user_link_rest_flattened(): +def test_delete_user_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33786,7 +38546,7 @@ 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 = None # get arguments that satisfy an http rule for this method sample_request = {"name": "accounts/sample1/userLinks/sample2"} @@ -33800,12 +38560,11 @@ def test_get_user_link_rest_flattened(): # 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) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_user_link(**mock_args) + client.delete_user_link(**mock_args) # Establish that the underlying call was made with the expected # request object values. @@ -33816,7 +38575,7 @@ def test_get_user_link_rest_flattened(): ) -def test_get_user_link_rest_flattened_error(transport: str = "rest"): +def test_delete_user_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -33825,13 +38584,13 @@ 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(), + client.delete_user_link( + analytics_admin.DeleteUserLinkRequest(), name="name_value", ) -def test_get_user_link_rest_error(): +def test_delete_user_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -33840,11 +38599,11 @@ def test_get_user_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchGetUserLinksRequest, + analytics_admin.BatchDeleteUserLinksRequest, dict, ], ) -def test_batch_get_user_links_rest(request_type): +def test_batch_delete_user_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -33857,30 +38616,28 @@ def test_batch_get_user_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.BatchGetUserLinksResponse() + return_value = None # 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) + json_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.batch_delete_user_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchGetUserLinksResponse) + assert response is None -def test_batch_get_user_links_rest_required_fields( - request_type=analytics_admin.BatchGetUserLinksRequest, +def test_batch_delete_user_links_rest_required_fields( + request_type=analytics_admin.BatchDeleteUserLinksRequest, ): 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( @@ -33892,32 +38649,24 @@ 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) + ).batch_delete_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",)) + ).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 "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(), @@ -33926,7 +38675,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 = 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 @@ -33938,52 +38687,45 @@ def test_batch_get_user_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.BatchGetUserLinksResponse.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.batch_get_user_links(request) + response = client.batch_delete_user_links(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_batch_delete_user_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_get_user_links._get_unset_required_fields({}) + unset_fields = transport.batch_delete_user_links._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("names",)) + set(()) & set( ( "parent", - "names", + "requests", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_get_user_links_rest_interceptors(null_interceptor): +def test_batch_delete_user_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -33996,14 +38738,11 @@ 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" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_get_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_delete_user_links" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.BatchGetUserLinksRequest.pb( - analytics_admin.BatchGetUserLinksRequest() + pb_message = analytics_admin.BatchDeleteUserLinksRequest.pb( + analytics_admin.BatchDeleteUserLinksRequest() ) transcode.return_value = { "method": "post", @@ -34015,19 +38754,15 @@ 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() - ) - request = analytics_admin.BatchGetUserLinksRequest() + request = analytics_admin.BatchDeleteUserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchGetUserLinksResponse() - client.batch_get_user_links( + client.batch_delete_user_links( request, metadata=[ ("key", "val"), @@ -34036,11 +38771,10 @@ def test_batch_get_user_links_rest_interceptors(null_interceptor): ) 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 +def test_batch_delete_user_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchDeleteUserLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34060,10 +38794,10 @@ 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.batch_delete_user_links(request) -def test_batch_get_user_links_rest_error(): +def test_batch_delete_user_links_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -34072,44 +38806,51 @@ def test_batch_get_user_links_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListUserLinksRequest, + analytics_admin.CreateFirebaseLinkRequest, dict, ], ) -def test_list_user_links_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 = {"parent": "accounts/sample1"} + 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.ListUserLinksResponse( - 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.ListUserLinksResponse.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_user_links(request) + response = client.create_firebase_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 isinstance(response, resources.FirebaseLink) + assert response.name == "name_value" + assert response.project == "project_value" -def test_list_user_links_rest_required_fields( - request_type=analytics_admin.ListUserLinksRequest, +def test_create_firebase_link_rest_required_fields( + request_type=analytics_admin.CreateFirebaseLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -34129,7 +38870,7 @@ 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) + ).create_firebase_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -34138,14 +38879,7 @@ 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) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) + ).create_firebase_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -34159,7 +38893,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 = 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 @@ -34171,46 +38905,47 @@ def test_list_user_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.ListUserLinksResponse.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_user_links(request) + response = client.create_firebase_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_create_firebase_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_user_links._get_unset_required_fields({}) + unset_fields = transport.create_firebase_link._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(()) + & set( ( - "pageSize", - "pageToken", + "parent", + "firebaseLink", ) ) - & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_user_links_rest_interceptors(null_interceptor): +def test_create_firebase_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -34223,14 +38958,14 @@ 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" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_firebase_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_firebase_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListUserLinksRequest.pb( - analytics_admin.ListUserLinksRequest() + pb_message = analytics_admin.CreateFirebaseLinkRequest.pb( + analytics_admin.CreateFirebaseLinkRequest() ) transcode.return_value = { "method": "post", @@ -34242,19 +38977,19 @@ 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() + req.return_value._content = resources.FirebaseLink.to_json( + resources.FirebaseLink() ) - request = analytics_admin.ListUserLinksRequest() + request = analytics_admin.CreateFirebaseLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListUserLinksResponse() + post.return_value = resources.FirebaseLink() - client.list_user_links( + client.create_firebase_link( request, metadata=[ ("key", "val"), @@ -34266,8 +39001,8 @@ def test_list_user_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListUserLinksRequest +def test_create_firebase_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateFirebaseLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34275,7 +39010,12 @@ def test_list_user_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + 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. @@ -34287,10 +39027,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.create_firebase_link(request) -def test_list_user_links_rest_flattened(): +def test_create_firebase_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34299,37 +39039,39 @@ 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 = resources.FirebaseLink() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "accounts/sample1"} + 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 = analytics_admin.ListUserLinksResponse.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 - client.list_user_links(**mock_args) + 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=accounts/*}/userLinks" % client.transport._host, args[1] + "%s/v1alpha/{parent=properties/*}/firebaseLinks" % client.transport._host, + args[1], ) -def test_list_user_links_rest_flattened_error(transport: str = "rest"): +def test_create_firebase_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -34338,121 +39080,61 @@ def test_list_user_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_user_links( - analytics_admin.ListUserLinksRequest(), + client.create_firebase_link( + analytics_admin.CreateFirebaseLinkRequest(), parent="parent_value", + firebase_link=resources.FirebaseLink(name="name_value"), ) -def test_list_user_links_rest_pager(transport: str = "rest"): +def test_create_firebase_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.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, + analytics_admin.DeleteFirebaseLinkRequest, dict, ], ) -def test_audit_user_links_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 = {"parent": "accounts/sample1"} + 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 = analytics_admin.AuditUserLinksResponse( - 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.AuditUserLinksResponse.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.audit_user_links(request) + response = client.delete_firebase_link(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" + assert response is None -def test_audit_user_links_rest_required_fields( - request_type=analytics_admin.AuditUserLinksRequest, +def test_delete_firebase_link_rest_required_fields( + request_type=analytics_admin.DeleteFirebaseLinkRequest, ): 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( @@ -34467,21 +39149,21 @@ 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) + ).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["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).audit_user_links._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 "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(), @@ -34490,7 +39172,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 = 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 @@ -34502,39 +39184,36 @@ def test_audit_user_links_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 = analytics_admin.AuditUserLinksResponse.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.audit_user_links(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_audit_user_links_rest_unset_required_fields(): +def test_delete_firebase_link_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.delete_firebase_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_audit_user_links_rest_interceptors(null_interceptor): +def test_delete_firebase_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -34547,14 +39226,11 @@ 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" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_audit_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_firebase_link" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.AuditUserLinksRequest.pb( - analytics_admin.AuditUserLinksRequest() + pb_message = analytics_admin.DeleteFirebaseLinkRequest.pb( + analytics_admin.DeleteFirebaseLinkRequest() ) transcode.return_value = { "method": "post", @@ -34566,19 +39242,15 @@ 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() - ) - request = analytics_admin.AuditUserLinksRequest() + request = analytics_admin.DeleteFirebaseLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.AuditUserLinksResponse() - client.audit_user_links( + client.delete_firebase_link( request, metadata=[ ("key", "val"), @@ -34587,11 +39259,10 @@ def test_audit_user_links_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_audit_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.AuditUserLinksRequest +def test_delete_firebase_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteFirebaseLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34599,7 +39270,7 @@ def test_audit_user_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + 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. @@ -34611,122 +39282,110 @@ 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.delete_firebase_link(request) -def test_audit_user_links_rest_pager(transport: str = "rest"): +def test_delete_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.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - next_page_token="abc", - ), - analytics_admin.AuditUserLinksResponse( - user_links=[], - next_page_token="def", - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - ], - next_page_token="ghi", - ), - analytics_admin.AuditUserLinksResponse( - user_links=[ - resources.AuditUserLink(), - resources.AuditUserLink(), - ], - ), + 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", ) - # Two responses for two calls - response = response + response + mock_args.update(sample_request) - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.AuditUserLinksResponse.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_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/{name=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 = {"parent": "accounts/sample1"} - pager = client.audit_user_links(request=sample_request) +def test_delete_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.AuditUserLink) 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_firebase_link( + analytics_admin.DeleteFirebaseLinkRequest(), + name="name_value", + ) - 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 + +def test_delete_firebase_link_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateUserLinkRequest, + analytics_admin.ListFirebaseLinksRequest, dict, ], ) -def test_create_user_link_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 = {"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 = {"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.UserLink( - name="name_value", - email_address="email_address_value", - direct_roles=["direct_roles_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.UserLink.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.create_user_link(request) + response = client.list_firebase_links(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.ListFirebaseLinksPager) + assert response.next_page_token == "next_page_token_value" -def test_create_user_link_rest_required_fields( - request_type=analytics_admin.CreateUserLinkRequest, +def test_list_firebase_links_rest_required_fields( + request_type=analytics_admin.ListFirebaseLinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -34746,7 +39405,7 @@ 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) + ).list_firebase_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -34755,9 +39414,14 @@ 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) + ).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(("notify_new_user",)) + 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 @@ -34771,7 +39435,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 = 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 @@ -34783,47 +39447,46 @@ 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 = 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.create_user_link(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_create_user_link_rest_unset_required_fields(): +def test_list_firebase_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_user_link._get_unset_required_fields({}) + unset_fields = transport.list_firebase_links._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("notifyNewUser",)) - & set( + set( ( - "parent", - "userLink", + "pageSize", + "pageToken", ) ) + & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_user_link_rest_interceptors(null_interceptor): +def test_list_firebase_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -34836,14 +39499,14 @@ 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_list_firebase_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_user_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_firebase_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateUserLinkRequest.pb( - analytics_admin.CreateUserLinkRequest() + pb_message = analytics_admin.ListFirebaseLinksRequest.pb( + analytics_admin.ListFirebaseLinksRequest() ) transcode.return_value = { "method": "post", @@ -34855,17 +39518,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 = analytics_admin.ListFirebaseLinksResponse.to_json( + analytics_admin.ListFirebaseLinksResponse() + ) - request = analytics_admin.CreateUserLinkRequest() + request = analytics_admin.ListFirebaseLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.UserLink() + post.return_value = analytics_admin.ListFirebaseLinksResponse() - client.create_user_link( + client.list_firebase_links( request, metadata=[ ("key", "val"), @@ -34877,8 +39542,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_list_firebase_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListFirebaseLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -34886,12 +39551,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 = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -34903,10 +39563,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.list_firebase_links(request) -def test_create_user_link_rest_flattened(): +def test_list_firebase_links_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -34915,38 +39575,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 = analytics_admin.ListFirebaseLinksResponse() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "accounts/sample1"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( 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.UserLink.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.create_user_link(**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/{parent=accounts/*}/userLinks" % client.transport._host, args[1] + "%s/v1alpha/{parent=properties/*}/firebaseLinks" % client.transport._host, + args[1], ) -def test_create_user_link_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, @@ -34955,62 +39615,123 @@ 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(), + client.list_firebase_links( + analytics_admin.ListFirebaseLinksRequest(), parent="parent_value", - user_link=resources.UserLink(name="name_value"), ) -def test_create_user_link_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.BatchCreateUserLinksRequest, + analytics_admin.GetGlobalSiteTagRequest, dict, ], ) -def test_batch_create_user_links_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 = {"parent": "accounts/sample1"} + 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 = analytics_admin.BatchCreateUserLinksResponse() + return_value = resources.GlobalSiteTag( + name="name_value", + snippet="snippet_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.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.batch_create_user_links(request) + response = client.get_global_site_tag(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchCreateUserLinksResponse) + assert isinstance(response, resources.GlobalSiteTag) + assert response.name == "name_value" + assert response.snippet == "snippet_value" -def test_batch_create_user_links_rest_required_fields( - request_type=analytics_admin.BatchCreateUserLinksRequest, +def test_get_global_site_tag_rest_required_fields( + request_type=analytics_admin.GetGlobalSiteTagRequest, ): 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( @@ -35025,21 +39746,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_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["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_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 "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(), @@ -35048,7 +39769,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.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 @@ -35060,49 +39781,38 @@ 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.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.batch_create_user_links(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_batch_create_user_links_rest_unset_required_fields(): +def test_get_global_site_tag_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_global_site_tag._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_global_site_tag_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -35115,14 +39825,14 @@ 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_global_site_tag" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_create_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_global_site_tag" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.BatchCreateUserLinksRequest.pb( - analytics_admin.BatchCreateUserLinksRequest() + pb_message = analytics_admin.GetGlobalSiteTagRequest.pb( + analytics_admin.GetGlobalSiteTagRequest() ) transcode.return_value = { "method": "post", @@ -35134,21 +39844,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.GlobalSiteTag.to_json( + resources.GlobalSiteTag() ) - request = analytics_admin.BatchCreateUserLinksRequest() + request = analytics_admin.GetGlobalSiteTagRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchCreateUserLinksResponse() + post.return_value = resources.GlobalSiteTag() - client.batch_create_user_links( + client.get_global_site_tag( request, metadata=[ ("key", "val"), @@ -35160,8 +39868,8 @@ 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_global_site_tag_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetGlobalSiteTagRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35169,7 +39877,7 @@ 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/globalSiteTag"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -35181,10 +39889,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_global_site_tag(request) -def test_batch_create_user_links_rest_error(): +def test_get_global_site_tag_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.GlobalSiteTag() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "properties/sample1/dataStreams/sample2/globalSiteTag" + } + + # 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.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.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/{name=properties/*/dataStreams/*/globalSiteTag}" + % client.transport._host, + args[1], + ) + + +def test_get_global_site_tag_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_global_site_tag( + analytics_admin.GetGlobalSiteTagRequest(), + name="name_value", + ) + + +def test_get_global_site_tag_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -35193,57 +39959,64 @@ def test_batch_create_user_links_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateUserLinkRequest, + analytics_admin.CreateGoogleAdsLinkRequest, dict, ], ) -def test_update_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 = {"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"} + 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.update_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_update_user_link_rest_required_fields( - request_type=analytics_admin.UpdateUserLinkRequest, +def test_create_google_ads_link_rest_required_fields( + request_type=analytics_admin.CreateGoogleAdsLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -35258,17 +40031,21 @@ 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) + ).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["parent"] = "parent_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_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 "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35277,7 +40054,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 = 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 @@ -35289,7 +40066,7 @@ def test_update_user_link_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 @@ -35298,30 +40075,38 @@ def test_update_user_link_rest_required_fields( 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.update_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_update_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.update_user_link._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("userLink",))) + 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_update_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 @@ -35334,14 +40119,14 @@ 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_create_google_ads_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_user_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_google_ads_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateUserLinkRequest.pb( - analytics_admin.UpdateUserLinkRequest() + pb_message = analytics_admin.CreateGoogleAdsLinkRequest.pb( + analytics_admin.CreateGoogleAdsLinkRequest() ) transcode.return_value = { "method": "post", @@ -35353,17 +40138,19 @@ 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 = resources.GoogleAdsLink.to_json( + resources.GoogleAdsLink() + ) - request = analytics_admin.UpdateUserLinkRequest() + 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.update_user_link( + client.create_google_ads_link( request, metadata=[ ("key", "val"), @@ -35375,8 +40162,8 @@ 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_create_google_ads_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35384,11 +40171,15 @@ 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"} + 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) @@ -35401,10 +40192,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.create_google_ads_link(request) -def test_update_user_link_rest_flattened(): +def test_create_google_ads_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -35413,39 +40204,39 @@ 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 = resources.GoogleAdsLink() # get arguments that satisfy an http rule for this method - sample_request = {"user_link": {"name": "accounts/sample1/userLinks/sample2"}} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - user_link=resources.UserLink(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.update_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/{user_link.name=accounts/*/userLinks/*}" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/googleAdsLinks" % client.transport._host, args[1], ) -def test_update_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, @@ -35454,13 +40245,14 @@ 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.create_google_ads_link( + analytics_admin.CreateGoogleAdsLinkRequest(), + parent="parent_value", + google_ads_link=resources.GoogleAdsLink(name="name_value"), ) -def test_update_user_link_rest_error(): +def test_create_google_ads_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -35469,46 +40261,65 @@ def test_update_user_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchUpdateUserLinksRequest, + analytics_admin.UpdateGoogleAdsLinkRequest, dict, ], ) -def test_batch_update_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.BatchUpdateUserLinksResponse() + 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.BatchUpdateUserLinksResponse.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_update_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.BatchUpdateUserLinksResponse) + 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_update_user_links_rest_required_fields( - request_type=analytics_admin.BatchUpdateUserLinksRequest, +def test_update_google_ads_link_rest_required_fields( + request_type=analytics_admin.UpdateGoogleAdsLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -35523,21 +40334,19 @@ 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) + ).update_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" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_update_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(("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(), @@ -35546,7 +40355,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.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 @@ -35558,7 +40367,7 @@ def test_batch_update_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 @@ -35567,40 +40376,30 @@ 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.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_update_user_links(request) + response = client.update_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_batch_update_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_update_user_links._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "requests", - ) - ) - ) + 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_update_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 @@ -35613,14 +40412,14 @@ 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_update_google_ads_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_update_user_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_google_ads_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.BatchUpdateUserLinksRequest.pb( - analytics_admin.BatchUpdateUserLinksRequest() + pb_message = analytics_admin.UpdateGoogleAdsLinkRequest.pb( + analytics_admin.UpdateGoogleAdsLinkRequest() ) transcode.return_value = { "method": "post", @@ -35632,21 +40431,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.GoogleAdsLink.to_json( + resources.GoogleAdsLink() ) - request = analytics_admin.BatchUpdateUserLinksRequest() + request = analytics_admin.UpdateGoogleAdsLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchUpdateUserLinksResponse() + post.return_value = resources.GoogleAdsLink() - client.batch_update_user_links( + client.update_google_ads_link( request, metadata=[ ("key", "val"), @@ -35658,8 +40455,8 @@ 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_update_google_ads_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35667,7 +40464,18 @@ def test_batch_update_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. @@ -35679,10 +40487,70 @@ 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.update_google_ads_link(request) -def test_batch_update_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" ) @@ -35691,18 +40559,18 @@ def test_batch_update_user_links_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteUserLinkRequest, + analytics_admin.DeleteGoogleAdsLinkRequest, dict, ], ) -def test_delete_user_link_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 = {"name": "accounts/sample1/userLinks/sample2"} + request_init = {"name": "properties/sample1/googleAdsLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -35717,14 +40585,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_google_ads_link(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_google_ads_link_rest_required_fields( + request_type=analytics_admin.DeleteGoogleAdsLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -35744,7 +40612,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_google_ads_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -35753,7 +40621,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_google_ads_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -35791,24 +40659,24 @@ 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_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_delete_user_link_rest_unset_required_fields(): +def test_delete_google_ads_link_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_google_ads_link._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_google_ads_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -35821,11 +40689,11 @@ 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_google_ads_link" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteUserLinkRequest.pb( - analytics_admin.DeleteUserLinkRequest() + pb_message = analytics_admin.DeleteGoogleAdsLinkRequest.pb( + analytics_admin.DeleteGoogleAdsLinkRequest() ) transcode.return_value = { "method": "post", @@ -35838,14 +40706,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.DeleteGoogleAdsLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - client.delete_user_link( + client.delete_google_ads_link( request, metadata=[ ("key", "val"), @@ -35856,8 +40724,8 @@ 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_google_ads_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteGoogleAdsLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -35865,7 +40733,7 @@ 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/googleAdsLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -35877,10 +40745,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_google_ads_link(request) -def test_delete_user_link_rest_flattened(): +def test_delete_google_ads_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -35892,7 +40760,7 @@ 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/googleAdsLinks/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -35907,18 +40775,19 @@ 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_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/{name=properties/*/googleAdsLinks/*}" % client.transport._host, + args[1], ) -def test_delete_user_link_rest_flattened_error(transport: str = "rest"): +def test_delete_google_ads_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -35927,13 +40796,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_google_ads_link( + analytics_admin.DeleteGoogleAdsLinkRequest(), name="name_value", ) -def test_delete_user_link_rest_error(): +def test_delete_google_ads_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -35942,40 +40811,44 @@ def test_delete_user_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchDeleteUserLinksRequest, + analytics_admin.ListGoogleAdsLinksRequest, dict, ], ) -def test_batch_delete_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 = None + 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 - json_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.batch_delete_user_links(request) + response = client.list_google_ads_links(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, pagers.ListGoogleAdsLinksPager) + assert response.next_page_token == "next_page_token_value" -def test_batch_delete_user_links_rest_required_fields( - request_type=analytics_admin.BatchDeleteUserLinksRequest, +def test_list_google_ads_links_rest_required_fields( + request_type=analytics_admin.ListGoogleAdsLinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -35995,7 +40868,7 @@ 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) + ).list_google_ads_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -36004,7 +40877,14 @@ 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) + ).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 @@ -36018,7 +40898,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 = 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 @@ -36030,45 +40910,48 @@ def test_batch_delete_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 - json_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.batch_delete_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_batch_delete_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.batch_delete_user_links._get_unset_required_fields({}) + unset_fields = transport.list_google_ads_links._get_unset_required_fields({}) assert set(unset_fields) == ( - set(()) - & set( + set( ( - "parent", - "requests", + "pageSize", + "pageToken", ) ) + & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_delete_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 @@ -36081,11 +40964,14 @@ 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_list_google_ads_links" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_google_ads_links" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.BatchDeleteUserLinksRequest.pb( - analytics_admin.BatchDeleteUserLinksRequest() + post.assert_not_called() + pb_message = analytics_admin.ListGoogleAdsLinksRequest.pb( + analytics_admin.ListGoogleAdsLinksRequest() ) transcode.return_value = { "method": "post", @@ -36097,15 +40983,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 = analytics_admin.ListGoogleAdsLinksResponse.to_json( + analytics_admin.ListGoogleAdsLinksResponse() + ) - request = analytics_admin.BatchDeleteUserLinksRequest() + request = analytics_admin.ListGoogleAdsLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = analytics_admin.ListGoogleAdsLinksResponse() - client.batch_delete_user_links( + client.list_google_ads_links( request, metadata=[ ("key", "val"), @@ -36113,92 +41003,208 @@ def test_batch_delete_user_links_rest_interceptors(null_interceptor): ], ) - pre.assert_called_once() - - -def test_batch_delete_user_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.BatchDeleteUserLinksRequest -): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) + pre.assert_called_once() + post.assert_called_once() + + +def test_list_google_ads_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListGoogleAdsLinksRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "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.list_google_ads_links(request) + + +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, + ) + + # 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.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + next_page_token="abc", + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[], + next_page_token="def", + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + ], + next_page_token="ghi", + ), + analytics_admin.ListGoogleAdsLinksResponse( + google_ads_links=[ + resources.GoogleAdsLink(), + resources.GoogleAdsLink(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + 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): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values - # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} - request = request_type(**request_init) + sample_request = {"parent": "properties/sample1"} - # 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_delete_user_links(request) + pager = client.list_google_ads_links(request=sample_request) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.GoogleAdsLink) for i in results) -def test_batch_delete_user_links_rest_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) + 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 @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateFirebaseLinkRequest, + analytics_admin.GetDataSharingSettingsRequest, dict, ], ) -def test_create_firebase_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": "properties/sample1"} - request_init["firebase_link"] = { - "name": "name_value", - "project": "project_value", - "create_time": {"seconds": 751, "nanos": 543}, - } + 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.FirebaseLink( + return_value = resources.DataSharingSettings( name="name_value", - project="project_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.FirebaseLink.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_firebase_link(request) + response = client.get_data_sharing_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.FirebaseLink) + assert isinstance(response, resources.DataSharingSettings) assert response.name == "name_value" - assert response.project == "project_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_firebase_link_rest_required_fields( - request_type=analytics_admin.CreateFirebaseLinkRequest, +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( @@ -36213,21 +41219,21 @@ 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) + ).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_firebase_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 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(), @@ -36236,7 +41242,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 = 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 @@ -36248,47 +41254,38 @@ def test_create_firebase_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.FirebaseLink.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_firebase_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_firebase_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_firebase_link._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "firebaseLink", - ) - ) - ) + 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_firebase_link_rest_interceptors(null_interceptor): +def test_get_data_sharing_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -36301,14 +41298,15 @@ 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_get_data_sharing_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_firebase_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_data_sharing_settings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateFirebaseLinkRequest.pb( - analytics_admin.CreateFirebaseLinkRequest() + pb_message = analytics_admin.GetDataSharingSettingsRequest.pb( + analytics_admin.GetDataSharingSettingsRequest() ) transcode.return_value = { "method": "post", @@ -36320,19 +41318,19 @@ 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 = resources.DataSharingSettings.to_json( + resources.DataSharingSettings() ) - request = analytics_admin.CreateFirebaseLinkRequest() + request = analytics_admin.GetDataSharingSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.FirebaseLink() + post.return_value = resources.DataSharingSettings() - client.create_firebase_link( + client.get_data_sharing_settings( request, metadata=[ ("key", "val"), @@ -36344,8 +41342,8 @@ 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_get_data_sharing_settings_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetDataSharingSettingsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -36353,12 +41351,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 = {"name": "accounts/sample1/dataSharingSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -36370,10 +41363,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) + client.get_data_sharing_settings(request) -def test_create_firebase_link_rest_flattened(): +def test_get_data_sharing_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -36382,39 +41375,38 @@ def test_create_firebase_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.FirebaseLink() + return_value = resources.DataSharingSettings() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "accounts/sample1/dataSharingSettings"} # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - firebase_link=resources.FirebaseLink(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.FirebaseLink.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_firebase_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=properties/*}/firebaseLinks" % client.transport._host, + "%s/v1alpha/{name=accounts/*/dataSharingSettings}" % client.transport._host, args[1], ) -def test_create_firebase_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, @@ -36423,14 +41415,13 @@ def test_create_firebase_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_firebase_link( - analytics_admin.CreateFirebaseLinkRequest(), - parent="parent_value", - firebase_link=resources.FirebaseLink(name="name_value"), + client.get_data_sharing_settings( + analytics_admin.GetDataSharingSettingsRequest(), + name="name_value", ) -def test_create_firebase_link_rest_error(): +def test_get_data_sharing_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -36439,40 +41430,50 @@ def test_create_firebase_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteFirebaseLinkRequest, + analytics_admin.GetMeasurementProtocolSecretRequest, dict, ], ) -def test_delete_firebase_link_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 = {"name": "properties/sample1/firebaseLinks/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. 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.delete_firebase_link(request) + response = client.get_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_delete_firebase_link_rest_required_fields( - request_type=analytics_admin.DeleteFirebaseLinkRequest, +def test_get_measurement_protocol_secret_rest_required_fields( + request_type=analytics_admin.GetMeasurementProtocolSecretRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -36492,7 +41493,7 @@ 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) + ).get_measurement_protocol_secret._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -36501,7 +41502,7 @@ 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) + ).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 @@ -36515,7 +41516,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 = 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 @@ -36527,36 +41528,40 @@ def test_delete_firebase_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 = 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.delete_firebase_link(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_delete_firebase_link_rest_unset_required_fields(): +def test_get_measurement_protocol_secret_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_firebase_link._get_unset_required_fields({}) + 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_delete_firebase_link_rest_interceptors(null_interceptor): +def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -36569,11 +41574,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_get_measurement_protocol_secret", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_get_measurement_protocol_secret", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteFirebaseLinkRequest.pb( - analytics_admin.DeleteFirebaseLinkRequest() + post.assert_not_called() + pb_message = analytics_admin.GetMeasurementProtocolSecretRequest.pb( + analytics_admin.GetMeasurementProtocolSecretRequest() ) transcode.return_value = { "method": "post", @@ -36585,15 +41595,19 @@ 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 = resources.MeasurementProtocolSecret.to_json( + resources.MeasurementProtocolSecret() + ) - request = analytics_admin.DeleteFirebaseLinkRequest() + request = analytics_admin.GetMeasurementProtocolSecretRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.MeasurementProtocolSecret() - client.delete_firebase_link( + client.get_measurement_protocol_secret( request, metadata=[ ("key", "val"), @@ -36602,10 +41616,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_get_measurement_protocol_secret_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.GetMeasurementProtocolSecretRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -36613,7 +41629,9 @@ def test_delete_firebase_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/firebaseLinks/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. @@ -36625,10 +41643,10 @@ 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.get_measurement_protocol_secret(request) -def test_delete_firebase_link_rest_flattened(): +def test_get_measurement_protocol_secret_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -36637,10 +41655,12 @@ def test_delete_firebase_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.MeasurementProtocolSecret() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/firebaseLinks/sample2"} + sample_request = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } # get truthy value for each flattened field mock_args = dict( @@ -36651,23 +41671,25 @@ def test_delete_firebase_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 = 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.delete_firebase_link(**mock_args) + 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/*/firebaseLinks/*}" % client.transport._host, + "%s/v1alpha/{name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + % client.transport._host, args[1], ) -def test_delete_firebase_link_rest_flattened_error(transport: str = "rest"): +def test_get_measurement_protocol_secret_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -36676,13 +41698,13 @@ def test_delete_firebase_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_firebase_link( - analytics_admin.DeleteFirebaseLinkRequest(), + client.get_measurement_protocol_secret( + analytics_admin.GetMeasurementProtocolSecretRequest(), name="name_value", ) -def test_delete_firebase_link_rest_error(): +def test_get_measurement_protocol_secret_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -36691,44 +41713,46 @@ def test_delete_firebase_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListFirebaseLinksRequest, + analytics_admin.ListMeasurementProtocolSecretsRequest, dict, ], ) -def test_list_firebase_links_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 = {"parent": "properties/sample1"} + 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 = analytics_admin.ListFirebaseLinksResponse( + 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 = analytics_admin.ListFirebaseLinksResponse.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.list_firebase_links(request) + response = client.list_measurement_protocol_secrets(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFirebaseLinksPager) + assert isinstance(response, pagers.ListMeasurementProtocolSecretsPager) assert response.next_page_token == "next_page_token_value" -def test_list_firebase_links_rest_required_fields( - request_type=analytics_admin.ListFirebaseLinksRequest, +def test_list_measurement_protocol_secrets_rest_required_fields( + request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -36748,7 +41772,7 @@ 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) + ).list_measurement_protocol_secrets._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -36757,7 +41781,7 @@ 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) + ).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( ( @@ -36778,7 +41802,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 = 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 @@ -36798,25 +41822,29 @@ 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 = 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.list_firebase_links(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_list_firebase_links_rest_unset_required_fields(): +def test_list_measurement_protocol_secrets_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_firebase_links._get_unset_required_fields({}) + unset_fields = ( + transport.list_measurement_protocol_secrets._get_unset_required_fields({}) + ) assert set(unset_fields) == ( set( ( @@ -36829,7 +41857,7 @@ def test_list_firebase_links_rest_unset_required_fields(): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_firebase_links_rest_interceptors(null_interceptor): +def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -36842,14 +41870,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_list_measurement_protocol_secrets", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_firebase_links" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_list_measurement_protocol_secrets", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListFirebaseLinksRequest.pb( - analytics_admin.ListFirebaseLinksRequest() + pb_message = analytics_admin.ListMeasurementProtocolSecretsRequest.pb( + analytics_admin.ListMeasurementProtocolSecretsRequest() ) transcode.return_value = { "method": "post", @@ -36861,19 +41891,21 @@ 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 = ( + analytics_admin.ListMeasurementProtocolSecretsResponse.to_json( + analytics_admin.ListMeasurementProtocolSecretsResponse() + ) ) - request = analytics_admin.ListFirebaseLinksRequest() + request = analytics_admin.ListMeasurementProtocolSecretsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListFirebaseLinksResponse() + post.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() - client.list_firebase_links( + client.list_measurement_protocol_secrets( request, metadata=[ ("key", "val"), @@ -36885,8 +41917,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_list_measurement_protocol_secrets_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -36894,7 +41927,7 @@ def test_list_firebase_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + 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. @@ -36906,10 +41939,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.list_measurement_protocol_secrets(request) -def test_list_firebase_links_rest_flattened(): +def test_list_measurement_protocol_secrets_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -36918,10 +41951,10 @@ 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 = analytics_admin.ListMeasurementProtocolSecretsResponse() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"parent": "properties/sample1/dataStreams/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -36932,24 +41965,29 @@ def test_list_firebase_links_rest_flattened(): # 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 = 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.list_firebase_links(**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/{parent=properties/*}/firebaseLinks" % client.transport._host, + "%s/v1alpha/{parent=properties/*/dataStreams/*}/measurementProtocolSecrets" + % client.transport._host, args[1], ) -def test_list_firebase_links_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, @@ -36958,13 +41996,13 @@ 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(), + client.list_measurement_protocol_secrets( + analytics_admin.ListMeasurementProtocolSecretsRequest(), parent="parent_value", ) -def test_list_firebase_links_rest_pager(transport: str = "rest"): +def test_list_measurement_protocol_secrets_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -36976,28 +42014,28 @@ def test_list_firebase_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.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), - resources.FirebaseLink(), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), ], next_page_token="abc", ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[], + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[], next_page_token="def", ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), ], next_page_token="ghi", ), - analytics_admin.ListFirebaseLinksResponse( - firebase_links=[ - resources.FirebaseLink(), - resources.FirebaseLink(), + analytics_admin.ListMeasurementProtocolSecretsResponse( + measurement_protocol_secrets=[ + resources.MeasurementProtocolSecret(), + resources.MeasurementProtocolSecret(), ], ), ) @@ -37006,7 +42044,8 @@ def test_list_firebase_links_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.ListFirebaseLinksResponse.to_json(x) for x in response + 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): @@ -37014,15 +42053,17 @@ def test_list_firebase_links_rest_pager(transport: str = "rest"): return_val.status_code = 200 req.side_effect = return_values - sample_request = {"parent": "properties/sample1"} + sample_request = {"parent": "properties/sample1/dataStreams/sample2"} - pager = client.list_firebase_links(request=sample_request) + pager = client.list_measurement_protocol_secrets(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.FirebaseLink) for i in results) + assert all(isinstance(i, resources.MeasurementProtocolSecret) for i in results) - pages = list(client.list_firebase_links(request=sample_request).pages) + 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 @@ -37030,51 +42071,58 @@ def test_list_firebase_links_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetGlobalSiteTagRequest, + analytics_admin.CreateMeasurementProtocolSecretRequest, dict, ], ) -def test_get_global_site_tag_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 = {"name": "properties/sample1/dataStreams/sample2/globalSiteTag"} + 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 = resources.GlobalSiteTag( + return_value = resources.MeasurementProtocolSecret( name="name_value", - snippet="snippet_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 = resources.GlobalSiteTag.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.get_global_site_tag(request) + response = client.create_measurement_protocol_secret(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.GlobalSiteTag) + assert isinstance(response, resources.MeasurementProtocolSecret) assert response.name == "name_value" - assert response.snippet == "snippet_value" + assert response.display_name == "display_name_value" + assert response.secret_value == "secret_value_value" -def test_get_global_site_tag_rest_required_fields( - request_type=analytics_admin.GetGlobalSiteTagRequest, +def test_create_measurement_protocol_secret_rest_required_fields( + request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, ): 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( @@ -37089,21 +42137,21 @@ 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) + ).create_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["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_global_site_tag._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 - 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(), @@ -37112,7 +42160,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.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 @@ -37124,38 +42172,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": "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.GlobalSiteTag.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.get_global_site_tag(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_get_global_site_tag_rest_unset_required_fields(): +def test_create_measurement_protocol_secret_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.create_measurement_protocol_secret._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "measurementProtocolSecret", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_global_site_tag_rest_interceptors(null_interceptor): +def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -37168,14 +42227,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_create_measurement_protocol_secret", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_global_site_tag" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_create_measurement_protocol_secret", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetGlobalSiteTagRequest.pb( - analytics_admin.GetGlobalSiteTagRequest() + pb_message = analytics_admin.CreateMeasurementProtocolSecretRequest.pb( + analytics_admin.CreateMeasurementProtocolSecretRequest() ) transcode.return_value = { "method": "post", @@ -37187,19 +42248,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.MeasurementProtocolSecret.to_json( + resources.MeasurementProtocolSecret() ) - request = analytics_admin.GetGlobalSiteTagRequest() + request = analytics_admin.CreateMeasurementProtocolSecretRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GlobalSiteTag() + post.return_value = resources.MeasurementProtocolSecret() - client.get_global_site_tag( + client.create_measurement_protocol_secret( request, metadata=[ ("key", "val"), @@ -37211,8 +42272,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_create_measurement_protocol_secret_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -37220,7 +42282,12 @@ 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 = {"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. @@ -37232,10 +42299,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.create_measurement_protocol_secret(request) -def test_get_global_site_tag_rest_flattened(): +def test_create_measurement_protocol_secret_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -37244,41 +42311,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.MeasurementProtocolSecret() # get arguments that satisfy an http rule for this method - sample_request = { - "name": "properties/sample1/dataStreams/sample2/globalSiteTag" - } + sample_request = {"parent": "properties/sample1/dataStreams/sample2"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + 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.GlobalSiteTag.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 - client.get_global_site_tag(**mock_args) + 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/{name=properties/*/dataStreams/*/globalSiteTag}" + "%s/v1alpha/{parent=properties/*/dataStreams/*}/measurementProtocolSecrets" % client.transport._host, args[1], ) -def test_get_global_site_tag_rest_flattened_error(transport: str = "rest"): +def test_create_measurement_protocol_secret_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -37287,13 +42357,16 @@ 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.create_measurement_protocol_secret( + analytics_admin.CreateMeasurementProtocolSecretRequest(), + parent="parent_value", + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), ) -def test_get_global_site_tag_rest_error(): +def test_create_measurement_protocol_secret_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -37302,64 +42375,47 @@ def test_get_global_site_tag_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateGoogleAdsLinkRequest, + analytics_admin.DeleteMeasurementProtocolSecretRequest, dict, ], ) -def test_create_google_ads_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 = {"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_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 = resources.GoogleAdsLink( - name="name_value", - customer_id="customer_id_value", - can_manage_clients=True, - creator_email_address="creator_email_address_value", - ) + return_value = None # 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) + json_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.delete_measurement_protocol_secret(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleAdsLink) - assert response.name == "name_value" - assert response.customer_id == "customer_id_value" - assert response.can_manage_clients is True - assert response.creator_email_address == "creator_email_address_value" + assert response is None -def test_create_google_ads_link_rest_required_fields( - request_type=analytics_admin.CreateGoogleAdsLinkRequest, +def test_delete_measurement_protocol_secret_rest_required_fields( + request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, ): 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( @@ -37374,21 +42430,21 @@ 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) + ).delete_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() - ).create_google_ads_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 - 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(), @@ -37397,7 +42453,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 = 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 @@ -37409,47 +42465,38 @@ def test_create_google_ads_link_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.GoogleAdsLink.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_google_ads_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_create_google_ads_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.create_google_ads_link._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "googleAdsLink", - ) - ) + 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_create_google_ads_link_rest_interceptors(null_interceptor): +def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -37462,14 +42509,12 @@ 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" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_google_ads_link" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_delete_measurement_protocol_secret", ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreateGoogleAdsLinkRequest.pb( - analytics_admin.CreateGoogleAdsLinkRequest() + pb_message = analytics_admin.DeleteMeasurementProtocolSecretRequest.pb( + analytics_admin.DeleteMeasurementProtocolSecretRequest() ) transcode.return_value = { "method": "post", @@ -37481,19 +42526,15 @@ 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() - ) - request = analytics_admin.CreateGoogleAdsLinkRequest() + request = analytics_admin.DeleteMeasurementProtocolSecretRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GoogleAdsLink() - client.create_google_ads_link( + client.delete_measurement_protocol_secret( request, metadata=[ ("key", "val"), @@ -37502,11 +42543,11 @@ def test_create_google_ads_link_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_google_ads_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateGoogleAdsLinkRequest +def test_delete_measurement_protocol_secret_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -37514,15 +42555,8 @@ 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"] = { - "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_init = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" } request = request_type(**request_init) @@ -37535,10 +42569,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.delete_measurement_protocol_secret(request) -def test_create_google_ads_link_rest_flattened(): +def test_delete_measurement_protocol_secret_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -37547,39 +42581,42 @@ 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 = None # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - google_ads_link=resources.GoogleAdsLink(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.GoogleAdsLink.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_google_ads_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/{parent=properties/*}/googleAdsLinks" % client.transport._host, + "%s/v1alpha/{name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + % client.transport._host, args[1], ) -def test_create_google_ads_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, @@ -37588,14 +42625,13 @@ 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(), - parent="parent_value", - google_ads_link=resources.GoogleAdsLink(name="name_value"), + client.delete_measurement_protocol_secret( + analytics_admin.DeleteMeasurementProtocolSecretRequest(), + name="name_value", ) -def test_create_google_ads_link_rest_error(): +def test_delete_measurement_protocol_secret_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -37604,11 +42640,11 @@ def test_create_google_ads_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateGoogleAdsLinkRequest, + analytics_admin.UpdateMeasurementProtocolSecretRequest, dict, ], ) -def test_update_google_ads_link_rest(request_type): +def test_update_measurement_protocol_secret_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -37616,49 +42652,45 @@ def test_update_google_ads_link_rest(request_type): # send a request that will satisfy transcoding request_init = { - "google_ads_link": {"name": "properties/sample1/googleAdsLinks/sample2"} + "measurement_protocol_secret": { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } } - 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["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 = resources.GoogleAdsLink( + return_value = resources.MeasurementProtocolSecret( name="name_value", - customer_id="customer_id_value", - can_manage_clients=True, - creator_email_address="creator_email_address_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 = resources.GoogleAdsLink.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.update_google_ads_link(request) + response = client.update_measurement_protocol_secret(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleAdsLink) + assert isinstance(response, resources.MeasurementProtocolSecret) 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.display_name == "display_name_value" + assert response.secret_value == "secret_value_value" -def test_update_google_ads_link_rest_required_fields( - request_type=analytics_admin.UpdateGoogleAdsLinkRequest, +def test_update_measurement_protocol_secret_rest_required_fields( + request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -37677,14 +42709,14 @@ 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) + ).update_measurement_protocol_secret._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_google_ads_link._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) @@ -37698,7 +42730,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.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 @@ -37719,30 +42751,34 @@ def test_update_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.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.update_google_ads_link(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_update_google_ads_link_rest_unset_required_fields(): +def test_update_measurement_protocol_secret_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.update_measurement_protocol_secret._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set(("updateMask",)) & set(("measurementProtocolSecret",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_google_ads_link_rest_interceptors(null_interceptor): +def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -37755,14 +42791,16 @@ 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_update_measurement_protocol_secret", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_google_ads_link" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_measurement_protocol_secret", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateGoogleAdsLinkRequest.pb( - analytics_admin.UpdateGoogleAdsLinkRequest() + pb_message = analytics_admin.UpdateMeasurementProtocolSecretRequest.pb( + analytics_admin.UpdateMeasurementProtocolSecretRequest() ) transcode.return_value = { "method": "post", @@ -37774,19 +42812,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.MeasurementProtocolSecret.to_json( + resources.MeasurementProtocolSecret() ) - request = analytics_admin.UpdateGoogleAdsLinkRequest() + request = analytics_admin.UpdateMeasurementProtocolSecretRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GoogleAdsLink() + post.return_value = resources.MeasurementProtocolSecret() - client.update_google_ads_link( + client.update_measurement_protocol_secret( request, metadata=[ ("key", "val"), @@ -37798,8 +42836,9 @@ 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_update_measurement_protocol_secret_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -37808,16 +42847,14 @@ 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"} + "measurement_protocol_secret": { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } } - 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["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) @@ -37830,10 +42867,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.update_measurement_protocol_secret(request) -def test_update_google_ads_link_rest_flattened(): +def test_update_measurement_protocol_secret_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -37842,16 +42879,20 @@ 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.MeasurementProtocolSecret() # get arguments that satisfy an http rule for this method sample_request = { - "google_ads_link": {"name": "properties/sample1/googleAdsLinks/sample2"} + "measurement_protocol_secret": { + "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + } } # get truthy value for each flattened field mock_args = dict( - google_ads_link=resources.GoogleAdsLink(name="name_value"), + measurement_protocol_secret=resources.MeasurementProtocolSecret( + name="name_value" + ), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) @@ -37859,25 +42900,27 @@ def test_update_google_ads_link_rest_flattened(): # 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.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_google_ads_link(**mock_args) + 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/{google_ads_link.name=properties/*/googleAdsLinks/*}" + "%s/v1alpha/{measurement_protocol_secret.name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" % client.transport._host, args[1], ) -def test_update_google_ads_link_rest_flattened_error(transport: str = "rest"): +def test_update_measurement_protocol_secret_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -37886,14 +42929,16 @@ 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"), + 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_google_ads_link_rest_error(): +def test_update_measurement_protocol_secret_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -37902,45 +42947,49 @@ def test_update_google_ads_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteGoogleAdsLinkRequest, + analytics_admin.AcknowledgeUserDataCollectionRequest, dict, ], ) -def test_delete_google_ads_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 = {"name": "properties/sample1/googleAdsLinks/sample2"} + 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 = None + return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_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.delete_google_ads_link(request) + response = client.acknowledge_user_data_collection(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, analytics_admin.AcknowledgeUserDataCollectionResponse) -def test_delete_google_ads_link_rest_required_fields( - request_type=analytics_admin.DeleteGoogleAdsLinkRequest, +def test_acknowledge_user_data_collection_rest_required_fields( + request_type=analytics_admin.AcknowledgeUserDataCollectionRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["property"] = "" + request_init["acknowledgement"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -37955,21 +43004,24 @@ 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) + ).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["name"] = "name_value" + jsonified_request["property"] = "property_value" + jsonified_request["acknowledgement"] = "acknowledgement_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_google_ads_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 "name" in jsonified_request - assert jsonified_request["name"] == "name_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(), @@ -37978,7 +43030,7 @@ def test_delete_google_ads_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + 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 @@ -37990,36 +43042,51 @@ def test_delete_google_ads_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.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.delete_google_ads_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_delete_google_ads_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.delete_google_ads_link._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = ( + transport.acknowledge_user_data_collection._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set(()) + & set( + ( + "property", + "acknowledgement", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_google_ads_link_rest_interceptors(null_interceptor): +def test_acknowledge_user_data_collection_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -38032,11 +43099,16 @@ 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, + "post_acknowledge_user_data_collection", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_acknowledge_user_data_collection", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteGoogleAdsLinkRequest.pb( - analytics_admin.DeleteGoogleAdsLinkRequest() + post.assert_not_called() + pb_message = analytics_admin.AcknowledgeUserDataCollectionRequest.pb( + analytics_admin.AcknowledgeUserDataCollectionRequest() ) transcode.return_value = { "method": "post", @@ -38048,15 +43120,21 @@ def test_delete_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 = ( + analytics_admin.AcknowledgeUserDataCollectionResponse.to_json( + analytics_admin.AcknowledgeUserDataCollectionResponse() + ) + ) - request = analytics_admin.DeleteGoogleAdsLinkRequest() + request = analytics_admin.AcknowledgeUserDataCollectionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() - client.delete_google_ads_link( + client.acknowledge_user_data_collection( request, metadata=[ ("key", "val"), @@ -38065,10 +43143,12 @@ def test_delete_google_ads_link_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_google_ads_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteGoogleAdsLinkRequest +def test_acknowledge_user_data_collection_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.AcknowledgeUserDataCollectionRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38076,7 +43156,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 = {"property": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -38088,64 +43168,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) - - -def test_delete_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 = None - - # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/googleAdsLinks/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_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=properties/*/googleAdsLinks/*}" % client.transport._host, - args[1], - ) - - -def test_delete_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.delete_google_ads_link( - analytics_admin.DeleteGoogleAdsLinkRequest(), - name="name_value", - ) + client.acknowledge_user_data_collection(request) -def test_delete_google_ads_link_rest_error(): +def test_acknowledge_user_data_collection_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -38154,49 +43180,51 @@ def test_delete_google_ads_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListGoogleAdsLinksRequest, + analytics_admin.SearchChangeHistoryEventsRequest, dict, ], ) -def test_list_google_ads_links_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 = {"parent": "properties/sample1"} + 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 = analytics_admin.ListGoogleAdsLinksResponse( + 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 - pb_return_value = analytics_admin.ListGoogleAdsLinksResponse.pb(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.list_google_ads_links(request) + response = client.search_change_history_events(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListGoogleAdsLinksPager) + assert isinstance(response, pagers.SearchChangeHistoryEventsPager) 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_search_change_history_events_rest_required_fields( + request_type=analytics_admin.SearchChangeHistoryEventsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["account"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -38211,28 +43239,21 @@ 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) + ).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["parent"] = "parent_value" + jsonified_request["account"] = "account_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).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", - ) - ) + ).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 "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "account" in jsonified_request + assert jsonified_request["account"] == "account_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38241,7 +43262,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.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 @@ -38253,15 +43274,16 @@ def test_list_google_ads_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.ListGoogleAdsLinksResponse.pb( + pb_return_value = analytics_admin.SearchChangeHistoryEventsResponse.pb( return_value ) json_return_value = json_format.MessageToJson(pb_return_value) @@ -38269,32 +43291,24 @@ 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.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_list_google_ads_links_rest_unset_required_fields(): +def test_search_change_history_events_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_google_ads_links._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + 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_list_google_ads_links_rest_interceptors(null_interceptor): +def test_search_change_history_events_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -38307,14 +43321,16 @@ 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_search_change_history_events", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_google_ads_links" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_search_change_history_events", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListGoogleAdsLinksRequest.pb( - analytics_admin.ListGoogleAdsLinksRequest() + pb_message = analytics_admin.SearchChangeHistoryEventsRequest.pb( + analytics_admin.SearchChangeHistoryEventsRequest() ) transcode.return_value = { "method": "post", @@ -38326,19 +43342,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.SearchChangeHistoryEventsResponse.to_json( + analytics_admin.SearchChangeHistoryEventsResponse() + ) ) - request = analytics_admin.ListGoogleAdsLinksRequest() + request = analytics_admin.SearchChangeHistoryEventsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListGoogleAdsLinksResponse() + post.return_value = analytics_admin.SearchChangeHistoryEventsResponse() - client.list_google_ads_links( + client.search_change_history_events( request, metadata=[ ("key", "val"), @@ -38350,8 +43368,9 @@ 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_search_change_history_events_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.SearchChangeHistoryEventsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38359,7 +43378,7 @@ def test_list_google_ads_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"account": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -38371,65 +43390,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) - - -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", - ) + client.search_change_history_events(request) -def test_list_google_ads_links_rest_pager(transport: str = "rest"): +def test_search_change_history_events_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -38441,28 +43405,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.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), ], next_page_token="abc", ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[], + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[], next_page_token="def", ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), ], next_page_token="ghi", ), - analytics_admin.ListGoogleAdsLinksResponse( - google_ads_links=[ - resources.GoogleAdsLink(), - resources.GoogleAdsLink(), + analytics_admin.SearchChangeHistoryEventsResponse( + change_history_events=[ + resources.ChangeHistoryEvent(), + resources.ChangeHistoryEvent(), ], ), ) @@ -38471,7 +43435,8 @@ 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.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): @@ -38479,15 +43444,15 @@ def test_list_google_ads_links_rest_pager(transport: str = "rest"): return_val.status_code = 200 req.side_effect = return_values - sample_request = {"parent": "properties/sample1"} + sample_request = {"account": "accounts/sample1"} - pager = client.list_google_ads_links(request=sample_request) + pager = client.search_change_history_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.ChangeHistoryEvent) for i in results) - pages = list(client.list_google_ads_links(request=sample_request).pages) + 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 @@ -38495,54 +43460,51 @@ def test_list_google_ads_links_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDataSharingSettingsRequest, + analytics_admin.GetGoogleSignalsSettingsRequest, dict, ], ) -def test_get_data_sharing_settings_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 = {"name": "accounts/sample1/dataSharingSettings"} + 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 = resources.DataSharingSettings( + return_value = resources.GoogleSignalsSettings( 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, + 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.DataSharingSettings.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_data_sharing_settings(request) + response = client.get_google_signals_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataSharingSettings) + assert isinstance(response, resources.GoogleSignalsSettings) 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.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert ( + response.consent + == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + ) -def test_get_data_sharing_settings_rest_required_fields( - request_type=analytics_admin.GetDataSharingSettingsRequest, +def test_get_google_signals_settings_rest_required_fields( + request_type=analytics_admin.GetGoogleSignalsSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -38562,7 +43524,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_google_signals_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -38571,7 +43533,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_google_signals_settings._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -38585,7 +43547,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.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 @@ -38605,30 +43567,30 @@ 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.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_data_sharing_settings(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_get_data_sharing_settings_rest_unset_required_fields(): +def test_get_google_signals_settings_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_google_signals_settings._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_google_signals_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -38642,14 +43604,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_google_signals_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_data_sharing_settings" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_get_google_signals_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetDataSharingSettingsRequest.pb( - analytics_admin.GetDataSharingSettingsRequest() + pb_message = analytics_admin.GetGoogleSignalsSettingsRequest.pb( + analytics_admin.GetGoogleSignalsSettingsRequest() ) transcode.return_value = { "method": "post", @@ -38661,19 +43624,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.GoogleSignalsSettings.to_json( + resources.GoogleSignalsSettings() ) - request = analytics_admin.GetDataSharingSettingsRequest() + request = analytics_admin.GetGoogleSignalsSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataSharingSettings() + post.return_value = resources.GoogleSignalsSettings() - client.get_data_sharing_settings( + client.get_google_signals_settings( request, metadata=[ ("key", "val"), @@ -38685,8 +43648,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_google_signals_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.GetGoogleSignalsSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38694,7 +43658,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/googleSignalsSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -38706,10 +43670,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_google_signals_settings(request) -def test_get_data_sharing_settings_rest_flattened(): +def test_get_google_signals_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -38718,10 +43682,10 @@ 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.GoogleSignalsSettings() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1/dataSharingSettings"} + sample_request = {"name": "properties/sample1/googleSignalsSettings"} # get truthy value for each flattened field mock_args = dict( @@ -38732,24 +43696,25 @@ 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.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_data_sharing_settings(**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/{name=accounts/*/dataSharingSettings}" % client.transport._host, + "%s/v1alpha/{name=properties/*/googleSignalsSettings}" + % client.transport._host, args[1], ) -def test_get_data_sharing_settings_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, @@ -38758,13 +43723,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_google_signals_settings( + analytics_admin.GetGoogleSignalsSettingsRequest(), name="name_value", ) -def test_get_data_sharing_settings_rest_error(): +def test_get_google_signals_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -38773,11 +43738,11 @@ def test_get_data_sharing_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetMeasurementProtocolSecretRequest, + analytics_admin.UpdateGoogleSignalsSettingsRequest, dict, ], ) -def test_get_measurement_protocol_secret_rest(request_type): +def test_update_google_signals_settings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -38785,43 +43750,50 @@ def test_get_measurement_protocol_secret_rest(request_type): # send a request that will satisfy transcoding request_init = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + "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.MeasurementProtocolSecret( + return_value = resources.GoogleSignalsSettings( name="name_value", - display_name="display_name_value", - secret_value="secret_value_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.MeasurementProtocolSecret.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_measurement_protocol_secret(request) + response = client.update_google_signals_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) + assert isinstance(response, resources.GoogleSignalsSettings) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.secret_value == "secret_value_value" + assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED + assert ( + response.consent + == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED + ) -def test_get_measurement_protocol_secret_rest_required_fields( - request_type=analytics_admin.GetMeasurementProtocolSecretRequest, +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( @@ -38836,21 +43808,19 @@ 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) + ).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_measurement_protocol_secret._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(), @@ -38859,7 +43829,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 = 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 @@ -38871,40 +43841,49 @@ def test_get_measurement_protocol_secret_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.MeasurementProtocolSecret.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_measurement_protocol_secret(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_measurement_protocol_secret_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_measurement_protocol_secret._get_unset_required_fields( + unset_fields = transport.update_google_signals_settings._get_unset_required_fields( {} ) - assert set(unset_fields) == (set(()) & set(("name",))) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "googleSignalsSettings", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): +def test_update_google_signals_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -38918,15 +43897,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_update_google_signals_settings", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_measurement_protocol_secret", + "pre_update_google_signals_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetMeasurementProtocolSecretRequest.pb( - analytics_admin.GetMeasurementProtocolSecretRequest() + pb_message = analytics_admin.UpdateGoogleSignalsSettingsRequest.pb( + analytics_admin.UpdateGoogleSignalsSettingsRequest() ) transcode.return_value = { "method": "post", @@ -38938,19 +43917,19 @@ 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 = resources.GoogleSignalsSettings.to_json( + resources.GoogleSignalsSettings() ) - request = analytics_admin.GetMeasurementProtocolSecretRequest() + request = analytics_admin.UpdateGoogleSignalsSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.MeasurementProtocolSecret() + post.return_value = resources.GoogleSignalsSettings() - client.get_measurement_protocol_secret( + client.update_google_signals_settings( request, metadata=[ ("key", "val"), @@ -38962,9 +43941,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_update_google_signals_settings_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.GetMeasurementProtocolSecretRequest, + request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -38973,7 +43952,12 @@ 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" + "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) @@ -38986,10 +43970,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.update_google_signals_settings(request) -def test_get_measurement_protocol_secret_rest_flattened(): +def test_update_google_signals_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -38998,41 +43982,44 @@ 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 = resources.GoogleSignalsSettings() # get arguments that satisfy an http rule for this method sample_request = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" + "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.MeasurementProtocolSecret.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_measurement_protocol_secret(**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/*/measurementProtocolSecrets/*}" + "%s/v1alpha/{google_signals_settings.name=properties/*/googleSignalsSettings}" % client.transport._host, args[1], ) -def test_get_measurement_protocol_secret_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, @@ -39041,13 +44028,14 @@ 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.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_measurement_protocol_secret_rest_error(): +def test_update_google_signals_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -39056,46 +44044,57 @@ def test_get_measurement_protocol_secret_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListMeasurementProtocolSecretsRequest, + analytics_admin.CreateConversionEventRequest, dict, ], ) -def test_list_measurement_protocol_secrets_rest(request_type): +def test_create_conversion_event_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["conversion_event"] = { + "name": "name_value", + "event_name": "event_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "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 = analytics_admin.ListMeasurementProtocolSecretsResponse( - next_page_token="next_page_token_value", + return_value = resources.ConversionEvent( + name="name_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 = analytics_admin.ListMeasurementProtocolSecretsResponse.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.list_measurement_protocol_secrets(request) + response = client.create_conversion_event(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.ConversionEvent) + assert response.name == "name_value" + assert response.event_name == "event_name_value" + assert response.deletable is True + assert response.custom is True -def test_list_measurement_protocol_secrets_rest_required_fields( - request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, +def test_create_conversion_event_rest_required_fields( + request_type=analytics_admin.CreateConversionEventRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -39115,7 +44114,7 @@ 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_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -39124,14 +44123,7 @@ 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_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -39145,7 +44137,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.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 @@ -39157,50 +44149,47 @@ 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.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.list_measurement_protocol_secrets(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_list_measurement_protocol_secrets_rest_unset_required_fields(): +def test_create_conversion_event_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.list_measurement_protocol_secrets._get_unset_required_fields({}) - ) + unset_fields = transport.create_conversion_event._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(()) + & set( ( - "pageSize", - "pageToken", + "conversionEvent", + "parent", ) ) - & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): +def test_create_conversion_event_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -39213,16 +44202,14 @@ def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_list_measurement_protocol_secrets", + transports.AnalyticsAdminServiceRestInterceptor, "post_create_conversion_event" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_list_measurement_protocol_secrets", + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_conversion_event" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListMeasurementProtocolSecretsRequest.pb( - analytics_admin.ListMeasurementProtocolSecretsRequest() + pb_message = analytics_admin.CreateConversionEventRequest.pb( + analytics_admin.CreateConversionEventRequest() ) transcode.return_value = { "method": "post", @@ -39234,21 +44221,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.ConversionEvent.to_json( + resources.ConversionEvent() ) - request = analytics_admin.ListMeasurementProtocolSecretsRequest() + request = analytics_admin.CreateConversionEventRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListMeasurementProtocolSecretsResponse() + post.return_value = resources.ConversionEvent() - client.list_measurement_protocol_secrets( + client.create_conversion_event( request, metadata=[ ("key", "val"), @@ -39260,9 +44245,8 @@ def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_measurement_protocol_secrets_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.ListMeasurementProtocolSecretsRequest, +def test_create_conversion_event_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateConversionEventRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39270,7 +44254,14 @@ 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["conversion_event"] = { + "name": "name_value", + "event_name": "event_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "deletable": True, + "custom": True, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -39282,10 +44273,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_conversion_event(request) -def test_list_measurement_protocol_secrets_rest_flattened(): +def test_create_conversion_event_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -39294,43 +44285,40 @@ 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.ConversionEvent() # 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", + 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 = analytics_admin.ListMeasurementProtocolSecretsResponse.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.list_measurement_protocol_secrets(**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/*/dataStreams/*}/measurementProtocolSecrets" + "%s/v1alpha/{parent=properties/*}/conversionEvents" % client.transport._host, args[1], ) -def test_list_measurement_protocol_secrets_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, @@ -39339,133 +44327,71 @@ 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_conversion_event( + analytics_admin.CreateConversionEventRequest(), parent="parent_value", + conversion_event=resources.ConversionEvent(name="name_value"), ) -def test_list_measurement_protocol_secrets_rest_pager(transport: str = "rest"): +def test_create_conversion_event_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.GetConversionEventRequest, dict, ], ) -def test_create_measurement_protocol_secret_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 = {"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/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.MeasurementProtocolSecret( + return_value = resources.ConversionEvent( name="name_value", - display_name="display_name_value", - secret_value="secret_value_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.MeasurementProtocolSecret.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_measurement_protocol_secret(request) + response = client.get_conversion_event(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.MeasurementProtocolSecret) + assert isinstance(response, resources.ConversionEvent) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.secret_value == "secret_value_value" + assert response.event_name == "event_name_value" + assert response.deletable is True + assert response.custom is True -def test_create_measurement_protocol_secret_rest_required_fields( - request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, +def test_get_conversion_event_rest_required_fields( + request_type=analytics_admin.GetConversionEventRequest, ): 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( @@ -39480,21 +44406,21 @@ 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) + ).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["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) + ).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 "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(), @@ -39503,7 +44429,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 = 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 @@ -39515,49 +44441,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": "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.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_measurement_protocol_secret(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_create_measurement_protocol_secret_rest_unset_required_fields(): +def test_get_conversion_event_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", - ) - ) - ) + 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_create_measurement_protocol_secret_rest_interceptors(null_interceptor): +def test_get_conversion_event_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -39570,16 +44485,14 @@ def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_create_measurement_protocol_secret", + transports.AnalyticsAdminServiceRestInterceptor, "post_get_conversion_event" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_create_measurement_protocol_secret", + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_conversion_event" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateMeasurementProtocolSecretRequest.pb( - analytics_admin.CreateMeasurementProtocolSecretRequest() + pb_message = analytics_admin.GetConversionEventRequest.pb( + analytics_admin.GetConversionEventRequest() ) transcode.return_value = { "method": "post", @@ -39591,19 +44504,19 @@ 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() + req.return_value._content = resources.ConversionEvent.to_json( + resources.ConversionEvent() ) - request = analytics_admin.CreateMeasurementProtocolSecretRequest() + request = analytics_admin.GetConversionEventRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.MeasurementProtocolSecret() + post.return_value = resources.ConversionEvent() - client.create_measurement_protocol_secret( + client.get_conversion_event( request, metadata=[ ("key", "val"), @@ -39615,9 +44528,8 @@ def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_measurement_protocol_secret_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.CreateMeasurementProtocolSecretRequest, +def test_get_conversion_event_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetConversionEventRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39625,12 +44537,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/conversionEvents/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -39642,10 +44549,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.get_conversion_event(request) -def test_create_measurement_protocol_secret_rest_flattened(): +def test_get_conversion_event_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -39654,44 +44561,39 @@ 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 = resources.ConversionEvent() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1/dataStreams/sample2"} + sample_request = {"name": "properties/sample1/conversionEvents/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) + 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_measurement_protocol_secret(**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/{parent=properties/*/dataStreams/*}/measurementProtocolSecrets" + "%s/v1alpha/{name=properties/*/conversionEvents/*}" % client.transport._host, args[1], ) -def test_create_measurement_protocol_secret_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, @@ -39700,16 +44602,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.get_conversion_event( + analytics_admin.GetConversionEventRequest(), + name="name_value", ) -def test_create_measurement_protocol_secret_rest_error(): +def test_get_conversion_event_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -39718,20 +44617,18 @@ def test_create_measurement_protocol_secret_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteMeasurementProtocolSecretRequest, + analytics_admin.DeleteConversionEventRequest, dict, ], ) -def test_delete_measurement_protocol_secret_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/dataStreams/sample2/measurementProtocolSecrets/sample3" - } + request_init = {"name": "properties/sample1/conversionEvents/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -39746,14 +44643,14 @@ def test_delete_measurement_protocol_secret_rest(request_type): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_measurement_protocol_secret(request) + response = client.delete_conversion_event(request) # Establish that the response is the type that we expect. assert response is None -def test_delete_measurement_protocol_secret_rest_required_fields( - request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, +def test_delete_conversion_event_rest_required_fields( + request_type=analytics_admin.DeleteConversionEventRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -39773,7 +44670,7 @@ 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) + ).delete_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -39782,7 +44679,7 @@ 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) + ).delete_conversion_event._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -39820,26 +44717,24 @@ def test_delete_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_measurement_protocol_secret(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_measurement_protocol_secret_rest_unset_required_fields(): +def test_delete_conversion_event_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.delete_measurement_protocol_secret._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_measurement_protocol_secret_rest_interceptors(null_interceptor): +def test_delete_conversion_event_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -39852,12 +44747,11 @@ def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_delete_measurement_protocol_secret", + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_conversion_event" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteMeasurementProtocolSecretRequest.pb( - analytics_admin.DeleteMeasurementProtocolSecretRequest() + pb_message = analytics_admin.DeleteConversionEventRequest.pb( + analytics_admin.DeleteConversionEventRequest() ) transcode.return_value = { "method": "post", @@ -39870,14 +44764,14 @@ def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - request = analytics_admin.DeleteMeasurementProtocolSecretRequest() + request = analytics_admin.DeleteConversionEventRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - client.delete_measurement_protocol_secret( + client.delete_conversion_event( request, metadata=[ ("key", "val"), @@ -39888,9 +44782,8 @@ def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): pre.assert_called_once() -def test_delete_measurement_protocol_secret_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.DeleteMeasurementProtocolSecretRequest, +def test_delete_conversion_event_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteConversionEventRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -39898,9 +44791,7 @@ 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" - } + 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. @@ -39912,10 +44803,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.delete_conversion_event(request) -def test_delete_measurement_protocol_secret_rest_flattened(): +def test_delete_conversion_event_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -39927,9 +44818,7 @@ def test_delete_measurement_protocol_secret_rest_flattened(): return_value = None # get arguments that satisfy an http rule for this method - sample_request = { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" - } + sample_request = {"name": "properties/sample1/conversionEvents/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -39944,22 +44833,20 @@ def test_delete_measurement_protocol_secret_rest_flattened(): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_measurement_protocol_secret(**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/*/dataStreams/*/measurementProtocolSecrets/*}" + "%s/v1alpha/{name=properties/*/conversionEvents/*}" % client.transport._host, args[1], ) -def test_delete_measurement_protocol_secret_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, @@ -39968,13 +44855,13 @@ 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(), + client.delete_conversion_event( + analytics_admin.DeleteConversionEventRequest(), name="name_value", ) -def test_delete_measurement_protocol_secret_rest_error(): +def test_delete_conversion_event_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -39983,61 +44870,49 @@ def test_delete_measurement_protocol_secret_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateMeasurementProtocolSecretRequest, + analytics_admin.ListConversionEventsRequest, dict, ], ) -def test_update_measurement_protocol_secret_rest(request_type): +def test_list_conversion_events_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # 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", - } + 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.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 = resources.MeasurementProtocolSecret.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.update_measurement_protocol_secret(request) + response = client.list_conversion_events(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.ListConversionEventsPager) + assert response.next_page_token == "next_page_token_value" -def test_update_measurement_protocol_secret_rest_required_fields( - request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, +def test_list_conversion_events_rest_required_fields( + request_type=analytics_admin.ListConversionEventsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -40052,19 +44927,28 @@ 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) + ).list_conversion_events._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_measurement_protocol_secret._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(("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(), @@ -40073,7 +44957,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 = 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 @@ -40085,43 +44969,48 @@ 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 = 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.update_measurement_protocol_secret(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_update_measurement_protocol_secret_rest_unset_required_fields(): +def test_list_conversion_events_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.update_measurement_protocol_secret._get_unset_required_fields({}) - ) + unset_fields = transport.list_conversion_events._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("updateMask",)) & set(("measurementProtocolSecret",)) + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): +def test_list_conversion_events_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -40134,16 +45023,14 @@ def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_update_measurement_protocol_secret", + transports.AnalyticsAdminServiceRestInterceptor, "post_list_conversion_events" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_measurement_protocol_secret", + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_conversion_events" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateMeasurementProtocolSecretRequest.pb( - analytics_admin.UpdateMeasurementProtocolSecretRequest() + pb_message = analytics_admin.ListConversionEventsRequest.pb( + analytics_admin.ListConversionEventsRequest() ) transcode.return_value = { "method": "post", @@ -40155,19 +45042,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 = ( + analytics_admin.ListConversionEventsResponse.to_json( + analytics_admin.ListConversionEventsResponse() + ) ) - request = analytics_admin.UpdateMeasurementProtocolSecretRequest() + request = analytics_admin.ListConversionEventsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.MeasurementProtocolSecret() + post.return_value = analytics_admin.ListConversionEventsResponse() - client.update_measurement_protocol_secret( + client.list_conversion_events( request, metadata=[ ("key", "val"), @@ -40179,9 +45068,8 @@ def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_measurement_protocol_secret_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.UpdateMeasurementProtocolSecretRequest, +def test_list_conversion_events_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListConversionEventsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40189,16 +45077,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", - } + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -40210,10 +45089,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.list_conversion_events(request) -def test_update_measurement_protocol_secret_rest_flattened(): +def test_list_conversion_events_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -40222,48 +45101,39 @@ 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 = analytics_admin.ListConversionEventsResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "measurement_protocol_secret": { - "name": "properties/sample1/dataStreams/sample2/measurementProtocolSecrets/sample3" - } - } + sample_request = {"parent": "properties/sample1"} # 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"]), + 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.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.update_measurement_protocol_secret(**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/{measurement_protocol_secret.name=properties/*/dataStreams/*/measurementProtocolSecrets/*}" + "%s/v1alpha/{parent=properties/*}/conversionEvents" % client.transport._host, args[1], ) -def test_update_measurement_protocol_secret_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, @@ -40272,67 +45142,125 @@ 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.list_conversion_events( + analytics_admin.ListConversionEventsRequest(), + parent="parent_value", ) -def test_update_measurement_protocol_secret_rest_error(): +def test_list_conversion_events_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.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + next_page_token="abc", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[], + next_page_token="def", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + ], + next_page_token="ghi", + ), + analytics_admin.ListConversionEventsResponse( + conversion_events=[ + resources.ConversionEvent(), + resources.ConversionEvent(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + 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): + 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_conversion_events(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.ConversionEvent) for i in results) + + 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 + @pytest.mark.parametrize( "request_type", [ - analytics_admin.AcknowledgeUserDataCollectionRequest, + analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, dict, ], ) -def test_acknowledge_user_data_collection_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 = {"property": "properties/sample1"} + 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 = analytics_admin.AcknowledgeUserDataCollectionResponse() + 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.AcknowledgeUserDataCollectionResponse.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.acknowledge_user_data_collection(request) + response = client.get_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.AcknowledgeUserDataCollectionResponse) + 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_acknowledge_user_data_collection_rest_required_fields( - request_type=analytics_admin.AcknowledgeUserDataCollectionRequest, +def test_get_display_video360_advertiser_link_rest_required_fields( + request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["property"] = "" - request_init["acknowledgement"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -40347,24 +45275,21 @@ 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) + ).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 - jsonified_request["property"] = "property_value" - jsonified_request["acknowledgement"] = "acknowledgement_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).acknowledge_user_data_collection._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 - assert "property" in jsonified_request - assert jsonified_request["property"] == "property_value" - assert "acknowledgement" in jsonified_request - assert jsonified_request["acknowledgement"] == "acknowledgement_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40373,7 +45298,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 = 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 @@ -40385,51 +45310,40 @@ 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 = 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.acknowledge_user_data_collection(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_acknowledge_user_data_collection_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.acknowledge_user_data_collection._get_unset_required_fields({}) - ) - assert set(unset_fields) == ( - set(()) - & set( - ( - "property", - "acknowledgement", - ) - ) + 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_acknowledge_user_data_collection_rest_interceptors(null_interceptor): +def test_get_display_video360_advertiser_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -40443,15 +45357,15 @@ 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_get_display_video360_advertiser_link", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_acknowledge_user_data_collection", + "pre_get_display_video360_advertiser_link", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.AcknowledgeUserDataCollectionRequest.pb( - analytics_admin.AcknowledgeUserDataCollectionRequest() + pb_message = analytics_admin.GetDisplayVideo360AdvertiserLinkRequest.pb( + analytics_admin.GetDisplayVideo360AdvertiserLinkRequest() ) transcode.return_value = { "method": "post", @@ -40463,21 +45377,19 @@ def test_acknowledge_user_data_collection_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.AcknowledgeUserDataCollectionResponse.to_json( - analytics_admin.AcknowledgeUserDataCollectionResponse() - ) + req.return_value._content = resources.DisplayVideo360AdvertiserLink.to_json( + resources.DisplayVideo360AdvertiserLink() ) - request = analytics_admin.AcknowledgeUserDataCollectionRequest() + request = analytics_admin.GetDisplayVideo360AdvertiserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.AcknowledgeUserDataCollectionResponse() + post.return_value = resources.DisplayVideo360AdvertiserLink() - client.acknowledge_user_data_collection( + client.get_display_video360_advertiser_link( request, metadata=[ ("key", "val"), @@ -40489,9 +45401,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_get_display_video360_advertiser_link_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.AcknowledgeUserDataCollectionRequest, + request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40499,7 +45411,7 @@ def test_acknowledge_user_data_collection_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"property": "properties/sample1"} + 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. @@ -40511,10 +45423,70 @@ 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.get_display_video360_advertiser_link(request) -def test_acknowledge_user_data_collection_rest_error(): +def test_get_display_video360_advertiser_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.DisplayVideo360AdvertiserLink() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "properties/sample1/displayVideo360AdvertiserLinks/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.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_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/*/displayVideo360AdvertiserLinks/*}" + % client.transport._host, + args[1], + ) + + +def test_get_display_video360_advertiser_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_display_video360_advertiser_link( + analytics_admin.GetDisplayVideo360AdvertiserLinkRequest(), + name="name_value", + ) + + +def test_get_display_video360_advertiser_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -40523,51 +45495,51 @@ def test_acknowledge_user_data_collection_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.SearchChangeHistoryEventsRequest, + analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, dict, ], ) -def test_search_change_history_events_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 = {"account": "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.SearchChangeHistoryEventsResponse( + 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 = analytics_admin.SearchChangeHistoryEventsResponse.pb( + 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.search_change_history_events(request) + response = client.list_display_video360_advertiser_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchChangeHistoryEventsPager) + assert isinstance(response, pagers.ListDisplayVideo360AdvertiserLinksPager) assert response.next_page_token == "next_page_token_value" -def test_search_change_history_events_rest_required_fields( - request_type=analytics_admin.SearchChangeHistoryEventsRequest, +def test_list_display_video360_advertiser_links_rest_required_fields( + request_type=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, ): 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( @@ -40582,21 +45554,32 @@ 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) + ).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["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) + ).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 "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(), @@ -40605,7 +45588,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 = 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 @@ -40617,41 +45600,52 @@ def test_search_change_history_events_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.SearchChangeHistoryEventsResponse.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.search_change_history_events(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_search_change_history_events_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.search_change_history_events._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("account",))) + unset_fields = ( + transport.list_display_video360_advertiser_links._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_search_change_history_events_rest_interceptors(null_interceptor): +def test_list_display_video360_advertiser_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -40665,15 +45659,15 @@ 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_list_display_video360_advertiser_links", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_search_change_history_events", + "pre_list_display_video360_advertiser_links", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.SearchChangeHistoryEventsRequest.pb( - analytics_admin.SearchChangeHistoryEventsRequest() + pb_message = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest.pb( + analytics_admin.ListDisplayVideo360AdvertiserLinksRequest() ) transcode.return_value = { "method": "post", @@ -40686,20 +45680,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() + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.to_json( + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() ) ) - request = analytics_admin.SearchChangeHistoryEventsRequest() + request = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.SearchChangeHistoryEventsResponse() + post.return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() - client.search_change_history_events( + client.list_display_video360_advertiser_links( request, metadata=[ ("key", "val"), @@ -40711,9 +45705,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_list_display_video360_advertiser_links_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.SearchChangeHistoryEventsRequest, + request_type=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -40721,7 +45715,7 @@ 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 = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -40733,10 +45727,70 @@ 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.list_display_video360_advertiser_links(request) -def test_search_change_history_events_rest_pager(transport: str = "rest"): +def test_list_display_video360_advertiser_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.ListDisplayVideo360AdvertiserLinksResponse() + + # 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.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.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/{parent=properties/*}/displayVideo360AdvertiserLinks" + % client.transport._host, + args[1], + ) + + +def test_list_display_video360_advertiser_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_display_video360_advertiser_links( + analytics_admin.ListDisplayVideo360AdvertiserLinksRequest(), + parent="parent_value", + ) + + +def test_list_display_video360_advertiser_links_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -40748,28 +45802,28 @@ def test_search_change_history_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.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + display_video_360_advertiser_links=[ + resources.DisplayVideo360AdvertiserLink(), + resources.DisplayVideo360AdvertiserLink(), + resources.DisplayVideo360AdvertiserLink(), ], next_page_token="abc", ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[], + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + display_video_360_advertiser_links=[], next_page_token="def", ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + display_video_360_advertiser_links=[ + resources.DisplayVideo360AdvertiserLink(), ], next_page_token="ghi", ), - analytics_admin.SearchChangeHistoryEventsResponse( - change_history_events=[ - resources.ChangeHistoryEvent(), - resources.ChangeHistoryEvent(), + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( + display_video_360_advertiser_links=[ + resources.DisplayVideo360AdvertiserLink(), + resources.DisplayVideo360AdvertiserLink(), ], ), ) @@ -40778,7 +45832,7 @@ def test_search_change_history_events_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.SearchChangeHistoryEventsResponse.to_json(x) + analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.to_json(x) for x in response ) return_values = tuple(Response() for i in response) @@ -40787,15 +45841,19 @@ def test_search_change_history_events_rest_pager(transport: str = "rest"): return_val.status_code = 200 req.side_effect = return_values - sample_request = {"account": "accounts/sample1"} + sample_request = {"parent": "properties/sample1"} - pager = client.search_change_history_events(request=sample_request) + pager = client.list_display_video360_advertiser_links(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.ChangeHistoryEvent) for i in results) + assert all( + isinstance(i, resources.DisplayVideo360AdvertiserLink) for i in results + ) - pages = list(client.search_change_history_events(request=sample_request).pages) + 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 @@ -40803,56 +45861,61 @@ def test_search_change_history_events_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetGoogleSignalsSettingsRequest, + analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, dict, ], ) -def test_get_google_signals_settings_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 = {"name": "properties/sample1/googleSignalsSettings"} + 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 = resources.GoogleSignalsSettings( + return_value = resources.DisplayVideo360AdvertiserLink( name="name_value", - state=resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED, - consent=resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED, + 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.GoogleSignalsSettings.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_google_signals_settings(request) + response = client.create_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.GoogleSignalsSettings) + assert isinstance(response, resources.DisplayVideo360AdvertiserLink) assert response.name == "name_value" - assert response.state == resources.GoogleSignalsState.GOOGLE_SIGNALS_ENABLED - assert ( - response.consent - == resources.GoogleSignalsConsent.GOOGLE_SIGNALS_CONSENT_CONSENTED - ) + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" -def test_get_google_signals_settings_rest_required_fields( - request_type=analytics_admin.GetGoogleSignalsSettingsRequest, +def test_create_display_video360_advertiser_link_rest_required_fields( + request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, ): 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( @@ -40867,21 +45930,25 @@ 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) + ).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 - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_google_signals_settings._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 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(), @@ -40890,7 +45957,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 = 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 @@ -40902,38 +45969,49 @@ def test_get_google_signals_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.GoogleSignalsSettings.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_google_signals_settings(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_get_google_signals_settings_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.get_google_signals_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = ( + transport.create_display_video360_advertiser_link._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "displayVideo360AdvertiserLink", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_google_signals_settings_rest_interceptors(null_interceptor): +def test_create_display_video360_advertiser_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -40947,15 +46025,15 @@ 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", + "post_create_display_video360_advertiser_link", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_google_signals_settings", + "pre_create_display_video360_advertiser_link", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetGoogleSignalsSettingsRequest.pb( - analytics_admin.GetGoogleSignalsSettingsRequest() + pb_message = analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest.pb( + analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest() ) transcode.return_value = { "method": "post", @@ -40967,19 +46045,19 @@ 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() + req.return_value._content = resources.DisplayVideo360AdvertiserLink.to_json( + resources.DisplayVideo360AdvertiserLink() ) - request = analytics_admin.GetGoogleSignalsSettingsRequest() + request = analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GoogleSignalsSettings() + post.return_value = resources.DisplayVideo360AdvertiserLink() - client.get_google_signals_settings( + client.create_display_video360_advertiser_link( request, metadata=[ ("key", "val"), @@ -40991,9 +46069,9 @@ def test_get_google_signals_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_google_signals_settings_rest_bad_request( +def test_create_display_video360_advertiser_link_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.GetGoogleSignalsSettingsRequest, + request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41001,7 +46079,15 @@ def test_get_google_signals_settings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/googleSignalsSettings"} + 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. @@ -41013,10 +46099,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.create_display_video360_advertiser_link(request) -def test_get_google_signals_settings_rest_flattened(): +def test_create_display_video360_advertiser_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41025,39 +46111,44 @@ 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 = resources.DisplayVideo360AdvertiserLink() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/googleSignalsSettings"} + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + 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 = resources.GoogleSignalsSettings.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_google_signals_settings(**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/{name=properties/*/googleSignalsSettings}" + "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinks" % client.transport._host, args[1], ) -def test_get_google_signals_settings_rest_flattened_error(transport: str = "rest"): +def test_create_display_video360_advertiser_link_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -41066,13 +46157,16 @@ 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(), - name="name_value", + client.create_display_video360_advertiser_link( + analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest(), + parent="parent_value", + display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( + name="name_value" + ), ) -def test_get_google_signals_settings_rest_error(): +def test_create_display_video360_advertiser_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -41081,62 +46175,45 @@ def test_get_google_signals_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateGoogleSignalsSettingsRequest, + analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, dict, ], ) -def test_update_google_signals_settings_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 = { - "google_signals_settings": {"name": "properties/sample1/googleSignalsSettings"} - } - request_init["google_signals_settings"] = { - "name": "properties/sample1/googleSignalsSettings", - "state": 1, - "consent": 2, - } + 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.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.update_google_signals_settings(request) + response = client.delete_display_video360_advertiser_link(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_update_google_signals_settings_rest_required_fields( - request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, +def test_delete_display_video360_advertiser_link_rest_required_fields( + request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -41151,19 +46228,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) + ).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["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",)) + ).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 "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41172,7 +46255,7 @@ 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 = 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 @@ -41184,49 +46267,38 @@ def test_update_google_signals_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.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.update_google_signals_settings(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_update_google_signals_settings_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.update_google_signals_settings._get_unset_required_fields( - {} - ) - assert set(unset_fields) == ( - set(("updateMask",)) - & set( - ( - "googleSignalsSettings", - "updateMask", - ) - ) + unset_fields = ( + 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_update_google_signals_settings_rest_interceptors(null_interceptor): +def test_delete_display_video360_advertiser_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -41240,15 +46312,11 @@ 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", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_google_signals_settings", + "pre_delete_display_video360_advertiser_link", ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.UpdateGoogleSignalsSettingsRequest.pb( - analytics_admin.UpdateGoogleSignalsSettingsRequest() + pb_message = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest.pb( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() ) transcode.return_value = { "method": "post", @@ -41260,19 +46328,15 @@ 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() - ) - request = analytics_admin.UpdateGoogleSignalsSettingsRequest() + request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.GoogleSignalsSettings() - client.update_google_signals_settings( + client.delete_display_video360_advertiser_link( request, metadata=[ ("key", "val"), @@ -41281,12 +46345,11 @@ def test_update_google_signals_settings_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_update_google_signals_settings_rest_bad_request( +def test_delete_display_video360_advertiser_link_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.UpdateGoogleSignalsSettingsRequest, + request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41294,14 +46357,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, - } + 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. @@ -41313,10 +46369,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) + client.delete_display_video360_advertiser_link(request) -def test_update_google_signals_settings_rest_flattened(): +def test_delete_display_video360_advertiser_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41325,44 +46381,42 @@ def test_update_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 = { - "google_signals_settings": { - "name": "properties/sample1/googleSignalsSettings" - } + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" } # 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"]), + 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.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.update_google_signals_settings(**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/{google_signals_settings.name=properties/*/googleSignalsSettings}" + "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinks/*}" % client.transport._host, args[1], ) -def test_update_google_signals_settings_rest_flattened_error(transport: str = "rest"): +def test_delete_display_video360_advertiser_link_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -41371,14 +46425,13 @@ def test_update_google_signals_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_google_signals_settings( - analytics_admin.UpdateGoogleSignalsSettingsRequest(), - google_signals_settings=resources.GoogleSignalsSettings(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.delete_display_video360_advertiser_link( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest(), + name="name_value", ) -def test_update_google_signals_settings_rest_error(): +def test_delete_display_video360_advertiser_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -41387,62 +46440,64 @@ def test_update_google_signals_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateConversionEventRequest, + analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, dict, ], ) -def test_create_conversion_event_rest(request_type): +def test_update_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"} - request_init["conversion_event"] = { - "name": "name_value", - "event_name": "event_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "deletable": True, - "custom": True, + 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 = 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.DisplayVideo360AdvertiserLink( name="name_value", - event_name="event_name_value", - deletable=True, - custom=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.ConversionEvent.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.create_conversion_event(request) + response = client.update_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.ConversionEvent) + assert isinstance(response, resources.DisplayVideo360AdvertiserLink) 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" -def test_create_conversion_event_rest_required_fields( - request_type=analytics_admin.CreateConversionEventRequest, +def test_update_display_video360_advertiser_link_rest_required_fields( + request_type=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -41457,21 +46512,23 @@ 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) + ).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["parent"] = "parent_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_conversion_event._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 "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41480,7 +46537,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.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 @@ -41492,7 +46549,7 @@ def test_create_conversion_event_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 @@ -41501,38 +46558,32 @@ 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.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.create_conversion_event(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_create_conversion_event_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.create_conversion_event._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "conversionEvent", - "parent", - ) - ) + unset_fields = ( + transport.update_display_video360_advertiser_link._get_unset_required_fields({}) ) + assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_conversion_event_rest_interceptors(null_interceptor): +def test_update_display_video360_advertiser_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -41545,14 +46596,16 @@ 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_update_display_video360_advertiser_link", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_conversion_event" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_display_video360_advertiser_link", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateConversionEventRequest.pb( - analytics_admin.CreateConversionEventRequest() + pb_message = analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest.pb( + analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest() ) transcode.return_value = { "method": "post", @@ -41564,19 +46617,19 @@ 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.DisplayVideo360AdvertiserLink.to_json( + resources.DisplayVideo360AdvertiserLink() ) - request = analytics_admin.CreateConversionEventRequest() + request = analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.ConversionEvent() + post.return_value = resources.DisplayVideo360AdvertiserLink() - client.create_conversion_event( + client.update_display_video360_advertiser_link( request, metadata=[ ("key", "val"), @@ -41588,8 +46641,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_update_display_video360_advertiser_link_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41597,13 +46651,18 @@ 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 = { + "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) @@ -41616,10 +46675,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) + client.update_display_video360_advertiser_link(request) -def test_create_conversion_event_rest_flattened(): +def test_update_display_video360_advertiser_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41628,40 +46687,48 @@ def test_create_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.DisplayVideo360AdvertiserLink() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = { + "display_video_360_advertiser_link": { + "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" + } + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - conversion_event=resources.ConversionEvent(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 - pb_return_value = resources.ConversionEvent.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.create_conversion_event(**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/{parent=properties/*}/conversionEvents" + "%s/v1alpha/{display_video_360_advertiser_link.name=properties/*/displayVideo360AdvertiserLinks/*}" % client.transport._host, args[1], ) -def test_create_conversion_event_rest_flattened_error(transport: str = "rest"): +def test_update_display_video360_advertiser_link_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -41670,14 +46737,16 @@ def test_create_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.create_conversion_event( - analytics_admin.CreateConversionEventRequest(), - parent="parent_value", - conversion_event=resources.ConversionEvent(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_create_conversion_event_rest_error(): +def test_update_display_video360_advertiser_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -41686,50 +46755,54 @@ def test_create_conversion_event_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetConversionEventRequest, + analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_get_conversion_event_rest(request_type): +def test_get_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/conversionEvents/sample2"} + 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.get_conversion_event(request) + response = client.get_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_get_conversion_event_rest_required_fields( - request_type=analytics_admin.GetConversionEventRequest, +def test_get_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -41749,7 +46822,9 @@ 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) + ).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 @@ -41758,7 +46833,9 @@ 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) + ).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 @@ -41772,7 +46849,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.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 @@ -41792,30 +46869,36 @@ def test_get_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.get_conversion_event(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_get_conversion_event_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.get_conversion_event._get_unset_required_fields({}) + 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_get_conversion_event_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 @@ -41828,14 +46911,16 @@ 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_get_display_video360_advertiser_link_proposal", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_conversion_event" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_get_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetConversionEventRequest.pb( - analytics_admin.GetConversionEventRequest() + pb_message = analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest() ) transcode.return_value = { "method": "post", @@ -41847,19 +46932,21 @@ 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.DisplayVideo360AdvertiserLinkProposal.to_json( + resources.DisplayVideo360AdvertiserLinkProposal() + ) ) - request = analytics_admin.GetConversionEventRequest() + request = analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.ConversionEvent() + post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() - client.get_conversion_event( + client.get_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -41871,8 +46958,9 @@ 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_get_display_video360_advertiser_link_proposal_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -41880,7 +46968,9 @@ def test_get_conversion_event_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/conversionEvents/sample2"} + 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. @@ -41892,10 +46982,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.get_display_video360_advertiser_link_proposal(request) -def test_get_conversion_event_rest_flattened(): +def test_get_display_video360_advertiser_link_proposal_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -41904,10 +46994,12 @@ 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.DisplayVideo360AdvertiserLinkProposal() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/conversionEvents/sample2"} + sample_request = { + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + } # get truthy value for each flattened field mock_args = dict( @@ -41918,25 +47010,29 @@ def test_get_conversion_event_rest_flattened(): # 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 - client.get_conversion_event(**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/{name=properties/*/conversionEvents/*}" + "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}" % client.transport._host, args[1], ) -def test_get_conversion_event_rest_flattened_error(transport: str = "rest"): +def test_get_display_video360_advertiser_link_proposal_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -41945,13 +47041,13 @@ 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(), + client.get_display_video360_advertiser_link_proposal( + analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest(), name="name_value", ) -def test_get_conversion_event_rest_error(): +def test_get_display_video360_advertiser_link_proposal_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -41960,45 +47056,55 @@ def test_get_conversion_event_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteConversionEventRequest, + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, dict, ], ) -def test_delete_conversion_event_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 = {"name": "properties/sample1/conversionEvents/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 = None + 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 - json_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.delete_conversion_event(request) + response = client.list_display_video360_advertiser_link_proposals(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, pagers.ListDisplayVideo360AdvertiserLinkProposalsPager) + assert response.next_page_token == "next_page_token_value" -def test_delete_conversion_event_rest_required_fields( - request_type=analytics_admin.DeleteConversionEventRequest, +def test_list_display_video360_advertiser_link_proposals_rest_required_fields( + request_type=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, ): 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( @@ -42013,21 +47119,32 @@ 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) + ).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["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_conversion_event._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 "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(), @@ -42036,7 +47153,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 = 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 @@ -42048,36 +47165,54 @@ def test_delete_conversion_event_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 = ( + 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.delete_conversion_event(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_delete_conversion_event_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.delete_conversion_event._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) - + unset_fields = transport.list_display_video360_advertiser_link_proposals._get_unset_required_fields( + {} + ) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_conversion_event_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 @@ -42090,11 +47225,18 @@ 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_list_display_video360_advertiser_link_proposals", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_list_display_video360_advertiser_link_proposals", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteConversionEventRequest.pb( - analytics_admin.DeleteConversionEventRequest() + post.assert_not_called() + pb_message = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest.pb( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest() + ) ) transcode.return_value = { "method": "post", @@ -42106,15 +47248,23 @@ 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 = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.to_json( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() + ) + ) - request = analytics_admin.DeleteConversionEventRequest() + request = analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() + ) - client.delete_conversion_event( + client.list_display_video360_advertiser_link_proposals( request, metadata=[ ("key", "val"), @@ -42123,10 +47273,12 @@ 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_list_display_video360_advertiser_link_proposals_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42134,7 +47286,7 @@ def test_delete_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 = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -42146,10 +47298,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.list_display_video360_advertiser_link_proposals(request) -def test_delete_conversion_event_rest_flattened(): +def test_list_display_video360_advertiser_link_proposals_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -42158,38 +47310,47 @@ 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 = ( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() + ) # 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", ) 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 = ( + 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.delete_conversion_event(**mock_args) + 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/{name=properties/*/conversionEvents/*}" + "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinkProposals" % client.transport._host, args[1], ) -def test_delete_conversion_event_rest_flattened_error(transport: str = "rest"): +def test_list_display_video360_advertiser_link_proposals_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -42198,26 +47359,97 @@ 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.list_display_video360_advertiser_link_proposals( + analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest(), + parent="parent_value", ) -def test_delete_conversion_event_rest_error(): +def test_list_display_video360_advertiser_link_proposals_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.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.ListConversionEventsRequest, + analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_list_conversion_events_rest(request_type): +def test_create_display_video360_advertiser_link_proposal_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -42225,32 +47457,54 @@ def test_list_conversion_events_rest(request_type): # 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 = 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.ListConversionEventsResponse( - 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.ListConversionEventsResponse.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.list_conversion_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.ListConversionEventsPager) - 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_list_conversion_events_rest_required_fields( - request_type=analytics_admin.ListConversionEventsRequest, +def test_create_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -42270,7 +47524,9 @@ 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) + ).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 @@ -42279,13 +47535,8 @@ 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) - # 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_proposal._get_unset_required_fields( + jsonified_request ) jsonified_request.update(unset_fields) @@ -42300,7 +47551,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 = 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 @@ -42312,15 +47563,16 @@ def test_list_conversion_events_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.ListConversionEventsResponse.pb( + pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( return_value ) json_return_value = json_format.MessageToJson(pb_return_value) @@ -42328,32 +47580,36 @@ 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.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_list_conversion_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.list_conversion_events._get_unset_required_fields({}) + unset_fields = transport.create_display_video360_advertiser_link_proposal._get_unset_required_fields( + {} + ) assert set(unset_fields) == ( - set( + set(()) + & set( ( - "pageSize", - "pageToken", + "parent", + "displayVideo360AdvertiserLinkProposal", ) ) - & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_conversion_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 @@ -42366,14 +47622,18 @@ 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_create_display_video360_advertiser_link_proposal", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_conversion_events" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_create_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListConversionEventsRequest.pb( - analytics_admin.ListConversionEventsRequest() + pb_message = ( + analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest() + ) ) transcode.return_value = { "method": "post", @@ -42386,20 +47646,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() + resources.DisplayVideo360AdvertiserLinkProposal.to_json( + resources.DisplayVideo360AdvertiserLinkProposal() ) ) - request = analytics_admin.ListConversionEventsRequest() + request = analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListConversionEventsResponse() + post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() - client.list_conversion_events( + client.create_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -42411,8 +47671,9 @@ 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_create_display_video360_advertiser_link_proposal_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42421,6 +47682,20 @@ def test_list_conversion_events_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 = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -42432,10 +47707,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.create_display_video360_advertiser_link_proposal(request) -def test_list_conversion_events_rest_flattened(): +def test_create_display_video360_advertiser_link_proposal_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -42444,7 +47719,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 = resources.DisplayVideo360AdvertiserLinkProposal() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -42452,31 +47727,38 @@ def test_list_conversion_events_rest_flattened(): # get truthy value for each flattened field mock_args = dict( parent="parent_value", + display_video_360_advertiser_link_proposal=resources.DisplayVideo360AdvertiserLinkProposal( + 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.ListConversionEventsResponse.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.list_conversion_events(**mock_args) + client.create_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/{parent=properties/*}/conversionEvents" + "%s/v1alpha/{parent=properties/*}/displayVideo360AdvertiserLinkProposals" % client.transport._host, args[1], ) -def test_list_conversion_events_rest_flattened_error(transport: str = "rest"): +def test_create_display_video360_advertiser_link_proposal_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -42485,120 +47767,60 @@ 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.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_list_conversion_events_rest_pager(transport: str = "rest"): +def test_create_display_video360_advertiser_link_proposal_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.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - next_page_token="abc", - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[], - next_page_token="def", - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - ], - next_page_token="ghi", - ), - analytics_admin.ListConversionEventsResponse( - conversion_events=[ - resources.ConversionEvent(), - resources.ConversionEvent(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - 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): - 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_conversion_events(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.ConversionEvent) for i in results) - - 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 - @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, + analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_get_display_video360_advertiser_link_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/displayVideo360AdvertiserLinks/sample2"} + 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.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.delete_display_video360_advertiser_link_proposal(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_delete_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -42618,7 +47840,9 @@ 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) + ).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 @@ -42627,7 +47851,9 @@ 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) + ).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 @@ -42641,7 +47867,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 @@ -42653,40 +47879,40 @@ 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": "delete", "query_params": 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.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_display_video360_advertiser_link_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_display_video360_advertiser_link._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_display_video360_advertiser_link_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 @@ -42700,15 +47926,13 @@ def test_get_display_video360_advertiser_link_rest_interceptors(null_interceptor 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", + "pre_delete_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.GetDisplayVideo360AdvertiserLinkRequest.pb( - analytics_admin.GetDisplayVideo360AdvertiserLinkRequest() + pb_message = ( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest() + ) ) transcode.return_value = { "method": "post", @@ -42720,19 +47944,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.DeleteDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLink() - client.get_display_video360_advertiser_link( + client.delete_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -42741,12 +47961,11 @@ 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( +def test_delete_display_video360_advertiser_link_proposal_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, + request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -42754,7 +47973,9 @@ 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/displayVideo360AdvertiserLinkProposals/sample2" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -42766,10 +47987,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.delete_display_video360_advertiser_link_proposal(request) -def test_get_display_video360_advertiser_link_rest_flattened(): +def test_delete_display_video360_advertiser_link_proposal_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -42778,11 +47999,11 @@ 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" + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } # get truthy value for each flattened field @@ -42794,25 +48015,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.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/*/displayVideo360AdvertiserLinks/*}" + "%s/v1alpha/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}" % client.transport._host, args[1], ) -def test_get_display_video360_advertiser_link_rest_flattened_error( +def test_delete_display_video360_advertiser_link_proposal_rest_flattened_error( transport: str = "rest", ): client = AnalyticsAdminServiceClient( @@ -42823,13 +48043,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.delete_display_video360_advertiser_link_proposal( + analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest(), name="name_value", ) -def test_get_display_video360_advertiser_link_rest_error(): +def test_delete_display_video360_advertiser_link_proposal_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -42838,51 +48058,56 @@ def test_get_display_video360_advertiser_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_list_display_video360_advertiser_links_rest(request_type): +def test_approve_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 = { + "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 = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse( - next_page_token="next_page_token_value", + return_value = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() ) # 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 = ( + 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.list_display_video360_advertiser_links(request) + response = client.approve_display_video360_advertiser_link_proposal(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, analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse + ) -def test_list_display_video360_advertiser_links_rest_required_fields( - request_type=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, +def test_approve_display_video360_advertiser_link_proposal_rest_required_fields( + request_type=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, ): 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( @@ -42897,32 +48122,25 @@ 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( + ).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["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", - ) + ).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 "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(), @@ -42931,7 +48149,9 @@ 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 = ( + 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 @@ -42943,16 +48163,17 @@ def test_list_display_video360_advertiser_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.ListDisplayVideo360AdvertiserLinksResponse.pb( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.pb( return_value ) ) @@ -42961,34 +48182,28 @@ def test_list_display_video360_advertiser_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_display_video360_advertiser_links(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_list_display_video360_advertiser_links_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.list_display_video360_advertiser_links._get_unset_required_fields({}) - ) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) + unset_fields = transport.approve_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_list_display_video360_advertiser_links_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 @@ -43002,15 +48217,17 @@ def test_list_display_video360_advertiser_links_rest_interceptors(null_intercept path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_list_display_video360_advertiser_links", + "post_approve_display_video360_advertiser_link_proposal", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_list_display_video360_advertiser_links", + "pre_approve_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest.pb( - analytics_admin.ListDisplayVideo360AdvertiserLinksRequest() + pb_message = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest() + ) ) transcode.return_value = { "method": "post", @@ -43022,21 +48239,21 @@ 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 = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.to_json( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() ) - request = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest() + request = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() + post.return_value = ( + analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() + ) - client.list_display_video360_advertiser_links( + client.approve_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -43048,9 +48265,9 @@ 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( +def test_approve_display_video360_advertiser_link_proposal_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, + request_type=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43058,7 +48275,9 @@ 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/displayVideo360AdvertiserLinkProposals/sample2" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -43070,195 +48289,71 @@ 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) - - -def test_list_display_video360_advertiser_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.ListDisplayVideo360AdvertiserLinksResponse() - - # 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.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.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/{parent=properties/*}/displayVideo360AdvertiserLinks" - % client.transport._host, - args[1], - ) - - -def test_list_display_video360_advertiser_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_display_video360_advertiser_links( - analytics_admin.ListDisplayVideo360AdvertiserLinksRequest(), - parent="parent_value", - ) + client.approve_display_video360_advertiser_link_proposal(request) -def test_list_display_video360_advertiser_links_rest_pager(transport: str = "rest"): +def test_approve_display_video360_advertiser_link_proposal_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.CancelDisplayVideo360AdvertiserLinkProposalRequest, dict, ], ) -def test_create_display_video360_advertiser_link_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["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_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.DisplayVideo360AdvertiserLink( + 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 = resources.DisplayVideo360AdvertiserLink.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_display_video360_advertiser_link(request) + response = client.cancel_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLink) + 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_create_display_video360_advertiser_link_rest_required_fields( - request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, +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( @@ -43273,25 +48368,25 @@ 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( + ).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_display_video360_advertiser_link._get_unset_required_fields( + ).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(), @@ -43300,7 +48395,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.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 @@ -43321,40 +48416,36 @@ 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.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_display_video360_advertiser_link(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_display_video360_advertiser_link_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_display_video360_advertiser_link._get_unset_required_fields({}) - ) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "displayVideo360AdvertiserLink", - ) - ) + 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_display_video360_advertiser_link_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 @@ -43368,15 +48459,17 @@ def test_create_display_video360_advertiser_link_rest_interceptors(null_intercep path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_create_display_video360_advertiser_link", + "post_cancel_display_video360_advertiser_link_proposal", ) as post, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "pre_create_display_video360_advertiser_link", + "pre_cancel_display_video360_advertiser_link_proposal", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest.pb( - analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest() + pb_message = ( + analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest.pb( + analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest() + ) ) transcode.return_value = { "method": "post", @@ -43388,19 +48481,21 @@ 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.DisplayVideo360AdvertiserLinkProposal.to_json( + resources.DisplayVideo360AdvertiserLinkProposal() + ) ) - request = analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest() + request = analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLink() + post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() - client.create_display_video360_advertiser_link( + client.cancel_display_video360_advertiser_link_proposal( request, metadata=[ ("key", "val"), @@ -43412,9 +48507,9 @@ 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( +def test_cancel_display_video360_advertiser_link_proposal_rest_bad_request( transport: str = "rest", - request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, + request_type=analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43422,14 +48517,8 @@ 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"] = { - "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_init = { + "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" } request = request_type(**request_init) @@ -43442,74 +48531,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) - - -def test_create_display_video360_advertiser_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.DisplayVideo360AdvertiserLink() - - # 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=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 = 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.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/*}/displayVideo360AdvertiserLinks" - % client.transport._host, - args[1], - ) - - -def test_create_display_video360_advertiser_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_display_video360_advertiser_link( - analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest(), - parent="parent_value", - display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( - name="name_value" - ), - ) + client.cancel_display_video360_advertiser_link_proposal(request) -def test_create_display_video360_advertiser_link_rest_error(): +def test_cancel_display_video360_advertiser_link_proposal_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -43518,45 +48543,67 @@ def test_create_display_video360_advertiser_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, + analytics_admin.CreateCustomDimensionRequest, dict, ], ) -def test_delete_display_video360_advertiser_link_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/displayVideo360AdvertiserLinks/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 = 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_display_video360_advertiser_link(request) + response = client.create_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_display_video360_advertiser_link_rest_required_fields( - request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, +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( @@ -43571,25 +48618,21 @@ 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 - ) + ).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() - ).delete_display_video360_advertiser_link._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(), @@ -43598,7 +48641,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.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 @@ -43610,38 +48653,47 @@ 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": "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 = 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_display_video360_advertiser_link(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_delete_display_video360_advertiser_link_rest_unset_required_fields(): +def test_create_custom_dimension_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.delete_display_video360_advertiser_link._get_unset_required_fields({}) + unset_fields = transport.create_custom_dimension._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "customDimension", + ) + ) ) - assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_display_video360_advertiser_link_rest_interceptors(null_interceptor): +def test_create_custom_dimension_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -43654,12 +48706,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_create_custom_dimension" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_custom_dimension" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest.pb( - analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() + post.assert_not_called() + pb_message = analytics_admin.CreateCustomDimensionRequest.pb( + analytics_admin.CreateCustomDimensionRequest() ) transcode.return_value = { "method": "post", @@ -43671,15 +48725,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.CustomDimension.to_json( + resources.CustomDimension() + ) - request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() + request = analytics_admin.CreateCustomDimensionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.CustomDimension() - client.delete_display_video360_advertiser_link( + client.create_custom_dimension( request, metadata=[ ("key", "val"), @@ -43688,11 +48746,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_create_custom_dimension_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateCustomDimensionRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43700,7 +48758,15 @@ 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 = {"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. @@ -43712,10 +48778,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.create_custom_dimension(request) -def test_delete_display_video360_advertiser_link_rest_flattened(): +def test_create_custom_dimension_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -43724,42 +48790,40 @@ 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.CustomDimension() # get arguments that satisfy an http rule for this method - sample_request = { - "name": "properties/sample1/displayVideo360AdvertiserLinks/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 - 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_display_video360_advertiser_link(**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/*/displayVideo360AdvertiserLinks/*}" + "%s/v1alpha/{parent=properties/*}/customDimensions" % client.transport._host, args[1], ) -def test_delete_display_video360_advertiser_link_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, @@ -43768,13 +48832,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.create_custom_dimension( + analytics_admin.CreateCustomDimensionRequest(), + parent="parent_value", + custom_dimension=resources.CustomDimension(name="name_value"), ) -def test_delete_display_video360_advertiser_link_rest_error(): +def test_create_custom_dimension_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -43783,11 +48848,11 @@ def test_delete_display_video360_advertiser_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, + analytics_admin.UpdateCustomDimensionRequest, dict, ], ) -def test_update_display_video360_advertiser_link_rest(request_type): +def test_update_custom_dimension_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -43795,48 +48860,52 @@ def test_update_display_video360_advertiser_link_rest(request_type): # send a request that will satisfy transcoding request_init = { - "display_video_360_advertiser_link": { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" - } + "custom_dimension": {"name": "properties/sample1/customDimensions/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["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 = resources.DisplayVideo360AdvertiserLink( + return_value = resources.CustomDimension( 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", + 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.DisplayVideo360AdvertiserLink.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.update_display_video360_advertiser_link(request) + response = client.update_custom_dimension(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLink) + assert isinstance(response, resources.CustomDimension) 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.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True -def test_update_display_video360_advertiser_link_rest_required_fields( - request_type=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, +def test_update_custom_dimension_rest_required_fields( + request_type=analytics_admin.UpdateCustomDimensionRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -43855,18 +48924,14 @@ 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 - ) + ).update_custom_dimension._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_display_video360_advertiser_link._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) @@ -43880,7 +48945,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 = 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 @@ -43901,32 +48966,30 @@ def test_update_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.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.update_display_video360_advertiser_link(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_update_display_video360_advertiser_link_rest_unset_required_fields(): +def test_update_custom_dimension_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.update_custom_dimension._get_unset_required_fields({}) 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_update_custom_dimension_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -43939,16 +49002,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_update_custom_dimension" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_display_video360_advertiser_link", + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_custom_dimension" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest.pb( - analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest() + pb_message = analytics_admin.UpdateCustomDimensionRequest.pb( + analytics_admin.UpdateCustomDimensionRequest() ) transcode.return_value = { "method": "post", @@ -43960,19 +49021,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 = resources.CustomDimension.to_json( + resources.CustomDimension() ) - request = analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest() + request = analytics_admin.UpdateCustomDimensionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLink() + post.return_value = resources.CustomDimension() - client.update_display_video360_advertiser_link( + client.update_custom_dimension( request, metadata=[ ("key", "val"), @@ -43984,9 +49045,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_update_custom_dimension_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateCustomDimensionRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -43995,17 +49055,15 @@ 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" - } + "custom_dimension": {"name": "properties/sample1/customDimensions/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["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) @@ -44018,10 +49076,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.update_custom_dimension(request) -def test_update_display_video360_advertiser_link_rest_flattened(): +def test_update_custom_dimension_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -44030,20 +49088,16 @@ 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 = resources.CustomDimension() # get arguments that satisfy an http rule for this method sample_request = { - "display_video_360_advertiser_link": { - "name": "properties/sample1/displayVideo360AdvertiserLinks/sample2" - } + "custom_dimension": {"name": "properties/sample1/customDimensions/sample2"} } # get truthy value for each flattened field mock_args = dict( - display_video_360_advertiser_link=resources.DisplayVideo360AdvertiserLink( - name="name_value" - ), + custom_dimension=resources.CustomDimension(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) @@ -44051,27 +49105,25 @@ def test_update_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) + 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.update_display_video360_advertiser_link(**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/{display_video_360_advertiser_link.name=properties/*/displayVideo360AdvertiserLinks/*}" + "%s/v1alpha/{custom_dimension.name=properties/*/customDimensions/*}" % client.transport._host, args[1], ) -def test_update_display_video360_advertiser_link_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, @@ -44080,16 +49132,14 @@ 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" - ), + 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_update_display_video360_advertiser_link_rest_error(): +def test_update_custom_dimension_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -44098,59 +49148,49 @@ def test_update_display_video360_advertiser_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.ListCustomDimensionsRequest, dict, ], ) -def test_get_display_video360_advertiser_link_proposal_rest(request_type): +def test_list_custom_dimensions_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 = 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 = 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 = resources.DisplayVideo360AdvertiserLinkProposal.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.get_display_video360_advertiser_link_proposal(request) + response = client.list_custom_dimensions(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 isinstance(response, pagers.ListCustomDimensionsPager) + assert response.next_page_token == "next_page_token_value" -def test_get_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, +def test_list_custom_dimensions_rest_required_fields( + request_type=analytics_admin.ListCustomDimensionsRequest, ): 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( @@ -44165,25 +49205,28 @@ 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 - ) + ).list_custom_dimensions._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_display_video360_advertiser_link_proposal._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( + ( + "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(), @@ -44192,7 +49235,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 = 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 @@ -44212,7 +49255,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DisplayVideo360AdvertiserLinkProposal.pb( + pb_return_value = analytics_admin.ListCustomDimensionsResponse.pb( return_value ) json_return_value = json_format.MessageToJson(pb_return_value) @@ -44220,28 +49263,32 @@ def test_get_display_video360_advertiser_link_proposal_rest_required_fields( 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.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_get_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_list_custom_dimensions_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.list_custom_dimensions._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_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +def test_list_custom_dimensions_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -44254,16 +49301,14 @@ 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", + transports.AnalyticsAdminServiceRestInterceptor, "post_list_custom_dimensions" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_custom_dimensions" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest() + pb_message = analytics_admin.ListCustomDimensionsRequest.pb( + analytics_admin.ListCustomDimensionsRequest() ) transcode.return_value = { "method": "post", @@ -44276,20 +49321,20 @@ def test_get_display_video360_advertiser_link_proposal_rest_interceptors( req.return_value.status_code = 200 req.return_value.request = PreparedRequest() req.return_value._content = ( - resources.DisplayVideo360AdvertiserLinkProposal.to_json( - resources.DisplayVideo360AdvertiserLinkProposal() + analytics_admin.ListCustomDimensionsResponse.to_json( + analytics_admin.ListCustomDimensionsResponse() ) ) - request = analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.ListCustomDimensionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() + post.return_value = analytics_admin.ListCustomDimensionsResponse() - client.get_display_video360_advertiser_link_proposal( + client.list_custom_dimensions( request, metadata=[ ("key", "val"), @@ -44301,9 +49346,8 @@ def test_get_display_video360_advertiser_link_proposal_rest_interceptors( 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_list_custom_dimensions_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListCustomDimensionsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -44311,9 +49355,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 = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -44325,10 +49367,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.list_custom_dimensions(request) -def test_get_display_video360_advertiser_link_proposal_rest_flattened(): +def test_list_custom_dimensions_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -44337,45 +49379,39 @@ 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 = analytics_admin.ListCustomDimensionsResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/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.DisplayVideo360AdvertiserLinkProposal.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.get_display_video360_advertiser_link_proposal(**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/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}" + "%s/v1alpha/{parent=properties/*}/customDimensions" % client.transport._host, args[1], ) -def test_get_display_video360_advertiser_link_proposal_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, @@ -44384,70 +49420,117 @@ 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(), - name="name_value", + client.list_custom_dimensions( + analytics_admin.ListCustomDimensionsRequest(), + parent="parent_value", ) -def test_get_display_video360_advertiser_link_proposal_rest_error(): +def test_list_custom_dimensions_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.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.ListDisplayVideo360AdvertiserLinkProposalsRequest, + analytics_admin.ArchiveCustomDimensionRequest, dict, ], ) -def test_list_display_video360_advertiser_link_proposals_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 = {"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.ListDisplayVideo360AdvertiserLinkProposalsResponse( - 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.ListDisplayVideo360AdvertiserLinkProposalsResponse.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_display_video360_advertiser_link_proposals(request) + response = client.archive_custom_dimension(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 response is None -def test_list_display_video360_advertiser_link_proposals_rest_required_fields( - request_type=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, +def test_archive_custom_dimension_rest_required_fields( + request_type=analytics_admin.ArchiveCustomDimensionRequest, ): 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( @@ -44462,32 +49545,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 - ) + ).archive_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_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", - ) - ) + ).archive_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(), @@ -44496,7 +49568,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 = 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 @@ -44508,54 +49580,37 @@ def test_list_display_video360_advertiser_link_proposals_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.ListDisplayVideo360AdvertiserLinkProposalsResponse.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_display_video360_advertiser_link_proposals(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_list_display_video360_advertiser_link_proposals_rest_unset_required_fields(): +def test_archive_custom_dimension_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.archive_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_link_proposals_rest_interceptors( - null_interceptor, -): +def test_archive_custom_dimension_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -44568,18 +49623,11 @@ 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", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_list_display_video360_advertiser_link_proposals", + transports.AnalyticsAdminServiceRestInterceptor, "pre_archive_custom_dimension" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest.pb( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest() - ) + pb_message = analytics_admin.ArchiveCustomDimensionRequest.pb( + analytics_admin.ArchiveCustomDimensionRequest() ) transcode.return_value = { "method": "post", @@ -44591,23 +49639,15 @@ 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() - ) - ) - request = analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest() + request = analytics_admin.ArchiveCustomDimensionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = ( - analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() - ) - client.list_display_video360_advertiser_link_proposals( + client.archive_custom_dimension( request, metadata=[ ("key", "val"), @@ -44616,12 +49656,10 @@ def test_list_display_video360_advertiser_link_proposals_rest_interceptors( ) pre.assert_called_once() - 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_archive_custom_dimension_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ArchiveCustomDimensionRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -44629,7 +49667,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/customDimensions/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -44641,10 +49679,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.archive_custom_dimension(request) -def test_list_display_video360_advertiser_link_proposals_rest_flattened(): +def test_archive_custom_dimension_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -44653,206 +49691,114 @@ 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 = None # 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.ListDisplayVideo360AdvertiserLinkProposalsResponse.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_display_video360_advertiser_link_proposals(**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/{parent=properties/*}/displayVideo360AdvertiserLinkProposals" + "%s/v1alpha/{name=properties/*/customDimensions/*}:archive" % 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", -): +def test_archive_custom_dimension_rest_flattened_error(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 + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.archive_custom_dimension( + analytics_admin.ArchiveCustomDimensionRequest(), + name="name_value", ) - 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 +def test_archive_custom_dimension_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.GetCustomDimensionRequest, dict, ], ) -def test_create_display_video360_advertiser_link_proposal_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["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/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.DisplayVideo360AdvertiserLinkProposal( + return_value = resources.CustomDimension( name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", - validation_email="validation_email_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 = resources.DisplayVideo360AdvertiserLinkProposal.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.create_display_video360_advertiser_link_proposal(request) + response = client.get_custom_dimension(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DisplayVideo360AdvertiserLinkProposal) + assert isinstance(response, resources.CustomDimension) 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.parameter_name == "parameter_name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.scope == resources.CustomDimension.DimensionScope.EVENT + assert response.disallow_ads_personalization is True -def test_create_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, +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( @@ -44867,25 +49813,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_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() - ).create_display_video360_advertiser_link_proposal._get_unset_required_fields( - jsonified_request - ) + ).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(), @@ -44894,7 +49836,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.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 @@ -44906,53 +49848,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.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.create_display_video360_advertiser_link_proposal(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_create_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_get_custom_dimension_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_custom_dimension._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_custom_dimension_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -44965,18 +49892,14 @@ def test_create_display_video360_advertiser_link_proposal_rest_interceptors( ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_create_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "post_get_custom_dimension" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_create_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_custom_dimension" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest() - ) + pb_message = analytics_admin.GetCustomDimensionRequest.pb( + analytics_admin.GetCustomDimensionRequest() ) transcode.return_value = { "method": "post", @@ -44988,21 +49911,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.CustomDimension.to_json( + resources.CustomDimension() ) - request = analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.GetCustomDimensionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() + post.return_value = resources.CustomDimension() - client.create_display_video360_advertiser_link_proposal( + client.get_custom_dimension( request, metadata=[ ("key", "val"), @@ -45014,9 +49935,8 @@ 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( - transport: str = "rest", - request_type=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, +def test_get_custom_dimension_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetCustomDimensionRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45024,21 +49944,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/customDimensions/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -45050,10 +49956,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_custom_dimension(request) -def test_create_display_video360_advertiser_link_proposal_rest_flattened(): +def test_get_custom_dimension_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -45062,46 +49968,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.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", - 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.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.create_display_video360_advertiser_link_proposal(**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/*}/displayVideo360AdvertiserLinkProposals" + "%s/v1alpha/{name=properties/*/customDimensions/*}" % client.transport._host, args[1], ) -def test_create_display_video360_advertiser_link_proposal_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, @@ -45110,16 +50009,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_custom_dimension( + analytics_admin.GetCustomDimensionRequest(), + name="name_value", ) -def test_create_display_video360_advertiser_link_proposal_rest_error(): +def test_get_custom_dimension_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -45128,47 +50024,74 @@ def test_create_display_video360_advertiser_link_proposal_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.CreateCustomMetricRequest, dict, ], ) -def test_delete_display_video360_advertiser_link_proposal_rest(request_type): +def test_create_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 = {"parent": "properties/sample1"} + request_init["custom_metric"] = { + "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], } 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_proposal(request) + response = client.create_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_proposal_rest_required_fields( - request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, +def test_create_custom_metric_rest_required_fields( + request_type=analytics_admin.CreateCustomMetricRequest, ): 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( @@ -45183,25 +50106,21 @@ 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 - ) + ).create_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" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_display_video360_advertiser_link_proposal._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 - 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(), @@ -45210,7 +50129,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.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 @@ -45222,40 +50141,47 @@ 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": "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 = 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_proposal(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_delete_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_create_custom_metric_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.create_custom_metric._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "customMetric", + ) + ) ) - assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +def test_create_custom_metric_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -45268,14 +50194,14 @@ def test_delete_display_video360_advertiser_link_proposal_rest_interceptors( ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_delete_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "post_create_custom_metric" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_custom_metric" ) as pre: pre.assert_not_called() - pb_message = ( - analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest() - ) + post.assert_not_called() + pb_message = analytics_admin.CreateCustomMetricRequest.pb( + analytics_admin.CreateCustomMetricRequest() ) transcode.return_value = { "method": "post", @@ -45287,15 +50213,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.CustomMetric.to_json( + resources.CustomMetric() + ) - request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.CreateCustomMetricRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.CustomMetric() - client.delete_display_video360_advertiser_link_proposal( + client.create_custom_metric( request, metadata=[ ("key", "val"), @@ -45304,11 +50234,11 @@ 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( - transport: str = "rest", - request_type=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, +def test_create_custom_metric_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateCustomMetricRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45316,8 +50246,15 @@ 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" + request_init = {"parent": "properties/sample1"} + request_init["custom_metric"] = { + "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], } request = request_type(**request_init) @@ -45330,10 +50267,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.create_custom_metric(request) -def test_delete_display_video360_advertiser_link_proposal_rest_flattened(): +def test_create_custom_metric_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -45342,42 +50279,39 @@ 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.CustomMetric() # get arguments that satisfy an http rule for this method - sample_request = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" - } + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_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 - 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_proposal(**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/{name=properties/*/displayVideo360AdvertiserLinkProposals/*}" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/customMetrics" % client.transport._host, args[1], ) -def test_delete_display_video360_advertiser_link_proposal_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, @@ -45386,13 +50320,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.create_custom_metric( + analytics_admin.CreateCustomMetricRequest(), + parent="parent_value", + custom_metric=resources.CustomMetric(name="name_value"), ) -def test_delete_display_video360_advertiser_link_proposal_rest_error(): +def test_create_custom_metric_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -45401,11 +50336,11 @@ def test_delete_display_video360_advertiser_link_proposal_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.UpdateCustomMetricRequest, dict, ], ) -def test_approve_display_video360_advertiser_link_proposal_rest(request_type): +def test_update_custom_metric_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -45413,44 +50348,63 @@ def test_approve_display_video360_advertiser_link_proposal_rest(request_type): # send a request that will satisfy transcoding request_init = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/sample2" + "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 = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() + 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.ApproveDisplayVideo360AdvertiserLinkProposalResponse.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.approve_display_video360_advertiser_link_proposal(request) + response = client.update_custom_metric(request) # Establish that the response is the type that we expect. - assert isinstance( - response, analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse - ) + 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_approve_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, +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( @@ -45465,25 +50419,19 @@ 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 - ) + ).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() - ).approve_display_video360_advertiser_link_proposal._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(), @@ -45492,9 +50440,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.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 @@ -45506,7 +50452,7 @@ def test_approve_display_video360_advertiser_link_proposal_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 @@ -45515,38 +50461,30 @@ 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.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.approve_display_video360_advertiser_link_proposal(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_approve_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_update_custom_metric_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.approve_display_video360_advertiser_link_proposal._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_approve_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_custom_metric_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -45559,18 +50497,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_update_custom_metric" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_approve_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_custom_metric" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest() - ) + pb_message = analytics_admin.UpdateCustomMetricRequest.pb( + analytics_admin.UpdateCustomMetricRequest() ) transcode.return_value = { "method": "post", @@ -45582,21 +50516,19 @@ 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.CustomMetric.to_json( + resources.CustomMetric() ) - request = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.UpdateCustomMetricRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = ( - analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() - ) + post.return_value = resources.CustomMetric() - client.approve_display_video360_advertiser_link_proposal( + client.update_custom_metric( request, metadata=[ ("key", "val"), @@ -45608,9 +50540,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_update_custom_metric_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateCustomMetricRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45619,7 +50550,16 @@ 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" + "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) @@ -45632,10 +50572,70 @@ 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.update_custom_metric(request) -def test_approve_display_video360_advertiser_link_proposal_rest_error(): +def test_update_custom_metric_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.CustomMetric() + + # get arguments that satisfy an http rule for this method + sample_request = { + "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} + } + + # get truthy value for each flattened field + mock_args = dict( + 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 + 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.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/{custom_metric.name=properties/*/customMetrics/*}" + % client.transport._host, + args[1], + ) + + +def test_update_custom_metric_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_custom_metric( + analytics_admin.UpdateCustomMetricRequest(), + custom_metric=resources.CustomMetric(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_custom_metric_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -45644,59 +50644,49 @@ def test_approve_display_video360_advertiser_link_proposal_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, + analytics_admin.ListCustomMetricsRequest, dict, ], ) -def test_cancel_display_video360_advertiser_link_proposal_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 = { - "name": "properties/sample1/displayVideo360AdvertiserLinkProposals/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.DisplayVideo360AdvertiserLinkProposal( - name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_name_value", - validation_email="validation_email_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.DisplayVideo360AdvertiserLinkProposal.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.cancel_display_video360_advertiser_link_proposal(request) + response = client.list_custom_metrics(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 isinstance(response, pagers.ListCustomMetricsPager) + assert response.next_page_token == "next_page_token_value" -def test_cancel_display_video360_advertiser_link_proposal_rest_required_fields( - request_type=analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, +def test_list_custom_metrics_rest_required_fields( + request_type=analytics_admin.ListCustomMetricsRequest, ): 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( @@ -45711,25 +50701,28 @@ 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 - ) + ).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["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).cancel_display_video360_advertiser_link_proposal._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( + ( + "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(), @@ -45738,7 +50731,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 = 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 @@ -45750,45 +50743,46 @@ 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": "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 = 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.cancel_display_video360_advertiser_link_proposal(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_cancel_display_video360_advertiser_link_proposal_rest_unset_required_fields(): +def test_list_custom_metrics_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.list_custom_metrics._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_cancel_display_video360_advertiser_link_proposal_rest_interceptors( - null_interceptor, -): +def test_list_custom_metrics_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -45801,18 +50795,14 @@ 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", + transports.AnalyticsAdminServiceRestInterceptor, "post_list_custom_metrics" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_cancel_display_video360_advertiser_link_proposal", + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_custom_metrics" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest.pb( - analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest() - ) + pb_message = analytics_admin.ListCustomMetricsRequest.pb( + analytics_admin.ListCustomMetricsRequest() ) transcode.return_value = { "method": "post", @@ -45824,21 +50814,19 @@ 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() - ) + req.return_value._content = analytics_admin.ListCustomMetricsResponse.to_json( + analytics_admin.ListCustomMetricsResponse() ) - request = analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest() + request = analytics_admin.ListCustomMetricsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DisplayVideo360AdvertiserLinkProposal() + post.return_value = analytics_admin.ListCustomMetricsResponse() - client.cancel_display_video360_advertiser_link_proposal( + client.list_custom_metrics( request, metadata=[ ("key", "val"), @@ -45850,9 +50838,8 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_interceptors( 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_list_custom_metrics_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListCustomMetricsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -45860,9 +50847,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 = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -45874,79 +50859,169 @@ 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.list_custom_metrics(request) -def test_cancel_display_video360_advertiser_link_proposal_rest_error(): +def test_list_custom_metrics_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.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", + ) + + +def test_list_custom_metrics_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.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.CreateCustomDimensionRequest, + analytics_admin.ArchiveCustomMetricRequest, dict, ], ) -def test_create_custom_dimension_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 = {"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_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.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 = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomDimension.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_custom_dimension(request) + response = client.archive_custom_metric(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 response is None -def test_create_custom_dimension_rest_required_fields( - request_type=analytics_admin.CreateCustomDimensionRequest, +def test_archive_custom_metric_rest_required_fields( + request_type=analytics_admin.ArchiveCustomMetricRequest, ): 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( @@ -45961,21 +51036,21 @@ 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) + ).archive_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() - ).create_custom_dimension._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 - 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(), @@ -45984,7 +51059,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 = 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 @@ -46004,39 +51079,29 @@ def test_create_custom_dimension_rest_required_fields( response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.CustomDimension.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_custom_dimension(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_create_custom_dimension_rest_unset_required_fields(): +def test_archive_custom_metric_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.archive_custom_metric._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_custom_dimension_rest_interceptors(null_interceptor): +def test_archive_custom_metric_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -46049,14 +51114,11 @@ 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" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "pre_archive_custom_metric" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreateCustomDimensionRequest.pb( - analytics_admin.CreateCustomDimensionRequest() + pb_message = analytics_admin.ArchiveCustomMetricRequest.pb( + analytics_admin.ArchiveCustomMetricRequest() ) transcode.return_value = { "method": "post", @@ -46068,19 +51130,15 @@ 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() - ) - request = analytics_admin.CreateCustomDimensionRequest() + request = analytics_admin.ArchiveCustomMetricRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomDimension() - client.create_custom_dimension( + client.archive_custom_metric( request, metadata=[ ("key", "val"), @@ -46089,11 +51147,10 @@ def test_create_custom_dimension_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_custom_dimension_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateCustomDimensionRequest +def test_archive_custom_metric_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ArchiveCustomMetricRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46101,15 +51158,7 @@ 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", - "display_name": "display_name_value", - "description": "description_value", - "scope": 1, - "disallow_ads_personalization": True, - } + 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. @@ -46121,10 +51170,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.archive_custom_metric(request) -def test_create_custom_dimension_rest_flattened(): +def test_archive_custom_metric_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -46133,40 +51182,38 @@ 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 = None # 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", - custom_dimension=resources.CustomDimension(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.CustomDimension.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_custom_dimension(**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/{parent=properties/*}/customDimensions" + "%s/v1alpha/{name=properties/*/customMetrics/*}:archive" % client.transport._host, args[1], ) -def test_create_custom_dimension_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, @@ -46175,14 +51222,13 @@ 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.archive_custom_metric( + analytics_admin.ArchiveCustomMetricRequest(), + name="name_value", ) -def test_create_custom_dimension_rest_error(): +def test_archive_custom_metric_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -46191,68 +51237,65 @@ def test_create_custom_dimension_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateCustomDimensionRequest, + analytics_admin.GetCustomMetricRequest, dict, ], ) -def test_update_custom_dimension_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 = { - "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 = {"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.CustomDimension( + return_value = resources.CustomMetric( 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, + 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.CustomDimension.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.update_custom_dimension(request) + response = client.get_custom_metric(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomDimension) + 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.scope == resources.CustomDimension.DimensionScope.EVENT - assert response.disallow_ads_personalization is True + 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_update_custom_dimension_rest_required_fields( - request_type=analytics_admin.UpdateCustomDimensionRequest, +def test_get_custom_metric_rest_required_fields( + request_type=analytics_admin.GetCustomMetricRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -46267,19 +51310,21 @@ 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) + ).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["name"] = "name_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).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",)) + ).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 "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46288,7 +51333,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 = 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 @@ -46300,39 +51345,38 @@ 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 = 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.update_custom_dimension(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_update_custom_dimension_rest_unset_required_fields(): +def test_get_custom_metric_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.get_custom_metric._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_custom_dimension_rest_interceptors(null_interceptor): +def test_get_custom_metric_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -46345,14 +51389,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_get_custom_metric" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_custom_metric" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateCustomDimensionRequest.pb( - analytics_admin.UpdateCustomDimensionRequest() + pb_message = analytics_admin.GetCustomMetricRequest.pb( + analytics_admin.GetCustomMetricRequest() ) transcode.return_value = { "method": "post", @@ -46364,19 +51408,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 = resources.CustomMetric.to_json( + resources.CustomMetric() ) - request = analytics_admin.UpdateCustomDimensionRequest() + request = analytics_admin.GetCustomMetricRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomDimension() + post.return_value = resources.CustomMetric() - client.update_custom_dimension( + client.get_custom_metric( request, metadata=[ ("key", "val"), @@ -46388,8 +51432,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_get_custom_metric_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetCustomMetricRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46397,17 +51441,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 = {"name": "properties/sample1/customMetrics/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -46419,10 +51453,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.get_custom_metric(request) -def test_update_custom_dimension_rest_flattened(): +def test_get_custom_metric_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -46431,42 +51465,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 = resources.CustomMetric() # get arguments that satisfy an http rule for this method - sample_request = { - "custom_dimension": {"name": "properties/sample1/customDimensions/sample2"} - } + sample_request = {"name": "properties/sample1/customMetrics/sample2"} # 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"]), + 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.CustomDimension.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.update_custom_dimension(**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/{custom_dimension.name=properties/*/customDimensions/*}" - % client.transport._host, + "%s/v1alpha/{name=properties/*/customMetrics/*}" % client.transport._host, args[1], ) -def test_update_custom_dimension_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, @@ -46475,14 +51505,13 @@ 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.get_custom_metric( + analytics_admin.GetCustomMetricRequest(), + name="name_value", ) -def test_update_custom_dimension_rest_error(): +def test_get_custom_metric_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -46491,49 +51520,56 @@ def test_update_custom_dimension_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListCustomDimensionsRequest, + analytics_admin.GetDataRetentionSettingsRequest, dict, ], ) -def test_list_custom_dimensions_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 = {"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 = analytics_admin.ListCustomDimensionsResponse( - next_page_token="next_page_token_value", + 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 - pb_return_value = analytics_admin.ListCustomDimensionsResponse.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.list_custom_dimensions(request) + response = client.get_data_retention_settings(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.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_list_custom_dimensions_rest_required_fields( - request_type=analytics_admin.ListCustomDimensionsRequest, +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( @@ -46548,28 +51584,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_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() - ).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_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(), @@ -46578,7 +51607,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.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 @@ -46598,40 +51627,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.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.list_custom_dimensions(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_list_custom_dimensions_rest_unset_required_fields(): +def test_get_data_retention_settings_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_retention_settings._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_retention_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -46644,14 +51663,16 @@ 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_retention_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_custom_dimensions" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_get_data_retention_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListCustomDimensionsRequest.pb( - analytics_admin.ListCustomDimensionsRequest() + pb_message = analytics_admin.GetDataRetentionSettingsRequest.pb( + analytics_admin.GetDataRetentionSettingsRequest() ) transcode.return_value = { "method": "post", @@ -46663,21 +51684,19 @@ 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.DataRetentionSettings.to_json( + resources.DataRetentionSettings() ) - request = analytics_admin.ListCustomDimensionsRequest() + request = analytics_admin.GetDataRetentionSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListCustomDimensionsResponse() + post.return_value = resources.DataRetentionSettings() - client.list_custom_dimensions( + client.get_data_retention_settings( request, metadata=[ ("key", "val"), @@ -46689,8 +51708,9 @@ 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_retention_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.GetDataRetentionSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -46698,7 +51718,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/dataRetentionSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -46710,10 +51730,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_retention_settings(request) -def test_list_custom_dimensions_rest_flattened(): +def test_get_data_retention_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -46722,39 +51742,39 @@ 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.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", + 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.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.list_custom_dimensions(**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/*}/customDimensions" + "%s/v1alpha/{name=properties/*/dataRetentionSettings}" % client.transport._host, args[1], ) -def test_list_custom_dimensions_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, @@ -46763,117 +51783,77 @@ 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_retention_settings( + analytics_admin.GetDataRetentionSettingsRequest(), + name="name_value", ) -def test_list_custom_dimensions_rest_pager(transport: str = "rest"): +def test_get_data_retention_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.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.UpdateDataRetentionSettingsRequest, dict, ], ) -def test_archive_custom_dimension_rest(request_type): +def test_update_data_retention_settings_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 = { + "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.archive_custom_dimension(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_archive_custom_dimension_rest_required_fields( - request_type=analytics_admin.ArchiveCustomDimensionRequest, +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( @@ -46888,21 +51868,19 @@ 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) + ).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() - ).archive_custom_dimension._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(), @@ -46911,7 +51889,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 = 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 @@ -46923,7 +51901,7 @@ def test_archive_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 @@ -46931,29 +51909,41 @@ def test_archive_custom_dimension_rest_required_fields( 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.archive_custom_dimension(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_archive_custom_dimension_rest_unset_required_fields(): +def test_update_data_retention_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.archive_custom_dimension._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.update_data_retention_settings._get_unset_required_fields( + {} + ) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "dataRetentionSettings", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_archive_custom_dimension_rest_interceptors(null_interceptor): +def test_update_data_retention_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -46966,11 +51956,16 @@ 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_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.ArchiveCustomDimensionRequest.pb( - analytics_admin.ArchiveCustomDimensionRequest() + post.assert_not_called() + pb_message = analytics_admin.UpdateDataRetentionSettingsRequest.pb( + analytics_admin.UpdateDataRetentionSettingsRequest() ) transcode.return_value = { "method": "post", @@ -46982,15 +51977,19 @@ 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 = resources.DataRetentionSettings.to_json( + resources.DataRetentionSettings() + ) - request = analytics_admin.ArchiveCustomDimensionRequest() + request = analytics_admin.UpdateDataRetentionSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.DataRetentionSettings() - client.archive_custom_dimension( + client.update_data_retention_settings( request, metadata=[ ("key", "val"), @@ -46999,10 +51998,12 @@ 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_update_data_retention_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.UpdateDataRetentionSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47010,7 +52011,14 @@ def test_archive_custom_dimension_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/customDimensions/sample2"} + 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 = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -47022,10 +52030,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.update_data_retention_settings(request) -def test_archive_custom_dimension_rest_flattened(): +def test_update_data_retention_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -47034,38 +52042,44 @@ 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 = resources.DataRetentionSettings() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/customDimensions/sample2"} + sample_request = { + "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.archive_custom_dimension(**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/*/customDimensions/*}:archive" + "%s/v1alpha/{data_retention_settings.name=properties/*/dataRetentionSettings}" % client.transport._host, args[1], ) -def test_archive_custom_dimension_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, @@ -47074,13 +52088,14 @@ 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(), - 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_archive_custom_dimension_rest_error(): +def test_update_data_retention_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -47089,59 +52104,76 @@ def test_archive_custom_dimension_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetCustomDimensionRequest, + analytics_admin.CreateDataStreamRequest, dict, ], ) -def test_get_custom_dimension_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/customDimensions/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 = 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.get_custom_dimension(request) + response = client.create_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_get_custom_dimension_rest_required_fields( - request_type=analytics_admin.GetCustomDimensionRequest, +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( @@ -47156,21 +52188,21 @@ 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) + ).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() - ).get_custom_dimension._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(), @@ -47179,7 +52211,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 = 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 @@ -47191,38 +52223,47 @@ def test_get_custom_dimension_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.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.get_custom_dimension(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_get_custom_dimension_rest_unset_required_fields(): +def test_create_data_stream_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.create_data_stream._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "dataStream", + ) + ) + ) + @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_custom_dimension_rest_interceptors(null_interceptor): +def test_create_data_stream_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -47235,14 +52276,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_create_data_stream" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_custom_dimension" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_data_stream" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetCustomDimensionRequest.pb( - analytics_admin.GetCustomDimensionRequest() + pb_message = analytics_admin.CreateDataStreamRequest.pb( + analytics_admin.CreateDataStreamRequest() ) transcode.return_value = { "method": "post", @@ -47254,19 +52295,17 @@ 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 = resources.DataStream.to_json(resources.DataStream()) - request = analytics_admin.GetCustomDimensionRequest() + request = analytics_admin.CreateDataStreamRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomDimension() + post.return_value = resources.DataStream() - client.get_custom_dimension( + client.create_data_stream( request, metadata=[ ("key", "val"), @@ -47278,8 +52317,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_create_data_stream_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateDataStreamRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47287,7 +52326,27 @@ 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_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 BadRequest error. @@ -47299,10 +52358,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.create_data_stream(request) -def test_get_custom_dimension_rest_flattened(): +def test_create_data_stream_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -47311,39 +52370,43 @@ 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 = resources.DataStream() # 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", + 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.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.get_custom_dimension(**mock_args) + 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/{name=properties/*/customDimensions/*}" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/dataStreams" % client.transport._host, args[1], ) -def test_get_custom_dimension_rest_flattened_error(transport: str = "rest"): +def test_create_data_stream_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -47352,13 +52415,18 @@ 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.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_get_custom_dimension_rest_error(): +def test_create_data_stream_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -47367,74 +52435,45 @@ def test_get_custom_dimension_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateCustomMetricRequest, + analytics_admin.DeleteDataStreamRequest, dict, ], ) -def test_create_custom_metric_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 = {"parent": "properties/sample1"} - request_init["custom_metric"] = { - "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], - } + 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.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 = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.CustomMetric.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_custom_metric(request) + response = client.delete_data_stream(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 response is None -def test_create_custom_metric_rest_required_fields( - request_type=analytics_admin.CreateCustomMetricRequest, +def test_delete_data_stream_rest_required_fields( + request_type=analytics_admin.DeleteDataStreamRequest, ): 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( @@ -47449,21 +52488,21 @@ 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) + ).delete_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() - ).create_custom_metric._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 - 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(), @@ -47472,7 +52511,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 = 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 @@ -47484,47 +52523,36 @@ def test_create_custom_metric_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.CustomMetric.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_custom_metric(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_create_custom_metric_rest_unset_required_fields(): +def test_delete_data_stream_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_custom_metric._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "customMetric", - ) - ) - ) + 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_create_custom_metric_rest_interceptors(null_interceptor): +def test_delete_data_stream_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -47537,14 +52565,11 @@ 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" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_data_stream" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreateCustomMetricRequest.pb( - analytics_admin.CreateCustomMetricRequest() + pb_message = analytics_admin.DeleteDataStreamRequest.pb( + analytics_admin.DeleteDataStreamRequest() ) transcode.return_value = { "method": "post", @@ -47556,19 +52581,15 @@ 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() - ) - request = analytics_admin.CreateCustomMetricRequest() + request = analytics_admin.DeleteDataStreamRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomMetric() - client.create_custom_metric( + client.delete_data_stream( request, metadata=[ ("key", "val"), @@ -47577,11 +52598,10 @@ def test_create_custom_metric_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_custom_metric_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateCustomMetricRequest +def test_delete_data_stream_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteDataStreamRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47589,16 +52609,7 @@ def test_create_custom_metric_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["custom_metric"] = { - "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], - } + 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. @@ -47610,10 +52621,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.delete_data_stream(request) -def test_create_custom_metric_rest_flattened(): +def test_delete_data_stream_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -47622,39 +52633,37 @@ 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 = None # 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", - custom_metric=resources.CustomMetric(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.CustomMetric.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_custom_metric(**mock_args) + 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/{parent=properties/*}/customMetrics" % client.transport._host, + "%s/v1alpha/{name=properties/*/dataStreams/*}" % client.transport._host, args[1], ) -def test_create_custom_metric_rest_flattened_error(transport: str = "rest"): +def test_delete_data_stream_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -47663,14 +52672,13 @@ 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(), - parent="parent_value", - custom_metric=resources.CustomMetric(name="name_value"), + client.delete_data_stream( + analytics_admin.DeleteDataStreamRequest(), + name="name_value", ) -def test_create_custom_metric_rest_error(): +def test_delete_data_stream_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -47679,71 +52687,71 @@ def test_create_custom_metric_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateCustomMetricRequest, + analytics_admin.UpdateDataStreamRequest, dict, ], ) -def test_update_custom_metric_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 = { - "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} - } - request_init["custom_metric"] = { - "name": "properties/sample1/customMetrics/sample2", - "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", - "measurement_unit": 1, - "scope": 1, - "restricted_metric_type": [1], + "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.CustomMetric( + 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", - measurement_unit=resources.CustomMetric.MeasurementUnit.STANDARD, - scope=resources.CustomMetric.MetricScope.EVENT, - restricted_metric_type=[ - resources.CustomMetric.RestrictedMetricType.COST_DATA - ], + 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.CustomMetric.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.update_custom_metric(request) + response = client.update_data_stream(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) + 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.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_update_custom_metric_rest_required_fields( - request_type=analytics_admin.UpdateCustomMetricRequest, +def test_update_data_stream_rest_required_fields( + request_type=analytics_admin.UpdateDataStreamRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -47762,14 +52770,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_data_stream._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_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) @@ -47783,7 +52791,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 = 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 @@ -47804,30 +52812,30 @@ 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 = 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.update_custom_metric(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_update_custom_metric_rest_unset_required_fields(): +def test_update_data_stream_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_custom_metric._get_unset_required_fields({}) + 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_update_custom_metric_rest_interceptors(null_interceptor): +def test_update_data_stream_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -47840,14 +52848,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_data_stream" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_data_stream" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateCustomMetricRequest.pb( - analytics_admin.UpdateCustomMetricRequest() + pb_message = analytics_admin.UpdateDataStreamRequest.pb( + analytics_admin.UpdateDataStreamRequest() ) transcode.return_value = { "method": "post", @@ -47859,19 +52867,17 @@ 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 = resources.DataStream.to_json(resources.DataStream()) - request = analytics_admin.UpdateCustomMetricRequest() + request = analytics_admin.UpdateDataStreamRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomMetric() + post.return_value = resources.DataStream() - client.update_custom_metric( + client.update_data_stream( request, metadata=[ ("key", "val"), @@ -47883,8 +52889,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_data_stream_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateDataStreamRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -47892,17 +52898,26 @@ 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 = {"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", - "measurement_unit": 1, - "scope": 1, - "restricted_metric_type": [1], + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, } request = request_type(**request_init) @@ -47915,10 +52930,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_data_stream(request) -def test_update_custom_metric_rest_flattened(): +def test_update_data_stream_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -47927,16 +52942,20 @@ 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 = resources.DataStream() # get arguments that satisfy an http rule for this method sample_request = { - "custom_metric": {"name": "properties/sample1/customMetrics/sample2"} + "data_stream": {"name": "properties/sample1/dataStreams/sample2"} } # get truthy value for each flattened field mock_args = dict( - custom_metric=resources.CustomMetric(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) @@ -47944,25 +52963,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 = 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.update_custom_metric(**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/{custom_metric.name=properties/*/customMetrics/*}" + "%s/v1alpha/{data_stream.name=properties/*/dataStreams/*}" % client.transport._host, args[1], ) -def test_update_custom_metric_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, @@ -47971,14 +52990,18 @@ 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_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_update_custom_metric_rest_error(): +def test_update_data_stream_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -47987,11 +53010,11 @@ def test_update_custom_metric_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListCustomMetricsRequest, + analytics_admin.ListDataStreamsRequest, dict, ], ) -def test_list_custom_metrics_rest(request_type): +def test_list_data_streams_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -48004,27 +53027,27 @@ def test_list_custom_metrics_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.ListCustomMetricsResponse( + 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 = analytics_admin.ListCustomMetricsResponse.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.list_custom_metrics(request) + response = client.list_data_streams(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomMetricsPager) + assert isinstance(response, pagers.ListDataStreamsPager) assert response.next_page_token == "next_page_token_value" -def test_list_custom_metrics_rest_required_fields( - request_type=analytics_admin.ListCustomMetricsRequest, +def test_list_data_streams_rest_required_fields( + request_type=analytics_admin.ListDataStreamsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -48044,7 +53067,7 @@ 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) + ).list_data_streams._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -48053,7 +53076,7 @@ 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) + ).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( ( @@ -48074,7 +53097,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 = 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 @@ -48094,25 +53117,25 @@ def test_list_custom_metrics_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListCustomMetricsResponse.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.list_custom_metrics(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_list_custom_metrics_rest_unset_required_fields(): +def test_list_data_streams_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_custom_metrics._get_unset_required_fields({}) + unset_fields = transport.list_data_streams._get_unset_required_fields({}) assert set(unset_fields) == ( set( ( @@ -48125,7 +53148,7 @@ def test_list_custom_metrics_rest_unset_required_fields(): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_custom_metrics_rest_interceptors(null_interceptor): +def test_list_data_streams_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -48138,14 +53161,14 @@ 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" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_data_streams" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_custom_metrics" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_data_streams" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListCustomMetricsRequest.pb( - analytics_admin.ListCustomMetricsRequest() + pb_message = analytics_admin.ListDataStreamsRequest.pb( + analytics_admin.ListDataStreamsRequest() ) transcode.return_value = { "method": "post", @@ -48157,19 +53180,19 @@ 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() + req.return_value._content = analytics_admin.ListDataStreamsResponse.to_json( + analytics_admin.ListDataStreamsResponse() ) - request = analytics_admin.ListCustomMetricsRequest() + request = analytics_admin.ListDataStreamsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListCustomMetricsResponse() + post.return_value = analytics_admin.ListDataStreamsResponse() - client.list_custom_metrics( + client.list_data_streams( request, metadata=[ ("key", "val"), @@ -48181,8 +53204,8 @@ def test_list_custom_metrics_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_custom_metrics_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListCustomMetricsRequest +def test_list_data_streams_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListDataStreamsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -48202,10 +53225,10 @@ 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) + client.list_data_streams(request) -def test_list_custom_metrics_rest_flattened(): +def test_list_data_streams_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -48214,7 +53237,7 @@ def test_list_custom_metrics_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.ListCustomMetricsResponse() + return_value = analytics_admin.ListDataStreamsResponse() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -48228,24 +53251,24 @@ def test_list_custom_metrics_rest_flattened(): # 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) + 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_custom_metrics(**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/{parent=properties/*}/customMetrics" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/dataStreams" % client.transport._host, args[1], ) -def test_list_custom_metrics_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, @@ -48254,13 +53277,13 @@ def test_list_custom_metrics_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_metrics( - analytics_admin.ListCustomMetricsRequest(), + client.list_data_streams( + analytics_admin.ListDataStreamsRequest(), parent="parent_value", ) -def test_list_custom_metrics_rest_pager(transport: str = "rest"): +def test_list_data_streams_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -48272,28 +53295,28 @@ def test_list_custom_metrics_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.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), - resources.CustomMetric(), + analytics_admin.ListDataStreamsResponse( + data_streams=[ + resources.DataStream(), + resources.DataStream(), + resources.DataStream(), ], next_page_token="abc", ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[], + analytics_admin.ListDataStreamsResponse( + data_streams=[], next_page_token="def", ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), + analytics_admin.ListDataStreamsResponse( + data_streams=[ + resources.DataStream(), ], next_page_token="ghi", ), - analytics_admin.ListCustomMetricsResponse( - custom_metrics=[ - resources.CustomMetric(), - resources.CustomMetric(), + analytics_admin.ListDataStreamsResponse( + data_streams=[ + resources.DataStream(), + resources.DataStream(), ], ), ) @@ -48302,7 +53325,7 @@ def test_list_custom_metrics_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.ListCustomMetricsResponse.to_json(x) for x in response + 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): @@ -48312,13 +53335,13 @@ def test_list_custom_metrics_rest_pager(transport: str = "rest"): sample_request = {"parent": "properties/sample1"} - pager = client.list_custom_metrics(request=sample_request) + pager = client.list_data_streams(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.CustomMetric) for i in results) + assert all(isinstance(i, resources.DataStream) for i in results) - pages = list(client.list_custom_metrics(request=sample_request).pages) + 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 @@ -48326,40 +53349,51 @@ def test_list_custom_metrics_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ArchiveCustomMetricRequest, + analytics_admin.GetDataStreamRequest, dict, ], ) -def test_archive_custom_metric_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 = {"name": "properties/sample1/customMetrics/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 = None + 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 - json_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.archive_custom_metric(request) + response = client.get_data_stream(request) # Establish that the response is the type that we expect. - assert response is None + 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_archive_custom_metric_rest_required_fields( - request_type=analytics_admin.ArchiveCustomMetricRequest, +def test_get_data_stream_rest_required_fields( + request_type=analytics_admin.GetDataStreamRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -48379,7 +53413,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_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -48388,7 +53422,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_data_stream._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -48402,7 +53436,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.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 @@ -48414,37 +53448,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.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.archive_custom_metric(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_archive_custom_metric_rest_unset_required_fields(): +def test_get_data_stream_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_data_stream._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_data_stream_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -48457,11 +53492,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_data_stream" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_data_stream" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.ArchiveCustomMetricRequest.pb( - analytics_admin.ArchiveCustomMetricRequest() + post.assert_not_called() + pb_message = analytics_admin.GetDataStreamRequest.pb( + analytics_admin.GetDataStreamRequest() ) transcode.return_value = { "method": "post", @@ -48473,15 +53511,17 @@ 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.DataStream.to_json(resources.DataStream()) - request = analytics_admin.ArchiveCustomMetricRequest() + request = analytics_admin.GetDataStreamRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.DataStream() - client.archive_custom_metric( + client.get_data_stream( request, metadata=[ ("key", "val"), @@ -48490,10 +53530,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_data_stream_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetDataStreamRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -48501,7 +53542,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/dataStreams/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -48513,10 +53554,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_data_stream(request) -def test_archive_custom_metric_rest_flattened(): +def test_get_data_stream_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -48525,10 +53566,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.DataStream() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/customMetrics/sample2"} + sample_request = {"name": "properties/sample1/dataStreams/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -48539,24 +53580,24 @@ 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.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.archive_custom_metric(**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/{name=properties/*/customMetrics/*}:archive" - % client.transport._host, + "%s/v1alpha/{name=properties/*/dataStreams/*}" % client.transport._host, args[1], ) -def test_archive_custom_metric_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, @@ -48565,13 +53606,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_data_stream( + analytics_admin.GetDataStreamRequest(), name="name_value", ) -def test_archive_custom_metric_rest_error(): +def test_get_data_stream_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -48580,60 +53621,57 @@ def test_archive_custom_metric_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetCustomMetricRequest, + analytics_admin.GetAudienceRequest, dict, ], ) -def test_get_custom_metric_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/customMetrics/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 = resources.CustomMetric( + return_value = 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=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 = 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.get_custom_metric(request) + response = client.get_audience(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.CustomMetric) + assert isinstance(response, 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 + == audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY + ) -def test_get_custom_metric_rest_required_fields( - request_type=analytics_admin.GetCustomMetricRequest, +def test_get_audience_rest_required_fields( + request_type=analytics_admin.GetAudienceRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -48653,7 +53691,7 @@ 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) + ).get_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -48662,7 +53700,7 @@ 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) + ).get_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -48676,7 +53714,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 = 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 @@ -48696,30 +53734,30 @@ 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 = 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.get_custom_metric(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_get_custom_metric_rest_unset_required_fields(): +def test_get_audience_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_custom_metric._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_get_custom_metric_rest_interceptors(null_interceptor): +def test_get_audience_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -48732,14 +53770,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_get_audience" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_custom_metric" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_audience" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetCustomMetricRequest.pb( - analytics_admin.GetCustomMetricRequest() + pb_message = analytics_admin.GetAudienceRequest.pb( + analytics_admin.GetAudienceRequest() ) transcode.return_value = { "method": "post", @@ -48751,19 +53789,17 @@ 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 = audience.Audience.to_json(audience.Audience()) - request = analytics_admin.GetCustomMetricRequest() + request = analytics_admin.GetAudienceRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.CustomMetric() + post.return_value = audience.Audience() - client.get_custom_metric( + client.get_audience( request, metadata=[ ("key", "val"), @@ -48775,8 +53811,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_get_audience_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetAudienceRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -48784,7 +53820,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 = {"name": "properties/sample1/audiences/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -48796,10 +53832,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.get_audience(request) -def test_get_custom_metric_rest_flattened(): +def test_get_audience_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -48808,10 +53844,10 @@ 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 = audience.Audience() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/customMetrics/sample2"} + sample_request = {"name": "properties/sample1/audiences/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -48822,24 +53858,24 @@ def test_get_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 = 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.get_custom_metric(**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/*/customMetrics/*}" % client.transport._host, + "%s/v1alpha/{name=properties/*/audiences/*}" % client.transport._host, args[1], ) -def test_get_custom_metric_rest_flattened_error(transport: str = "rest"): +def test_get_audience_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -48848,13 +53884,13 @@ 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(), + client.get_audience( + analytics_admin.GetAudienceRequest(), name="name_value", ) -def test_get_custom_metric_rest_error(): +def test_get_audience_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -48863,56 +53899,49 @@ def test_get_custom_metric_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDataRetentionSettingsRequest, + analytics_admin.ListAudiencesRequest, dict, ], ) -def test_get_data_retention_settings_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/dataRetentionSettings"} + 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.DataRetentionSettings( - name="name_value", - event_data_retention=resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS, - reset_user_data_on_new_activity=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.DataRetentionSettings.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_data_retention_settings(request) + response = client.list_audiences(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 isinstance(response, pagers.ListAudiencesPager) + assert response.next_page_token == "next_page_token_value" -def test_get_data_retention_settings_rest_required_fields( - request_type=analytics_admin.GetDataRetentionSettingsRequest, +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( @@ -48927,21 +53956,28 @@ 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) + ).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_data_retention_settings._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(), @@ -48950,7 +53986,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 = 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 @@ -48970,30 +54006,38 @@ def test_get_data_retention_settings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataRetentionSettings.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_data_retention_settings(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_data_retention_settings_rest_unset_required_fields(): +def test_list_audiences_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.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_data_retention_settings_rest_interceptors(null_interceptor): +def test_list_audiences_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -49006,16 +54050,14 @@ def test_get_data_retention_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_get_data_retention_settings", + transports.AnalyticsAdminServiceRestInterceptor, "post_list_audiences" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_data_retention_settings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_audiences" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetDataRetentionSettingsRequest.pb( - analytics_admin.GetDataRetentionSettingsRequest() + pb_message = analytics_admin.ListAudiencesRequest.pb( + analytics_admin.ListAudiencesRequest() ) transcode.return_value = { "method": "post", @@ -49027,19 +54069,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 = analytics_admin.ListAudiencesResponse.to_json( + analytics_admin.ListAudiencesResponse() ) - request = analytics_admin.GetDataRetentionSettingsRequest() + request = analytics_admin.ListAudiencesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataRetentionSettings() + post.return_value = analytics_admin.ListAudiencesResponse() - client.get_data_retention_settings( + client.list_audiences( request, metadata=[ ("key", "val"), @@ -49051,9 +54093,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_list_audiences_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListAudiencesRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -49061,7 +54102,7 @@ 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 = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -49073,10 +54114,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.list_audiences(request) -def test_get_data_retention_settings_rest_flattened(): +def test_list_audiences_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -49085,39 +54126,38 @@ 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 = analytics_admin.ListAudiencesResponse() # 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", ) 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 = 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_data_retention_settings(**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/*/dataRetentionSettings}" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/audiences" % client.transport._host, args[1], ) -def test_get_data_retention_settings_rest_flattened_error(transport: str = "rest"): +def test_list_audiences_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -49126,77 +54166,194 @@ 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.list_audiences( + analytics_admin.ListAudiencesRequest(), + parent="parent_value", ) -def test_get_data_retention_settings_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.UpdateDataRetentionSettingsRequest, + analytics_admin.CreateAudienceRequest, dict, ], ) -def test_update_data_retention_settings_rest(request_type): +def test_create_audience_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 = {"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 = 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 = gaa_audience.Audience( name="name_value", - event_data_retention=resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS, - reset_user_data_on_new_activity=True, + 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, ) # 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 = 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_data_retention_settings(request) + response = client.create_audience(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataRetentionSettings) + 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.event_data_retention - == resources.DataRetentionSettings.RetentionDuration.TWO_MONTHS + response.exclusion_duration_mode + == gaa_audience.Audience.AudienceExclusionDurationMode.EXCLUDE_TEMPORARILY ) - assert response.reset_user_data_on_new_activity is True -def test_update_data_retention_settings_rest_required_fields( - request_type=analytics_admin.UpdateDataRetentionSettingsRequest, +def test_create_audience_rest_required_fields( + request_type=analytics_admin.CreateAudienceRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -49211,19 +54368,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) + ).create_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" + 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",)) + ).create_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" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -49232,7 +54391,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 = 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 @@ -49244,7 +54403,7 @@ def test_update_data_retention_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 @@ -49253,40 +54412,38 @@ def test_update_data_retention_settings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.DataRetentionSettings.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_data_retention_settings(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_update_data_retention_settings_rest_unset_required_fields(): +def test_create_audience_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_data_retention_settings._get_unset_required_fields( - {} - ) + unset_fields = transport.create_audience._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("updateMask",)) + set(()) & set( ( - "dataRetentionSettings", - "updateMask", + "parent", + "audience", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_data_retention_settings_rest_interceptors(null_interceptor): +def test_create_audience_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -49298,17 +54455,15 @@ def test_update_data_retention_settings_rest_interceptors(null_interceptor): type(client.transport._session), "request" ) as req, mock.patch.object( path_template, "transcode" - ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_update_data_retention_settings", + ) as transcode, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "post_create_audience" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_data_retention_settings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_audience" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateDataRetentionSettingsRequest.pb( - analytics_admin.UpdateDataRetentionSettingsRequest() + pb_message = analytics_admin.CreateAudienceRequest.pb( + analytics_admin.CreateAudienceRequest() ) transcode.return_value = { "method": "post", @@ -49320,19 +54475,19 @@ 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() + req.return_value._content = gaa_audience.Audience.to_json( + gaa_audience.Audience() ) - request = analytics_admin.UpdateDataRetentionSettingsRequest() + request = analytics_admin.CreateAudienceRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataRetentionSettings() + post.return_value = gaa_audience.Audience() - client.update_data_retention_settings( + client.create_audience( request, metadata=[ ("key", "val"), @@ -49344,9 +54499,8 @@ def test_update_data_retention_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_data_retention_settings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.UpdateDataRetentionSettingsRequest, +def test_create_audience_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateAudienceRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -49354,13 +54508,66 @@ 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 = {"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 = request_type(**request_init) @@ -49373,10 +54580,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.create_audience(request) -def test_update_data_retention_settings_rest_flattened(): +def test_create_audience_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -49385,44 +54592,39 @@ 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 = gaa_audience.Audience() # get arguments that satisfy an http rule for this method - sample_request = { - "data_retention_settings": { - "name": "properties/sample1/dataRetentionSettings" - } - } + sample_request = {"parent": "properties/sample1"} # 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"]), + parent="parent_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.DataRetentionSettings.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_data_retention_settings(**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/{data_retention_settings.name=properties/*/dataRetentionSettings}" - % client.transport._host, + "%s/v1alpha/{parent=properties/*}/audiences" % client.transport._host, args[1], ) -def test_update_data_retention_settings_rest_flattened_error(transport: str = "rest"): +def test_create_audience_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -49431,14 +54633,14 @@ 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.create_audience( + analytics_admin.CreateAudienceRequest(), + parent="parent_value", + audience=gaa_audience.Audience(name="name_value"), ) -def test_update_data_retention_settings_rest_error(): +def test_create_audience_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -49447,76 +54649,121 @@ def test_update_data_retention_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateDataStreamRequest, + analytics_admin.UpdateAudienceRequest, dict, ], ) -def test_create_data_stream_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 = {"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, + request_init = {"audience": {"name": "properties/sample1/audiences/sample2"}} + request_init["audience"] = { + "name": "properties/sample1/audiences/sample2", "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, + "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 = 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 = gaa_audience.Audience( 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" - ), + description="description_value", + 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.DataStream.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_data_stream(request) + response = client.update_audience(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.DataStream) + assert isinstance(response, gaa_audience.Audience) assert response.name == "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.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_data_stream_rest_required_fields( - request_type=analytics_admin.CreateDataStreamRequest, +def test_update_audience_rest_required_fields( + request_type=analytics_admin.UpdateAudienceRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -49531,21 +54778,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_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" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_data_stream._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) # 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(), @@ -49554,7 +54799,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 = 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 @@ -49566,7 +54811,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 @@ -49575,38 +54820,38 @@ 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 = 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_data_stream(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_create_data_stream_rest_unset_required_fields(): +def test_update_audience_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_data_stream._get_unset_required_fields({}) + unset_fields = transport.update_audience._get_unset_required_fields({}) assert set(unset_fields) == ( - set(()) + set(("updateMask",)) & set( ( - "parent", - "dataStream", + "audience", + "updateMask", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_data_stream_rest_interceptors(null_interceptor): +def test_update_audience_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -49619,14 +54864,14 @@ 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_audience" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_audience" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateDataStreamRequest.pb( - analytics_admin.CreateDataStreamRequest() + pb_message = analytics_admin.UpdateAudienceRequest.pb( + analytics_admin.UpdateAudienceRequest() ) transcode.return_value = { "method": "post", @@ -49638,17 +54883,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 = gaa_audience.Audience.to_json( + gaa_audience.Audience() + ) - request = analytics_admin.CreateDataStreamRequest() + request = analytics_admin.UpdateAudienceRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataStream() + post.return_value = gaa_audience.Audience() - client.create_data_stream( + client.update_audience( request, metadata=[ ("key", "val"), @@ -49660,8 +54907,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_audience_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateAudienceRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -49669,26 +54916,66 @@ 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, + request_init = {"audience": {"name": "properties/sample1/audiences/sample2"}} + request_init["audience"] = { + "name": "properties/sample1/audiences/sample2", "display_name": "display_name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, + "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 = request_type(**request_init) @@ -49701,10 +54988,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_audience(request) -def test_create_data_stream_rest_flattened(): +def test_update_audience_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -49713,43 +55000,40 @@ 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 = gaa_audience.Audience() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"audience": {"name": "properties/sample1/audiences/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" - ) - ), + audience=gaa_audience.Audience(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 = 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_data_stream(**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/{parent=properties/*}/dataStreams" % client.transport._host, + "%s/v1alpha/{audience.name=properties/*/audiences/*}" + % client.transport._host, args[1], ) -def test_create_data_stream_rest_flattened_error(transport: str = "rest"): +def test_update_audience_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -49758,18 +55042,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_audience( + analytics_admin.UpdateAudienceRequest(), + audience=gaa_audience.Audience(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_create_data_stream_rest_error(): +def test_update_audience_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -49778,18 +55058,18 @@ def test_create_data_stream_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteDataStreamRequest, + analytics_admin.ArchiveAudienceRequest, dict, ], ) -def test_delete_data_stream_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 = {"name": "properties/sample1/dataStreams/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. @@ -49804,14 +55084,14 @@ def test_delete_data_stream_rest(request_type): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_data_stream(request) + response = client.archive_audience(request) # Establish that the response is the type that we expect. assert response is None -def test_delete_data_stream_rest_required_fields( - request_type=analytics_admin.DeleteDataStreamRequest, +def test_archive_audience_rest_required_fields( + request_type=analytics_admin.ArchiveAudienceRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -49831,7 +55111,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) + ).archive_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -49840,7 +55120,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) + ).archive_audience._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -49866,9 +55146,10 @@ def test_delete_data_stream_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() @@ -49878,24 +55159,24 @@ def test_delete_data_stream_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_data_stream(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_delete_data_stream_rest_unset_required_fields(): +def test_archive_audience_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_data_stream._get_unset_required_fields({}) + 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_delete_data_stream_rest_interceptors(null_interceptor): +def test_archive_audience_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -49908,11 +55189,11 @@ 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, "pre_archive_audience" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteDataStreamRequest.pb( - analytics_admin.DeleteDataStreamRequest() + pb_message = analytics_admin.ArchiveAudienceRequest.pb( + analytics_admin.ArchiveAudienceRequest() ) transcode.return_value = { "method": "post", @@ -49921,107 +55202,53 @@ def test_delete_data_stream_rest_interceptors(null_interceptor): "query_params": pb_message, } - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - - request = analytics_admin.DeleteDataStreamRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_data_stream( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - - -def test_delete_data_stream_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteDataStreamRequest -): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - 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. - 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_data_stream(request) - - -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) + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() - # 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], + request = analytics_admin.ArchiveAudienceRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.archive_audience( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) + pre.assert_called_once() -def test_delete_data_stream_rest_flattened_error(transport: str = "rest"): + +def test_archive_audience_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ArchiveAudienceRequest +): 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", - ) + # send a request that will satisfy transcoding + 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. + 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.archive_audience(request) -def test_delete_data_stream_rest_error(): +def test_archive_audience_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -50030,75 +55257,53 @@ def test_delete_data_stream_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateDataStreamRequest, + analytics_admin.GetSearchAds360LinkRequest, dict, ], ) -def test_update_data_stream_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 = {"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 = {"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.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.update_data_stream(request) + response = client.get_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_update_data_stream_rest_required_fields( - request_type=analytics_admin.UpdateDataStreamRequest, +def test_get_search_ads360_link_rest_required_fields( + request_type=analytics_admin.GetSearchAds360LinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -50113,19 +55318,21 @@ 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) + ).get_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_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",)) + ).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 + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -50134,7 +55341,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.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 @@ -50146,39 +55353,38 @@ def test_update_data_stream_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.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.update_data_stream(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_update_data_stream_rest_unset_required_fields(): +def test_get_search_ads360_link_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.get_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_stream_rest_interceptors(null_interceptor): +def test_get_search_ads360_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -50191,14 +55397,14 @@ 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_get_search_ads360_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_search_ads360_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateDataStreamRequest.pb( - analytics_admin.UpdateDataStreamRequest() + pb_message = analytics_admin.GetSearchAds360LinkRequest.pb( + analytics_admin.GetSearchAds360LinkRequest() ) transcode.return_value = { "method": "post", @@ -50210,17 +55416,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.SearchAds360Link.to_json( + resources.SearchAds360Link() + ) - request = analytics_admin.UpdateDataStreamRequest() + request = analytics_admin.GetSearchAds360LinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataStream() + post.return_value = resources.SearchAds360Link() - client.update_data_stream( + client.get_search_ads360_link( request, metadata=[ ("key", "val"), @@ -50232,8 +55440,8 @@ 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_get_search_ads360_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetSearchAds360LinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -50241,27 +55449,7 @@ 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 = {"name": "properties/sample1/searchAds360Links/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -50273,10 +55461,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.get_search_ads360_link(request) -def test_update_data_stream_rest_flattened(): +def test_get_search_ads360_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -50285,46 +55473,39 @@ 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.SearchAds360Link() # get arguments that satisfy an http rule for this method - sample_request = { - "data_stream": {"name": "properties/sample1/dataStreams/sample2"} - } + sample_request = {"name": "properties/sample1/searchAds360Links/sample2"} # 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" - ) - ), - 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.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.update_data_stream(**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/{data_stream.name=properties/*/dataStreams/*}" + "%s/v1alpha/{name=properties/*/searchAds360Links/*}" % client.transport._host, args[1], ) -def test_update_data_stream_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, @@ -50333,18 +55514,13 @@ 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" - ) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_search_ads360_link( + analytics_admin.GetSearchAds360LinkRequest(), + name="name_value", ) -def test_update_data_stream_rest_error(): +def test_get_search_ads360_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -50353,11 +55529,11 @@ def test_update_data_stream_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListDataStreamsRequest, + analytics_admin.ListSearchAds360LinksRequest, dict, ], ) -def test_list_data_streams_rest(request_type): +def test_list_search_ads360_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -50370,27 +55546,27 @@ def test_list_data_streams_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.ListDataStreamsResponse( + 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 = analytics_admin.ListDataStreamsResponse.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.list_data_streams(request) + response = client.list_search_ads360_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDataStreamsPager) + assert isinstance(response, pagers.ListSearchAds360LinksPager) assert response.next_page_token == "next_page_token_value" -def test_list_data_streams_rest_required_fields( - request_type=analytics_admin.ListDataStreamsRequest, +def test_list_search_ads360_links_rest_required_fields( + request_type=analytics_admin.ListSearchAds360LinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -50410,7 +55586,7 @@ def test_list_data_streams_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_data_streams._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 @@ -50419,7 +55595,7 @@ def test_list_data_streams_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_data_streams._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( ( @@ -50440,7 +55616,7 @@ def test_list_data_streams_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListDataStreamsResponse() + 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 @@ -50460,25 +55636,27 @@ def test_list_data_streams_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListDataStreamsResponse.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.list_data_streams(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_list_data_streams_rest_unset_required_fields(): +def test_list_search_ads360_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_data_streams._get_unset_required_fields({}) + unset_fields = transport.list_search_ads360_links._get_unset_required_fields({}) assert set(unset_fields) == ( set( ( @@ -50491,7 +55669,7 @@ def test_list_data_streams_rest_unset_required_fields(): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_data_streams_rest_interceptors(null_interceptor): +def test_list_search_ads360_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -50504,14 +55682,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_list_search_ads360_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_data_streams" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_search_ads360_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListDataStreamsRequest.pb( - analytics_admin.ListDataStreamsRequest() + pb_message = analytics_admin.ListSearchAds360LinksRequest.pb( + analytics_admin.ListSearchAds360LinksRequest() ) transcode.return_value = { "method": "post", @@ -50523,19 +55701,21 @@ 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.ListSearchAds360LinksResponse.to_json( + analytics_admin.ListSearchAds360LinksResponse() + ) ) - request = analytics_admin.ListDataStreamsRequest() + request = analytics_admin.ListSearchAds360LinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListDataStreamsResponse() + post.return_value = analytics_admin.ListSearchAds360LinksResponse() - client.list_data_streams( + client.list_search_ads360_links( request, metadata=[ ("key", "val"), @@ -50547,8 +55727,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_list_search_ads360_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListSearchAds360LinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -50568,10 +55748,10 @@ 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) + client.list_search_ads360_links(request) -def test_list_data_streams_rest_flattened(): +def test_list_search_ads360_links_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -50580,7 +55760,7 @@ def test_list_data_streams_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.ListDataStreamsResponse() + return_value = analytics_admin.ListSearchAds360LinksResponse() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -50594,24 +55774,25 @@ def test_list_data_streams_rest_flattened(): # 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.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_data_streams(**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/{parent=properties/*}/dataStreams" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/searchAds360Links" + % client.transport._host, args[1], ) -def test_list_data_streams_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, @@ -50620,13 +55801,13 @@ def test_list_data_streams_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_data_streams( - analytics_admin.ListDataStreamsRequest(), + client.list_search_ads360_links( + analytics_admin.ListSearchAds360LinksRequest(), parent="parent_value", ) -def test_list_data_streams_rest_pager(transport: str = "rest"): +def test_list_search_ads360_links_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -50638,28 +55819,28 @@ def test_list_data_streams_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.ListDataStreamsResponse( - data_streams=[ - resources.DataStream(), - resources.DataStream(), - resources.DataStream(), + analytics_admin.ListSearchAds360LinksResponse( + search_ads_360_links=[ + resources.SearchAds360Link(), + resources.SearchAds360Link(), + resources.SearchAds360Link(), ], next_page_token="abc", ), - analytics_admin.ListDataStreamsResponse( - data_streams=[], + analytics_admin.ListSearchAds360LinksResponse( + search_ads_360_links=[], next_page_token="def", ), - analytics_admin.ListDataStreamsResponse( - data_streams=[ - resources.DataStream(), + analytics_admin.ListSearchAds360LinksResponse( + search_ads_360_links=[ + resources.SearchAds360Link(), ], next_page_token="ghi", ), - analytics_admin.ListDataStreamsResponse( - data_streams=[ - resources.DataStream(), - resources.DataStream(), + analytics_admin.ListSearchAds360LinksResponse( + search_ads_360_links=[ + resources.SearchAds360Link(), + resources.SearchAds360Link(), ], ), ) @@ -50668,7 +55849,7 @@ def test_list_data_streams_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.ListDataStreamsResponse.to_json(x) for x in response + 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): @@ -50678,13 +55859,13 @@ def test_list_data_streams_rest_pager(transport: str = "rest"): sample_request = {"parent": "properties/sample1"} - pager = client.list_data_streams(request=sample_request) + pager = client.list_search_ads360_links(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.DataStream) for i in results) + assert all(isinstance(i, resources.SearchAds360Link) for i in results) - pages = list(client.list_data_streams(request=sample_request).pages) + 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 @@ -50692,56 +55873,62 @@ def test_list_data_streams_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetDataStreamRequest, + analytics_admin.CreateSearchAds360LinkRequest, dict, ], ) -def test_get_data_stream_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/dataStreams/sample2"} + 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.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.get_data_stream(request) + response = client.create_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_get_data_stream_rest_required_fields( - request_type=analytics_admin.GetDataStreamRequest, +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( @@ -50756,21 +55943,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_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_stream._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(), @@ -50779,7 +55966,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.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 @@ -50791,38 +55978,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.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_stream(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_stream_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_stream._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_stream_rest_interceptors(null_interceptor): +def test_create_search_ads360_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -50835,14 +56031,15 @@ 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_search_ads360_link", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_data_stream" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_search_ads360_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetDataStreamRequest.pb( - analytics_admin.GetDataStreamRequest() + pb_message = analytics_admin.CreateSearchAds360LinkRequest.pb( + analytics_admin.CreateSearchAds360LinkRequest() ) transcode.return_value = { "method": "post", @@ -50854,17 +56051,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.SearchAds360Link.to_json( + resources.SearchAds360Link() + ) - request = analytics_admin.GetDataStreamRequest() + request = analytics_admin.CreateSearchAds360LinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.DataStream() + post.return_value = resources.SearchAds360Link() - client.get_data_stream( + client.create_search_ads360_link( request, metadata=[ ("key", "val"), @@ -50876,8 +56075,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_search_ads360_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateSearchAds360LinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -50885,7 +56084,16 @@ 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": "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. @@ -50897,10 +56105,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_search_ads360_link(request) -def test_get_data_stream_rest_flattened(): +def test_create_search_ads360_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -50909,38 +56117,40 @@ 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.SearchAds360Link() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/dataStreams/sample2"} + 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.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.get_data_stream(**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/*/dataStreams/*}" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/searchAds360Links" + % client.transport._host, args[1], ) -def test_get_data_stream_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, @@ -50949,13 +56159,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_search_ads360_link( + analytics_admin.CreateSearchAds360LinkRequest(), + parent="parent_value", + search_ads_360_link=resources.SearchAds360Link(name="name_value"), ) -def test_get_data_stream_rest_error(): +def test_create_search_ads360_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -50964,57 +56175,40 @@ def test_get_data_stream_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetAudienceRequest, + analytics_admin.DeleteSearchAds360LinkRequest, dict, ], ) -def test_get_audience_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 = {"name": "properties/sample1/audiences/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 = 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, - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = 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.get_audience(request) + response = client.delete_search_ads360_link(request) # Establish that the response is the type that we expect. - 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 - ) + assert response is None -def test_get_audience_rest_required_fields( - request_type=analytics_admin.GetAudienceRequest, +def test_delete_search_ads360_link_rest_required_fields( + request_type=analytics_admin.DeleteSearchAds360LinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -51034,7 +56228,7 @@ def test_get_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_audience._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 @@ -51043,7 +56237,7 @@ def test_get_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_audience._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 non-default values are left alone @@ -51057,7 +56251,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 = 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 @@ -51069,38 +56263,36 @@ def test_get_audience_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 = 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.get_audience(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_get_audience_rest_unset_required_fields(): +def test_delete_search_ads360_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_audience._get_unset_required_fields({}) + 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_get_audience_rest_interceptors(null_interceptor): +def test_delete_search_ads360_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -51113,14 +56305,11 @@ 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" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_audience" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_search_ads360_link" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.GetAudienceRequest.pb( - analytics_admin.GetAudienceRequest() + pb_message = analytics_admin.DeleteSearchAds360LinkRequest.pb( + analytics_admin.DeleteSearchAds360LinkRequest() ) transcode.return_value = { "method": "post", @@ -51132,17 +56321,15 @@ 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()) - request = analytics_admin.GetAudienceRequest() + request = analytics_admin.DeleteSearchAds360LinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = audience.Audience() - client.get_audience( + client.delete_search_ads360_link( request, metadata=[ ("key", "val"), @@ -51151,11 +56338,10 @@ def test_get_audience_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_get_audience_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetAudienceRequest +def test_delete_search_ads360_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteSearchAds360LinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -51163,7 +56349,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": "properties/sample1/searchAds360Links/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -51175,10 +56361,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.delete_search_ads360_link(request) -def test_get_audience_rest_flattened(): +def test_delete_search_ads360_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -51187,10 +56373,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 = None # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/audiences/sample2"} + sample_request = {"name": "properties/sample1/searchAds360Links/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -51201,24 +56387,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) - 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_audience(**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/{name=properties/*/audiences/*}" % client.transport._host, + "%s/v1alpha/{name=properties/*/searchAds360Links/*}" + % client.transport._host, args[1], ) -def test_get_audience_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, @@ -51227,13 +56413,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.delete_search_ads360_link( + analytics_admin.DeleteSearchAds360LinkRequest(), name="name_value", ) -def test_get_audience_rest_error(): +def test_delete_search_ads360_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -51242,49 +56428,63 @@ def test_get_audience_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListAudiencesRequest, + analytics_admin.UpdateSearchAds360LinkRequest, dict, ], ) -def test_list_audiences_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 = { + "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 = analytics_admin.ListAudiencesResponse( - next_page_token="next_page_token_value", + 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 - pb_return_value = analytics_admin.ListAudiencesResponse.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.list_audiences(request) + response = client.update_search_ads360_link(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.SearchAds360Link) + assert response.name == "name_value" + assert response.advertiser_id == "advertiser_id_value" + assert response.advertiser_display_name == "advertiser_display_name_value" -def test_list_audiences_rest_required_fields( - request_type=analytics_admin.ListAudiencesRequest, +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( @@ -51299,28 +56499,19 @@ def test_list_audiences_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_audiences._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() - ).list_audiences._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( - ( - "page_size", - "page_token", - ) - ) + 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(), @@ -51329,7 +56520,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.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 @@ -51341,46 +56532,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.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.list_audiences(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_list_audiences_rest_unset_required_fields(): +def test_update_search_ads360_link_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_search_ads360_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("updateMask",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_audiences_rest_interceptors(null_interceptor): +def test_update_search_ads360_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -51393,14 +56577,15 @@ 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_search_ads360_link", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_audiences" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_search_ads360_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListAudiencesRequest.pb( - analytics_admin.ListAudiencesRequest() + pb_message = analytics_admin.UpdateSearchAds360LinkRequest.pb( + analytics_admin.UpdateSearchAds360LinkRequest() ) transcode.return_value = { "method": "post", @@ -51412,19 +56597,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.SearchAds360Link.to_json( + resources.SearchAds360Link() ) - request = analytics_admin.ListAudiencesRequest() + request = analytics_admin.UpdateSearchAds360LinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListAudiencesResponse() + post.return_value = resources.SearchAds360Link() - client.list_audiences( + client.update_search_ads360_link( request, metadata=[ ("key", "val"), @@ -51436,8 +56621,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_search_ads360_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateSearchAds360LinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -51445,7 +56630,18 @@ def test_list_audiences_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + 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 BadRequest error. @@ -51457,10 +56653,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_search_ads360_link(request) -def test_list_audiences_rest_flattened(): +def test_update_search_ads360_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -51469,38 +56665,44 @@ 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.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", + 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 = analytics_admin.ListAudiencesResponse.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.list_audiences(**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/*}/audiences" % client.transport._host, + "%s/v1alpha/{search_ads_360_link.name=properties/*/searchAds360Links/*}" + % client.transport._host, args[1], ) -def test_list_audiences_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, @@ -51509,194 +56711,80 @@ 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_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_list_audiences_rest_pager(transport: str = "rest"): +def test_update_search_ads360_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.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.GetAttributionSettingsRequest, dict, ], ) -def test_create_audience_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 = {"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": "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 = gaa_audience.Audience( + return_value = resources.AttributionSettings( 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, + 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 = gaa_audience.Audience.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.create_audience(request) + response = client.get_attribution_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, gaa_audience.Audience) + assert isinstance(response, resources.AttributionSettings) 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 + 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_create_audience_rest_required_fields( - request_type=analytics_admin.CreateAudienceRequest, +def test_get_attribution_settings_rest_required_fields( + request_type=analytics_admin.GetAttributionSettingsRequest, ): 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( @@ -51711,21 +56799,21 @@ def test_create_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_audience._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 - 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) + ).get_attribution_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(), @@ -51734,7 +56822,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 = 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 @@ -51746,47 +56834,38 @@ def test_create_audience_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 = gaa_audience.Audience.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.create_audience(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_create_audience_rest_unset_required_fields(): +def test_get_attribution_settings_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.get_attribution_settings._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_get_attribution_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -51799,119 +56878,59 @@ 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" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_attribution_settings" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_audience" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_attribution_settings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateAudienceRequest.pb( - analytics_admin.CreateAudienceRequest() - ) - 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 = gaa_audience.Audience.to_json( - gaa_audience.Audience() - ) - - request = analytics_admin.CreateAudienceRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gaa_audience.Audience() - - client.create_audience( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_audience_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateAudienceRequest -): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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, - } - ], - } + pb_message = analytics_admin.GetAttributionSettingsRequest.pb( + analytics_admin.GetAttributionSettingsRequest() + ) + 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.AttributionSettings.to_json( + resources.AttributionSettings() + ) + + request = analytics_admin.GetAttributionSettingsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.AttributionSettings() + + client.get_attribution_settings( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_attribution_settings_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetAttributionSettingsRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "properties/sample1/attributionSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -51923,10 +56942,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.get_attribution_settings(request) -def test_create_audience_rest_flattened(): +def test_get_attribution_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -51935,39 +56954,39 @@ 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 = resources.AttributionSettings() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "properties/sample1/attributionSettings"} # 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) + 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.create_audience(**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/{parent=properties/*}/audiences" % client.transport._host, + "%s/v1alpha/{name=properties/*/attributionSettings}" + % client.transport._host, args[1], ) -def test_create_audience_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, @@ -51976,14 +56995,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.get_attribution_settings( + analytics_admin.GetAttributionSettingsRequest(), + name="name_value", ) -def test_create_audience_rest_error(): +def test_get_attribution_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -51992,117 +57010,67 @@ def test_create_audience_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateAudienceRequest, + analytics_admin.UpdateAttributionSettingsRequest, dict, ], ) -def test_update_audience_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 = {"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 = { + "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 = gaa_audience.Audience( + return_value = resources.AttributionSettings( 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, + 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 = gaa_audience.Audience.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_audience(request) + response = client.update_attribution_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, gaa_audience.Audience) + assert isinstance(response, resources.AttributionSettings) 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 + 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_audience_rest_required_fields( - request_type=analytics_admin.UpdateAudienceRequest, +def test_update_attribution_settings_rest_required_fields( + request_type=analytics_admin.UpdateAttributionSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -52121,14 +57089,14 @@ def test_update_audience_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_audience._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_audience._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) @@ -52142,7 +57110,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 = 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 @@ -52163,30 +57131,30 @@ def test_update_audience_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_audience.Audience.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_audience(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_audience_rest_unset_required_fields(): +def test_update_attribution_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_audience._get_unset_required_fields({}) + unset_fields = transport.update_attribution_settings._get_unset_required_fields({}) assert set(unset_fields) == ( set(("updateMask",)) & set( ( - "audience", + "attributionSettings", "updateMask", ) ) @@ -52194,7 +57162,7 @@ def test_update_audience_rest_unset_required_fields(): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_audience_rest_interceptors(null_interceptor): +def test_update_attribution_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -52207,14 +57175,16 @@ 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_update_attribution_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_audience" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_attribution_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateAudienceRequest.pb( - analytics_admin.UpdateAudienceRequest() + pb_message = analytics_admin.UpdateAttributionSettingsRequest.pb( + analytics_admin.UpdateAttributionSettingsRequest() ) transcode.return_value = { "method": "post", @@ -52226,19 +57196,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 = resources.AttributionSettings.to_json( + resources.AttributionSettings() ) - request = analytics_admin.UpdateAudienceRequest() + request = analytics_admin.UpdateAttributionSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gaa_audience.Audience() + post.return_value = resources.AttributionSettings() - client.update_audience( + client.update_attribution_settings( request, metadata=[ ("key", "val"), @@ -52250,8 +57220,9 @@ 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_update_attribution_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.UpdateAttributionSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -52259,66 +57230,14 @@ 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 = { + "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) @@ -52331,10 +57250,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.update_attribution_settings(request) -def test_update_audience_rest_flattened(): +def test_update_attribution_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -52343,14 +57262,16 @@ 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 = resources.AttributionSettings() # get arguments that satisfy an http rule for this method - sample_request = {"audience": {"name": "properties/sample1/audiences/sample2"}} + sample_request = { + "attribution_settings": {"name": "properties/sample1/attributionSettings"} + } # get truthy value for each flattened field mock_args = dict( - audience=gaa_audience.Audience(name="name_value"), + attribution_settings=resources.AttributionSettings(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) @@ -52358,25 +57279,25 @@ def test_update_audience_rest_flattened(): # 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 = 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_audience(**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/{audience.name=properties/*/audiences/*}" + "%s/v1alpha/{attribution_settings.name=properties/*/attributionSettings}" % client.transport._host, args[1], ) -def test_update_audience_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, @@ -52385,14 +57306,14 @@ 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"), + 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_audience_rest_error(): +def test_update_attribution_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -52401,125 +57322,44 @@ def test_update_audience_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ArchiveAudienceRequest, + analytics_admin.RunAccessReportRequest, dict, ], ) -def test_archive_audience_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 = {"name": "properties/sample1/audiences/sample2"} + 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 = None + return_value = analytics_admin.RunAccessReportResponse( + row_count=992, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_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.archive_audience(request) + response = client.run_access_report(request) # Establish that the response is the type that we expect. - assert response is None - - -def test_archive_audience_rest_required_fields( - request_type=analytics_admin.ArchiveAudienceRequest, -): - 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() - ).archive_audience._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() - ).archive_audience._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": "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 = "" - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - 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_archive_audience_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",))) + assert isinstance(response, analytics_admin.RunAccessReportResponse) + assert response.row_count == 992 @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_archive_audience_rest_interceptors(null_interceptor): +def test_run_access_report_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -52532,11 +57372,14 @@ 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_run_access_report" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_run_access_report" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.ArchiveAudienceRequest.pb( - analytics_admin.ArchiveAudienceRequest() + post.assert_not_called() + pb_message = analytics_admin.RunAccessReportRequest.pb( + analytics_admin.RunAccessReportRequest() ) transcode.return_value = { "method": "post", @@ -52548,15 +57391,19 @@ 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.RunAccessReportResponse.to_json( + analytics_admin.RunAccessReportResponse() + ) - request = analytics_admin.ArchiveAudienceRequest() + request = analytics_admin.RunAccessReportRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = analytics_admin.RunAccessReportResponse() - client.archive_audience( + client.run_access_report( request, metadata=[ ("key", "val"), @@ -52565,10 +57412,11 @@ 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_run_access_report_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.RunAccessReportRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -52576,7 +57424,7 @@ def test_archive_audience_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/audiences/sample2"} + request_init = {"entity": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -52588,10 +57436,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.run_access_report(request) -def test_archive_audience_rest_error(): +def test_run_access_report_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -52600,53 +57448,57 @@ def test_archive_audience_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetSearchAds360LinkRequest, + analytics_admin.CreateAccessBindingRequest, dict, ], ) -def test_get_search_ads360_link_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/searchAds360Links/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.SearchAds360Link( + return_value = resources.AccessBinding( name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_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 = resources.SearchAds360Link.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_search_ads360_link(request) + response = client.create_access_binding(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.SearchAds360Link) + assert isinstance(response, resources.AccessBinding) assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" + assert response.roles == ["roles_value"] -def test_get_search_ads360_link_rest_required_fields( - request_type=analytics_admin.GetSearchAds360LinkRequest, +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( @@ -52661,21 +57513,21 @@ def test_get_search_ads360_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_search_ads360_link._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_search_ads360_link._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(), @@ -52684,7 +57536,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 = 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 @@ -52696,38 +57548,47 @@ def test_get_search_ads360_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.SearchAds360Link.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_search_ads360_link(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_search_ads360_link_rest_unset_required_fields(): +def test_create_access_binding_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.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_search_ads360_link_rest_interceptors(null_interceptor): +def test_create_access_binding_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -52740,14 +57601,14 @@ 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_create_access_binding" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_search_ads360_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_access_binding" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetSearchAds360LinkRequest.pb( - analytics_admin.GetSearchAds360LinkRequest() + pb_message = analytics_admin.CreateAccessBindingRequest.pb( + analytics_admin.CreateAccessBindingRequest() ) transcode.return_value = { "method": "post", @@ -52759,19 +57620,19 @@ 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 = resources.AccessBinding.to_json( + resources.AccessBinding() ) - request = analytics_admin.GetSearchAds360LinkRequest() + request = analytics_admin.CreateAccessBindingRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.SearchAds360Link() + post.return_value = resources.AccessBinding() - client.get_search_ads360_link( + client.create_access_binding( request, metadata=[ ("key", "val"), @@ -52783,8 +57644,8 @@ def test_get_search_ads360_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_search_ads360_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetSearchAds360LinkRequest +def test_create_access_binding_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateAccessBindingRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -52792,7 +57653,12 @@ 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_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. @@ -52804,10 +57670,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) + client.create_access_binding(request) -def test_get_search_ads360_link_rest_flattened(): +def test_create_access_binding_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -52816,39 +57682,39 @@ def test_get_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 = resources.AccessBinding() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/searchAds360Links/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.SearchAds360Link.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_search_ads360_link(**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/*/searchAds360Links/*}" - % client.transport._host, + "%s/v1alpha/{parent=accounts/*}/accessBindings" % client.transport._host, args[1], ) -def test_get_search_ads360_link_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, @@ -52857,13 +57723,14 @@ def test_get_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.get_search_ads360_link( - analytics_admin.GetSearchAds360LinkRequest(), - name="name_value", + client.create_access_binding( + analytics_admin.CreateAccessBindingRequest(), + parent="parent_value", + access_binding=resources.AccessBinding(user="user_value"), ) -def test_get_search_ads360_link_rest_error(): +def test_create_access_binding_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -52872,49 +57739,52 @@ def test_get_search_ads360_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListSearchAds360LinksRequest, + analytics_admin.GetAccessBindingRequest, dict, ], ) -def test_list_search_ads360_links_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 = {"parent": "properties/sample1"} + 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 = analytics_admin.ListSearchAds360LinksResponse( - 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.ListSearchAds360LinksResponse.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_search_ads360_links(request) + response = client.get_access_binding(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, resources.AccessBinding) + assert response.name == "name_value" + assert response.roles == ["roles_value"] -def test_list_search_ads360_links_rest_required_fields( - request_type=analytics_admin.ListSearchAds360LinksRequest, +def test_get_access_binding_rest_required_fields( + request_type=analytics_admin.GetAccessBindingRequest, ): 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( @@ -52929,28 +57799,21 @@ 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) + ).get_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() - ).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", - ) - ) + ).get_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(), @@ -52959,7 +57822,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 = 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 @@ -52979,40 +57842,30 @@ def test_list_search_ads360_links_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListSearchAds360LinksResponse.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_search_ads360_links(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_list_search_ads360_links_rest_unset_required_fields(): +def test_get_access_binding_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_search_ads360_links._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + 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_list_search_ads360_links_rest_interceptors(null_interceptor): +def test_get_access_binding_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -53025,14 +57878,14 @@ 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_get_access_binding" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_search_ads360_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_access_binding" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListSearchAds360LinksRequest.pb( - analytics_admin.ListSearchAds360LinksRequest() + pb_message = analytics_admin.GetAccessBindingRequest.pb( + analytics_admin.GetAccessBindingRequest() ) transcode.return_value = { "method": "post", @@ -53044,21 +57897,19 @@ def test_list_search_ads360_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.ListSearchAds360LinksResponse.to_json( - analytics_admin.ListSearchAds360LinksResponse() - ) + req.return_value._content = resources.AccessBinding.to_json( + resources.AccessBinding() ) - request = analytics_admin.ListSearchAds360LinksRequest() + request = analytics_admin.GetAccessBindingRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListSearchAds360LinksResponse() + post.return_value = resources.AccessBinding() - client.list_search_ads360_links( + client.get_access_binding( request, metadata=[ ("key", "val"), @@ -53070,8 +57921,8 @@ 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_get_access_binding_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetAccessBindingRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -53079,7 +57930,7 @@ def test_list_search_ads360_links_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + 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. @@ -53091,10 +57942,10 @@ 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) + client.get_access_binding(request) -def test_list_search_ads360_links_rest_flattened(): +def test_get_access_binding_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -53103,39 +57954,38 @@ def test_list_search_ads360_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.ListSearchAds360LinksResponse() + return_value = resources.AccessBinding() # 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", + 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.ListSearchAds360LinksResponse.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_search_ads360_links(**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/{parent=properties/*}/searchAds360Links" - % client.transport._host, + "%s/v1alpha/{name=accounts/*/accessBindings/*}" % client.transport._host, args[1], ) -def test_list_search_ads360_links_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, @@ -53144,134 +57994,73 @@ def test_list_search_ads360_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_search_ads360_links( - analytics_admin.ListSearchAds360LinksRequest(), - parent="parent_value", + client.get_access_binding( + analytics_admin.GetAccessBindingRequest(), + name="name_value", ) -def test_list_search_ads360_links_rest_pager(transport: str = "rest"): +def test_get_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.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.UpdateAccessBindingRequest, dict, ], ) -def test_create_search_ads360_link_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["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 = { + "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 = resources.SearchAds360Link( + return_value = resources.AccessBinding( name="name_value", - advertiser_id="advertiser_id_value", - advertiser_display_name="advertiser_display_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 = resources.SearchAds360Link.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.create_search_ads360_link(request) + response = client.update_access_binding(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.SearchAds360Link) + assert isinstance(response, resources.AccessBinding) assert response.name == "name_value" - assert response.advertiser_id == "advertiser_id_value" - assert response.advertiser_display_name == "advertiser_display_name_value" + assert response.roles == ["roles_value"] -def test_create_search_ads360_link_rest_required_fields( - request_type=analytics_admin.CreateSearchAds360LinkRequest, +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( @@ -53286,21 +58075,17 @@ 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) + ).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() - ).create_search_ads360_link._get_unset_required_fields(jsonified_request) + ).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(), @@ -53309,7 +58094,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 = 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 @@ -53321,7 +58106,7 @@ def test_create_search_ads360_link_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 @@ -53330,38 +58115,30 @@ 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) + 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.create_search_ads360_link(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_create_search_ads360_link_rest_unset_required_fields(): +def test_update_access_binding_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_search_ads360_link._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "searchAds360Link", - ) - ) - ) + 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_create_search_ads360_link_rest_interceptors(null_interceptor): +def test_update_access_binding_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -53374,15 +58151,14 @@ def test_create_search_ads360_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_create_search_ads360_link", + transports.AnalyticsAdminServiceRestInterceptor, "post_update_access_binding" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_search_ads360_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_access_binding" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateSearchAds360LinkRequest.pb( - analytics_admin.CreateSearchAds360LinkRequest() + pb_message = analytics_admin.UpdateAccessBindingRequest.pb( + analytics_admin.UpdateAccessBindingRequest() ) transcode.return_value = { "method": "post", @@ -53394,19 +58170,19 @@ 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() + req.return_value._content = resources.AccessBinding.to_json( + resources.AccessBinding() ) - request = analytics_admin.CreateSearchAds360LinkRequest() + request = analytics_admin.UpdateAccessBindingRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.SearchAds360Link() + post.return_value = resources.AccessBinding() - client.create_search_ads360_link( + client.update_access_binding( request, metadata=[ ("key", "val"), @@ -53418,8 +58194,8 @@ def test_create_search_ads360_link_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_search_ads360_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateSearchAds360LinkRequest +def test_update_access_binding_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateAccessBindingRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -53427,15 +58203,13 @@ 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 = { + "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) @@ -53448,10 +58222,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) + client.update_access_binding(request) -def test_create_search_ads360_link_rest_flattened(): +def test_update_access_binding_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -53460,40 +58234,41 @@ def test_create_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 = 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", - search_ads_360_link=resources.SearchAds360Link(name="name_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.SearchAds360Link.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.create_search_ads360_link(**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/*}/searchAds360Links" + "%s/v1alpha/{access_binding.name=accounts/*/accessBindings/*}" % client.transport._host, args[1], ) -def test_create_search_ads360_link_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, @@ -53502,14 +58277,13 @@ def test_create_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.create_search_ads360_link( - analytics_admin.CreateSearchAds360LinkRequest(), - parent="parent_value", - search_ads_360_link=resources.SearchAds360Link(name="name_value"), + client.update_access_binding( + analytics_admin.UpdateAccessBindingRequest(), + access_binding=resources.AccessBinding(user="user_value"), ) -def test_create_search_ads360_link_rest_error(): +def test_update_access_binding_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -53518,18 +58292,18 @@ def test_create_search_ads360_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteSearchAds360LinkRequest, + analytics_admin.DeleteAccessBindingRequest, dict, ], ) -def test_delete_search_ads360_link_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 = {"name": "properties/sample1/searchAds360Links/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. @@ -53544,14 +58318,14 @@ def test_delete_search_ads360_link_rest(request_type): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_search_ads360_link(request) + response = client.delete_access_binding(request) # Establish that the response is the type that we expect. assert response is None -def test_delete_search_ads360_link_rest_required_fields( - request_type=analytics_admin.DeleteSearchAds360LinkRequest, +def test_delete_access_binding_rest_required_fields( + request_type=analytics_admin.DeleteAccessBindingRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -53571,7 +58345,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) + ).delete_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -53580,7 +58354,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) + ).delete_access_binding._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -53618,24 +58392,24 @@ def test_delete_search_ads360_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_search_ads360_link(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_delete_search_ads360_link_rest_unset_required_fields(): +def test_delete_access_binding_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.delete_access_binding._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_delete_access_binding_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -53648,11 +58422,11 @@ 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, "pre_delete_access_binding" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteSearchAds360LinkRequest.pb( - analytics_admin.DeleteSearchAds360LinkRequest() + pb_message = analytics_admin.DeleteAccessBindingRequest.pb( + analytics_admin.DeleteAccessBindingRequest() ) transcode.return_value = { "method": "post", @@ -53665,14 +58439,14 @@ def test_delete_search_ads360_link_rest_interceptors(null_interceptor): req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - request = analytics_admin.DeleteSearchAds360LinkRequest() + request = analytics_admin.DeleteAccessBindingRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - client.delete_search_ads360_link( + client.delete_access_binding( request, metadata=[ ("key", "val"), @@ -53683,8 +58457,8 @@ def test_delete_search_ads360_link_rest_interceptors(null_interceptor): pre.assert_called_once() -def test_delete_search_ads360_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteSearchAds360LinkRequest +def test_delete_access_binding_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteAccessBindingRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -53692,7 +58466,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": "accounts/sample1/accessBindings/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -53704,10 +58478,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.delete_access_binding(request) -def test_delete_search_ads360_link_rest_flattened(): +def test_delete_access_binding_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -53719,7 +58493,7 @@ def test_delete_search_ads360_link_rest_flattened(): return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/searchAds360Links/sample2"} + sample_request = {"name": "accounts/sample1/accessBindings/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -53734,20 +58508,19 @@ def test_delete_search_ads360_link_rest_flattened(): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_search_ads360_link(**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/{name=properties/*/searchAds360Links/*}" - % client.transport._host, + "%s/v1alpha/{name=accounts/*/accessBindings/*}" % client.transport._host, args[1], ) -def test_delete_search_ads360_link_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, @@ -53756,13 +58529,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.delete_access_binding( + analytics_admin.DeleteAccessBindingRequest(), name="name_value", ) -def test_delete_search_ads360_link_rest_error(): +def test_delete_access_binding_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -53771,63 +58544,49 @@ def test_delete_search_ads360_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateSearchAds360LinkRequest, + analytics_admin.ListAccessBindingsRequest, dict, ], ) -def test_update_search_ads360_link_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 = { - "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": "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.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 = resources.SearchAds360Link.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_search_ads360_link(request) + response = client.list_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, pagers.ListAccessBindingsPager) + 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_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( @@ -53842,19 +58601,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_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_search_ads360_link._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(), @@ -53863,7 +58631,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.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 @@ -53875,39 +58643,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.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_search_ads360_link(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_search_ads360_link_rest_unset_required_fields(): +def test_list_access_bindings_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_access_bindings._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_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -53920,15 +58697,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_access_bindings" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_search_ads360_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_access_bindings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateSearchAds360LinkRequest.pb( - analytics_admin.UpdateSearchAds360LinkRequest() + pb_message = analytics_admin.ListAccessBindingsRequest.pb( + analytics_admin.ListAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -53940,19 +58716,19 @@ 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.ListAccessBindingsResponse.to_json( + analytics_admin.ListAccessBindingsResponse() ) - request = analytics_admin.UpdateSearchAds360LinkRequest() + request = analytics_admin.ListAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.SearchAds360Link() + post.return_value = analytics_admin.ListAccessBindingsResponse() - client.update_search_ads360_link( + client.list_access_bindings( request, metadata=[ ("key", "val"), @@ -53964,8 +58740,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_access_bindings_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListAccessBindingsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -53973,18 +58749,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": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -53996,10 +58761,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_access_bindings(request) -def test_update_search_ads360_link_rest_flattened(): +def test_list_access_bindings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -54008,44 +58773,38 @@ 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.ListAccessBindingsResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "search_ads_360_link": { - "name": "properties/sample1/searchAds360Links/sample2" - } - } + sample_request = {"parent": "accounts/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.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_search_ads360_link(**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/{search_ads_360_link.name=properties/*/searchAds360Links/*}" - % client.transport._host, + "%s/v1alpha/{parent=accounts/*}/accessBindings" % client.transport._host, args[1], ) -def test_update_search_ads360_link_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, @@ -54054,80 +58813,120 @@ 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_access_bindings( + analytics_admin.ListAccessBindingsRequest(), + parent="parent_value", ) -def test_update_search_ads360_link_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.GetAttributionSettingsRequest, + analytics_admin.BatchCreateAccessBindingsRequest, dict, ], ) -def test_get_attribution_settings_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/attributionSettings"} + 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.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, - ) + return_value = analytics_admin.BatchCreateAccessBindingsResponse() # 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 = 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.get_attribution_settings(request) + response = client.batch_create_access_bindings(request) # Establish that the response is the type that we expect. - 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 - ) + assert isinstance(response, analytics_admin.BatchCreateAccessBindingsResponse) -def test_get_attribution_settings_rest_required_fields( - request_type=analytics_admin.GetAttributionSettingsRequest, +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( @@ -54142,21 +58941,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) + ).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() - ).get_attribution_settings._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(), @@ -54165,7 +58964,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 = 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 @@ -54177,38 +58976,49 @@ 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 = 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.get_attribution_settings(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_get_attribution_settings_rest_unset_required_fields(): +def test_batch_create_access_bindings_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.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_get_attribution_settings_rest_interceptors(null_interceptor): +def test_batch_create_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -54221,14 +59031,16 @@ 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_batch_create_access_bindings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_attribution_settings" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_batch_create_access_bindings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetAttributionSettingsRequest.pb( - analytics_admin.GetAttributionSettingsRequest() + pb_message = analytics_admin.BatchCreateAccessBindingsRequest.pb( + analytics_admin.BatchCreateAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -54240,19 +59052,21 @@ 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 = ( + analytics_admin.BatchCreateAccessBindingsResponse.to_json( + analytics_admin.BatchCreateAccessBindingsResponse() + ) ) - request = analytics_admin.GetAttributionSettingsRequest() + request = analytics_admin.BatchCreateAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.AttributionSettings() + post.return_value = analytics_admin.BatchCreateAccessBindingsResponse() - client.get_attribution_settings( + client.batch_create_access_bindings( request, metadata=[ ("key", "val"), @@ -54264,8 +59078,9 @@ 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_batch_create_access_bindings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.BatchCreateAccessBindingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -54273,7 +59088,7 @@ def test_get_attribution_settings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/attributionSettings"} + request_init = {"parent": "accounts/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -54285,66 +59100,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) - - -def test_get_attribution_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.AttributionSettings() - - # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/attributionSettings"} - - # 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.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.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/*/attributionSettings}" - % client.transport._host, - args[1], - ) - - -def test_get_attribution_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.get_attribution_settings( - analytics_admin.GetAttributionSettingsRequest(), - name="name_value", - ) + client.batch_create_access_bindings(request) -def test_get_attribution_settings_rest_error(): +def test_batch_create_access_bindings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -54353,71 +59112,49 @@ def test_get_attribution_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateAttributionSettingsRequest, + analytics_admin.BatchGetAccessBindingsRequest, dict, ], ) -def test_update_attribution_settings_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 = { - "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_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.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, - ) + 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.AttributionSettings.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.update_attribution_settings(request) + response = client.batch_get_access_bindings(request) # Establish that the response is the type that we expect. - 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 - ) + assert isinstance(response, analytics_admin.BatchGetAccessBindingsResponse) -def test_update_attribution_settings_rest_required_fields( - request_type=analytics_admin.UpdateAttributionSettingsRequest, +def test_batch_get_access_bindings_rest_required_fields( + request_type=analytics_admin.BatchGetAccessBindingsRequest, ): 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( @@ -54429,22 +59166,32 @@ def test_update_attribution_settings_rest_required_fields( ) # verify fields with default values are dropped + assert "names" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_attribution_settings._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["parent"] = "parent_value" + jsonified_request["names"] = "names_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_attribution_settings._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(("update_mask",)) + 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(), @@ -54453,7 +59200,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 = 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 @@ -54465,47 +59212,54 @@ def test_update_attribution_settings_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.AttributionSettings.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.update_attribution_settings(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_update_attribution_settings_rest_unset_required_fields(): +def test_batch_get_access_bindings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_attribution_settings._get_unset_required_fields({}) + unset_fields = transport.batch_get_access_bindings._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("updateMask",)) + set(("names",)) & set( ( - "attributionSettings", - "updateMask", + "parent", + "names", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_attribution_settings_rest_interceptors(null_interceptor): +def test_batch_get_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -54519,15 +59273,14 @@ def test_update_attribution_settings_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.AnalyticsAdminServiceRestInterceptor, - "post_update_attribution_settings", + "post_batch_get_access_bindings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_attribution_settings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_get_access_bindings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateAttributionSettingsRequest.pb( - analytics_admin.UpdateAttributionSettingsRequest() + pb_message = analytics_admin.BatchGetAccessBindingsRequest.pb( + analytics_admin.BatchGetAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -54539,124 +59292,57 @@ 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 = ( + analytics_admin.BatchGetAccessBindingsResponse.to_json( + analytics_admin.BatchGetAccessBindingsResponse() + ) ) - request = analytics_admin.UpdateAttributionSettingsRequest() + request = analytics_admin.BatchGetAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.AttributionSettings() - - client.update_attribution_settings( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_attribution_settings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.UpdateAttributionSettingsRequest, -): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - 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 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_attribution_settings(request) - - -def test_update_attribution_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.AttributionSettings() - - # get arguments that satisfy an http rule for this method - sample_request = { - "attribution_settings": {"name": "properties/sample1/attributionSettings"} - } - - # get truthy value for each flattened field - mock_args = dict( - attribution_settings=resources.AttributionSettings(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.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_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/{attribution_settings.name=properties/*/attributionSettings}" - % client.transport._host, - args[1], + post.return_value = analytics_admin.BatchGetAccessBindingsResponse() + + client.batch_get_access_bindings( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) + pre.assert_called_once() + post.assert_called_once() + -def test_update_attribution_settings_rest_flattened_error(transport: str = "rest"): +def test_batch_get_access_bindings_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.BatchGetAccessBindingsRequest +): 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_attribution_settings( - analytics_admin.UpdateAttributionSettingsRequest(), - attribution_settings=resources.AttributionSettings(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) + # 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_access_bindings(request) -def test_update_attribution_settings_rest_error(): +def test_batch_get_access_bindings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -54665,44 +59351,140 @@ def test_update_attribution_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.RunAccessReportRequest, + analytics_admin.BatchUpdateAccessBindingsRequest, dict, ], ) -def test_run_access_report_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 = {"entity": "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.RunAccessReportResponse( - row_count=992, - ) + 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.RunAccessReportResponse.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.run_access_report(request) + response = client.batch_update_access_bindings(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.RunAccessReportResponse) - assert response.row_count == 992 + assert isinstance(response, analytics_admin.BatchUpdateAccessBindingsResponse) + + +def test_batch_update_access_bindings_rest_required_fields( + request_type=analytics_admin.BatchUpdateAccessBindingsRequest, +): + 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_update_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() + ).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 + 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.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 + # 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.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.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_batch_update_access_bindings_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.batch_update_access_bindings._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "requests", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_run_access_report_rest_interceptors(null_interceptor): +def test_batch_update_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -54715,14 +59497,16 @@ 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" + transports.AnalyticsAdminServiceRestInterceptor, + "post_batch_update_access_bindings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_run_access_report" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_batch_update_access_bindings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.RunAccessReportRequest.pb( - analytics_admin.RunAccessReportRequest() + pb_message = analytics_admin.BatchUpdateAccessBindingsRequest.pb( + analytics_admin.BatchUpdateAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -54734,19 +59518,21 @@ 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() + req.return_value._content = ( + analytics_admin.BatchUpdateAccessBindingsResponse.to_json( + analytics_admin.BatchUpdateAccessBindingsResponse() + ) ) - request = analytics_admin.RunAccessReportRequest() + request = analytics_admin.BatchUpdateAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.RunAccessReportResponse() + post.return_value = analytics_admin.BatchUpdateAccessBindingsResponse() - client.run_access_report( + client.batch_update_access_bindings( request, metadata=[ ("key", "val"), @@ -54758,8 +59544,9 @@ def test_run_access_report_rest_interceptors(null_interceptor): post.assert_called_once() -def test_run_access_report_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.RunAccessReportRequest +def test_batch_update_access_bindings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.BatchUpdateAccessBindingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -54767,7 +59554,7 @@ def test_run_access_report_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"entity": "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. @@ -54779,10 +59566,10 @@ 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.batch_update_access_bindings(request) -def test_run_access_report_rest_error(): +def test_batch_update_access_bindings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -54791,11 +59578,11 @@ def test_run_access_report_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.CreateAccessBindingRequest, + analytics_admin.BatchDeleteAccessBindingsRequest, dict, ], ) -def test_create_access_binding_rest(request_type): +def test_batch_delete_access_bindings_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -54803,40 +59590,28 @@ def test_create_access_binding_rest(request_type): # send a request that will satisfy transcoding 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.AccessBinding( - name="name_value", - roles=["roles_value"], - user="user_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AccessBinding.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_access_binding(request) + response = client.batch_delete_access_bindings(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.AccessBinding) - assert response.name == "name_value" - assert response.roles == ["roles_value"] + assert response is None -def test_create_access_binding_rest_required_fields( - request_type=analytics_admin.CreateAccessBindingRequest, +def test_batch_delete_access_bindings_rest_required_fields( + request_type=analytics_admin.BatchDeleteAccessBindingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -54856,7 +59631,7 @@ def test_create_access_binding_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_access_binding._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 @@ -54865,7 +59640,7 @@ def test_create_access_binding_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_access_binding._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 @@ -54879,7 +59654,7 @@ def test_create_access_binding_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.AccessBinding() + 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 @@ -54899,39 +59674,37 @@ def test_create_access_binding_rest_required_fields( response_value = Response() response_value.status_code = 200 - - pb_return_value = resources.AccessBinding.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_access_binding(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_access_binding_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_access_binding._get_unset_required_fields({}) + unset_fields = transport.batch_delete_access_bindings._get_unset_required_fields({}) assert set(unset_fields) == ( set(()) & set( ( "parent", - "accessBinding", + "requests", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_access_binding_rest_interceptors(null_interceptor): +def test_batch_delete_access_bindings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -54944,14 +59717,12 @@ def test_create_access_binding_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_access_binding" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_access_binding" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_batch_delete_access_bindings", ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreateAccessBindingRequest.pb( - analytics_admin.CreateAccessBindingRequest() + pb_message = analytics_admin.BatchDeleteAccessBindingsRequest.pb( + analytics_admin.BatchDeleteAccessBindingsRequest() ) transcode.return_value = { "method": "post", @@ -54963,19 +59734,15 @@ def test_create_access_binding_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.AccessBinding.to_json( - resources.AccessBinding() - ) - request = analytics_admin.CreateAccessBindingRequest() + request = analytics_admin.BatchDeleteAccessBindingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.AccessBinding() - client.create_access_binding( + client.batch_delete_access_bindings( request, metadata=[ ("key", "val"), @@ -54984,11 +59751,11 @@ def test_create_access_binding_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_access_binding_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateAccessBindingRequest +def test_batch_delete_access_bindings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.BatchDeleteAccessBindingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -54997,11 +59764,6 @@ def test_create_access_binding_rest_bad_request( # send a request that will satisfy transcoding 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. @@ -55013,67 +59775,10 @@ def test_create_access_binding_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_access_binding(request) - - -def test_create_access_binding_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.AccessBinding() - - # 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", - 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.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.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/{parent=accounts/*}/accessBindings" % client.transport._host, - args[1], - ) - - -def test_create_access_binding_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_access_binding( - analytics_admin.CreateAccessBindingRequest(), - parent="parent_value", - access_binding=resources.AccessBinding(user="user_value"), - ) + client.batch_delete_access_bindings(request) -def test_create_access_binding_rest_error(): +def test_batch_delete_access_bindings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -55082,47 +59787,52 @@ def test_create_access_binding_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetAccessBindingRequest, + analytics_admin.GetExpandedDataSetRequest, dict, ], ) -def test_get_access_binding_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": "accounts/sample1/accessBindings/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 = resources.AccessBinding( + return_value = expanded_data_set.ExpandedDataSet( name="name_value", - roles=["roles_value"], - user="user_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 - pb_return_value = resources.AccessBinding.pb(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.get_access_binding(request) + response = client.get_expanded_data_set(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.AccessBinding) + assert isinstance(response, expanded_data_set.ExpandedDataSet) assert response.name == "name_value" - assert response.roles == ["roles_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_access_binding_rest_required_fields( - request_type=analytics_admin.GetAccessBindingRequest, +def test_get_expanded_data_set_rest_required_fields( + request_type=analytics_admin.GetExpandedDataSetRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -55142,7 +59852,7 @@ def test_get_access_binding_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_access_binding._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 @@ -55151,7 +59861,7 @@ def test_get_access_binding_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_access_binding._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 @@ -55165,7 +59875,7 @@ def test_get_access_binding_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.AccessBinding() + 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 @@ -55185,30 +59895,30 @@ def test_get_access_binding_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AccessBinding.pb(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.get_access_binding(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_get_access_binding_rest_unset_required_fields(): +def test_get_expanded_data_set_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_access_binding._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_get_access_binding_rest_interceptors(null_interceptor): +def test_get_expanded_data_set_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -55221,14 +59931,14 @@ def test_get_access_binding_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_access_binding" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_expanded_data_set" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_access_binding" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_expanded_data_set" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetAccessBindingRequest.pb( - analytics_admin.GetAccessBindingRequest() + pb_message = analytics_admin.GetExpandedDataSetRequest.pb( + analytics_admin.GetExpandedDataSetRequest() ) transcode.return_value = { "method": "post", @@ -55240,19 +59950,19 @@ def test_get_access_binding_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.AccessBinding.to_json( - resources.AccessBinding() + req.return_value._content = expanded_data_set.ExpandedDataSet.to_json( + expanded_data_set.ExpandedDataSet() ) - request = analytics_admin.GetAccessBindingRequest() + request = analytics_admin.GetExpandedDataSetRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.AccessBinding() + post.return_value = expanded_data_set.ExpandedDataSet() - client.get_access_binding( + client.get_expanded_data_set( request, metadata=[ ("key", "val"), @@ -55264,8 +59974,8 @@ def test_get_access_binding_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_access_binding_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetAccessBindingRequest +def test_get_expanded_data_set_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetExpandedDataSetRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -55273,7 +59983,7 @@ def test_get_access_binding_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1/accessBindings/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. @@ -55285,10 +59995,10 @@ def test_get_access_binding_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_access_binding(request) + client.get_expanded_data_set(request) -def test_get_access_binding_rest_flattened(): +def test_get_expanded_data_set_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -55297,10 +60007,10 @@ def test_get_access_binding_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.AccessBinding() + return_value = expanded_data_set.ExpandedDataSet() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1/accessBindings/sample2"} + sample_request = {"name": "properties/sample1/expandedDataSets/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -55311,24 +60021,25 @@ def test_get_access_binding_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.AccessBinding.pb(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.get_access_binding(**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=accounts/*/accessBindings/*}" % client.transport._host, + "%s/v1alpha/{name=properties/*/expandedDataSets/*}" + % client.transport._host, args[1], ) -def test_get_access_binding_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, @@ -55337,13 +60048,13 @@ def test_get_access_binding_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_access_binding( - analytics_admin.GetAccessBindingRequest(), + client.get_expanded_data_set( + analytics_admin.GetExpandedDataSetRequest(), name="name_value", ) -def test_get_access_binding_rest_error(): +def test_get_expanded_data_set_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -55352,58 +60063,49 @@ def test_get_access_binding_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateAccessBindingRequest, + analytics_admin.ListExpandedDataSetsRequest, dict, ], ) -def test_update_access_binding_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 = { - "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_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.AccessBinding( - name="name_value", - roles=["roles_value"], - user="user_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.AccessBinding.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_access_binding(request) + response = client.list_expanded_data_sets(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.AccessBinding) - assert response.name == "name_value" - assert response.roles == ["roles_value"] + assert isinstance(response, pagers.ListExpandedDataSetsPager) + assert response.next_page_token == "next_page_token_value" -def test_update_access_binding_rest_required_fields( - request_type=analytics_admin.UpdateAccessBindingRequest, +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( @@ -55418,17 +60120,28 @@ def test_update_access_binding_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_access_binding._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_access_binding._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( + ( + "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(), @@ -55437,7 +60150,7 @@ def test_update_access_binding_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.AccessBinding() + 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 @@ -55449,39 +60162,48 @@ def test_update_access_binding_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.AccessBinding.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_access_binding(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_access_binding_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_access_binding._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("accessBinding",))) + 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_access_binding_rest_interceptors(null_interceptor): +def test_list_expanded_data_sets_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -55494,14 +60216,14 @@ def test_update_access_binding_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_access_binding" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_expanded_data_sets" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_access_binding" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_expanded_data_sets" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateAccessBindingRequest.pb( - analytics_admin.UpdateAccessBindingRequest() + pb_message = analytics_admin.ListExpandedDataSetsRequest.pb( + analytics_admin.ListExpandedDataSetsRequest() ) transcode.return_value = { "method": "post", @@ -55513,19 +60235,21 @@ def test_update_access_binding_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = resources.AccessBinding.to_json( - resources.AccessBinding() + req.return_value._content = ( + analytics_admin.ListExpandedDataSetsResponse.to_json( + analytics_admin.ListExpandedDataSetsResponse() + ) ) - request = analytics_admin.UpdateAccessBindingRequest() + request = analytics_admin.ListExpandedDataSetsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.AccessBinding() + post.return_value = analytics_admin.ListExpandedDataSetsResponse() - client.update_access_binding( + client.list_expanded_data_sets( request, metadata=[ ("key", "val"), @@ -55537,8 +60261,8 @@ def test_update_access_binding_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_access_binding_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateAccessBindingRequest +def test_list_expanded_data_sets_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListExpandedDataSetsRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -55546,14 +60270,7 @@ def test_update_access_binding_rest_bad_request( ) # send a request that will satisfy transcoding - 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_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -55565,10 +60282,10 @@ def test_update_access_binding_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_access_binding(request) + client.list_expanded_data_sets(request) -def test_update_access_binding_rest_flattened(): +def test_list_expanded_data_sets_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -55577,41 +60294,39 @@ def test_update_access_binding_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.AccessBinding() + return_value = analytics_admin.ListExpandedDataSetsResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "access_binding": {"name": "accounts/sample1/accessBindings/sample2"} - } + sample_request = {"parent": "properties/sample1"} # get truthy value for each flattened field mock_args = dict( - access_binding=resources.AccessBinding(user="user_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.AccessBinding.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_access_binding(**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/{access_binding.name=accounts/*/accessBindings/*}" + "%s/v1alpha/{parent=properties/*}/expandedDataSets" % client.transport._host, args[1], ) -def test_update_access_binding_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, @@ -55620,60 +60335,153 @@ def test_update_access_binding_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_access_binding( - analytics_admin.UpdateAccessBindingRequest(), - access_binding=resources.AccessBinding(user="user_value"), + client.list_expanded_data_sets( + analytics_admin.ListExpandedDataSetsRequest(), + parent="parent_value", ) -def test_update_access_binding_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.DeleteAccessBindingRequest, + analytics_admin.CreateExpandedDataSetRequest, dict, ], ) -def test_delete_access_binding_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": "accounts/sample1/accessBindings/sample2"} + 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 = None + 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"], + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_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.delete_access_binding(request) + response = client.create_expanded_data_set(request) # Establish that the response is the type that we expect. - assert response is None + 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_delete_access_binding_rest_required_fields( - request_type=analytics_admin.DeleteAccessBindingRequest, +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( @@ -55688,21 +60496,21 @@ def test_delete_access_binding_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_access_binding._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() - ).delete_access_binding._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(), @@ -55711,7 +60519,7 @@ def test_delete_access_binding_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + 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 @@ -55723,36 +60531,47 @@ def test_delete_access_binding_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 = 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.delete_access_binding(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_delete_access_binding_rest_unset_required_fields(): +def test_create_expanded_data_set_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_access_binding._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_delete_access_binding_rest_interceptors(null_interceptor): +def test_create_expanded_data_set_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -55765,11 +60584,14 @@ def test_delete_access_binding_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_access_binding" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_expanded_data_set" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_expanded_data_set" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteAccessBindingRequest.pb( - analytics_admin.DeleteAccessBindingRequest() + post.assert_not_called() + pb_message = analytics_admin.CreateExpandedDataSetRequest.pb( + analytics_admin.CreateExpandedDataSetRequest() ) transcode.return_value = { "method": "post", @@ -55781,15 +60603,19 @@ def test_delete_access_binding_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = gaa_expanded_data_set.ExpandedDataSet.to_json( + gaa_expanded_data_set.ExpandedDataSet() + ) - request = analytics_admin.DeleteAccessBindingRequest() + request = analytics_admin.CreateExpandedDataSetRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = gaa_expanded_data_set.ExpandedDataSet() - client.delete_access_binding( + client.create_expanded_data_set( request, metadata=[ ("key", "val"), @@ -55798,10 +60624,11 @@ def test_delete_access_binding_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_access_binding_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteAccessBindingRequest +def test_create_expanded_data_set_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateExpandedDataSetRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -55809,7 +60636,31 @@ def test_delete_access_binding_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "accounts/sample1/accessBindings/sample2"} + 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. @@ -55821,10 +60672,10 @@ def test_delete_access_binding_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_access_binding(request) + client.create_expanded_data_set(request) -def test_delete_access_binding_rest_flattened(): +def test_create_expanded_data_set_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -55833,37 +60684,40 @@ def test_delete_access_binding_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 = gaa_expanded_data_set.ExpandedDataSet() # get arguments that satisfy an http rule for this method - sample_request = {"name": "accounts/sample1/accessBindings/sample2"} + 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 - json_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.delete_access_binding(**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=accounts/*/accessBindings/*}" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/expandedDataSets" + % client.transport._host, args[1], ) -def test_delete_access_binding_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, @@ -55872,13 +60726,14 @@ def test_delete_access_binding_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_access_binding( - analytics_admin.DeleteAccessBindingRequest(), - 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_delete_access_binding_rest_error(): +def test_create_expanded_data_set_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -55887,49 +60742,82 @@ def test_delete_access_binding_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListAccessBindingsRequest, + analytics_admin.UpdateExpandedDataSetRequest, dict, ], ) -def test_list_access_bindings_rest(request_type): +def test_update_expanded_data_set_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 = { + "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} + } + 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 = analytics_admin.ListAccessBindingsResponse( - next_page_token="next_page_token_value", + 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"], ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListAccessBindingsResponse.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.list_access_bindings(request) + response = client.update_expanded_data_set(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAccessBindingsPager) - assert response.next_page_token == "next_page_token_value" + 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_list_access_bindings_rest_required_fields( - request_type=analytics_admin.ListAccessBindingsRequest, +def test_update_expanded_data_set_rest_required_fields( + request_type=analytics_admin.UpdateExpandedDataSetRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -55944,28 +60832,19 @@ def test_list_access_bindings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_access_bindings._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 - jsonified_request["parent"] = "parent_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_access_bindings._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( - ( - "page_size", - "page_token", - ) - ) + 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(), @@ -55974,7 +60853,7 @@ def test_list_access_bindings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListAccessBindingsResponse() + 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 @@ -55986,48 +60865,47 @@ def test_list_access_bindings_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.ListAccessBindingsResponse.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.list_access_bindings(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_list_access_bindings_rest_unset_required_fields(): +def test_update_expanded_data_set_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_access_bindings._get_unset_required_fields({}) + unset_fields = transport.update_expanded_data_set._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(("updateMask",)) + & set( ( - "pageSize", - "pageToken", + "expandedDataSet", + "updateMask", ) ) - & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_access_bindings_rest_interceptors(null_interceptor): +def test_update_expanded_data_set_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -56040,14 +60918,14 @@ def test_list_access_bindings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_access_bindings" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_expanded_data_set" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_access_bindings" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_expanded_data_set" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListAccessBindingsRequest.pb( - analytics_admin.ListAccessBindingsRequest() + pb_message = analytics_admin.UpdateExpandedDataSetRequest.pb( + analytics_admin.UpdateExpandedDataSetRequest() ) transcode.return_value = { "method": "post", @@ -56059,19 +60937,19 @@ def test_list_access_bindings_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.ListAccessBindingsResponse.to_json( - analytics_admin.ListAccessBindingsResponse() + req.return_value._content = gaa_expanded_data_set.ExpandedDataSet.to_json( + gaa_expanded_data_set.ExpandedDataSet() ) - request = analytics_admin.ListAccessBindingsRequest() + request = analytics_admin.UpdateExpandedDataSetRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListAccessBindingsResponse() + post.return_value = gaa_expanded_data_set.ExpandedDataSet() - client.list_access_bindings( + client.update_expanded_data_set( request, metadata=[ ("key", "val"), @@ -56083,8 +60961,8 @@ def test_list_access_bindings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_access_bindings_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListAccessBindingsRequest +def test_update_expanded_data_set_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateExpandedDataSetRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -56092,7 +60970,33 @@ def test_list_access_bindings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = { + "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} + } + 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 BadRequest error. @@ -56104,10 +61008,10 @@ def test_list_access_bindings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_access_bindings(request) + client.update_expanded_data_set(request) -def test_list_access_bindings_rest_flattened(): +def test_update_expanded_data_set_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -56116,38 +61020,42 @@ def test_list_access_bindings_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.ListAccessBindingsResponse() + return_value = gaa_expanded_data_set.ExpandedDataSet() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "accounts/sample1"} + sample_request = { + "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} + } # get truthy value for each flattened field mock_args = dict( - parent="parent_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) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListAccessBindingsResponse.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.list_access_bindings(**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/{parent=accounts/*}/accessBindings" % client.transport._host, + "%s/v1alpha/{expanded_data_set.name=properties/*/expandedDataSets/*}" + % client.transport._host, args[1], ) -def test_list_access_bindings_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, @@ -56156,120 +61064,61 @@ def test_list_access_bindings_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_access_bindings( - analytics_admin.ListAccessBindingsRequest(), - parent="parent_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_list_access_bindings_rest_pager(transport: str = "rest"): +def test_update_expanded_data_set_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.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.BatchCreateAccessBindingsRequest, + analytics_admin.DeleteExpandedDataSetRequest, dict, ], ) -def test_batch_create_access_bindings_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 = {"parent": "accounts/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.BatchCreateAccessBindingsResponse() + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchCreateAccessBindingsResponse.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.batch_create_access_bindings(request) + response = client.delete_expanded_data_set(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchCreateAccessBindingsResponse) + assert response is None -def test_batch_create_access_bindings_rest_required_fields( - request_type=analytics_admin.BatchCreateAccessBindingsRequest, +def test_delete_expanded_data_set_rest_required_fields( + request_type=analytics_admin.DeleteExpandedDataSetRequest, ): 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( @@ -56284,21 +61133,21 @@ def test_batch_create_access_bindings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_create_access_bindings._get_unset_required_fields(jsonified_request) + ).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["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_create_access_bindings._get_unset_required_fields(jsonified_request) + ).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 "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(), @@ -56307,7 +61156,7 @@ def test_batch_create_access_bindings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchCreateAccessBindingsResponse() + 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 @@ -56319,49 +61168,36 @@ def test_batch_create_access_bindings_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 = analytics_admin.BatchCreateAccessBindingsResponse.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.batch_create_access_bindings(request) + 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_batch_create_access_bindings_rest_unset_required_fields(): +def test_delete_expanded_data_set_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_create_access_bindings._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "requests", - ) - ) - ) + 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_batch_create_access_bindings_rest_interceptors(null_interceptor): +def test_delete_expanded_data_set_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -56374,16 +61210,11 @@ def test_batch_create_access_bindings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_batch_create_access_bindings", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_batch_create_access_bindings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_expanded_data_set" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.BatchCreateAccessBindingsRequest.pb( - analytics_admin.BatchCreateAccessBindingsRequest() + pb_message = analytics_admin.DeleteExpandedDataSetRequest.pb( + analytics_admin.DeleteExpandedDataSetRequest() ) transcode.return_value = { "method": "post", @@ -56395,21 +61226,15 @@ def test_batch_create_access_bindings_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.BatchCreateAccessBindingsRequest() + request = analytics_admin.DeleteExpandedDataSetRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchCreateAccessBindingsResponse() - client.batch_create_access_bindings( + client.delete_expanded_data_set( request, metadata=[ ("key", "val"), @@ -56418,12 +61243,10 @@ def test_batch_create_access_bindings_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_batch_create_access_bindings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.BatchCreateAccessBindingsRequest, +def test_delete_expanded_data_set_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteExpandedDataSetRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -56431,7 +61254,7 @@ def test_batch_create_access_bindings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/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. @@ -56443,10 +61266,65 @@ def test_batch_create_access_bindings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.batch_create_access_bindings(request) + client.delete_expanded_data_set(request) -def test_batch_create_access_bindings_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" ) @@ -56455,49 +61333,55 @@ def test_batch_create_access_bindings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchGetAccessBindingsRequest, + analytics_admin.GetChannelGroupRequest, dict, ], ) -def test_batch_get_access_bindings_rest(request_type): +def test_get_channel_group_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/channelGroups/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.BatchGetAccessBindingsResponse() + return_value = channel_group.ChannelGroup( + name="name_value", + display_name="display_name_value", + description="description_value", + system_defined=True, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchGetAccessBindingsResponse.pb( - return_value - ) + pb_return_value = channel_group.ChannelGroup.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_access_bindings(request) + response = client.get_channel_group(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchGetAccessBindingsResponse) + assert isinstance(response, channel_group.ChannelGroup) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.system_defined is True -def test_batch_get_access_bindings_rest_required_fields( - request_type=analytics_admin.BatchGetAccessBindingsRequest, +def test_get_channel_group_rest_required_fields( + request_type=analytics_admin.GetChannelGroupRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" - request_init["names"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -56509,32 +61393,24 @@ def test_batch_get_access_bindings_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_access_bindings._get_unset_required_fields(jsonified_request) + ).get_channel_group._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" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).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",)) + ).get_channel_group._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 "names" in jsonified_request - assert jsonified_request["names"] == "names_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -56543,7 +61419,7 @@ def test_batch_get_access_bindings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchGetAccessBindingsResponse() + return_value = channel_group.ChannelGroup() # 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 @@ -56563,46 +61439,30 @@ def test_batch_get_access_bindings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.BatchGetAccessBindingsResponse.pb( - return_value - ) + pb_return_value = channel_group.ChannelGroup.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_access_bindings(request) + response = client.get_channel_group(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_access_bindings_rest_unset_required_fields(): +def test_get_channel_group_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_get_access_bindings._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("names",)) - & set( - ( - "parent", - "names", - ) - ) - ) + unset_fields = transport.get_channel_group._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_get_access_bindings_rest_interceptors(null_interceptor): +def test_get_channel_group_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -56615,15 +61475,14 @@ def test_batch_get_access_bindings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_batch_get_access_bindings", + transports.AnalyticsAdminServiceRestInterceptor, "post_get_channel_group" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_batch_get_access_bindings" + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_channel_group" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.BatchGetAccessBindingsRequest.pb( - analytics_admin.BatchGetAccessBindingsRequest() + pb_message = analytics_admin.GetChannelGroupRequest.pb( + analytics_admin.GetChannelGroupRequest() ) transcode.return_value = { "method": "post", @@ -56635,21 +61494,19 @@ def test_batch_get_access_bindings_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.BatchGetAccessBindingsResponse.to_json( - analytics_admin.BatchGetAccessBindingsResponse() - ) + req.return_value._content = channel_group.ChannelGroup.to_json( + channel_group.ChannelGroup() ) - request = analytics_admin.BatchGetAccessBindingsRequest() + request = analytics_admin.GetChannelGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchGetAccessBindingsResponse() + post.return_value = channel_group.ChannelGroup() - client.batch_get_access_bindings( + client.get_channel_group( request, metadata=[ ("key", "val"), @@ -56661,8 +61518,8 @@ def test_batch_get_access_bindings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_batch_get_access_bindings_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.BatchGetAccessBindingsRequest +def test_get_channel_group_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetChannelGroupRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -56670,7 +61527,7 @@ def test_batch_get_access_bindings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = {"name": "properties/sample1/channelGroups/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -56682,10 +61539,65 @@ def test_batch_get_access_bindings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.batch_get_access_bindings(request) + client.get_channel_group(request) -def test_batch_get_access_bindings_rest_error(): +def test_get_channel_group_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 = channel_group.ChannelGroup() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "properties/sample1/channelGroups/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 = channel_group.ChannelGroup.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_channel_group(**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/*/channelGroups/*}" % client.transport._host, + args[1], + ) + + +def test_get_channel_group_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_channel_group( + analytics_admin.GetChannelGroupRequest(), + name="name_value", + ) + + +def test_get_channel_group_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -56694,43 +61606,44 @@ def test_batch_get_access_bindings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.BatchUpdateAccessBindingsRequest, + analytics_admin.ListChannelGroupsRequest, dict, ], ) -def test_batch_update_access_bindings_rest(request_type): +def test_list_channel_groups_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.BatchUpdateAccessBindingsResponse() + return_value = analytics_admin.ListChannelGroupsResponse( + 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.BatchUpdateAccessBindingsResponse.pb( - return_value - ) + pb_return_value = analytics_admin.ListChannelGroupsResponse.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_access_bindings(request) + response = client.list_channel_groups(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.BatchUpdateAccessBindingsResponse) + assert isinstance(response, pagers.ListChannelGroupsPager) + assert response.next_page_token == "next_page_token_value" -def test_batch_update_access_bindings_rest_required_fields( - request_type=analytics_admin.BatchUpdateAccessBindingsRequest, +def test_list_channel_groups_rest_required_fields( + request_type=analytics_admin.ListChannelGroupsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -56750,7 +61663,7 @@ def test_batch_update_access_bindings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_update_access_bindings._get_unset_required_fields(jsonified_request) + ).list_channel_groups._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -56759,7 +61672,14 @@ def test_batch_update_access_bindings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_update_access_bindings._get_unset_required_fields(jsonified_request) + ).list_channel_groups._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 @@ -56773,7 +61693,7 @@ def test_batch_update_access_bindings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.BatchUpdateAccessBindingsResponse() + return_value = analytics_admin.ListChannelGroupsResponse() # 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 @@ -56785,49 +61705,46 @@ def test_batch_update_access_bindings_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.BatchUpdateAccessBindingsResponse.pb( - return_value - ) + pb_return_value = analytics_admin.ListChannelGroupsResponse.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_access_bindings(request) + response = client.list_channel_groups(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_batch_update_access_bindings_rest_unset_required_fields(): +def test_list_channel_groups_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_update_access_bindings._get_unset_required_fields({}) + unset_fields = transport.list_channel_groups._get_unset_required_fields({}) assert set(unset_fields) == ( - set(()) - & set( + set( ( - "parent", - "requests", + "pageSize", + "pageToken", ) ) + & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_update_access_bindings_rest_interceptors(null_interceptor): +def test_list_channel_groups_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -56840,16 +61757,14 @@ def test_batch_update_access_bindings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_batch_update_access_bindings", + transports.AnalyticsAdminServiceRestInterceptor, "post_list_channel_groups" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_batch_update_access_bindings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_channel_groups" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.BatchUpdateAccessBindingsRequest.pb( - analytics_admin.BatchUpdateAccessBindingsRequest() + pb_message = analytics_admin.ListChannelGroupsRequest.pb( + analytics_admin.ListChannelGroupsRequest() ) transcode.return_value = { "method": "post", @@ -56861,21 +61776,19 @@ def test_batch_update_access_bindings_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.BatchUpdateAccessBindingsResponse.to_json( - analytics_admin.BatchUpdateAccessBindingsResponse() - ) + req.return_value._content = analytics_admin.ListChannelGroupsResponse.to_json( + analytics_admin.ListChannelGroupsResponse() ) - request = analytics_admin.BatchUpdateAccessBindingsRequest() + request = analytics_admin.ListChannelGroupsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.BatchUpdateAccessBindingsResponse() + post.return_value = analytics_admin.ListChannelGroupsResponse() - client.batch_update_access_bindings( + client.list_channel_groups( request, metadata=[ ("key", "val"), @@ -56883,78 +61796,222 @@ def test_batch_update_access_bindings_rest_interceptors(null_interceptor): ], ) - pre.assert_called_once() - post.assert_called_once() - - -def test_batch_update_access_bindings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.BatchUpdateAccessBindingsRequest, -): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) + pre.assert_called_once() + post.assert_called_once() + + +def test_list_channel_groups_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListChannelGroupsRequest +): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "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.list_channel_groups(request) + + +def test_list_channel_groups_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.ListChannelGroupsResponse() + + # 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.ListChannelGroupsResponse.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_channel_groups(**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/*}/channelGroups" % client.transport._host, + args[1], + ) + + +def test_list_channel_groups_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_channel_groups( + analytics_admin.ListChannelGroupsRequest(), + parent="parent_value", + ) + + +def test_list_channel_groups_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.ListChannelGroupsResponse( + channel_groups=[ + channel_group.ChannelGroup(), + channel_group.ChannelGroup(), + channel_group.ChannelGroup(), + ], + next_page_token="abc", + ), + analytics_admin.ListChannelGroupsResponse( + channel_groups=[], + next_page_token="def", + ), + analytics_admin.ListChannelGroupsResponse( + channel_groups=[ + channel_group.ChannelGroup(), + ], + next_page_token="ghi", + ), + analytics_admin.ListChannelGroupsResponse( + channel_groups=[ + channel_group.ChannelGroup(), + channel_group.ChannelGroup(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListChannelGroupsResponse.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 - # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} - request = request_type(**request_init) + sample_request = {"parent": "properties/sample1"} - # 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_update_access_bindings(request) + pager = client.list_channel_groups(request=sample_request) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, channel_group.ChannelGroup) for i in results) -def test_batch_update_access_bindings_rest_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) + pages = list(client.list_channel_groups(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.BatchDeleteAccessBindingsRequest, + analytics_admin.CreateChannelGroupRequest, dict, ], ) -def test_batch_delete_access_bindings_rest(request_type): +def test_create_channel_group_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_init["channel_group"] = { + "name": "name_value", + "display_name": "display_name_value", + "description": "description_value", + "grouping_rule": [ + { + "display_name": "display_name_value", + "expression": { + "and_group": {"filter_expressions": {}}, + "or_group": {}, + "not_expression": {}, + "filter": { + "string_filter": {"match_type": 1, "value": "value_value"}, + "in_list_filter": { + "values": ["values_value1", "values_value2"] + }, + "field_name": "field_name_value", + }, + }, + } + ], + "system_defined": 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 = gaa_channel_group.ChannelGroup( + name="name_value", + display_name="display_name_value", + description="description_value", + system_defined=True, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = gaa_channel_group.ChannelGroup.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_access_bindings(request) + response = client.create_channel_group(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, gaa_channel_group.ChannelGroup) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.description == "description_value" + assert response.system_defined is True -def test_batch_delete_access_bindings_rest_required_fields( - request_type=analytics_admin.BatchDeleteAccessBindingsRequest, +def test_create_channel_group_rest_required_fields( + request_type=analytics_admin.CreateChannelGroupRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -56974,7 +62031,7 @@ def test_batch_delete_access_bindings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_delete_access_bindings._get_unset_required_fields(jsonified_request) + ).create_channel_group._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -56983,7 +62040,7 @@ def test_batch_delete_access_bindings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_delete_access_bindings._get_unset_required_fields(jsonified_request) + ).create_channel_group._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -56997,7 +62054,7 @@ def test_batch_delete_access_bindings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = gaa_channel_group.ChannelGroup() # 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 @@ -57017,37 +62074,39 @@ def test_batch_delete_access_bindings_rest_required_fields( response_value = Response() response_value.status_code = 200 - json_return_value = "" + + pb_return_value = gaa_channel_group.ChannelGroup.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_access_bindings(request) + response = client.create_channel_group(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_batch_delete_access_bindings_rest_unset_required_fields(): +def test_create_channel_group_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_delete_access_bindings._get_unset_required_fields({}) + unset_fields = transport.create_channel_group._get_unset_required_fields({}) assert set(unset_fields) == ( set(()) & set( ( "parent", - "requests", + "channelGroup", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_delete_access_bindings_rest_interceptors(null_interceptor): +def test_create_channel_group_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -57060,12 +62119,14 @@ def test_batch_delete_access_bindings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_batch_delete_access_bindings", + transports.AnalyticsAdminServiceRestInterceptor, "post_create_channel_group" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_channel_group" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.BatchDeleteAccessBindingsRequest.pb( - analytics_admin.BatchDeleteAccessBindingsRequest() + post.assert_not_called() + pb_message = analytics_admin.CreateChannelGroupRequest.pb( + analytics_admin.CreateChannelGroupRequest() ) transcode.return_value = { "method": "post", @@ -57077,15 +62138,19 @@ def test_batch_delete_access_bindings_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = gaa_channel_group.ChannelGroup.to_json( + gaa_channel_group.ChannelGroup() + ) - request = analytics_admin.BatchDeleteAccessBindingsRequest() + request = analytics_admin.CreateChannelGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = gaa_channel_group.ChannelGroup() - client.batch_delete_access_bindings( + client.create_channel_group( request, metadata=[ ("key", "val"), @@ -57094,11 +62159,11 @@ def test_batch_delete_access_bindings_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_batch_delete_access_bindings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.BatchDeleteAccessBindingsRequest, +def test_create_channel_group_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateChannelGroupRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -57106,7 +62171,30 @@ def test_batch_delete_access_bindings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "accounts/sample1"} + request_init = {"parent": "properties/sample1"} + request_init["channel_group"] = { + "name": "name_value", + "display_name": "display_name_value", + "description": "description_value", + "grouping_rule": [ + { + "display_name": "display_name_value", + "expression": { + "and_group": {"filter_expressions": {}}, + "or_group": {}, + "not_expression": {}, + "filter": { + "string_filter": {"match_type": 1, "value": "value_value"}, + "in_list_filter": { + "values": ["values_value1", "values_value2"] + }, + "field_name": "field_name_value", + }, + }, + } + ], + "system_defined": True, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -57118,10 +62206,67 @@ def test_batch_delete_access_bindings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.batch_delete_access_bindings(request) + client.create_channel_group(request) -def test_batch_delete_access_bindings_rest_error(): +def test_create_channel_group_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 = gaa_channel_group.ChannelGroup() + + # 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", + channel_group=gaa_channel_group.ChannelGroup(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_channel_group.ChannelGroup.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_channel_group(**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/*}/channelGroups" % client.transport._host, + args[1], + ) + + +def test_create_channel_group_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_channel_group( + analytics_admin.CreateChannelGroupRequest(), + parent="parent_value", + channel_group=gaa_channel_group.ChannelGroup(name="name_value"), + ) + + +def test_create_channel_group_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -57130,57 +62275,79 @@ def test_batch_delete_access_bindings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetExpandedDataSetRequest, + analytics_admin.UpdateChannelGroupRequest, dict, ], ) -def test_get_expanded_data_set_rest(request_type): +def test_update_channel_group_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/expandedDataSets/sample2"} + request_init = { + "channel_group": {"name": "properties/sample1/channelGroups/sample2"} + } + request_init["channel_group"] = { + "name": "properties/sample1/channelGroups/sample2", + "display_name": "display_name_value", + "description": "description_value", + "grouping_rule": [ + { + "display_name": "display_name_value", + "expression": { + "and_group": {"filter_expressions": {}}, + "or_group": {}, + "not_expression": {}, + "filter": { + "string_filter": {"match_type": 1, "value": "value_value"}, + "in_list_filter": { + "values": ["values_value1", "values_value2"] + }, + "field_name": "field_name_value", + }, + }, + } + ], + "system_defined": 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 = expanded_data_set.ExpandedDataSet( + return_value = gaa_channel_group.ChannelGroup( name="name_value", display_name="display_name_value", description="description_value", - dimension_names=["dimension_names_value"], - metric_names=["metric_names_value"], + system_defined=True, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = expanded_data_set.ExpandedDataSet.pb(return_value) + pb_return_value = gaa_channel_group.ChannelGroup.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_expanded_data_set(request) + response = client.update_channel_group(request) # Establish that the response is the type that we expect. - assert isinstance(response, expanded_data_set.ExpandedDataSet) + assert isinstance(response, gaa_channel_group.ChannelGroup) 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"] + assert response.system_defined is True -def test_get_expanded_data_set_rest_required_fields( - request_type=analytics_admin.GetExpandedDataSetRequest, +def test_update_channel_group_rest_required_fields( + request_type=analytics_admin.UpdateChannelGroupRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -57195,21 +62362,19 @@ def test_get_expanded_data_set_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_expanded_data_set._get_unset_required_fields(jsonified_request) + ).update_channel_group._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_expanded_data_set._get_unset_required_fields(jsonified_request) + ).update_channel_group._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(), @@ -57218,7 +62383,7 @@ def test_get_expanded_data_set_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = expanded_data_set.ExpandedDataSet() + return_value = gaa_channel_group.ChannelGroup() # 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 @@ -57230,38 +62395,47 @@ def test_get_expanded_data_set_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 = expanded_data_set.ExpandedDataSet.pb(return_value) + pb_return_value = gaa_channel_group.ChannelGroup.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_expanded_data_set(request) + response = client.update_channel_group(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_expanded_data_set_rest_unset_required_fields(): +def test_update_channel_group_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_expanded_data_set._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.update_channel_group._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "channelGroup", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_expanded_data_set_rest_interceptors(null_interceptor): +def test_update_channel_group_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -57274,14 +62448,14 @@ def test_get_expanded_data_set_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_expanded_data_set" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_channel_group" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_expanded_data_set" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_channel_group" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetExpandedDataSetRequest.pb( - analytics_admin.GetExpandedDataSetRequest() + pb_message = analytics_admin.UpdateChannelGroupRequest.pb( + analytics_admin.UpdateChannelGroupRequest() ) transcode.return_value = { "method": "post", @@ -57293,19 +62467,19 @@ def test_get_expanded_data_set_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() + req.return_value._content = gaa_channel_group.ChannelGroup.to_json( + gaa_channel_group.ChannelGroup() ) - request = analytics_admin.GetExpandedDataSetRequest() + request = analytics_admin.UpdateChannelGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = expanded_data_set.ExpandedDataSet() + post.return_value = gaa_channel_group.ChannelGroup() - client.get_expanded_data_set( + client.update_channel_group( request, metadata=[ ("key", "val"), @@ -57317,8 +62491,8 @@ def test_get_expanded_data_set_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_expanded_data_set_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetExpandedDataSetRequest +def test_update_channel_group_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateChannelGroupRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -57326,7 +62500,32 @@ def test_get_expanded_data_set_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/expandedDataSets/sample2"} + request_init = { + "channel_group": {"name": "properties/sample1/channelGroups/sample2"} + } + request_init["channel_group"] = { + "name": "properties/sample1/channelGroups/sample2", + "display_name": "display_name_value", + "description": "description_value", + "grouping_rule": [ + { + "display_name": "display_name_value", + "expression": { + "and_group": {"filter_expressions": {}}, + "or_group": {}, + "not_expression": {}, + "filter": { + "string_filter": {"match_type": 1, "value": "value_value"}, + "in_list_filter": { + "values": ["values_value1", "values_value2"] + }, + "field_name": "field_name_value", + }, + }, + } + ], + "system_defined": True, + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -57338,10 +62537,10 @@ def test_get_expanded_data_set_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_expanded_data_set(request) + client.update_channel_group(request) -def test_get_expanded_data_set_rest_flattened(): +def test_update_channel_group_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -57350,39 +62549,42 @@ def test_get_expanded_data_set_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 = expanded_data_set.ExpandedDataSet() + return_value = gaa_channel_group.ChannelGroup() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/expandedDataSets/sample2"} + sample_request = { + "channel_group": {"name": "properties/sample1/channelGroups/sample2"} + } # get truthy value for each flattened field mock_args = dict( - name="name_value", + channel_group=gaa_channel_group.ChannelGroup(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 = expanded_data_set.ExpandedDataSet.pb(return_value) + pb_return_value = gaa_channel_group.ChannelGroup.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_expanded_data_set(**mock_args) + client.update_channel_group(**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/*}" + "%s/v1alpha/{channel_group.name=properties/*/channelGroups/*}" % client.transport._host, args[1], ) -def test_get_expanded_data_set_rest_flattened_error(transport: str = "rest"): +def test_update_channel_group_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -57391,13 +62593,14 @@ def test_get_expanded_data_set_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_expanded_data_set( - analytics_admin.GetExpandedDataSetRequest(), - name="name_value", + client.update_channel_group( + analytics_admin.UpdateChannelGroupRequest(), + channel_group=gaa_channel_group.ChannelGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_get_expanded_data_set_rest_error(): +def test_update_channel_group_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -57406,49 +62609,45 @@ def test_get_expanded_data_set_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListExpandedDataSetsRequest, + analytics_admin.DeleteChannelGroupRequest, dict, ], ) -def test_list_expanded_data_sets_rest(request_type): +def test_delete_channel_group_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/channelGroups/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.ListExpandedDataSetsResponse( - 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.ListExpandedDataSetsResponse.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_expanded_data_sets(request) + response = client.delete_channel_group(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListExpandedDataSetsPager) - assert response.next_page_token == "next_page_token_value" + assert response is None -def test_list_expanded_data_sets_rest_required_fields( - request_type=analytics_admin.ListExpandedDataSetsRequest, +def test_delete_channel_group_rest_required_fields( + request_type=analytics_admin.DeleteChannelGroupRequest, ): 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( @@ -57463,28 +62662,21 @@ def test_list_expanded_data_sets_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_expanded_data_sets._get_unset_required_fields(jsonified_request) + ).delete_channel_group._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_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( - ( - "page_size", - "page_token", - ) - ) + ).delete_channel_group._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(), @@ -57493,7 +62685,7 @@ def test_list_expanded_data_sets_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListExpandedDataSetsResponse() + 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 @@ -57505,48 +62697,36 @@ def test_list_expanded_data_sets_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.ListExpandedDataSetsResponse.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_expanded_data_sets(request) + response = client.delete_channel_group(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_expanded_data_sets_rest_unset_required_fields(): +def test_delete_channel_group_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_expanded_data_sets._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.delete_channel_group._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_expanded_data_sets_rest_interceptors(null_interceptor): +def test_delete_channel_group_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -57559,14 +62739,11 @@ def test_list_expanded_data_sets_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_expanded_data_sets" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_expanded_data_sets" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_channel_group" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.ListExpandedDataSetsRequest.pb( - analytics_admin.ListExpandedDataSetsRequest() + pb_message = analytics_admin.DeleteChannelGroupRequest.pb( + analytics_admin.DeleteChannelGroupRequest() ) transcode.return_value = { "method": "post", @@ -57578,21 +62755,15 @@ def test_list_expanded_data_sets_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.ListExpandedDataSetsResponse.to_json( - analytics_admin.ListExpandedDataSetsResponse() - ) - ) - request = analytics_admin.ListExpandedDataSetsRequest() + request = analytics_admin.DeleteChannelGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListExpandedDataSetsResponse() - client.list_expanded_data_sets( + client.delete_channel_group( request, metadata=[ ("key", "val"), @@ -57601,11 +62772,10 @@ def test_list_expanded_data_sets_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_list_expanded_data_sets_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListExpandedDataSetsRequest +def test_delete_channel_group_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteChannelGroupRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -57613,7 +62783,7 @@ def test_list_expanded_data_sets_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = {"name": "properties/sample1/channelGroups/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -57625,10 +62795,10 @@ def test_list_expanded_data_sets_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_expanded_data_sets(request) + client.delete_channel_group(request) -def test_list_expanded_data_sets_rest_flattened(): +def test_delete_channel_group_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -57637,39 +62807,37 @@ def test_list_expanded_data_sets_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.ListExpandedDataSetsResponse() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = {"name": "properties/sample1/channelGroups/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.ListExpandedDataSetsResponse.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_expanded_data_sets(**mock_args) + client.delete_channel_group(**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/*}/expandedDataSets" - % client.transport._host, + "%s/v1alpha/{name=properties/*/channelGroups/*}" % client.transport._host, args[1], ) -def test_list_expanded_data_sets_rest_flattened_error(transport: str = "rest"): +def test_delete_channel_group_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -57678,153 +62846,65 @@ def test_list_expanded_data_sets_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_expanded_data_sets( - analytics_admin.ListExpandedDataSetsRequest(), - parent="parent_value", + client.delete_channel_group( + analytics_admin.DeleteChannelGroupRequest(), + name="name_value", ) -def test_list_expanded_data_sets_rest_pager(transport: str = "rest"): +def test_delete_channel_group_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.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.CreateExpandedDataSetRequest, + analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, dict, ], ) -def test_create_expanded_data_set_rest(request_type): +def test_set_automated_ga4_configuration_opt_out_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["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_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 = 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"], - ) + return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) + pb_return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.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_expanded_data_set(request) + response = client.set_automated_ga4_configuration_opt_out(request) # 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"] + assert isinstance( + response, analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse + ) -def test_create_expanded_data_set_rest_required_fields( - request_type=analytics_admin.CreateExpandedDataSetRequest, +def test_set_automated_ga4_configuration_opt_out_rest_required_fields( + request_type=analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" + request_init["property"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -57839,21 +62919,25 @@ def test_create_expanded_data_set_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_expanded_data_set._get_unset_required_fields(jsonified_request) + ).set_automated_ga4_configuration_opt_out._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" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_expanded_data_set._get_unset_required_fields(jsonified_request) + ).set_automated_ga4_configuration_opt_out._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" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -57862,7 +62946,7 @@ def test_create_expanded_data_set_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = gaa_expanded_data_set.ExpandedDataSet() + return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() # 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 @@ -57883,38 +62967,36 @@ def test_create_expanded_data_set_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) + pb_return_value = ( + analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.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_expanded_data_set(request) + response = client.set_automated_ga4_configuration_opt_out(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_expanded_data_set_rest_unset_required_fields(): +def test_set_automated_ga4_configuration_opt_out_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_expanded_data_set._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "expandedDataSet", - ) - ) + unset_fields = ( + transport.set_automated_ga4_configuration_opt_out._get_unset_required_fields({}) ) + assert set(unset_fields) == (set(()) & set(("property",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_expanded_data_set_rest_interceptors(null_interceptor): +def test_set_automated_ga4_configuration_opt_out_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -57927,14 +63009,16 @@ def test_create_expanded_data_set_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_expanded_data_set" + transports.AnalyticsAdminServiceRestInterceptor, + "post_set_automated_ga4_configuration_opt_out", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_expanded_data_set" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_set_automated_ga4_configuration_opt_out", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateExpandedDataSetRequest.pb( - analytics_admin.CreateExpandedDataSetRequest() + pb_message = analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest.pb( + analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() ) transcode.return_value = { "method": "post", @@ -57946,19 +63030,21 @@ def test_create_expanded_data_set_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = gaa_expanded_data_set.ExpandedDataSet.to_json( - gaa_expanded_data_set.ExpandedDataSet() + req.return_value._content = ( + analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.to_json( + analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() + ) ) - request = analytics_admin.CreateExpandedDataSetRequest() + request = analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gaa_expanded_data_set.ExpandedDataSet() + post.return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() - client.create_expanded_data_set( + client.set_automated_ga4_configuration_opt_out( request, metadata=[ ("key", "val"), @@ -57970,8 +63056,9 @@ def test_create_expanded_data_set_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_expanded_data_set_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateExpandedDataSetRequest +def test_set_automated_ga4_configuration_opt_out_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -57979,31 +63066,7 @@ def test_create_expanded_data_set_rest_bad_request( ) # send a request that will satisfy transcoding - 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_init = {} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -58015,68 +63078,10 @@ def test_create_expanded_data_set_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_expanded_data_set(request) - - -def test_create_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 = gaa_expanded_data_set.ExpandedDataSet() - - # 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", - 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 = 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.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/{parent=properties/*}/expandedDataSets" - % client.transport._host, - args[1], - ) - - -def test_create_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.create_expanded_data_set( - analytics_admin.CreateExpandedDataSetRequest(), - parent="parent_value", - expanded_data_set=gaa_expanded_data_set.ExpandedDataSet(name="name_value"), - ) + client.set_automated_ga4_configuration_opt_out(request) -def test_create_expanded_data_set_rest_error(): +def test_set_automated_ga4_configuration_opt_out_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -58085,82 +63090,55 @@ def test_create_expanded_data_set_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateExpandedDataSetRequest, + analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, dict, ], ) -def test_update_expanded_data_set_rest(request_type): +def test_fetch_automated_ga4_configuration_opt_out_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} - } - 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_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 = 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"], + return_value = analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse( + opt_out=True, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) + pb_return_value = ( + analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.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_expanded_data_set(request) + response = client.fetch_automated_ga4_configuration_opt_out(request) # 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"] + assert isinstance( + response, analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse + ) + assert response.opt_out is True -def test_update_expanded_data_set_rest_required_fields( - request_type=analytics_admin.UpdateExpandedDataSetRequest, +def test_fetch_automated_ga4_configuration_opt_out_rest_required_fields( + request_type=analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["property"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -58175,19 +63153,25 @@ def test_update_expanded_data_set_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_expanded_data_set._get_unset_required_fields(jsonified_request) + ).fetch_automated_ga4_configuration_opt_out._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" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).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",)) + ).fetch_automated_ga4_configuration_opt_out._get_unset_required_fields( + jsonified_request + ) 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" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -58196,7 +63180,7 @@ def test_update_expanded_data_set_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = gaa_expanded_data_set.ExpandedDataSet() + return_value = analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse() # 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 @@ -58208,7 +63192,7 @@ def test_update_expanded_data_set_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 @@ -58217,38 +63201,38 @@ def test_update_expanded_data_set_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_expanded_data_set.ExpandedDataSet.pb(return_value) + pb_return_value = ( + analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.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_expanded_data_set(request) + response = client.fetch_automated_ga4_configuration_opt_out(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_expanded_data_set_rest_unset_required_fields(): +def test_fetch_automated_ga4_configuration_opt_out_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_expanded_data_set._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("updateMask",)) - & set( - ( - "expandedDataSet", - "updateMask", - ) + unset_fields = ( + transport.fetch_automated_ga4_configuration_opt_out._get_unset_required_fields( + {} ) ) + assert set(unset_fields) == (set(()) & set(("property",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_expanded_data_set_rest_interceptors(null_interceptor): +def test_fetch_automated_ga4_configuration_opt_out_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -58261,14 +63245,16 @@ def test_update_expanded_data_set_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_expanded_data_set" + transports.AnalyticsAdminServiceRestInterceptor, + "post_fetch_automated_ga4_configuration_opt_out", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_expanded_data_set" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_fetch_automated_ga4_configuration_opt_out", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateExpandedDataSetRequest.pb( - analytics_admin.UpdateExpandedDataSetRequest() + pb_message = analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest.pb( + analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() ) transcode.return_value = { "method": "post", @@ -58280,19 +63266,23 @@ def test_update_expanded_data_set_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = gaa_expanded_data_set.ExpandedDataSet.to_json( - gaa_expanded_data_set.ExpandedDataSet() + req.return_value._content = ( + analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.to_json( + analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse() + ) ) - request = analytics_admin.UpdateExpandedDataSetRequest() + request = analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gaa_expanded_data_set.ExpandedDataSet() + post.return_value = ( + analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse() + ) - client.update_expanded_data_set( + client.fetch_automated_ga4_configuration_opt_out( request, metadata=[ ("key", "val"), @@ -58304,8 +63294,9 @@ def test_update_expanded_data_set_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_expanded_data_set_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateExpandedDataSetRequest +def test_fetch_automated_ga4_configuration_opt_out_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -58313,33 +63304,7 @@ def test_update_expanded_data_set_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} - } - 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_init = {} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -58351,70 +63316,10 @@ def test_update_expanded_data_set_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_expanded_data_set(request) - - -def test_update_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 = gaa_expanded_data_set.ExpandedDataSet() - - # get arguments that satisfy an http rule for this method - sample_request = { - "expanded_data_set": {"name": "properties/sample1/expandedDataSets/sample2"} - } - - # get truthy value for each flattened field - mock_args = dict( - 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) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - 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_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/{expanded_data_set.name=properties/*/expandedDataSets/*}" - % client.transport._host, - args[1], - ) - - -def test_update_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.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"]), - ) + client.fetch_automated_ga4_configuration_opt_out(request) -def test_update_expanded_data_set_rest_error(): +def test_fetch_automated_ga4_configuration_opt_out_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -58423,40 +63328,58 @@ def test_update_expanded_data_set_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteExpandedDataSetRequest, + analytics_admin.GetBigQueryLinkRequest, dict, ], ) -def test_delete_expanded_data_set_rest(request_type): +def test_get_big_query_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/expandedDataSets/sample2"} + request_init = {"name": "properties/sample1/bigQueryLinks/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.BigQueryLink( + name="name_value", + project="project_value", + daily_export_enabled=True, + streaming_export_enabled=True, + intraday_export_enabled=True, + include_advertising_id=True, + export_streams=["export_streams_value"], + excluded_events=["excluded_events_value"], + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + pb_return_value = resources.BigQueryLink.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_expanded_data_set(request) + response = client.get_big_query_link(request) # Establish that the response is the type that we expect. - assert response is None + 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.intraday_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_delete_expanded_data_set_rest_required_fields( - request_type=analytics_admin.DeleteExpandedDataSetRequest, +def test_get_big_query_link_rest_required_fields( + request_type=analytics_admin.GetBigQueryLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -58476,7 +63399,7 @@ def test_delete_expanded_data_set_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_expanded_data_set._get_unset_required_fields(jsonified_request) + ).get_big_query_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -58485,7 +63408,7 @@ def test_delete_expanded_data_set_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_expanded_data_set._get_unset_required_fields(jsonified_request) + ).get_big_query_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -58499,7 +63422,7 @@ def test_delete_expanded_data_set_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = resources.BigQueryLink() # 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 @@ -58511,36 +63434,38 @@ def test_delete_expanded_data_set_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.BigQueryLink.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_expanded_data_set(request) + response = client.get_big_query_link(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(): +def test_get_big_query_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_expanded_data_set._get_unset_required_fields({}) + unset_fields = transport.get_big_query_link._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_expanded_data_set_rest_interceptors(null_interceptor): +def test_get_big_query_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -58553,11 +63478,14 @@ def test_delete_expanded_data_set_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_expanded_data_set" + transports.AnalyticsAdminServiceRestInterceptor, "post_get_big_query_link" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_big_query_link" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteExpandedDataSetRequest.pb( - analytics_admin.DeleteExpandedDataSetRequest() + post.assert_not_called() + pb_message = analytics_admin.GetBigQueryLinkRequest.pb( + analytics_admin.GetBigQueryLinkRequest() ) transcode.return_value = { "method": "post", @@ -58569,15 +63497,19 @@ def test_delete_expanded_data_set_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() + req.return_value._content = resources.BigQueryLink.to_json( + resources.BigQueryLink() + ) - request = analytics_admin.DeleteExpandedDataSetRequest() + request = analytics_admin.GetBigQueryLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = resources.BigQueryLink() - client.delete_expanded_data_set( + client.get_big_query_link( request, metadata=[ ("key", "val"), @@ -58586,10 +63518,11 @@ def test_delete_expanded_data_set_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_expanded_data_set_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteExpandedDataSetRequest +def test_get_big_query_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetBigQueryLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -58597,7 +63530,7 @@ def test_delete_expanded_data_set_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/expandedDataSets/sample2"} + request_init = {"name": "properties/sample1/bigQueryLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -58609,10 +63542,10 @@ def test_delete_expanded_data_set_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_expanded_data_set(request) + client.get_big_query_link(request) -def test_delete_expanded_data_set_rest_flattened(): +def test_get_big_query_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -58621,10 +63554,10 @@ def test_delete_expanded_data_set_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.BigQueryLink() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/expandedDataSets/sample2"} + sample_request = {"name": "properties/sample1/bigQueryLinks/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -58635,24 +63568,24 @@ def test_delete_expanded_data_set_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.BigQueryLink.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_expanded_data_set(**mock_args) + client.get_big_query_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/*/expandedDataSets/*}" - % client.transport._host, + "%s/v1alpha/{name=properties/*/bigQueryLinks/*}" % client.transport._host, args[1], ) -def test_delete_expanded_data_set_rest_flattened_error(transport: str = "rest"): +def test_get_big_query_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -58661,13 +63594,13 @@ def test_delete_expanded_data_set_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_expanded_data_set( - analytics_admin.DeleteExpandedDataSetRequest(), + client.get_big_query_link( + analytics_admin.GetBigQueryLinkRequest(), name="name_value", ) -def test_delete_expanded_data_set_rest_error(): +def test_get_big_query_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -58676,55 +63609,49 @@ def test_delete_expanded_data_set_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetChannelGroupRequest, + analytics_admin.ListBigQueryLinksRequest, dict, ], ) -def test_get_channel_group_rest(request_type): +def test_list_big_query_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/channelGroups/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 = channel_group.ChannelGroup( - name="name_value", - display_name="display_name_value", - description="description_value", - system_defined=True, + return_value = analytics_admin.ListBigQueryLinksResponse( + 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 = channel_group.ChannelGroup.pb(return_value) + pb_return_value = analytics_admin.ListBigQueryLinksResponse.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_channel_group(request) + response = client.list_big_query_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, channel_group.ChannelGroup) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.system_defined is True + assert isinstance(response, pagers.ListBigQueryLinksPager) + assert response.next_page_token == "next_page_token_value" -def test_get_channel_group_rest_required_fields( - request_type=analytics_admin.GetChannelGroupRequest, +def test_list_big_query_links_rest_required_fields( + request_type=analytics_admin.ListBigQueryLinksRequest, ): 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( @@ -58739,21 +63666,28 @@ def test_get_channel_group_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_channel_group._get_unset_required_fields(jsonified_request) + ).list_big_query_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_channel_group._get_unset_required_fields(jsonified_request) + ).list_big_query_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(), @@ -58762,7 +63696,7 @@ def test_get_channel_group_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = channel_group.ChannelGroup() + return_value = analytics_admin.ListBigQueryLinksResponse() # 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 @@ -58782,30 +63716,38 @@ def test_get_channel_group_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = channel_group.ChannelGroup.pb(return_value) + pb_return_value = analytics_admin.ListBigQueryLinksResponse.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_channel_group(request) + response = client.list_big_query_links(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_channel_group_rest_unset_required_fields(): +def test_list_big_query_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_channel_group._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.list_big_query_links._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_channel_group_rest_interceptors(null_interceptor): +def test_list_big_query_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -58818,14 +63760,14 @@ def test_get_channel_group_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_channel_group" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_big_query_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_channel_group" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_big_query_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetChannelGroupRequest.pb( - analytics_admin.GetChannelGroupRequest() + pb_message = analytics_admin.ListBigQueryLinksRequest.pb( + analytics_admin.ListBigQueryLinksRequest() ) transcode.return_value = { "method": "post", @@ -58837,19 +63779,19 @@ def test_get_channel_group_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = channel_group.ChannelGroup.to_json( - channel_group.ChannelGroup() + req.return_value._content = analytics_admin.ListBigQueryLinksResponse.to_json( + analytics_admin.ListBigQueryLinksResponse() ) - request = analytics_admin.GetChannelGroupRequest() + request = analytics_admin.ListBigQueryLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = channel_group.ChannelGroup() + post.return_value = analytics_admin.ListBigQueryLinksResponse() - client.get_channel_group( + client.list_big_query_links( request, metadata=[ ("key", "val"), @@ -58861,8 +63803,8 @@ def test_get_channel_group_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_channel_group_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetChannelGroupRequest +def test_list_big_query_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListBigQueryLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -58870,7 +63812,7 @@ def test_get_channel_group_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/channelGroups/sample2"} + request_init = {"parent": "properties/sample1"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -58882,10 +63824,10 @@ def test_get_channel_group_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_channel_group(request) + client.list_big_query_links(request) -def test_get_channel_group_rest_flattened(): +def test_list_big_query_links_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -58894,38 +63836,38 @@ def test_get_channel_group_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 = channel_group.ChannelGroup() + return_value = analytics_admin.ListBigQueryLinksResponse() # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/channelGroups/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 = channel_group.ChannelGroup.pb(return_value) + pb_return_value = analytics_admin.ListBigQueryLinksResponse.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_channel_group(**mock_args) + client.list_big_query_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/*/channelGroups/*}" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/bigQueryLinks" % client.transport._host, args[1], ) -def test_get_channel_group_rest_flattened_error(transport: str = "rest"): +def test_list_big_query_links_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -58934,64 +63876,143 @@ def test_get_channel_group_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_channel_group( - analytics_admin.GetChannelGroupRequest(), - name="name_value", + client.list_big_query_links( + analytics_admin.ListBigQueryLinksRequest(), + parent="parent_value", ) -def test_get_channel_group_rest_error(): +def test_list_big_query_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.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(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListBigQueryLinksResponse.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_big_query_links(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.BigQueryLink) for i in results) + + pages = list(client.list_big_query_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.ListChannelGroupsRequest, + analytics_admin.GetEnhancedMeasurementSettingsRequest, dict, ], ) -def test_list_channel_groups_rest(request_type): +def test_get_enhanced_measurement_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/dataStreams/sample2/enhancedMeasurementSettings" + } 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.ListChannelGroupsResponse( - next_page_token="next_page_token_value", + return_value = resources.EnhancedMeasurementSettings( + name="name_value", + stream_enabled=True, + scrolls_enabled=True, + outbound_clicks_enabled=True, + site_search_enabled=True, + video_engagement_enabled=True, + file_downloads_enabled=True, + page_changes_enabled=True, + form_interactions_enabled=True, + search_query_parameter="search_query_parameter_value", + uri_query_parameter="uri_query_parameter_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListChannelGroupsResponse.pb(return_value) + pb_return_value = resources.EnhancedMeasurementSettings.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_channel_groups(request) + response = client.get_enhanced_measurement_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListChannelGroupsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.EnhancedMeasurementSettings) + assert response.name == "name_value" + assert response.stream_enabled is True + assert response.scrolls_enabled is True + assert response.outbound_clicks_enabled is True + assert response.site_search_enabled is True + assert response.video_engagement_enabled is True + assert response.file_downloads_enabled is True + assert response.page_changes_enabled is True + assert response.form_interactions_enabled is True + assert response.search_query_parameter == "search_query_parameter_value" + assert response.uri_query_parameter == "uri_query_parameter_value" -def test_list_channel_groups_rest_required_fields( - request_type=analytics_admin.ListChannelGroupsRequest, +def test_get_enhanced_measurement_settings_rest_required_fields( + request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest, ): 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( @@ -59006,28 +64027,21 @@ def test_list_channel_groups_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_channel_groups._get_unset_required_fields(jsonified_request) + ).get_enhanced_measurement_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_channel_groups._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_enhanced_measurement_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(), @@ -59036,7 +64050,7 @@ def test_list_channel_groups_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListChannelGroupsResponse() + return_value = resources.EnhancedMeasurementSettings() # 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 @@ -59056,38 +64070,32 @@ def test_list_channel_groups_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListChannelGroupsResponse.pb(return_value) + pb_return_value = resources.EnhancedMeasurementSettings.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_channel_groups(request) + response = client.get_enhanced_measurement_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_channel_groups_rest_unset_required_fields(): +def test_get_enhanced_measurement_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_channel_groups._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) + unset_fields = ( + transport.get_enhanced_measurement_settings._get_unset_required_fields({}) ) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_channel_groups_rest_interceptors(null_interceptor): +def test_get_enhanced_measurement_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -59100,14 +64108,16 @@ def test_list_channel_groups_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_channel_groups" + transports.AnalyticsAdminServiceRestInterceptor, + "post_get_enhanced_measurement_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_channel_groups" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_get_enhanced_measurement_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListChannelGroupsRequest.pb( - analytics_admin.ListChannelGroupsRequest() + pb_message = analytics_admin.GetEnhancedMeasurementSettingsRequest.pb( + analytics_admin.GetEnhancedMeasurementSettingsRequest() ) transcode.return_value = { "method": "post", @@ -59119,19 +64129,19 @@ def test_list_channel_groups_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.ListChannelGroupsResponse.to_json( - analytics_admin.ListChannelGroupsResponse() + req.return_value._content = resources.EnhancedMeasurementSettings.to_json( + resources.EnhancedMeasurementSettings() ) - request = analytics_admin.ListChannelGroupsRequest() + request = analytics_admin.GetEnhancedMeasurementSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListChannelGroupsResponse() + post.return_value = resources.EnhancedMeasurementSettings() - client.list_channel_groups( + client.get_enhanced_measurement_settings( request, metadata=[ ("key", "val"), @@ -59143,8 +64153,9 @@ def test_list_channel_groups_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_channel_groups_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListChannelGroupsRequest +def test_get_enhanced_measurement_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -59152,7 +64163,9 @@ def test_list_channel_groups_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} + request_init = { + "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -59164,10 +64177,10 @@ def test_list_channel_groups_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_channel_groups(request) + client.get_enhanced_measurement_settings(request) -def test_list_channel_groups_rest_flattened(): +def test_get_enhanced_measurement_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -59176,38 +64189,43 @@ def test_list_channel_groups_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.ListChannelGroupsResponse() + return_value = resources.EnhancedMeasurementSettings() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = { + "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" + } # 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.ListChannelGroupsResponse.pb(return_value) + pb_return_value = resources.EnhancedMeasurementSettings.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_channel_groups(**mock_args) + client.get_enhanced_measurement_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/*}/channelGroups" % client.transport._host, + "%s/v1alpha/{name=properties/*/dataStreams/*/enhancedMeasurementSettings}" + % client.transport._host, args[1], ) -def test_list_channel_groups_rest_flattened_error(transport: str = "rest"): +def test_get_enhanced_measurement_settings_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -59216,150 +64234,100 @@ def test_list_channel_groups_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_channel_groups( - analytics_admin.ListChannelGroupsRequest(), - parent="parent_value", + client.get_enhanced_measurement_settings( + analytics_admin.GetEnhancedMeasurementSettingsRequest(), + name="name_value", ) -def test_list_channel_groups_rest_pager(transport: str = "rest"): +def test_get_enhanced_measurement_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.ListChannelGroupsResponse( - channel_groups=[ - channel_group.ChannelGroup(), - channel_group.ChannelGroup(), - channel_group.ChannelGroup(), - ], - next_page_token="abc", - ), - analytics_admin.ListChannelGroupsResponse( - channel_groups=[], - next_page_token="def", - ), - analytics_admin.ListChannelGroupsResponse( - channel_groups=[ - channel_group.ChannelGroup(), - ], - next_page_token="ghi", - ), - analytics_admin.ListChannelGroupsResponse( - channel_groups=[ - channel_group.ChannelGroup(), - channel_group.ChannelGroup(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - analytics_admin.ListChannelGroupsResponse.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_channel_groups(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, channel_group.ChannelGroup) for i in results) - - pages = list(client.list_channel_groups(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.CreateChannelGroupRequest, + analytics_admin.UpdateEnhancedMeasurementSettingsRequest, dict, ], ) -def test_create_channel_group_rest(request_type): +def test_update_enhanced_measurement_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["channel_group"] = { - "name": "name_value", - "display_name": "display_name_value", - "description": "description_value", - "grouping_rule": [ - { - "display_name": "display_name_value", - "expression": { - "and_group": {"filter_expressions": {}}, - "or_group": {}, - "not_expression": {}, - "filter": { - "string_filter": {"match_type": 1, "value": "value_value"}, - "in_list_filter": { - "values": ["values_value1", "values_value2"] - }, - "field_name": "field_name_value", - }, - }, - } - ], - "system_defined": True, + + # send a request that will satisfy transcoding + request_init = { + "enhanced_measurement_settings": { + "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" + } + } + request_init["enhanced_measurement_settings"] = { + "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings", + "stream_enabled": True, + "scrolls_enabled": True, + "outbound_clicks_enabled": True, + "site_search_enabled": True, + "video_engagement_enabled": True, + "file_downloads_enabled": True, + "page_changes_enabled": True, + "form_interactions_enabled": True, + "search_query_parameter": "search_query_parameter_value", + "uri_query_parameter": "uri_query_parameter_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 = gaa_channel_group.ChannelGroup( + return_value = resources.EnhancedMeasurementSettings( name="name_value", - display_name="display_name_value", - description="description_value", - system_defined=True, + stream_enabled=True, + scrolls_enabled=True, + outbound_clicks_enabled=True, + site_search_enabled=True, + video_engagement_enabled=True, + file_downloads_enabled=True, + page_changes_enabled=True, + form_interactions_enabled=True, + search_query_parameter="search_query_parameter_value", + uri_query_parameter="uri_query_parameter_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_channel_group.ChannelGroup.pb(return_value) + pb_return_value = resources.EnhancedMeasurementSettings.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_channel_group(request) + response = client.update_enhanced_measurement_settings(request) # Establish that the response is the type that we expect. - assert isinstance(response, gaa_channel_group.ChannelGroup) + assert isinstance(response, resources.EnhancedMeasurementSettings) assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.system_defined is True + assert response.stream_enabled is True + assert response.scrolls_enabled is True + assert response.outbound_clicks_enabled is True + assert response.site_search_enabled is True + assert response.video_engagement_enabled is True + assert response.file_downloads_enabled is True + assert response.page_changes_enabled is True + assert response.form_interactions_enabled is True + assert response.search_query_parameter == "search_query_parameter_value" + assert response.uri_query_parameter == "uri_query_parameter_value" -def test_create_channel_group_rest_required_fields( - request_type=analytics_admin.CreateChannelGroupRequest, +def test_update_enhanced_measurement_settings_rest_required_fields( + request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -59374,21 +64342,19 @@ def test_create_channel_group_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_channel_group._get_unset_required_fields(jsonified_request) + ).update_enhanced_measurement_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" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_channel_group._get_unset_required_fields(jsonified_request) + ).update_enhanced_measurement_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 "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -59397,7 +64363,7 @@ def test_create_channel_group_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = gaa_channel_group.ChannelGroup() + return_value = resources.EnhancedMeasurementSettings() # 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 @@ -59409,7 +64375,7 @@ def test_create_channel_group_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 @@ -59418,38 +64384,40 @@ def test_create_channel_group_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_channel_group.ChannelGroup.pb(return_value) + pb_return_value = resources.EnhancedMeasurementSettings.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_channel_group(request) + response = client.update_enhanced_measurement_settings(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_channel_group_rest_unset_required_fields(): +def test_update_enhanced_measurement_settings_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_channel_group._get_unset_required_fields({}) + unset_fields = ( + transport.update_enhanced_measurement_settings._get_unset_required_fields({}) + ) assert set(unset_fields) == ( - set(()) + set(("updateMask",)) & set( ( - "parent", - "channelGroup", + "enhancedMeasurementSettings", + "updateMask", ) ) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_channel_group_rest_interceptors(null_interceptor): +def test_update_enhanced_measurement_settings_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -59462,14 +64430,16 @@ def test_create_channel_group_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_create_channel_group" + transports.AnalyticsAdminServiceRestInterceptor, + "post_update_enhanced_measurement_settings", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_channel_group" + transports.AnalyticsAdminServiceRestInterceptor, + "pre_update_enhanced_measurement_settings", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.CreateChannelGroupRequest.pb( - analytics_admin.CreateChannelGroupRequest() + pb_message = analytics_admin.UpdateEnhancedMeasurementSettingsRequest.pb( + analytics_admin.UpdateEnhancedMeasurementSettingsRequest() ) transcode.return_value = { "method": "post", @@ -59481,19 +64451,19 @@ def test_create_channel_group_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = gaa_channel_group.ChannelGroup.to_json( - gaa_channel_group.ChannelGroup() + req.return_value._content = resources.EnhancedMeasurementSettings.to_json( + resources.EnhancedMeasurementSettings() ) - request = analytics_admin.CreateChannelGroupRequest() + request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gaa_channel_group.ChannelGroup() + post.return_value = resources.EnhancedMeasurementSettings() - client.create_channel_group( + client.update_enhanced_measurement_settings( request, metadata=[ ("key", "val"), @@ -59505,8 +64475,9 @@ def test_create_channel_group_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_channel_group_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateChannelGroupRequest +def test_update_enhanced_measurement_settings_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -59514,29 +64485,23 @@ def test_create_channel_group_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"parent": "properties/sample1"} - request_init["channel_group"] = { - "name": "name_value", - "display_name": "display_name_value", - "description": "description_value", - "grouping_rule": [ - { - "display_name": "display_name_value", - "expression": { - "and_group": {"filter_expressions": {}}, - "or_group": {}, - "not_expression": {}, - "filter": { - "string_filter": {"match_type": 1, "value": "value_value"}, - "in_list_filter": { - "values": ["values_value1", "values_value2"] - }, - "field_name": "field_name_value", - }, - }, - } - ], - "system_defined": True, + request_init = { + "enhanced_measurement_settings": { + "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" + } + } + request_init["enhanced_measurement_settings"] = { + "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings", + "stream_enabled": True, + "scrolls_enabled": True, + "outbound_clicks_enabled": True, + "site_search_enabled": True, + "video_engagement_enabled": True, + "file_downloads_enabled": True, + "page_changes_enabled": True, + "form_interactions_enabled": True, + "search_query_parameter": "search_query_parameter_value", + "uri_query_parameter": "uri_query_parameter_value", } request = request_type(**request_init) @@ -59549,10 +64514,10 @@ def test_create_channel_group_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.create_channel_group(request) + client.update_enhanced_measurement_settings(request) -def test_create_channel_group_rest_flattened(): +def test_update_enhanced_measurement_settings_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -59561,39 +64526,48 @@ def test_create_channel_group_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_channel_group.ChannelGroup() + return_value = resources.EnhancedMeasurementSettings() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "properties/sample1"} + sample_request = { + "enhanced_measurement_settings": { + "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" + } + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - channel_group=gaa_channel_group.ChannelGroup(name="name_value"), + enhanced_measurement_settings=resources.EnhancedMeasurementSettings( + 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 = gaa_channel_group.ChannelGroup.pb(return_value) + pb_return_value = resources.EnhancedMeasurementSettings.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_channel_group(**mock_args) + client.update_enhanced_measurement_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/*}/channelGroups" % client.transport._host, + "%s/v1alpha/{enhanced_measurement_settings.name=properties/*/dataStreams/*/enhancedMeasurementSettings}" + % client.transport._host, args[1], ) -def test_create_channel_group_rest_flattened_error(transport: str = "rest"): +def test_update_enhanced_measurement_settings_rest_flattened_error( + transport: str = "rest", +): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -59602,14 +64576,16 @@ def test_create_channel_group_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_channel_group( - analytics_admin.CreateChannelGroupRequest(), - parent="parent_value", - channel_group=gaa_channel_group.ChannelGroup(name="name_value"), + client.update_enhanced_measurement_settings( + analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), + enhanced_measurement_settings=resources.EnhancedMeasurementSettings( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_create_channel_group_rest_error(): +def test_update_enhanced_measurement_settings_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -59618,75 +64594,43 @@ def test_create_channel_group_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateChannelGroupRequest, + analytics_admin.CreateConnectedSiteTagRequest, dict, ], ) -def test_update_channel_group_rest(request_type): +def test_create_connected_site_tag_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "channel_group": {"name": "properties/sample1/channelGroups/sample2"} - } - request_init["channel_group"] = { - "name": "properties/sample1/channelGroups/sample2", - "display_name": "display_name_value", - "description": "description_value", - "grouping_rule": [ - { - "display_name": "display_name_value", - "expression": { - "and_group": {"filter_expressions": {}}, - "or_group": {}, - "not_expression": {}, - "filter": { - "string_filter": {"match_type": 1, "value": "value_value"}, - "in_list_filter": { - "values": ["values_value1", "values_value2"] - }, - "field_name": "field_name_value", - }, - }, - } - ], - "system_defined": True, - } + 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 = gaa_channel_group.ChannelGroup( - name="name_value", - display_name="display_name_value", - description="description_value", - system_defined=True, - ) + return_value = analytics_admin.CreateConnectedSiteTagResponse() # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_channel_group.ChannelGroup.pb(return_value) + pb_return_value = analytics_admin.CreateConnectedSiteTagResponse.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_channel_group(request) + response = client.create_connected_site_tag(request) # Establish that the response is the type that we expect. - assert isinstance(response, gaa_channel_group.ChannelGroup) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.system_defined is True + assert isinstance(response, analytics_admin.CreateConnectedSiteTagResponse) -def test_update_channel_group_rest_required_fields( - request_type=analytics_admin.UpdateChannelGroupRequest, +def test_create_connected_site_tag_rest_required_fields( + request_type=analytics_admin.CreateConnectedSiteTagRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -59705,16 +64649,14 @@ def test_update_channel_group_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_channel_group._get_unset_required_fields(jsonified_request) + ).create_connected_site_tag._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_channel_group._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",)) + ).create_connected_site_tag._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -59726,7 +64668,7 @@ def test_update_channel_group_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = gaa_channel_group.ChannelGroup() + return_value = analytics_admin.CreateConnectedSiteTagResponse() # 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 @@ -59738,7 +64680,7 @@ def test_update_channel_group_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 @@ -59747,38 +64689,32 @@ def test_update_channel_group_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gaa_channel_group.ChannelGroup.pb(return_value) + pb_return_value = analytics_admin.CreateConnectedSiteTagResponse.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_channel_group(request) + response = client.create_connected_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_channel_group_rest_unset_required_fields(): +def test_create_connected_site_tag_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_channel_group._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("updateMask",)) - & set( - ( - "channelGroup", - "updateMask", - ) - ) - ) + unset_fields = transport.create_connected_site_tag._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("connectedSiteTag",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_channel_group_rest_interceptors(null_interceptor): +def test_create_connected_site_tag_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -59791,14 +64727,15 @@ def test_update_channel_group_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_update_channel_group" + transports.AnalyticsAdminServiceRestInterceptor, + "post_create_connected_site_tag", ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_update_channel_group" + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_connected_site_tag" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateChannelGroupRequest.pb( - analytics_admin.UpdateChannelGroupRequest() + pb_message = analytics_admin.CreateConnectedSiteTagRequest.pb( + analytics_admin.CreateConnectedSiteTagRequest() ) transcode.return_value = { "method": "post", @@ -59810,19 +64747,21 @@ def test_update_channel_group_rest_interceptors(null_interceptor): req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = gaa_channel_group.ChannelGroup.to_json( - gaa_channel_group.ChannelGroup() + req.return_value._content = ( + analytics_admin.CreateConnectedSiteTagResponse.to_json( + analytics_admin.CreateConnectedSiteTagResponse() + ) ) - request = analytics_admin.UpdateChannelGroupRequest() + request = analytics_admin.CreateConnectedSiteTagRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gaa_channel_group.ChannelGroup() + post.return_value = analytics_admin.CreateConnectedSiteTagResponse() - client.update_channel_group( + client.create_connected_site_tag( request, metadata=[ ("key", "val"), @@ -59834,8 +64773,8 @@ def test_update_channel_group_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_channel_group_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.UpdateChannelGroupRequest +def test_create_connected_site_tag_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateConnectedSiteTagRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -59843,32 +64782,7 @@ def test_update_channel_group_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "channel_group": {"name": "properties/sample1/channelGroups/sample2"} - } - request_init["channel_group"] = { - "name": "properties/sample1/channelGroups/sample2", - "display_name": "display_name_value", - "description": "description_value", - "grouping_rule": [ - { - "display_name": "display_name_value", - "expression": { - "and_group": {"filter_expressions": {}}, - "or_group": {}, - "not_expression": {}, - "filter": { - "string_filter": {"match_type": 1, "value": "value_value"}, - "in_list_filter": { - "values": ["values_value1", "values_value2"] - }, - "field_name": "field_name_value", - }, - }, - } - ], - "system_defined": True, - } + request_init = {} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -59880,70 +64794,249 @@ def test_update_channel_group_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_channel_group(request) + client.create_connected_site_tag(request) -def test_update_channel_group_rest_flattened(): +def test_create_connected_site_tag_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.DeleteConnectedSiteTagRequest, + dict, + ], +) +def test_delete_connected_site_tag_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 = gaa_channel_group.ChannelGroup() + return_value = None - # get arguments that satisfy an http rule for this method - sample_request = { - "channel_group": {"name": "properties/sample1/channelGroups/sample2"} + # 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_connected_site_tag(request) + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_connected_site_tag_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_connected_site_tag" + ) as pre: + pre.assert_not_called() + pb_message = analytics_admin.DeleteConnectedSiteTagRequest.pb( + analytics_admin.DeleteConnectedSiteTagRequest() + ) + 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.DeleteConnectedSiteTagRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_connected_site_tag( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_delete_connected_site_tag_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteConnectedSiteTagRequest +): + 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.delete_connected_site_tag(request) + + +def test_delete_connected_site_tag_rest_error(): + client = AnalyticsAdminServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + analytics_admin.ListConnectedSiteTagsRequest, + dict, + ], +) +def test_list_connected_site_tags_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.ListConnectedSiteTagsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = analytics_admin.ListConnectedSiteTagsResponse.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_connected_site_tags(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, analytics_admin.ListConnectedSiteTagsResponse) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_connected_site_tags_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_connected_site_tags" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_connected_site_tags" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = analytics_admin.ListConnectedSiteTagsRequest.pb( + analytics_admin.ListConnectedSiteTagsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, } - # get truthy value for each flattened field - mock_args = dict( - channel_group=gaa_channel_group.ChannelGroup(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + analytics_admin.ListConnectedSiteTagsResponse.to_json( + analytics_admin.ListConnectedSiteTagsResponse() + ) ) - 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_channel_group.ChannelGroup.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_channel_group(**mock_args) + request = analytics_admin.ListConnectedSiteTagsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = analytics_admin.ListConnectedSiteTagsResponse() - # 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/{channel_group.name=properties/*/channelGroups/*}" - % client.transport._host, - args[1], + client.list_connected_site_tags( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) + pre.assert_called_once() + post.assert_called_once() + -def test_update_channel_group_rest_flattened_error(transport: str = "rest"): +def test_list_connected_site_tags_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListConnectedSiteTagsRequest +): 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_channel_group( - analytics_admin.UpdateChannelGroupRequest(), - channel_group=gaa_channel_group.ChannelGroup(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) + # 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_connected_site_tags(request) -def test_update_channel_group_rest_error(): + +def test_list_connected_site_tags_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -59952,45 +65045,51 @@ def test_update_channel_group_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.DeleteChannelGroupRequest, + analytics_admin.FetchConnectedGa4PropertyRequest, dict, ], ) -def test_delete_channel_group_rest(request_type): +def test_fetch_connected_ga4_property_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/channelGroups/sample2"} + 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 = None + return_value = analytics_admin.FetchConnectedGa4PropertyResponse( + property="property_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.FetchConnectedGa4PropertyResponse.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_channel_group(request) + response = client.fetch_connected_ga4_property(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, analytics_admin.FetchConnectedGa4PropertyResponse) + assert response.property == "property_value" -def test_delete_channel_group_rest_required_fields( - request_type=analytics_admin.DeleteChannelGroupRequest, +def test_fetch_connected_ga4_property_rest_required_fields( + request_type=analytics_admin.FetchConnectedGa4PropertyRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["name"] = "" + request_init["property"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -60002,24 +65101,29 @@ def test_delete_channel_group_rest_required_fields( ) # verify fields with default values are dropped + assert "property" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_channel_group._get_unset_required_fields(jsonified_request) + ).fetch_connected_ga4_property._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + assert "property" in jsonified_request + assert jsonified_request["property"] == request_init["property"] - jsonified_request["name"] = "name_value" + jsonified_request["property"] = "property_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_channel_group._get_unset_required_fields(jsonified_request) + ).fetch_connected_ga4_property._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("property",)) 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 "property" in jsonified_request + assert jsonified_request["property"] == "property_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -60028,7 +65132,7 @@ def test_delete_channel_group_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = analytics_admin.FetchConnectedGa4PropertyResponse() # 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 @@ -60040,36 +65144,46 @@ def test_delete_channel_group_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 = analytics_admin.FetchConnectedGa4PropertyResponse.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_channel_group(request) + response = client.fetch_connected_ga4_property(request) - expected_params = [("$alt", "json;enum-encoding=int")] + expected_params = [ + ( + "property", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_channel_group_rest_unset_required_fields(): +def test_fetch_connected_ga4_property_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_channel_group._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.fetch_connected_ga4_property._get_unset_required_fields({}) + assert set(unset_fields) == (set(("property",)) & set(("property",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_channel_group_rest_interceptors(null_interceptor): +def test_fetch_connected_ga4_property_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -60082,11 +65196,16 @@ def test_delete_channel_group_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_channel_group" + transports.AnalyticsAdminServiceRestInterceptor, + "post_fetch_connected_ga4_property", + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, + "pre_fetch_connected_ga4_property", ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteChannelGroupRequest.pb( - analytics_admin.DeleteChannelGroupRequest() + post.assert_not_called() + pb_message = analytics_admin.FetchConnectedGa4PropertyRequest.pb( + analytics_admin.FetchConnectedGa4PropertyRequest() ) transcode.return_value = { "method": "post", @@ -60098,15 +65217,21 @@ def test_delete_channel_group_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.FetchConnectedGa4PropertyResponse.to_json( + analytics_admin.FetchConnectedGa4PropertyResponse() + ) + ) - request = analytics_admin.DeleteChannelGroupRequest() + request = analytics_admin.FetchConnectedGa4PropertyRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = analytics_admin.FetchConnectedGa4PropertyResponse() - client.delete_channel_group( + client.fetch_connected_ga4_property( request, metadata=[ ("key", "val"), @@ -60115,10 +65240,12 @@ def test_delete_channel_group_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_channel_group_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteChannelGroupRequest +def test_fetch_connected_ga4_property_rest_bad_request( + transport: str = "rest", + request_type=analytics_admin.FetchConnectedGa4PropertyRequest, ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -60126,7 +65253,7 @@ def test_delete_channel_group_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/channelGroups/sample2"} + request_init = {} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -60138,64 +65265,10 @@ def test_delete_channel_group_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_channel_group(request) - - -def test_delete_channel_group_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/channelGroups/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_channel_group(**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/*/channelGroups/*}" % client.transport._host, - args[1], - ) - - -def test_delete_channel_group_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_channel_group( - analytics_admin.DeleteChannelGroupRequest(), - name="name_value", - ) + client.fetch_connected_ga4_property(request) -def test_delete_channel_group_rest_error(): +def test_fetch_connected_ga4_property_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -60204,50 +65277,51 @@ def test_delete_channel_group_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, + analytics_admin.GetAdSenseLinkRequest, dict, ], ) -def test_set_automated_ga4_configuration_opt_out_rest(request_type): +def test_get_ad_sense_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"name": "properties/sample1/adSenseLinks/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.SetAutomatedGa4ConfigurationOptOutResponse() + return_value = resources.AdSenseLink( + name="name_value", + ad_client_code="ad_client_code_value", + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.pb( - return_value - ) + pb_return_value = resources.AdSenseLink.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.set_automated_ga4_configuration_opt_out(request) + response = client.get_ad_sense_link(request) # Establish that the response is the type that we expect. - assert isinstance( - response, analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse - ) + assert isinstance(response, resources.AdSenseLink) + assert response.name == "name_value" + assert response.ad_client_code == "ad_client_code_value" -def test_set_automated_ga4_configuration_opt_out_rest_required_fields( - request_type=analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, +def test_get_ad_sense_link_rest_required_fields( + request_type=analytics_admin.GetAdSenseLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["property"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -60262,25 +65336,21 @@ def test_set_automated_ga4_configuration_opt_out_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_automated_ga4_configuration_opt_out._get_unset_required_fields( - jsonified_request - ) + ).get_ad_sense_link._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["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_automated_ga4_configuration_opt_out._get_unset_required_fields( - jsonified_request - ) + ).get_ad_sense_link._get_unset_required_fields(jsonified_request) 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 "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -60289,7 +65359,7 @@ def test_set_automated_ga4_configuration_opt_out_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() + return_value = resources.AdSenseLink() # 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 @@ -60301,45 +65371,38 @@ def test_set_automated_ga4_configuration_opt_out_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.SetAutomatedGa4ConfigurationOptOutResponse.pb( - return_value - ) - ) + pb_return_value = resources.AdSenseLink.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.set_automated_ga4_configuration_opt_out(request) + response = client.get_ad_sense_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_automated_ga4_configuration_opt_out_rest_unset_required_fields(): +def test_get_ad_sense_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.set_automated_ga4_configuration_opt_out._get_unset_required_fields({}) - ) - assert set(unset_fields) == (set(()) & set(("property",))) + unset_fields = transport.get_ad_sense_link._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_automated_ga4_configuration_opt_out_rest_interceptors(null_interceptor): +def test_get_ad_sense_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -60352,16 +65415,14 @@ def test_set_automated_ga4_configuration_opt_out_rest_interceptors(null_intercep ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_set_automated_ga4_configuration_opt_out", + transports.AnalyticsAdminServiceRestInterceptor, "post_get_ad_sense_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_set_automated_ga4_configuration_opt_out", + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_ad_sense_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest.pb( - analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() + pb_message = analytics_admin.GetAdSenseLinkRequest.pb( + analytics_admin.GetAdSenseLinkRequest() ) transcode.return_value = { "method": "post", @@ -60373,21 +65434,19 @@ def test_set_automated_ga4_configuration_opt_out_rest_interceptors(null_intercep req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.to_json( - analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() - ) + req.return_value._content = resources.AdSenseLink.to_json( + resources.AdSenseLink() ) - request = analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest() + request = analytics_admin.GetAdSenseLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() + post.return_value = resources.AdSenseLink() - client.set_automated_ga4_configuration_opt_out( + client.get_ad_sense_link( request, metadata=[ ("key", "val"), @@ -60399,9 +65458,8 @@ def test_set_automated_ga4_configuration_opt_out_rest_interceptors(null_intercep post.assert_called_once() -def test_set_automated_ga4_configuration_opt_out_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, +def test_get_ad_sense_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetAdSenseLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -60409,7 +65467,7 @@ def test_set_automated_ga4_configuration_opt_out_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"name": "properties/sample1/adSenseLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -60421,10 +65479,65 @@ def test_set_automated_ga4_configuration_opt_out_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.set_automated_ga4_configuration_opt_out(request) + client.get_ad_sense_link(request) -def test_set_automated_ga4_configuration_opt_out_rest_error(): +def test_get_ad_sense_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.AdSenseLink() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "properties/sample1/adSenseLinks/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.AdSenseLink.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_ad_sense_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/*/adSenseLinks/*}" % client.transport._host, + args[1], + ) + + +def test_get_ad_sense_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_ad_sense_link( + analytics_admin.GetAdSenseLinkRequest(), + name="name_value", + ) + + +def test_get_ad_sense_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -60433,55 +65546,55 @@ def test_set_automated_ga4_configuration_opt_out_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, + analytics_admin.CreateAdSenseLinkRequest, dict, ], ) -def test_fetch_automated_ga4_configuration_opt_out_rest(request_type): +def test_create_ad_sense_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["adsense_link"] = { + "name": "name_value", + "ad_client_code": "ad_client_code_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.FetchAutomatedGa4ConfigurationOptOutResponse( - opt_out=True, + return_value = resources.AdSenseLink( + name="name_value", + ad_client_code="ad_client_code_value", ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = ( - analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.pb( - return_value - ) - ) + pb_return_value = resources.AdSenseLink.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.fetch_automated_ga4_configuration_opt_out(request) + response = client.create_ad_sense_link(request) # Establish that the response is the type that we expect. - assert isinstance( - response, analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse - ) - assert response.opt_out is True + assert isinstance(response, resources.AdSenseLink) + assert response.name == "name_value" + assert response.ad_client_code == "ad_client_code_value" -def test_fetch_automated_ga4_configuration_opt_out_rest_required_fields( - request_type=analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, +def test_create_ad_sense_link_rest_required_fields( + request_type=analytics_admin.CreateAdSenseLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["property"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -60496,25 +65609,21 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).fetch_automated_ga4_configuration_opt_out._get_unset_required_fields( - jsonified_request - ) + ).create_ad_sense_link._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["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).fetch_automated_ga4_configuration_opt_out._get_unset_required_fields( - jsonified_request - ) + ).create_ad_sense_link._get_unset_required_fields(jsonified_request) 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 "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -60523,7 +65632,7 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse() + return_value = resources.AdSenseLink() # 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 @@ -60544,38 +65653,38 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = ( - analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.pb( - return_value - ) - ) + pb_return_value = resources.AdSenseLink.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.fetch_automated_ga4_configuration_opt_out(request) + response = client.create_ad_sense_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_fetch_automated_ga4_configuration_opt_out_rest_unset_required_fields(): +def test_create_ad_sense_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.fetch_automated_ga4_configuration_opt_out._get_unset_required_fields( - {} + unset_fields = transport.create_ad_sense_link._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "adsenseLink", + ) ) ) - assert set(unset_fields) == (set(()) & set(("property",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_fetch_automated_ga4_configuration_opt_out_rest_interceptors(null_interceptor): +def test_create_ad_sense_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -60588,16 +65697,14 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_interceptors(null_interc ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_fetch_automated_ga4_configuration_opt_out", + transports.AnalyticsAdminServiceRestInterceptor, "post_create_ad_sense_link" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_fetch_automated_ga4_configuration_opt_out", + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_ad_sense_link" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest.pb( - analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() + pb_message = analytics_admin.CreateAdSenseLinkRequest.pb( + analytics_admin.CreateAdSenseLinkRequest() ) transcode.return_value = { "method": "post", @@ -60609,23 +65716,19 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_interceptors(null_interc req.return_value = Response() req.return_value.status_code = 200 req.return_value.request = PreparedRequest() - req.return_value._content = ( - analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.to_json( - analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse() - ) + req.return_value._content = resources.AdSenseLink.to_json( + resources.AdSenseLink() ) - request = analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest() + request = analytics_admin.CreateAdSenseLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = ( - analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse() - ) + post.return_value = resources.AdSenseLink() - client.fetch_automated_ga4_configuration_opt_out( + client.create_ad_sense_link( request, metadata=[ ("key", "val"), @@ -60637,9 +65740,8 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_interceptors(null_interc post.assert_called_once() -def test_fetch_automated_ga4_configuration_opt_out_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, +def test_create_ad_sense_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateAdSenseLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -60647,7 +65749,11 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"parent": "properties/sample1"} + request_init["adsense_link"] = { + "name": "name_value", + "ad_client_code": "ad_client_code_value", + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -60659,10 +65765,67 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.fetch_automated_ga4_configuration_opt_out(request) + client.create_ad_sense_link(request) -def test_fetch_automated_ga4_configuration_opt_out_rest_error(): +def test_create_ad_sense_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.AdSenseLink() + + # 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", + adsense_link=resources.AdSenseLink(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.AdSenseLink.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_ad_sense_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/*}/adSenseLinks" % client.transport._host, + args[1], + ) + + +def test_create_ad_sense_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_ad_sense_link( + analytics_admin.CreateAdSenseLinkRequest(), + parent="parent_value", + adsense_link=resources.AdSenseLink(name="name_value"), + ) + + +def test_create_ad_sense_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -60671,58 +65834,40 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetBigQueryLinkRequest, + analytics_admin.DeleteAdSenseLinkRequest, dict, ], ) -def test_get_big_query_link_rest(request_type): +def test_delete_ad_sense_link_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/bigQueryLinks/sample2"} + request_init = {"name": "properties/sample1/adSenseLinks/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.BigQueryLink( - name="name_value", - project="project_value", - daily_export_enabled=True, - streaming_export_enabled=True, - intraday_export_enabled=True, - include_advertising_id=True, - export_streams=["export_streams_value"], - excluded_events=["excluded_events_value"], - ) + return_value = None # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.BigQueryLink.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_big_query_link(request) + response = client.delete_ad_sense_link(request) # 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.intraday_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 is None -def test_get_big_query_link_rest_required_fields( - request_type=analytics_admin.GetBigQueryLinkRequest, +def test_delete_ad_sense_link_rest_required_fields( + request_type=analytics_admin.DeleteAdSenseLinkRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -60742,7 +65887,7 @@ def test_get_big_query_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_big_query_link._get_unset_required_fields(jsonified_request) + ).delete_ad_sense_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -60751,7 +65896,7 @@ def test_get_big_query_link_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_big_query_link._get_unset_required_fields(jsonified_request) + ).delete_ad_sense_link._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -60765,7 +65910,7 @@ def test_get_big_query_link_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.BigQueryLink() + 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 @@ -60777,38 +65922,36 @@ def test_get_big_query_link_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.BigQueryLink.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + 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.get_big_query_link(request) + response = client.delete_ad_sense_link(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_big_query_link_rest_unset_required_fields(): +def test_delete_ad_sense_link_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_big_query_link._get_unset_required_fields({}) + unset_fields = transport.delete_ad_sense_link._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_big_query_link_rest_interceptors(null_interceptor): +def test_delete_ad_sense_link_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -60821,14 +65964,11 @@ def test_get_big_query_link_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_get_big_query_link" - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_get_big_query_link" + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_ad_sense_link" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.GetBigQueryLinkRequest.pb( - analytics_admin.GetBigQueryLinkRequest() + pb_message = analytics_admin.DeleteAdSenseLinkRequest.pb( + analytics_admin.DeleteAdSenseLinkRequest() ) transcode.return_value = { "method": "post", @@ -60840,19 +65980,15 @@ def test_get_big_query_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.BigQueryLink.to_json( - resources.BigQueryLink() - ) - request = analytics_admin.GetBigQueryLinkRequest() + request = analytics_admin.DeleteAdSenseLinkRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.BigQueryLink() - client.get_big_query_link( + client.delete_ad_sense_link( request, metadata=[ ("key", "val"), @@ -60861,11 +65997,10 @@ def test_get_big_query_link_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_get_big_query_link_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.GetBigQueryLinkRequest +def test_delete_ad_sense_link_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteAdSenseLinkRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -60873,7 +66008,7 @@ def test_get_big_query_link_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {"name": "properties/sample1/bigQueryLinks/sample2"} + request_init = {"name": "properties/sample1/adSenseLinks/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -60885,10 +66020,10 @@ def test_get_big_query_link_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_big_query_link(request) + client.delete_ad_sense_link(request) -def test_get_big_query_link_rest_flattened(): +def test_delete_ad_sense_link_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -60897,10 +66032,10 @@ def test_get_big_query_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.BigQueryLink() + return_value = None # get arguments that satisfy an http rule for this method - sample_request = {"name": "properties/sample1/bigQueryLinks/sample2"} + sample_request = {"name": "properties/sample1/adSenseLinks/sample2"} # get truthy value for each flattened field mock_args = dict( @@ -60911,24 +66046,23 @@ def test_get_big_query_link_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.BigQueryLink.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_big_query_link(**mock_args) + client.delete_ad_sense_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/*/bigQueryLinks/*}" % client.transport._host, + "%s/v1alpha/{name=properties/*/adSenseLinks/*}" % client.transport._host, args[1], ) -def test_get_big_query_link_rest_flattened_error(transport: str = "rest"): +def test_delete_ad_sense_link_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -60937,13 +66071,13 @@ def test_get_big_query_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_big_query_link( - analytics_admin.GetBigQueryLinkRequest(), + client.delete_ad_sense_link( + analytics_admin.DeleteAdSenseLinkRequest(), name="name_value", ) -def test_get_big_query_link_rest_error(): +def test_delete_ad_sense_link_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -60952,11 +66086,11 @@ def test_get_big_query_link_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListBigQueryLinksRequest, + analytics_admin.ListAdSenseLinksRequest, dict, ], ) -def test_list_big_query_links_rest(request_type): +def test_list_ad_sense_links_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -60969,27 +66103,27 @@ def test_list_big_query_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.ListBigQueryLinksResponse( + return_value = analytics_admin.ListAdSenseLinksResponse( 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.ListBigQueryLinksResponse.pb(return_value) + pb_return_value = analytics_admin.ListAdSenseLinksResponse.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_big_query_links(request) + response = client.list_ad_sense_links(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBigQueryLinksPager) + assert isinstance(response, pagers.ListAdSenseLinksPager) assert response.next_page_token == "next_page_token_value" -def test_list_big_query_links_rest_required_fields( - request_type=analytics_admin.ListBigQueryLinksRequest, +def test_list_ad_sense_links_rest_required_fields( + request_type=analytics_admin.ListAdSenseLinksRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -61009,7 +66143,7 @@ def test_list_big_query_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_big_query_links._get_unset_required_fields(jsonified_request) + ).list_ad_sense_links._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -61018,7 +66152,7 @@ def test_list_big_query_links_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_big_query_links._get_unset_required_fields(jsonified_request) + ).list_ad_sense_links._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set( ( @@ -61039,7 +66173,7 @@ def test_list_big_query_links_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.ListBigQueryLinksResponse() + return_value = analytics_admin.ListAdSenseLinksResponse() # 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 @@ -61059,25 +66193,25 @@ def test_list_big_query_links_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListBigQueryLinksResponse.pb(return_value) + pb_return_value = analytics_admin.ListAdSenseLinksResponse.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_big_query_links(request) + response = client.list_ad_sense_links(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_big_query_links_rest_unset_required_fields(): +def test_list_ad_sense_links_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_big_query_links._get_unset_required_fields({}) + unset_fields = transport.list_ad_sense_links._get_unset_required_fields({}) assert set(unset_fields) == ( set( ( @@ -61090,7 +66224,7 @@ def test_list_big_query_links_rest_unset_required_fields(): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_big_query_links_rest_interceptors(null_interceptor): +def test_list_ad_sense_links_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -61103,14 +66237,14 @@ def test_list_big_query_links_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_big_query_links" + transports.AnalyticsAdminServiceRestInterceptor, "post_list_ad_sense_links" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_big_query_links" + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_ad_sense_links" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListBigQueryLinksRequest.pb( - analytics_admin.ListBigQueryLinksRequest() + pb_message = analytics_admin.ListAdSenseLinksRequest.pb( + analytics_admin.ListAdSenseLinksRequest() ) transcode.return_value = { "method": "post", @@ -61122,19 +66256,19 @@ def test_list_big_query_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.ListBigQueryLinksResponse.to_json( - analytics_admin.ListBigQueryLinksResponse() + req.return_value._content = analytics_admin.ListAdSenseLinksResponse.to_json( + analytics_admin.ListAdSenseLinksResponse() ) - request = analytics_admin.ListBigQueryLinksRequest() + request = analytics_admin.ListAdSenseLinksRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListBigQueryLinksResponse() + post.return_value = analytics_admin.ListAdSenseLinksResponse() - client.list_big_query_links( + client.list_ad_sense_links( request, metadata=[ ("key", "val"), @@ -61146,8 +66280,8 @@ def test_list_big_query_links_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_big_query_links_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListBigQueryLinksRequest +def test_list_ad_sense_links_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListAdSenseLinksRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -61167,10 +66301,10 @@ def test_list_big_query_links_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_big_query_links(request) + client.list_ad_sense_links(request) -def test_list_big_query_links_rest_flattened(): +def test_list_ad_sense_links_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -61179,7 +66313,7 @@ def test_list_big_query_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.ListBigQueryLinksResponse() + return_value = analytics_admin.ListAdSenseLinksResponse() # get arguments that satisfy an http rule for this method sample_request = {"parent": "properties/sample1"} @@ -61193,24 +66327,24 @@ def test_list_big_query_links_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListBigQueryLinksResponse.pb(return_value) + pb_return_value = analytics_admin.ListAdSenseLinksResponse.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_big_query_links(**mock_args) + client.list_ad_sense_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/*}/bigQueryLinks" % client.transport._host, + "%s/v1alpha/{parent=properties/*}/adSenseLinks" % client.transport._host, args[1], ) -def test_list_big_query_links_rest_flattened_error(transport: str = "rest"): +def test_list_ad_sense_links_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -61219,13 +66353,13 @@ def test_list_big_query_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_big_query_links( - analytics_admin.ListBigQueryLinksRequest(), + client.list_ad_sense_links( + analytics_admin.ListAdSenseLinksRequest(), parent="parent_value", ) -def test_list_big_query_links_rest_pager(transport: str = "rest"): +def test_list_ad_sense_links_rest_pager(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -61237,28 +66371,28 @@ def test_list_big_query_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.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), - resources.BigQueryLink(), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), + resources.AdSenseLink(), ], next_page_token="abc", ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[], + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[], next_page_token="def", ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), ], next_page_token="ghi", ), - analytics_admin.ListBigQueryLinksResponse( - bigquery_links=[ - resources.BigQueryLink(), - resources.BigQueryLink(), + analytics_admin.ListAdSenseLinksResponse( + adsense_links=[ + resources.AdSenseLink(), + resources.AdSenseLink(), ], ), ) @@ -61267,7 +66401,7 @@ def test_list_big_query_links_rest_pager(transport: str = "rest"): # Wrap the values into proper Response objs response = tuple( - analytics_admin.ListBigQueryLinksResponse.to_json(x) for x in response + analytics_admin.ListAdSenseLinksResponse.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): @@ -61277,13 +66411,13 @@ def test_list_big_query_links_rest_pager(transport: str = "rest"): sample_request = {"parent": "properties/sample1"} - pager = client.list_big_query_links(request=sample_request) + pager = client.list_ad_sense_links(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, resources.BigQueryLink) for i in results) + assert all(isinstance(i, resources.AdSenseLink) for i in results) - pages = list(client.list_big_query_links(request=sample_request).pages) + pages = list(client.list_ad_sense_links(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -61291,11 +66425,11 @@ def test_list_big_query_links_rest_pager(transport: str = "rest"): @pytest.mark.parametrize( "request_type", [ - analytics_admin.GetEnhancedMeasurementSettingsRequest, + analytics_admin.GetEventCreateRuleRequest, dict, ], ) -def test_get_enhanced_measurement_settings_rest(request_type): +def test_get_event_create_rule_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -61303,54 +66437,38 @@ def test_get_enhanced_measurement_settings_rest(request_type): # send a request that will satisfy transcoding request_init = { - "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/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 = resources.EnhancedMeasurementSettings( + return_value = event_create_and_edit.EventCreateRule( name="name_value", - stream_enabled=True, - scrolls_enabled=True, - outbound_clicks_enabled=True, - site_search_enabled=True, - video_engagement_enabled=True, - file_downloads_enabled=True, - page_changes_enabled=True, - form_interactions_enabled=True, - search_query_parameter="search_query_parameter_value", - uri_query_parameter="uri_query_parameter_value", + destination_event="destination_event_value", + source_copy_parameters=True, ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.EnhancedMeasurementSettings.pb(return_value) + pb_return_value = event_create_and_edit.EventCreateRule.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_enhanced_measurement_settings(request) + response = client.get_event_create_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.EnhancedMeasurementSettings) + assert isinstance(response, event_create_and_edit.EventCreateRule) assert response.name == "name_value" - assert response.stream_enabled is True - assert response.scrolls_enabled is True - assert response.outbound_clicks_enabled is True - assert response.site_search_enabled is True - assert response.video_engagement_enabled is True - assert response.file_downloads_enabled is True - assert response.page_changes_enabled is True - assert response.form_interactions_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.uri_query_parameter == "uri_query_parameter_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True -def test_get_enhanced_measurement_settings_rest_required_fields( - request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest, +def test_get_event_create_rule_rest_required_fields( + request_type=analytics_admin.GetEventCreateRuleRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport @@ -61370,7 +66488,7 @@ def test_get_enhanced_measurement_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_enhanced_measurement_settings._get_unset_required_fields(jsonified_request) + ).get_event_create_rule._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -61379,7 +66497,7 @@ def test_get_enhanced_measurement_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_enhanced_measurement_settings._get_unset_required_fields(jsonified_request) + ).get_event_create_rule._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -61393,7 +66511,7 @@ def test_get_enhanced_measurement_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.EnhancedMeasurementSettings() + return_value = event_create_and_edit.EventCreateRule() # 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 @@ -61413,32 +66531,30 @@ def test_get_enhanced_measurement_settings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.EnhancedMeasurementSettings.pb(return_value) + pb_return_value = event_create_and_edit.EventCreateRule.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_enhanced_measurement_settings(request) + response = client.get_event_create_rule(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_enhanced_measurement_settings_rest_unset_required_fields(): +def test_get_event_create_rule_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.get_enhanced_measurement_settings._get_unset_required_fields({}) - ) + unset_fields = transport.get_event_create_rule._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_enhanced_measurement_settings_rest_interceptors(null_interceptor): +def test_get_event_create_rule_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -61451,16 +66567,14 @@ def test_get_enhanced_measurement_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_get_enhanced_measurement_settings", + transports.AnalyticsAdminServiceRestInterceptor, "post_get_event_create_rule" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_get_enhanced_measurement_settings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_get_event_create_rule" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.GetEnhancedMeasurementSettingsRequest.pb( - analytics_admin.GetEnhancedMeasurementSettingsRequest() + pb_message = analytics_admin.GetEventCreateRuleRequest.pb( + analytics_admin.GetEventCreateRuleRequest() ) transcode.return_value = { "method": "post", @@ -61472,19 +66586,19 @@ def test_get_enhanced_measurement_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.EnhancedMeasurementSettings.to_json( - resources.EnhancedMeasurementSettings() + req.return_value._content = event_create_and_edit.EventCreateRule.to_json( + event_create_and_edit.EventCreateRule() ) - request = analytics_admin.GetEnhancedMeasurementSettingsRequest() + request = analytics_admin.GetEventCreateRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.EnhancedMeasurementSettings() + post.return_value = event_create_and_edit.EventCreateRule() - client.get_enhanced_measurement_settings( + client.get_event_create_rule( request, metadata=[ ("key", "val"), @@ -61496,9 +66610,8 @@ def test_get_enhanced_measurement_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_enhanced_measurement_settings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.GetEnhancedMeasurementSettingsRequest, +def test_get_event_create_rule_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.GetEventCreateRuleRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -61507,7 +66620,7 @@ def test_get_enhanced_measurement_settings_rest_bad_request( # send a request that will satisfy transcoding request_init = { - "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/sample3" } request = request_type(**request_init) @@ -61520,10 +66633,10 @@ def test_get_enhanced_measurement_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.get_enhanced_measurement_settings(request) + client.get_event_create_rule(request) -def test_get_enhanced_measurement_settings_rest_flattened(): +def test_get_event_create_rule_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -61532,11 +66645,11 @@ def test_get_enhanced_measurement_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.EnhancedMeasurementSettings() + return_value = event_create_and_edit.EventCreateRule() # get arguments that satisfy an http rule for this method sample_request = { - "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/sample3" } # get truthy value for each flattened field @@ -61548,27 +66661,25 @@ def test_get_enhanced_measurement_settings_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.EnhancedMeasurementSettings.pb(return_value) + pb_return_value = event_create_and_edit.EventCreateRule.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_enhanced_measurement_settings(**mock_args) + client.get_event_create_rule(**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/*/enhancedMeasurementSettings}" + "%s/v1alpha/{name=properties/*/dataStreams/*/eventCreateRules/*}" % client.transport._host, args[1], ) -def test_get_enhanced_measurement_settings_rest_flattened_error( - transport: str = "rest", -): +def test_get_event_create_rule_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -61577,13 +66688,13 @@ def test_get_enhanced_measurement_settings_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_enhanced_measurement_settings( - analytics_admin.GetEnhancedMeasurementSettingsRequest(), + client.get_event_create_rule( + analytics_admin.GetEventCreateRuleRequest(), name="name_value", ) -def test_get_enhanced_measurement_settings_rest_error(): +def test_get_event_create_rule_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -61592,85 +66703,49 @@ def test_get_enhanced_measurement_settings_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.UpdateEnhancedMeasurementSettingsRequest, + analytics_admin.ListEventCreateRulesRequest, dict, ], ) -def test_update_enhanced_measurement_settings_rest(request_type): +def test_list_event_create_rules_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = { - "enhanced_measurement_settings": { - "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" - } - } - request_init["enhanced_measurement_settings"] = { - "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings", - "stream_enabled": True, - "scrolls_enabled": True, - "outbound_clicks_enabled": True, - "site_search_enabled": True, - "video_engagement_enabled": True, - "file_downloads_enabled": True, - "page_changes_enabled": True, - "form_interactions_enabled": True, - "search_query_parameter": "search_query_parameter_value", - "uri_query_parameter": "uri_query_parameter_value", - } + 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.EnhancedMeasurementSettings( - name="name_value", - stream_enabled=True, - scrolls_enabled=True, - outbound_clicks_enabled=True, - site_search_enabled=True, - video_engagement_enabled=True, - file_downloads_enabled=True, - page_changes_enabled=True, - form_interactions_enabled=True, - search_query_parameter="search_query_parameter_value", - uri_query_parameter="uri_query_parameter_value", + return_value = analytics_admin.ListEventCreateRulesResponse( + 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.EnhancedMeasurementSettings.pb(return_value) + pb_return_value = analytics_admin.ListEventCreateRulesResponse.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_enhanced_measurement_settings(request) + response = client.list_event_create_rules(request) # Establish that the response is the type that we expect. - assert isinstance(response, resources.EnhancedMeasurementSettings) - assert response.name == "name_value" - assert response.stream_enabled is True - assert response.scrolls_enabled is True - assert response.outbound_clicks_enabled is True - assert response.site_search_enabled is True - assert response.video_engagement_enabled is True - assert response.file_downloads_enabled is True - assert response.page_changes_enabled is True - assert response.form_interactions_enabled is True - assert response.search_query_parameter == "search_query_parameter_value" - assert response.uri_query_parameter == "uri_query_parameter_value" + assert isinstance(response, pagers.ListEventCreateRulesPager) + assert response.next_page_token == "next_page_token_value" -def test_update_enhanced_measurement_settings_rest_required_fields( - request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest, +def test_list_event_create_rules_rest_required_fields( + request_type=analytics_admin.ListEventCreateRulesRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -61685,19 +66760,28 @@ def test_update_enhanced_measurement_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_enhanced_measurement_settings._get_unset_required_fields(jsonified_request) + ).list_event_create_rules._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_enhanced_measurement_settings._get_unset_required_fields(jsonified_request) + ).list_event_create_rules._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(), @@ -61706,7 +66790,7 @@ def test_update_enhanced_measurement_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = resources.EnhancedMeasurementSettings() + return_value = analytics_admin.ListEventCreateRulesResponse() # 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 @@ -61718,49 +66802,48 @@ def test_update_enhanced_measurement_settings_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.EnhancedMeasurementSettings.pb(return_value) + pb_return_value = analytics_admin.ListEventCreateRulesResponse.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_enhanced_measurement_settings(request) + response = client.list_event_create_rules(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_enhanced_measurement_settings_rest_unset_required_fields(): +def test_list_event_create_rules_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = ( - transport.update_enhanced_measurement_settings._get_unset_required_fields({}) - ) + unset_fields = transport.list_event_create_rules._get_unset_required_fields({}) assert set(unset_fields) == ( - set(("updateMask",)) - & set( + set( ( - "enhancedMeasurementSettings", - "updateMask", + "pageSize", + "pageToken", ) ) + & set(("parent",)) ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_enhanced_measurement_settings_rest_interceptors(null_interceptor): +def test_list_event_create_rules_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -61773,16 +66856,14 @@ def test_update_enhanced_measurement_settings_rest_interceptors(null_interceptor ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_update_enhanced_measurement_settings", + transports.AnalyticsAdminServiceRestInterceptor, "post_list_event_create_rules" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_update_enhanced_measurement_settings", + transports.AnalyticsAdminServiceRestInterceptor, "pre_list_event_create_rules" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.UpdateEnhancedMeasurementSettingsRequest.pb( - analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + pb_message = analytics_admin.ListEventCreateRulesRequest.pb( + analytics_admin.ListEventCreateRulesRequest() ) transcode.return_value = { "method": "post", @@ -61794,19 +66875,21 @@ def test_update_enhanced_measurement_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.EnhancedMeasurementSettings.to_json( - resources.EnhancedMeasurementSettings() + req.return_value._content = ( + analytics_admin.ListEventCreateRulesResponse.to_json( + analytics_admin.ListEventCreateRulesResponse() + ) ) - request = analytics_admin.UpdateEnhancedMeasurementSettingsRequest() + request = analytics_admin.ListEventCreateRulesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.EnhancedMeasurementSettings() + post.return_value = analytics_admin.ListEventCreateRulesResponse() - client.update_enhanced_measurement_settings( + client.list_event_create_rules( request, metadata=[ ("key", "val"), @@ -61818,9 +66901,8 @@ def test_update_enhanced_measurement_settings_rest_interceptors(null_interceptor post.assert_called_once() -def test_update_enhanced_measurement_settings_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.UpdateEnhancedMeasurementSettingsRequest, +def test_list_event_create_rules_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.ListEventCreateRulesRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -61828,24 +66910,7 @@ def test_update_enhanced_measurement_settings_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = { - "enhanced_measurement_settings": { - "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" - } - } - request_init["enhanced_measurement_settings"] = { - "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings", - "stream_enabled": True, - "scrolls_enabled": True, - "outbound_clicks_enabled": True, - "site_search_enabled": True, - "video_engagement_enabled": True, - "file_downloads_enabled": True, - "page_changes_enabled": True, - "form_interactions_enabled": True, - "search_query_parameter": "search_query_parameter_value", - "uri_query_parameter": "uri_query_parameter_value", - } + 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. @@ -61857,10 +66922,10 @@ def test_update_enhanced_measurement_settings_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.update_enhanced_measurement_settings(request) + client.list_event_create_rules(request) -def test_update_enhanced_measurement_settings_rest_flattened(): +def test_list_event_create_rules_rest_flattened(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -61869,48 +66934,39 @@ def test_update_enhanced_measurement_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.EnhancedMeasurementSettings() + return_value = analytics_admin.ListEventCreateRulesResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "enhanced_measurement_settings": { - "name": "properties/sample1/dataStreams/sample2/enhancedMeasurementSettings" - } - } + sample_request = {"parent": "properties/sample1/dataStreams/sample2"} # get truthy value for each flattened field mock_args = dict( - enhanced_measurement_settings=resources.EnhancedMeasurementSettings( - 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.EnhancedMeasurementSettings.pb(return_value) + pb_return_value = analytics_admin.ListEventCreateRulesResponse.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_enhanced_measurement_settings(**mock_args) + client.list_event_create_rules(**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/{enhanced_measurement_settings.name=properties/*/dataStreams/*/enhancedMeasurementSettings}" + "%s/v1alpha/{parent=properties/*/dataStreams/*}/eventCreateRules" % client.transport._host, args[1], ) -def test_update_enhanced_measurement_settings_rest_flattened_error( - transport: str = "rest", -): +def test_list_event_create_rules_rest_flattened_error(transport: str = "rest"): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -61919,65 +66975,143 @@ def test_update_enhanced_measurement_settings_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_enhanced_measurement_settings( - analytics_admin.UpdateEnhancedMeasurementSettingsRequest(), - enhanced_measurement_settings=resources.EnhancedMeasurementSettings( - name="name_value" - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.list_event_create_rules( + analytics_admin.ListEventCreateRulesRequest(), + parent="parent_value", ) -def test_update_enhanced_measurement_settings_rest_error(): +def test_list_event_create_rules_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.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + next_page_token="abc", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[], + next_page_token="def", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + ], + next_page_token="ghi", + ), + analytics_admin.ListEventCreateRulesResponse( + event_create_rules=[ + event_create_and_edit.EventCreateRule(), + event_create_and_edit.EventCreateRule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + analytics_admin.ListEventCreateRulesResponse.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_event_create_rules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all( + isinstance(i, event_create_and_edit.EventCreateRule) for i in results + ) + + pages = list(client.list_event_create_rules(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.CreateConnectedSiteTagRequest, + analytics_admin.CreateEventCreateRuleRequest, dict, ], ) -def test_create_connected_site_tag_rest(request_type): +def test_create_event_create_rule_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/dataStreams/sample2"} + request_init["event_create_rule"] = { + "name": "name_value", + "destination_event": "destination_event_value", + "event_conditions": [ + { + "field": "field_value", + "comparison_type": 1, + "value": "value_value", + "negated": True, + } + ], + "source_copy_parameters": True, + "parameter_mutations": [ + {"parameter": "parameter_value", "parameter_value": "parameter_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.CreateConnectedSiteTagResponse() + return_value = event_create_and_edit.EventCreateRule( + name="name_value", + destination_event="destination_event_value", + source_copy_parameters=True, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.CreateConnectedSiteTagResponse.pb( - return_value - ) + pb_return_value = event_create_and_edit.EventCreateRule.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_connected_site_tag(request) + response = client.create_event_create_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.CreateConnectedSiteTagResponse) + assert isinstance(response, event_create_and_edit.EventCreateRule) + assert response.name == "name_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True -def test_create_connected_site_tag_rest_required_fields( - request_type=analytics_admin.CreateConnectedSiteTagRequest, +def test_create_event_create_rule_rest_required_fields( + request_type=analytics_admin.CreateEventCreateRuleRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -61992,17 +67126,21 @@ def test_create_connected_site_tag_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_connected_site_tag._get_unset_required_fields(jsonified_request) + ).create_event_create_rule._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_connected_site_tag._get_unset_required_fields(jsonified_request) + ).create_event_create_rule._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(), @@ -62011,7 +67149,7 @@ def test_create_connected_site_tag_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.CreateConnectedSiteTagResponse() + return_value = event_create_and_edit.EventCreateRule() # 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 @@ -62032,157 +67170,38 @@ def test_create_connected_site_tag_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.CreateConnectedSiteTagResponse.pb( - return_value - ) + pb_return_value = event_create_and_edit.EventCreateRule.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_connected_site_tag(request) + response = client.create_event_create_rule(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_create_connected_site_tag_rest_unset_required_fields(): - transport = transports.AnalyticsAdminServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.create_connected_site_tag._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("connectedSiteTag",))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_connected_site_tag_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_connected_site_tag", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_create_connected_site_tag" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.CreateConnectedSiteTagRequest.pb( - analytics_admin.CreateConnectedSiteTagRequest() - ) - 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.CreateConnectedSiteTagResponse.to_json( - analytics_admin.CreateConnectedSiteTagResponse() - ) - ) - - request = analytics_admin.CreateConnectedSiteTagRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = analytics_admin.CreateConnectedSiteTagResponse() - - client.create_connected_site_tag( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_connected_site_tag_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.CreateConnectedSiteTagRequest -): - 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.create_connected_site_tag(request) - - -def test_create_connected_site_tag_rest_error(): - client = AnalyticsAdminServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - -@pytest.mark.parametrize( - "request_type", - [ - analytics_admin.DeleteConnectedSiteTagRequest, - dict, - ], -) -def test_delete_connected_site_tag_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 = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = "" + assert expected_params == actual_params - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.delete_connected_site_tag(request) - # Establish that the response is the type that we expect. - assert response is None +def test_create_event_create_rule_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_event_create_rule._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "eventCreateRule", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_connected_site_tag_rest_interceptors(null_interceptor): +def test_create_event_create_rule_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -62195,11 +67214,14 @@ def test_delete_connected_site_tag_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_connected_site_tag" + transports.AnalyticsAdminServiceRestInterceptor, "post_create_event_create_rule" + ) as post, mock.patch.object( + transports.AnalyticsAdminServiceRestInterceptor, "pre_create_event_create_rule" ) as pre: pre.assert_not_called() - pb_message = analytics_admin.DeleteConnectedSiteTagRequest.pb( - analytics_admin.DeleteConnectedSiteTagRequest() + post.assert_not_called() + pb_message = analytics_admin.CreateEventCreateRuleRequest.pb( + analytics_admin.CreateEventCreateRuleRequest() ) transcode.return_value = { "method": "post", @@ -62211,15 +67233,19 @@ def test_delete_connected_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 = event_create_and_edit.EventCreateRule.to_json( + event_create_and_edit.EventCreateRule() + ) - request = analytics_admin.DeleteConnectedSiteTagRequest() + request = analytics_admin.CreateEventCreateRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = event_create_and_edit.EventCreateRule() - client.delete_connected_site_tag( + client.create_event_create_rule( request, metadata=[ ("key", "val"), @@ -62228,10 +67254,11 @@ def test_delete_connected_site_tag_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_delete_connected_site_tag_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.DeleteConnectedSiteTagRequest +def test_create_event_create_rule_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.CreateEventCreateRuleRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -62239,7 +67266,23 @@ def test_delete_connected_site_tag_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + request_init = {"parent": "properties/sample1/dataStreams/sample2"} + request_init["event_create_rule"] = { + "name": "name_value", + "destination_event": "destination_event_value", + "event_conditions": [ + { + "field": "field_value", + "comparison_type": 1, + "value": "value_value", + "negated": True, + } + ], + "source_copy_parameters": True, + "parameter_mutations": [ + {"parameter": "parameter_value", "parameter_value": "parameter_value_value"} + ], + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -62251,10 +67294,68 @@ def test_delete_connected_site_tag_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.delete_connected_site_tag(request) + client.create_event_create_rule(request) -def test_delete_connected_site_tag_rest_error(): +def test_create_event_create_rule_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 = event_create_and_edit.EventCreateRule() + + # 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", + event_create_rule=event_create_and_edit.EventCreateRule(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 = event_create_and_edit.EventCreateRule.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_event_create_rule(**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/*}/eventCreateRules" + % client.transport._host, + args[1], + ) + + +def test_create_event_create_rule_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_event_create_rule( + analytics_admin.CreateEventCreateRuleRequest(), + parent="parent_value", + event_create_rule=event_create_and_edit.EventCreateRule(name="name_value"), + ) + + +def test_create_event_create_rule_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -62263,41 +67364,160 @@ def test_delete_connected_site_tag_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.ListConnectedSiteTagsRequest, + analytics_admin.UpdateEventCreateRuleRequest, dict, ], ) -def test_list_connected_site_tags_rest(request_type): +def test_update_event_create_rule_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {} + request_init = { + "event_create_rule": { + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/sample3" + } + } + request_init["event_create_rule"] = { + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/sample3", + "destination_event": "destination_event_value", + "event_conditions": [ + { + "field": "field_value", + "comparison_type": 1, + "value": "value_value", + "negated": True, + } + ], + "source_copy_parameters": True, + "parameter_mutations": [ + {"parameter": "parameter_value", "parameter_value": "parameter_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.ListConnectedSiteTagsResponse() + return_value = event_create_and_edit.EventCreateRule( + name="name_value", + destination_event="destination_event_value", + source_copy_parameters=True, + ) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = analytics_admin.ListConnectedSiteTagsResponse.pb(return_value) + pb_return_value = event_create_and_edit.EventCreateRule.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_connected_site_tags(request) + response = client.update_event_create_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.ListConnectedSiteTagsResponse) + assert isinstance(response, event_create_and_edit.EventCreateRule) + assert response.name == "name_value" + assert response.destination_event == "destination_event_value" + assert response.source_copy_parameters is True + + +def test_update_event_create_rule_rest_required_fields( + request_type=analytics_admin.UpdateEventCreateRuleRequest, +): + 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_event_create_rule._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_event_create_rule._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 = event_create_and_edit.EventCreateRule() + # 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 = event_create_and_edit.EventCreateRule.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_event_create_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_event_create_rule_rest_unset_required_fields(): + transport = transports.AnalyticsAdminServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_event_create_rule._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "eventCreateRule", + "updateMask", + ) + ) + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_connected_site_tags_rest_interceptors(null_interceptor): +def test_update_event_create_rule_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -62310,14 +67530,14 @@ def test_list_connected_site_tags_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "post_list_connected_site_tags" + transports.AnalyticsAdminServiceRestInterceptor, "post_update_event_create_rule" ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, "pre_list_connected_site_tags" + transports.AnalyticsAdminServiceRestInterceptor, "pre_update_event_create_rule" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = analytics_admin.ListConnectedSiteTagsRequest.pb( - analytics_admin.ListConnectedSiteTagsRequest() + pb_message = analytics_admin.UpdateEventCreateRuleRequest.pb( + analytics_admin.UpdateEventCreateRuleRequest() ) transcode.return_value = { "method": "post", @@ -62329,21 +67549,19 @@ def test_list_connected_site_tags_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.ListConnectedSiteTagsResponse.to_json( - analytics_admin.ListConnectedSiteTagsResponse() - ) + req.return_value._content = event_create_and_edit.EventCreateRule.to_json( + event_create_and_edit.EventCreateRule() ) - request = analytics_admin.ListConnectedSiteTagsRequest() + request = analytics_admin.UpdateEventCreateRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.ListConnectedSiteTagsResponse() + post.return_value = event_create_and_edit.EventCreateRule() - client.list_connected_site_tags( + client.update_event_create_rule( request, metadata=[ ("key", "val"), @@ -62355,8 +67573,8 @@ def test_list_connected_site_tags_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_connected_site_tags_rest_bad_request( - transport: str = "rest", request_type=analytics_admin.ListConnectedSiteTagsRequest +def test_update_event_create_rule_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.UpdateEventCreateRuleRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -62364,7 +67582,27 @@ def test_list_connected_site_tags_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + request_init = { + "event_create_rule": { + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/sample3" + } + } + request_init["event_create_rule"] = { + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/sample3", + "destination_event": "destination_event_value", + "event_conditions": [ + { + "field": "field_value", + "comparison_type": 1, + "value": "value_value", + "negated": True, + } + ], + "source_copy_parameters": True, + "parameter_mutations": [ + {"parameter": "parameter_value", "parameter_value": "parameter_value_value"} + ], + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -62376,10 +67614,72 @@ def test_list_connected_site_tags_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.list_connected_site_tags(request) + client.update_event_create_rule(request) -def test_list_connected_site_tags_rest_error(): +def test_update_event_create_rule_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 = event_create_and_edit.EventCreateRule() + + # get arguments that satisfy an http rule for this method + sample_request = { + "event_create_rule": { + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + event_create_rule=event_create_and_edit.EventCreateRule(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 = event_create_and_edit.EventCreateRule.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_event_create_rule(**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/{event_create_rule.name=properties/*/dataStreams/*/eventCreateRules/*}" + % client.transport._host, + args[1], + ) + + +def test_update_event_create_rule_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_event_create_rule( + analytics_admin.UpdateEventCreateRuleRequest(), + event_create_rule=event_create_and_edit.EventCreateRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_event_create_rule_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -62388,51 +67688,47 @@ def test_list_connected_site_tags_rest_error(): @pytest.mark.parametrize( "request_type", [ - analytics_admin.FetchConnectedGa4PropertyRequest, + analytics_admin.DeleteEventCreateRuleRequest, dict, ], ) -def test_fetch_connected_ga4_property_rest(request_type): +def test_delete_event_create_rule_rest(request_type): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # send a request that will satisfy transcoding - request_init = {} + request_init = { + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/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.FetchConnectedGa4PropertyResponse( - property="property_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.FetchConnectedGa4PropertyResponse.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.fetch_connected_ga4_property(request) + response = client.delete_event_create_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, analytics_admin.FetchConnectedGa4PropertyResponse) - assert response.property == "property_value" + assert response is None -def test_fetch_connected_ga4_property_rest_required_fields( - request_type=analytics_admin.FetchConnectedGa4PropertyRequest, +def test_delete_event_create_rule_rest_required_fields( + request_type=analytics_admin.DeleteEventCreateRuleRequest, ): transport_class = transports.AnalyticsAdminServiceRestTransport request_init = {} - request_init["property"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -62444,29 +67740,24 @@ def test_fetch_connected_ga4_property_rest_required_fields( ) # verify fields with default values are dropped - assert "property" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).fetch_connected_ga4_property._get_unset_required_fields(jsonified_request) + ).delete_event_create_rule._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - assert "property" in jsonified_request - assert jsonified_request["property"] == request_init["property"] - jsonified_request["property"] = "property_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).fetch_connected_ga4_property._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("property",)) + ).delete_event_create_rule._get_unset_required_fields(jsonified_request) 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 "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -62475,7 +67766,7 @@ def test_fetch_connected_ga4_property_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = analytics_admin.FetchConnectedGa4PropertyResponse() + 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 @@ -62487,46 +67778,36 @@ def test_fetch_connected_ga4_property_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.FetchConnectedGa4PropertyResponse.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.fetch_connected_ga4_property(request) + response = client.delete_event_create_rule(request) - expected_params = [ - ( - "property", - "", - ), - ("$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_fetch_connected_ga4_property_rest_unset_required_fields(): +def test_delete_event_create_rule_rest_unset_required_fields(): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.fetch_connected_ga4_property._get_unset_required_fields({}) - assert set(unset_fields) == (set(("property",)) & set(("property",))) + unset_fields = transport.delete_event_create_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_fetch_connected_ga4_property_rest_interceptors(null_interceptor): +def test_delete_event_create_rule_rest_interceptors(null_interceptor): transport = transports.AnalyticsAdminServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -62539,16 +67820,11 @@ def test_fetch_connected_ga4_property_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "post_fetch_connected_ga4_property", - ) as post, mock.patch.object( - transports.AnalyticsAdminServiceRestInterceptor, - "pre_fetch_connected_ga4_property", + transports.AnalyticsAdminServiceRestInterceptor, "pre_delete_event_create_rule" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = analytics_admin.FetchConnectedGa4PropertyRequest.pb( - analytics_admin.FetchConnectedGa4PropertyRequest() + pb_message = analytics_admin.DeleteEventCreateRuleRequest.pb( + analytics_admin.DeleteEventCreateRuleRequest() ) transcode.return_value = { "method": "post", @@ -62560,21 +67836,15 @@ def test_fetch_connected_ga4_property_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.FetchConnectedGa4PropertyResponse.to_json( - analytics_admin.FetchConnectedGa4PropertyResponse() - ) - ) - request = analytics_admin.FetchConnectedGa4PropertyRequest() + request = analytics_admin.DeleteEventCreateRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = analytics_admin.FetchConnectedGa4PropertyResponse() - client.fetch_connected_ga4_property( + client.delete_event_create_rule( request, metadata=[ ("key", "val"), @@ -62583,12 +67853,10 @@ def test_fetch_connected_ga4_property_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_fetch_connected_ga4_property_rest_bad_request( - transport: str = "rest", - request_type=analytics_admin.FetchConnectedGa4PropertyRequest, +def test_delete_event_create_rule_rest_bad_request( + transport: str = "rest", request_type=analytics_admin.DeleteEventCreateRuleRequest ): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -62596,7 +67864,9 @@ def test_fetch_connected_ga4_property_rest_bad_request( ) # send a request that will satisfy transcoding - request_init = {} + request_init = { + "name": "properties/sample1/dataStreams/sample2/eventCreateRules/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -62608,10 +67878,67 @@ def test_fetch_connected_ga4_property_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value - client.fetch_connected_ga4_property(request) + client.delete_event_create_rule(request) -def test_fetch_connected_ga4_property_rest_error(): +def test_delete_event_create_rule_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/eventCreateRules/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 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_event_create_rule(**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/*/eventCreateRules/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_event_create_rule_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_event_create_rule( + analytics_admin.DeleteEventCreateRuleRequest(), + name="name_value", + ) + + +def test_delete_event_create_rule_rest_error(): client = AnalyticsAdminServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -62869,6 +68196,15 @@ def test_analytics_admin_service_base_transport(): "delete_connected_site_tag", "list_connected_site_tags", "fetch_connected_ga4_property", + "get_ad_sense_link", + "create_ad_sense_link", + "delete_ad_sense_link", + "list_ad_sense_links", + "get_event_create_rule", + "list_event_create_rules", + "create_event_create_rule", + "update_event_create_rule", + "delete_event_create_rule", ) for method in methods: with pytest.raises(NotImplementedError): @@ -63510,6 +68846,33 @@ def test_analytics_admin_service_client_transport_session_collision(transport_na session1 = client1.transport.fetch_connected_ga4_property._session session2 = client2.transport.fetch_connected_ga4_property._session assert session1 != session2 + session1 = client1.transport.get_ad_sense_link._session + session2 = client2.transport.get_ad_sense_link._session + assert session1 != session2 + session1 = client1.transport.create_ad_sense_link._session + session2 = client2.transport.create_ad_sense_link._session + assert session1 != session2 + session1 = client1.transport.delete_ad_sense_link._session + session2 = client2.transport.delete_ad_sense_link._session + assert session1 != session2 + session1 = client1.transport.list_ad_sense_links._session + session2 = client2.transport.list_ad_sense_links._session + assert session1 != session2 + session1 = client1.transport.get_event_create_rule._session + session2 = client2.transport.get_event_create_rule._session + assert session1 != session2 + session1 = client1.transport.list_event_create_rules._session + session2 = client2.transport.list_event_create_rules._session + assert session1 != session2 + session1 = client1.transport.create_event_create_rule._session + session2 = client2.transport.create_event_create_rule._session + assert session1 != session2 + session1 = client1.transport.update_event_create_rule._session + session2 = client2.transport.update_event_create_rule._session + assert session1 != session2 + session1 = client1.transport.delete_event_create_rule._session + session2 = client2.transport.delete_event_create_rule._session + assert session1 != session2 def test_analytics_admin_service_grpc_transport_channel(): @@ -63701,8 +69064,31 @@ def test_parse_account_summary_path(): assert expected == actual -def test_attribution_settings_path(): +def test_ad_sense_link_path(): property = "winkle" + adsense_link = "nautilus" + expected = "properties/{property}/adSenseLinks/{adsense_link}".format( + property=property, + adsense_link=adsense_link, + ) + actual = AnalyticsAdminServiceClient.ad_sense_link_path(property, adsense_link) + assert expected == actual + + +def test_parse_ad_sense_link_path(): + expected = { + "property": "scallop", + "adsense_link": "abalone", + } + path = AnalyticsAdminServiceClient.ad_sense_link_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_ad_sense_link_path(path) + assert expected == actual + + +def test_attribution_settings_path(): + property = "squid" expected = "properties/{property}/attributionSettings".format( property=property, ) @@ -63712,7 +69098,7 @@ def test_attribution_settings_path(): def test_parse_attribution_settings_path(): expected = { - "property": "nautilus", + "property": "clam", } path = AnalyticsAdminServiceClient.attribution_settings_path(**expected) @@ -63722,8 +69108,8 @@ def test_parse_attribution_settings_path(): def test_audience_path(): - property = "scallop" - audience = "abalone" + property = "whelk" + audience = "octopus" expected = "properties/{property}/audiences/{audience}".format( property=property, audience=audience, @@ -63734,8 +69120,8 @@ def test_audience_path(): def test_parse_audience_path(): expected = { - "property": "squid", - "audience": "clam", + "property": "oyster", + "audience": "nudibranch", } path = AnalyticsAdminServiceClient.audience_path(**expected) @@ -63745,8 +69131,8 @@ def test_parse_audience_path(): def test_big_query_link_path(): - property = "whelk" - bigquery_link = "octopus" + property = "cuttlefish" + bigquery_link = "mussel" expected = "properties/{property}/bigQueryLinks/{bigquery_link}".format( property=property, bigquery_link=bigquery_link, @@ -63757,8 +69143,8 @@ def test_big_query_link_path(): def test_parse_big_query_link_path(): expected = { - "property": "oyster", - "bigquery_link": "nudibranch", + "property": "winkle", + "bigquery_link": "nautilus", } path = AnalyticsAdminServiceClient.big_query_link_path(**expected) @@ -63768,8 +69154,8 @@ def test_parse_big_query_link_path(): def test_channel_group_path(): - property = "cuttlefish" - channel_group = "mussel" + property = "scallop" + channel_group = "abalone" expected = "properties/{property}/channelGroups/{channel_group}".format( property=property, channel_group=channel_group, @@ -63780,8 +69166,8 @@ def test_channel_group_path(): def test_parse_channel_group_path(): expected = { - "property": "winkle", - "channel_group": "nautilus", + "property": "squid", + "channel_group": "clam", } path = AnalyticsAdminServiceClient.channel_group_path(**expected) @@ -63791,8 +69177,8 @@ def test_parse_channel_group_path(): def test_conversion_event_path(): - property = "scallop" - conversion_event = "abalone" + property = "whelk" + conversion_event = "octopus" expected = "properties/{property}/conversionEvents/{conversion_event}".format( property=property, conversion_event=conversion_event, @@ -63805,8 +69191,8 @@ def test_conversion_event_path(): def test_parse_conversion_event_path(): expected = { - "property": "squid", - "conversion_event": "clam", + "property": "oyster", + "conversion_event": "nudibranch", } path = AnalyticsAdminServiceClient.conversion_event_path(**expected) @@ -63816,8 +69202,8 @@ def test_parse_conversion_event_path(): def test_custom_dimension_path(): - property = "whelk" - custom_dimension = "octopus" + property = "cuttlefish" + custom_dimension = "mussel" expected = "properties/{property}/customDimensions/{custom_dimension}".format( property=property, custom_dimension=custom_dimension, @@ -63830,8 +69216,8 @@ def test_custom_dimension_path(): def test_parse_custom_dimension_path(): expected = { - "property": "oyster", - "custom_dimension": "nudibranch", + "property": "winkle", + "custom_dimension": "nautilus", } path = AnalyticsAdminServiceClient.custom_dimension_path(**expected) @@ -63841,8 +69227,8 @@ def test_parse_custom_dimension_path(): def test_custom_metric_path(): - property = "cuttlefish" - custom_metric = "mussel" + property = "scallop" + custom_metric = "abalone" expected = "properties/{property}/customMetrics/{custom_metric}".format( property=property, custom_metric=custom_metric, @@ -63853,8 +69239,8 @@ def test_custom_metric_path(): def test_parse_custom_metric_path(): expected = { - "property": "winkle", - "custom_metric": "nautilus", + "property": "squid", + "custom_metric": "clam", } path = AnalyticsAdminServiceClient.custom_metric_path(**expected) @@ -63864,7 +69250,7 @@ def test_parse_custom_metric_path(): def test_data_retention_settings_path(): - property = "scallop" + property = "whelk" expected = "properties/{property}/dataRetentionSettings".format( property=property, ) @@ -63874,7 +69260,7 @@ def test_data_retention_settings_path(): def test_parse_data_retention_settings_path(): expected = { - "property": "abalone", + "property": "octopus", } path = AnalyticsAdminServiceClient.data_retention_settings_path(**expected) @@ -63884,7 +69270,7 @@ def test_parse_data_retention_settings_path(): def test_data_sharing_settings_path(): - account = "squid" + account = "oyster" expected = "accounts/{account}/dataSharingSettings".format( account=account, ) @@ -63894,7 +69280,7 @@ def test_data_sharing_settings_path(): def test_parse_data_sharing_settings_path(): expected = { - "account": "clam", + "account": "nudibranch", } path = AnalyticsAdminServiceClient.data_sharing_settings_path(**expected) @@ -63904,8 +69290,8 @@ def test_parse_data_sharing_settings_path(): def test_data_stream_path(): - property = "whelk" - data_stream = "octopus" + property = "cuttlefish" + data_stream = "mussel" expected = "properties/{property}/dataStreams/{data_stream}".format( property=property, data_stream=data_stream, @@ -63916,8 +69302,8 @@ def test_data_stream_path(): def test_parse_data_stream_path(): expected = { - "property": "oyster", - "data_stream": "nudibranch", + "property": "winkle", + "data_stream": "nautilus", } path = AnalyticsAdminServiceClient.data_stream_path(**expected) @@ -63927,8 +69313,8 @@ def test_parse_data_stream_path(): def test_display_video360_advertiser_link_path(): - property = "cuttlefish" - display_video_360_advertiser_link = "mussel" + property = "scallop" + display_video_360_advertiser_link = "abalone" expected = "properties/{property}/displayVideo360AdvertiserLinks/{display_video_360_advertiser_link}".format( property=property, display_video_360_advertiser_link=display_video_360_advertiser_link, @@ -63941,8 +69327,8 @@ def test_display_video360_advertiser_link_path(): def test_parse_display_video360_advertiser_link_path(): expected = { - "property": "winkle", - "display_video_360_advertiser_link": "nautilus", + "property": "squid", + "display_video_360_advertiser_link": "clam", } path = AnalyticsAdminServiceClient.display_video360_advertiser_link_path(**expected) @@ -63954,8 +69340,8 @@ def test_parse_display_video360_advertiser_link_path(): def test_display_video360_advertiser_link_proposal_path(): - property = "scallop" - display_video_360_advertiser_link_proposal = "abalone" + property = "whelk" + display_video_360_advertiser_link_proposal = "octopus" 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, @@ -63968,8 +69354,8 @@ def test_display_video360_advertiser_link_proposal_path(): def test_parse_display_video360_advertiser_link_proposal_path(): expected = { - "property": "squid", - "display_video_360_advertiser_link_proposal": "clam", + "property": "oyster", + "display_video_360_advertiser_link_proposal": "nudibranch", } path = AnalyticsAdminServiceClient.display_video360_advertiser_link_proposal_path( **expected @@ -63983,8 +69369,8 @@ def test_parse_display_video360_advertiser_link_proposal_path(): def test_enhanced_measurement_settings_path(): - property = "whelk" - data_stream = "octopus" + property = "cuttlefish" + data_stream = "mussel" expected = "properties/{property}/dataStreams/{data_stream}/enhancedMeasurementSettings".format( property=property, data_stream=data_stream, @@ -63997,8 +69383,8 @@ def test_enhanced_measurement_settings_path(): def test_parse_enhanced_measurement_settings_path(): expected = { - "property": "oyster", - "data_stream": "nudibranch", + "property": "winkle", + "data_stream": "nautilus", } path = AnalyticsAdminServiceClient.enhanced_measurement_settings_path(**expected) @@ -64007,9 +69393,37 @@ def test_parse_enhanced_measurement_settings_path(): assert expected == actual +def test_event_create_rule_path(): + property = "scallop" + data_stream = "abalone" + event_create_rule = "squid" + expected = "properties/{property}/dataStreams/{data_stream}/eventCreateRules/{event_create_rule}".format( + property=property, + data_stream=data_stream, + event_create_rule=event_create_rule, + ) + actual = AnalyticsAdminServiceClient.event_create_rule_path( + property, data_stream, event_create_rule + ) + assert expected == actual + + +def test_parse_event_create_rule_path(): + expected = { + "property": "clam", + "data_stream": "whelk", + "event_create_rule": "octopus", + } + path = AnalyticsAdminServiceClient.event_create_rule_path(**expected) + + # Check that the path construction is reversible. + actual = AnalyticsAdminServiceClient.parse_event_create_rule_path(path) + assert expected == actual + + def test_expanded_data_set_path(): - property = "cuttlefish" - expanded_data_set = "mussel" + property = "oyster" + expanded_data_set = "nudibranch" expected = "properties/{property}/expandedDataSets/{expanded_data_set}".format( property=property, expanded_data_set=expanded_data_set, @@ -64022,8 +69436,8 @@ def test_expanded_data_set_path(): def test_parse_expanded_data_set_path(): expected = { - "property": "winkle", - "expanded_data_set": "nautilus", + "property": "cuttlefish", + "expanded_data_set": "mussel", } path = AnalyticsAdminServiceClient.expanded_data_set_path(**expected) @@ -64033,8 +69447,8 @@ def test_parse_expanded_data_set_path(): def test_firebase_link_path(): - property = "scallop" - firebase_link = "abalone" + property = "winkle" + firebase_link = "nautilus" expected = "properties/{property}/firebaseLinks/{firebase_link}".format( property=property, firebase_link=firebase_link, @@ -64045,8 +69459,8 @@ def test_firebase_link_path(): def test_parse_firebase_link_path(): expected = { - "property": "squid", - "firebase_link": "clam", + "property": "scallop", + "firebase_link": "abalone", } path = AnalyticsAdminServiceClient.firebase_link_path(**expected) @@ -64056,8 +69470,8 @@ def test_parse_firebase_link_path(): def test_global_site_tag_path(): - property = "whelk" - data_stream = "octopus" + property = "squid" + data_stream = "clam" expected = "properties/{property}/dataStreams/{data_stream}/globalSiteTag".format( property=property, data_stream=data_stream, @@ -64068,8 +69482,8 @@ def test_global_site_tag_path(): def test_parse_global_site_tag_path(): expected = { - "property": "oyster", - "data_stream": "nudibranch", + "property": "whelk", + "data_stream": "octopus", } path = AnalyticsAdminServiceClient.global_site_tag_path(**expected) @@ -64079,8 +69493,8 @@ def test_parse_global_site_tag_path(): def test_google_ads_link_path(): - property = "cuttlefish" - google_ads_link = "mussel" + property = "oyster" + google_ads_link = "nudibranch" expected = "properties/{property}/googleAdsLinks/{google_ads_link}".format( property=property, google_ads_link=google_ads_link, @@ -64091,8 +69505,8 @@ def test_google_ads_link_path(): def test_parse_google_ads_link_path(): expected = { - "property": "winkle", - "google_ads_link": "nautilus", + "property": "cuttlefish", + "google_ads_link": "mussel", } path = AnalyticsAdminServiceClient.google_ads_link_path(**expected) @@ -64102,7 +69516,7 @@ def test_parse_google_ads_link_path(): def test_google_signals_settings_path(): - property = "scallop" + property = "winkle" expected = "properties/{property}/googleSignalsSettings".format( property=property, ) @@ -64112,7 +69526,7 @@ def test_google_signals_settings_path(): def test_parse_google_signals_settings_path(): expected = { - "property": "abalone", + "property": "nautilus", } path = AnalyticsAdminServiceClient.google_signals_settings_path(**expected) @@ -64122,9 +69536,9 @@ def test_parse_google_signals_settings_path(): def test_measurement_protocol_secret_path(): - property = "squid" - data_stream = "clam" - measurement_protocol_secret = "whelk" + property = "scallop" + data_stream = "abalone" + measurement_protocol_secret = "squid" expected = "properties/{property}/dataStreams/{data_stream}/measurementProtocolSecrets/{measurement_protocol_secret}".format( property=property, data_stream=data_stream, @@ -64138,9 +69552,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": "clam", + "data_stream": "whelk", + "measurement_protocol_secret": "octopus", } path = AnalyticsAdminServiceClient.measurement_protocol_secret_path(**expected) @@ -64150,7 +69564,7 @@ def test_parse_measurement_protocol_secret_path(): def test_property_path(): - property = "cuttlefish" + property = "oyster" expected = "properties/{property}".format( property=property, ) @@ -64160,7 +69574,7 @@ def test_property_path(): def test_parse_property_path(): expected = { - "property": "mussel", + "property": "nudibranch", } path = AnalyticsAdminServiceClient.property_path(**expected) @@ -64170,8 +69584,8 @@ def test_parse_property_path(): def test_search_ads360_link_path(): - property = "winkle" - search_ads_360_link = "nautilus" + property = "cuttlefish" + search_ads_360_link = "mussel" expected = "properties/{property}/searchAds360Links/{search_ads_360_link}".format( property=property, search_ads_360_link=search_ads_360_link, @@ -64184,8 +69598,8 @@ def test_search_ads360_link_path(): def test_parse_search_ads360_link_path(): expected = { - "property": "scallop", - "search_ads_360_link": "abalone", + "property": "winkle", + "search_ads_360_link": "nautilus", } path = AnalyticsAdminServiceClient.search_ads360_link_path(**expected) @@ -64195,8 +69609,8 @@ def test_parse_search_ads360_link_path(): def test_user_link_path(): - account = "squid" - user_link = "clam" + account = "scallop" + user_link = "abalone" expected = "accounts/{account}/userLinks/{user_link}".format( account=account, user_link=user_link, @@ -64207,8 +69621,8 @@ def test_user_link_path(): def test_parse_user_link_path(): expected = { - "account": "whelk", - "user_link": "octopus", + "account": "squid", + "user_link": "clam", } path = AnalyticsAdminServiceClient.user_link_path(**expected) @@ -64218,7 +69632,7 @@ def test_parse_user_link_path(): def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "whelk" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -64228,7 +69642,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "octopus", } path = AnalyticsAdminServiceClient.common_billing_account_path(**expected) @@ -64238,7 +69652,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "oyster" expected = "folders/{folder}".format( folder=folder, ) @@ -64248,7 +69662,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "nudibranch", } path = AnalyticsAdminServiceClient.common_folder_path(**expected) @@ -64258,7 +69672,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "cuttlefish" expected = "organizations/{organization}".format( organization=organization, ) @@ -64268,7 +69682,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "mussel", } path = AnalyticsAdminServiceClient.common_organization_path(**expected) @@ -64278,7 +69692,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "winkle" expected = "projects/{project}".format( project=project, ) @@ -64288,7 +69702,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "nautilus", } path = AnalyticsAdminServiceClient.common_project_path(**expected) @@ -64298,8 +69712,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -64310,8 +69724,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "squid", + "location": "clam", } path = AnalyticsAdminServiceClient.common_location_path(**expected)