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

feat: add UpdateConversionEvent method to the Admin API v1 beta #375

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions google/analytics/admin_v1beta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
SearchChangeHistoryEventsRequest,
SearchChangeHistoryEventsResponse,
UpdateAccountRequest,
UpdateConversionEventRequest,
UpdateCustomDimensionRequest,
UpdateCustomMetricRequest,
UpdateDataRetentionSettingsRequest,
Expand Down Expand Up @@ -229,6 +230,7 @@
"SearchChangeHistoryEventsResponse",
"ServiceLevel",
"UpdateAccountRequest",
"UpdateConversionEventRequest",
"UpdateCustomDimensionRequest",
"UpdateCustomMetricRequest",
"UpdateDataRetentionSettingsRequest",
Expand Down
15 changes: 15 additions & 0 deletions google/analytics/admin_v1beta/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@
"update_account"
]
},
"UpdateConversionEvent": {
"methods": [
"update_conversion_event"
]
},
"UpdateCustomDimension": {
"methods": [
"update_custom_dimension"
Expand Down Expand Up @@ -460,6 +465,11 @@
"update_account"
]
},
"UpdateConversionEvent": {
"methods": [
"update_conversion_event"
]
},
"UpdateCustomDimension": {
"methods": [
"update_custom_dimension"
Expand Down Expand Up @@ -705,6 +715,11 @@
"update_account"
]
},
"UpdateConversionEvent": {
"methods": [
"update_conversion_event"
]
},
"UpdateCustomDimension": {
"methods": [
"update_custom_dimension"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2761,8 +2761,9 @@ async def sample_update_measurement_protocol_secret():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
The list of fields to be updated.
Omitted fields will not be updated.
Required. The list of fields to be
updated. Omitted fields will not be
updated.

This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down Expand Up @@ -3130,6 +3131,125 @@ async def sample_create_conversion_event():
# Done; return the response.
return response

async def update_conversion_event(
self,
request: Optional[
Union[analytics_admin.UpdateConversionEventRequest, dict]
] = None,
*,
conversion_event: Optional[resources.ConversionEvent] = 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]] = (),
) -> resources.ConversionEvent:
r"""Updates a conversion event with the specified
attributes.

.. 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_v1beta

async def sample_update_conversion_event():
# Create a client
client = admin_v1beta.AnalyticsAdminServiceAsyncClient()

# Initialize request argument(s)
request = admin_v1beta.UpdateConversionEventRequest(
)

# Make the request
response = await client.update_conversion_event(request=request)

# Handle the response
print(response)

Args:
request (Optional[Union[google.analytics.admin_v1beta.types.UpdateConversionEventRequest, dict]]):
The request object. Request message for
UpdateConversionEvent RPC
conversion_event (:class:`google.analytics.admin_v1beta.types.ConversionEvent`):
Required. The conversion event to update. The ``name``
field is used to identify the settings to be updated.

This corresponds to the ``conversion_event`` 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_v1beta.types.ConversionEvent:
A conversion event in a Google
Analytics property.

"""
# 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([conversion_event, 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.UpdateConversionEventRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if conversion_event is not None:
request.conversion_event = conversion_event
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_conversion_event,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("conversion_event.name", request.conversion_event.name),)
),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def get_conversion_event(
self,
request: Optional[
Expand Down Expand Up @@ -3483,7 +3603,7 @@ async def sample_create_custom_dimension():
custom_dimension = admin_v1beta.CustomDimension()
custom_dimension.parameter_name = "parameter_name_value"
custom_dimension.display_name = "display_name_value"
custom_dimension.scope = "USER"
custom_dimension.scope = "ITEM"

request = admin_v1beta.CreateCustomDimensionRequest(
parent="parent_value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3143,8 +3143,9 @@ def sample_update_measurement_protocol_secret():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (google.protobuf.field_mask_pb2.FieldMask):
The list of fields to be updated.
Omitted fields will not be updated.
Required. The list of fields to be
updated. Omitted fields will not be
updated.

This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down Expand Up @@ -3524,6 +3525,125 @@ def sample_create_conversion_event():
# Done; return the response.
return response

def update_conversion_event(
self,
request: Optional[
Union[analytics_admin.UpdateConversionEventRequest, dict]
] = None,
*,
conversion_event: Optional[resources.ConversionEvent] = 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]] = (),
) -> resources.ConversionEvent:
r"""Updates a conversion event with the specified
attributes.

.. 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_v1beta

def sample_update_conversion_event():
# Create a client
client = admin_v1beta.AnalyticsAdminServiceClient()

# Initialize request argument(s)
request = admin_v1beta.UpdateConversionEventRequest(
)

# Make the request
response = client.update_conversion_event(request=request)

# Handle the response
print(response)

Args:
request (Union[google.analytics.admin_v1beta.types.UpdateConversionEventRequest, dict]):
The request object. Request message for
UpdateConversionEvent RPC
conversion_event (google.analytics.admin_v1beta.types.ConversionEvent):
Required. The conversion event to update. The ``name``
field is used to identify the settings to be updated.

This corresponds to the ``conversion_event`` 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_v1beta.types.ConversionEvent:
A conversion event in a Google
Analytics property.

"""
# 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([conversion_event, 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.UpdateConversionEventRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, analytics_admin.UpdateConversionEventRequest):
request = analytics_admin.UpdateConversionEventRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if conversion_event is not None:
request.conversion_event = conversion_event
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_conversion_event]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("conversion_event.name", request.conversion_event.name),)
),
)

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def get_conversion_event(
self,
request: Optional[
Expand Down Expand Up @@ -3877,7 +3997,7 @@ def sample_create_custom_dimension():
custom_dimension = admin_v1beta.CustomDimension()
custom_dimension.parameter_name = "parameter_name_value"
custom_dimension.display_name = "display_name_value"
custom_dimension.scope = "USER"
custom_dimension.scope = "ITEM"

request = admin_v1beta.CreateCustomDimensionRequest(
parent="parent_value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.update_conversion_event: gapic_v1.method.wrap_method(
self.update_conversion_event,
default_timeout=None,
client_info=client_info,
),
self.get_conversion_event: gapic_v1.method.wrap_method(
self.get_conversion_event,
default_timeout=None,
Expand Down Expand Up @@ -656,6 +661,15 @@ def create_conversion_event(
]:
raise NotImplementedError()

@property
def update_conversion_event(
self,
) -> Callable[
[analytics_admin.UpdateConversionEventRequest],
Union[resources.ConversionEvent, Awaitable[resources.ConversionEvent]],
]:
raise NotImplementedError()

@property
def get_conversion_event(
self,
Expand Down
Loading