Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit 7c8f27f

Browse files
feat: add UpdateConversionEvent method to the Admin API v1 beta (#375)
* feat: add `UpdateConversionEvent` method to the Admin API v1 beta feat: add the `counting_method` field to the `ConversionEvent` type feat: add the `ConversionCountingMethod` enum feat: add the `ITEM` option to the `DimensionScope` enum feat: make the field `default_uri` of `WebStreamData` mutable fix!: add the missing `REQUIRED` annotation to the `update_mask` field of `UpdateMeasurementProtocolSecretRequest` PiperOrigin-RevId: 559470845 Source-Link: googleapis/googleapis@751dfcf Source-Link: https://github.com/googleapis/googleapis-gen/commit/d2ef8190576bce8ea3c45ad9dd86c08533c36371 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDJlZjgxOTA1NzZiY2U4ZWEzYzQ1YWQ5ZGQ4NmMwODUzM2MzNjM3MSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 81d6b15 commit 7c8f27f

19 files changed

Lines changed: 1464 additions & 26 deletions

google/analytics/admin_v1beta/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
SearchChangeHistoryEventsRequest,
100100
SearchChangeHistoryEventsResponse,
101101
UpdateAccountRequest,
102+
UpdateConversionEventRequest,
102103
UpdateCustomDimensionRequest,
103104
UpdateCustomMetricRequest,
104105
UpdateDataRetentionSettingsRequest,
@@ -229,6 +230,7 @@
229230
"SearchChangeHistoryEventsResponse",
230231
"ServiceLevel",
231232
"UpdateAccountRequest",
233+
"UpdateConversionEventRequest",
232234
"UpdateCustomDimensionRequest",
233235
"UpdateCustomMetricRequest",
234236
"UpdateDataRetentionSettingsRequest",

google/analytics/admin_v1beta/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@
215215
"update_account"
216216
]
217217
},
218+
"UpdateConversionEvent": {
219+
"methods": [
220+
"update_conversion_event"
221+
]
222+
},
218223
"UpdateCustomDimension": {
219224
"methods": [
220225
"update_custom_dimension"
@@ -460,6 +465,11 @@
460465
"update_account"
461466
]
462467
},
468+
"UpdateConversionEvent": {
469+
"methods": [
470+
"update_conversion_event"
471+
]
472+
},
463473
"UpdateCustomDimension": {
464474
"methods": [
465475
"update_custom_dimension"
@@ -705,6 +715,11 @@
705715
"update_account"
706716
]
707717
},
718+
"UpdateConversionEvent": {
719+
"methods": [
720+
"update_conversion_event"
721+
]
722+
},
708723
"UpdateCustomDimension": {
709724
"methods": [
710725
"update_custom_dimension"

google/analytics/admin_v1beta/services/analytics_admin_service/async_client.py

Lines changed: 123 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,8 +2761,9 @@ async def sample_update_measurement_protocol_secret():
27612761
on the ``request`` instance; if ``request`` is provided, this
27622762
should not be set.
27632763
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
2764-
The list of fields to be updated.
2765-
Omitted fields will not be updated.
2764+
Required. The list of fields to be
2765+
updated. Omitted fields will not be
2766+
updated.
27662767
27672768
This corresponds to the ``update_mask`` field
27682769
on the ``request`` instance; if ``request`` is provided, this
@@ -3130,6 +3131,125 @@ async def sample_create_conversion_event():
31303131
# Done; return the response.
31313132
return response
31323133

3134+
async def update_conversion_event(
3135+
self,
3136+
request: Optional[
3137+
Union[analytics_admin.UpdateConversionEventRequest, dict]
3138+
] = None,
3139+
*,
3140+
conversion_event: Optional[resources.ConversionEvent] = None,
3141+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
3142+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
3143+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3144+
metadata: Sequence[Tuple[str, str]] = (),
3145+
) -> resources.ConversionEvent:
3146+
r"""Updates a conversion event with the specified
3147+
attributes.
3148+
3149+
.. code-block:: python
3150+
3151+
# This snippet has been automatically generated and should be regarded as a
3152+
# code template only.
3153+
# It will require modifications to work:
3154+
# - It may require correct/in-range values for request initialization.
3155+
# - It may require specifying regional endpoints when creating the service
3156+
# client as shown in:
3157+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
3158+
from google.analytics import admin_v1beta
3159+
3160+
async def sample_update_conversion_event():
3161+
# Create a client
3162+
client = admin_v1beta.AnalyticsAdminServiceAsyncClient()
3163+
3164+
# Initialize request argument(s)
3165+
request = admin_v1beta.UpdateConversionEventRequest(
3166+
)
3167+
3168+
# Make the request
3169+
response = await client.update_conversion_event(request=request)
3170+
3171+
# Handle the response
3172+
print(response)
3173+
3174+
Args:
3175+
request (Optional[Union[google.analytics.admin_v1beta.types.UpdateConversionEventRequest, dict]]):
3176+
The request object. Request message for
3177+
UpdateConversionEvent RPC
3178+
conversion_event (:class:`google.analytics.admin_v1beta.types.ConversionEvent`):
3179+
Required. The conversion event to update. The ``name``
3180+
field is used to identify the settings to be updated.
3181+
3182+
This corresponds to the ``conversion_event`` field
3183+
on the ``request`` instance; if ``request`` is provided, this
3184+
should not be set.
3185+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
3186+
Required. The list of fields to be updated. Field names
3187+
must be in snake case (e.g., "field_to_update"). Omitted
3188+
fields will not be updated. To replace the entire
3189+
entity, use one path with the string "*" to match all
3190+
fields.
3191+
3192+
This corresponds to the ``update_mask`` field
3193+
on the ``request`` instance; if ``request`` is provided, this
3194+
should not be set.
3195+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
3196+
should be retried.
3197+
timeout (float): The timeout for this request.
3198+
metadata (Sequence[Tuple[str, str]]): Strings which should be
3199+
sent along with the request as metadata.
3200+
3201+
Returns:
3202+
google.analytics.admin_v1beta.types.ConversionEvent:
3203+
A conversion event in a Google
3204+
Analytics property.
3205+
3206+
"""
3207+
# Create or coerce a protobuf request object.
3208+
# Quick check: If we got a request object, we should *not* have
3209+
# gotten any keyword arguments that map to the request.
3210+
has_flattened_params = any([conversion_event, update_mask])
3211+
if request is not None and has_flattened_params:
3212+
raise ValueError(
3213+
"If the `request` argument is set, then none of "
3214+
"the individual field arguments should be set."
3215+
)
3216+
3217+
request = analytics_admin.UpdateConversionEventRequest(request)
3218+
3219+
# If we have keyword arguments corresponding to fields on the
3220+
# request, apply these.
3221+
if conversion_event is not None:
3222+
request.conversion_event = conversion_event
3223+
if update_mask is not None:
3224+
request.update_mask = update_mask
3225+
3226+
# Wrap the RPC method; this adds retry and timeout information,
3227+
# and friendly error handling.
3228+
rpc = gapic_v1.method_async.wrap_method(
3229+
self._client._transport.update_conversion_event,
3230+
default_timeout=None,
3231+
client_info=DEFAULT_CLIENT_INFO,
3232+
)
3233+
3234+
# Certain fields should be provided within the metadata header;
3235+
# add these here.
3236+
metadata = tuple(metadata) + (
3237+
gapic_v1.routing_header.to_grpc_metadata(
3238+
(("conversion_event.name", request.conversion_event.name),)
3239+
),
3240+
)
3241+
3242+
# Send the request.
3243+
response = await rpc(
3244+
request,
3245+
retry=retry,
3246+
timeout=timeout,
3247+
metadata=metadata,
3248+
)
3249+
3250+
# Done; return the response.
3251+
return response
3252+
31333253
async def get_conversion_event(
31343254
self,
31353255
request: Optional[
@@ -3483,7 +3603,7 @@ async def sample_create_custom_dimension():
34833603
custom_dimension = admin_v1beta.CustomDimension()
34843604
custom_dimension.parameter_name = "parameter_name_value"
34853605
custom_dimension.display_name = "display_name_value"
3486-
custom_dimension.scope = "USER"
3606+
custom_dimension.scope = "ITEM"
34873607
34883608
request = admin_v1beta.CreateCustomDimensionRequest(
34893609
parent="parent_value",

google/analytics/admin_v1beta/services/analytics_admin_service/client.py

Lines changed: 123 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,8 +3143,9 @@ def sample_update_measurement_protocol_secret():
31433143
on the ``request`` instance; if ``request`` is provided, this
31443144
should not be set.
31453145
update_mask (google.protobuf.field_mask_pb2.FieldMask):
3146-
The list of fields to be updated.
3147-
Omitted fields will not be updated.
3146+
Required. The list of fields to be
3147+
updated. Omitted fields will not be
3148+
updated.
31483149
31493150
This corresponds to the ``update_mask`` field
31503151
on the ``request`` instance; if ``request`` is provided, this
@@ -3524,6 +3525,125 @@ def sample_create_conversion_event():
35243525
# Done; return the response.
35253526
return response
35263527

3528+
def update_conversion_event(
3529+
self,
3530+
request: Optional[
3531+
Union[analytics_admin.UpdateConversionEventRequest, dict]
3532+
] = None,
3533+
*,
3534+
conversion_event: Optional[resources.ConversionEvent] = None,
3535+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
3536+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
3537+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3538+
metadata: Sequence[Tuple[str, str]] = (),
3539+
) -> resources.ConversionEvent:
3540+
r"""Updates a conversion event with the specified
3541+
attributes.
3542+
3543+
.. code-block:: python
3544+
3545+
# This snippet has been automatically generated and should be regarded as a
3546+
# code template only.
3547+
# It will require modifications to work:
3548+
# - It may require correct/in-range values for request initialization.
3549+
# - It may require specifying regional endpoints when creating the service
3550+
# client as shown in:
3551+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
3552+
from google.analytics import admin_v1beta
3553+
3554+
def sample_update_conversion_event():
3555+
# Create a client
3556+
client = admin_v1beta.AnalyticsAdminServiceClient()
3557+
3558+
# Initialize request argument(s)
3559+
request = admin_v1beta.UpdateConversionEventRequest(
3560+
)
3561+
3562+
# Make the request
3563+
response = client.update_conversion_event(request=request)
3564+
3565+
# Handle the response
3566+
print(response)
3567+
3568+
Args:
3569+
request (Union[google.analytics.admin_v1beta.types.UpdateConversionEventRequest, dict]):
3570+
The request object. Request message for
3571+
UpdateConversionEvent RPC
3572+
conversion_event (google.analytics.admin_v1beta.types.ConversionEvent):
3573+
Required. The conversion event to update. The ``name``
3574+
field is used to identify the settings to be updated.
3575+
3576+
This corresponds to the ``conversion_event`` field
3577+
on the ``request`` instance; if ``request`` is provided, this
3578+
should not be set.
3579+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
3580+
Required. The list of fields to be updated. Field names
3581+
must be in snake case (e.g., "field_to_update"). Omitted
3582+
fields will not be updated. To replace the entire
3583+
entity, use one path with the string "*" to match all
3584+
fields.
3585+
3586+
This corresponds to the ``update_mask`` field
3587+
on the ``request`` instance; if ``request`` is provided, this
3588+
should not be set.
3589+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
3590+
should be retried.
3591+
timeout (float): The timeout for this request.
3592+
metadata (Sequence[Tuple[str, str]]): Strings which should be
3593+
sent along with the request as metadata.
3594+
3595+
Returns:
3596+
google.analytics.admin_v1beta.types.ConversionEvent:
3597+
A conversion event in a Google
3598+
Analytics property.
3599+
3600+
"""
3601+
# Create or coerce a protobuf request object.
3602+
# Quick check: If we got a request object, we should *not* have
3603+
# gotten any keyword arguments that map to the request.
3604+
has_flattened_params = any([conversion_event, update_mask])
3605+
if request is not None and has_flattened_params:
3606+
raise ValueError(
3607+
"If the `request` argument is set, then none of "
3608+
"the individual field arguments should be set."
3609+
)
3610+
3611+
# Minor optimization to avoid making a copy if the user passes
3612+
# in a analytics_admin.UpdateConversionEventRequest.
3613+
# There's no risk of modifying the input as we've already verified
3614+
# there are no flattened fields.
3615+
if not isinstance(request, analytics_admin.UpdateConversionEventRequest):
3616+
request = analytics_admin.UpdateConversionEventRequest(request)
3617+
# If we have keyword arguments corresponding to fields on the
3618+
# request, apply these.
3619+
if conversion_event is not None:
3620+
request.conversion_event = conversion_event
3621+
if update_mask is not None:
3622+
request.update_mask = update_mask
3623+
3624+
# Wrap the RPC method; this adds retry and timeout information,
3625+
# and friendly error handling.
3626+
rpc = self._transport._wrapped_methods[self._transport.update_conversion_event]
3627+
3628+
# Certain fields should be provided within the metadata header;
3629+
# add these here.
3630+
metadata = tuple(metadata) + (
3631+
gapic_v1.routing_header.to_grpc_metadata(
3632+
(("conversion_event.name", request.conversion_event.name),)
3633+
),
3634+
)
3635+
3636+
# Send the request.
3637+
response = rpc(
3638+
request,
3639+
retry=retry,
3640+
timeout=timeout,
3641+
metadata=metadata,
3642+
)
3643+
3644+
# Done; return the response.
3645+
return response
3646+
35273647
def get_conversion_event(
35283648
self,
35293649
request: Optional[
@@ -3877,7 +3997,7 @@ def sample_create_custom_dimension():
38773997
custom_dimension = admin_v1beta.CustomDimension()
38783998
custom_dimension.parameter_name = "parameter_name_value"
38793999
custom_dimension.display_name = "display_name_value"
3880-
custom_dimension.scope = "USER"
4000+
custom_dimension.scope = "ITEM"
38814001
38824002
request = admin_v1beta.CreateCustomDimensionRequest(
38834003
parent="parent_value",

google/analytics/admin_v1beta/services/analytics_admin_service/transports/base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ def _prep_wrapped_messages(self, client_info):
261261
default_timeout=None,
262262
client_info=client_info,
263263
),
264+
self.update_conversion_event: gapic_v1.method.wrap_method(
265+
self.update_conversion_event,
266+
default_timeout=None,
267+
client_info=client_info,
268+
),
264269
self.get_conversion_event: gapic_v1.method.wrap_method(
265270
self.get_conversion_event,
266271
default_timeout=None,
@@ -656,6 +661,15 @@ def create_conversion_event(
656661
]:
657662
raise NotImplementedError()
658663

664+
@property
665+
def update_conversion_event(
666+
self,
667+
) -> Callable[
668+
[analytics_admin.UpdateConversionEventRequest],
669+
Union[resources.ConversionEvent, Awaitable[resources.ConversionEvent]],
670+
]:
671+
raise NotImplementedError()
672+
659673
@property
660674
def get_conversion_event(
661675
self,

0 commit comments

Comments
 (0)