Skip to content

update_metric async

update_metric(
    app_id: AppId,
    metric_id: MetricId,
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
    name: Optional[MetricDisplayName] = None,
    description: Optional[MetricDescription] = None,
    event_type: Optional[SourceEventType] = None,
    unit_name: Optional[UnitName] = None,
    definition: Optional[MetricDefinition] = None,
) -> UpdateMetricResponse

Updates an existing metric. Only a draft metric, one that has never been published, can be modified. After a metric is published, every field is frozen and any update is rejected with a ConflictException. To change a published metric, archive it and create a new metric.

Parameters:

  • app_id (AppId) –

    The ID of the app.

  • metric_id (MetricId) –

    The ID of the metric to update.

  • name (Optional[MetricDisplayName], default: None ) –

    A human-readable display name for the metric.

  • description (Optional[MetricDescription], default: None ) –

    A description of what the metric measures.

  • event_type (Optional[SourceEventType], default: None ) –

    The event type this metric aggregates.

  • unit_name (Optional[UnitName], default: None ) –

    The unit of measure for the metric (for example, "requests"), in lowercase snake_case.

  • definition (Optional[MetricDefinition], default: None ) –

    The aggregation definition: filters, aggregation function, grouping, and period.

Raises:

Source code in docs_src/capo_appmonetization/_services/async_app_monetization.py
async def update_metric(
    self,
    app_id: "capo_appmonetization.types.app_id.AppId",
    metric_id: "capo_appmonetization.types.metric_id.MetricId",
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
    name: Optional[
        "capo_appmonetization.types.metric_display_name.MetricDisplayName"
    ] = None,
    description: Optional[
        "capo_appmonetization.types.metric_description.MetricDescription"
    ] = None,
    event_type: Optional[
        "capo_appmonetization.types.source_event_type.SourceEventType"
    ] = None,
    unit_name: Optional["capo_appmonetization.types.unit_name.UnitName"] = None,
    definition: Optional[
        "capo_appmonetization.types.metric_definition.MetricDefinition"
    ] = None,
) -> "capo_appmonetization.types.update_metric_response.UpdateMetricResponse":
    """Updates an existing metric. Only a draft metric, one that has never been published, can be modified. After a metric is published, every field is frozen and any update is rejected with a ConflictException. To change a published metric, archive it and create a new metric.

    Args:
        app_id: The ID of the app.
        metric_id: The ID of the metric to update.
        name: A human-readable display name for the metric.
        description: A description of what the metric measures.
        event_type: The event type this metric aggregates.
        unit_name: The unit of measure for the metric (for example, "requests"), in lowercase snake_case.
        definition: The aggregation definition: filters, aggregation function, grouping, and period.

    Raises:
        capo_appmonetization.errors.access_denied_exception.AccessDeniedException: The caller does not have sufficient permission to perform this action.
        capo_appmonetization.errors.conflict_exception.ConflictException: The request conflicts with the current state of the resource, such as a duplicate identifier or a version mismatch. Retrieve the current state of the resource and retry the request.
        capo_appmonetization.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_appmonetization.errors.invalid_configuration_exception.InvalidConfigurationException: The requested configuration is not valid.
        capo_appmonetization.errors.resource_not_found_exception.ResourceNotFoundException: The referenced resource does not exist.
        capo_appmonetization.errors.revision_conflict_exception.RevisionConflictException: The request's revision does not match the resource's current revision. Retry with the current revision.
        capo_appmonetization.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: The request would cause a service quota to be exceeded.
        capo_appmonetization.errors.throttling_exception.ThrottlingException: The request was denied due to request throttling.
        capo_appmonetization.errors.validation_exception.ValidationException: The request failed input validation.
        capo_appmonetization.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_appmonetization.types.update_metric_request.UpdateMetricRequest]",
    ) -> AsyncOperationResponse[
        "capo_appmonetization.types.update_metric_response.UpdateMetricResponse"
    ]:
        import capo_appmonetization._operations.aws_monetization_ai_front_end.update_metric

        (
            output,
            http_response,
        ) = await capo_appmonetization._operations.aws_monetization_ai_front_end.update_metric.async_update_metric(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateMetric")
    )
    input_: capo_appmonetization.types.update_metric_request.UpdateMetricRequest = {
        "app_id": app_id,
        "metric_id": metric_id,
    }
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if event_type is not None:
        input_["event_type"] = event_type
    if unit_name is not None:
        input_["unit_name"] = unit_name
    if definition is not None:
        input_["definition"] = definition

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output