Skip to content

create_fleet_metric async

create_fleet_metric(
    metric_name: FleetMetricName,
    query_string: QueryString,
    aggregation_type: AggregationType,
    period: FleetMetricPeriod,
    aggregation_field: AggregationField,
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    description: Optional[FleetMetricDescription] = None,
    query_version: Optional[QueryVersion] = None,
    index_name: Optional[IndexName] = None,
    unit: Optional[FleetMetricUnit] = None,
    tags: Optional[TagList] = None,
) -> CreateFleetMetricResponse

Creates a fleet metric.

Requires permission to access the CreateFleetMetric action.

Parameters:

  • metric_name (FleetMetricName) –

    The name of the fleet metric to create.

  • query_string (QueryString) –

    The search query string.

  • aggregation_type (AggregationType) –

    The type of the aggregation query.

  • period (FleetMetricPeriod) –

    The time in seconds between fleet metric emissions. Range [60(1 min), 86400(1 day)] and must be multiple of 60.

  • aggregation_field (AggregationField) –

    The field to aggregate.

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

    The fleet metric description.

  • query_version (Optional[QueryVersion], default: None ) –

    The query version.

  • index_name (Optional[IndexName], default: None ) –

    The name of the index to search.

  • unit (Optional[FleetMetricUnit], default: None ) –

    Used to support unit transformation such as milliseconds to seconds. The unit must be supported by CW metric. Default to null.

  • tags (Optional[TagList], default: None ) –

    Metadata, which can be used to manage the fleet metric.

Raises:

Source code in docs_src/capo_iot/_services/async_io_t.py
async def create_fleet_metric(
    self,
    metric_name: "capo_iot.types.fleet_metric_name.FleetMetricName",
    query_string: "capo_iot.types.query_string.QueryString",
    aggregation_type: "capo_iot.types.aggregation_type.AggregationType",
    period: "capo_iot.types.fleet_metric_period.FleetMetricPeriod",
    aggregation_field: "capo_iot.types.aggregation_field.AggregationField",
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    description: Optional[
        "capo_iot.types.fleet_metric_description.FleetMetricDescription"
    ] = None,
    query_version: Optional["capo_iot.types.query_version.QueryVersion"] = None,
    index_name: Optional["capo_iot.types.index_name.IndexName"] = None,
    unit: Optional["capo_iot.types.fleet_metric_unit.FleetMetricUnit"] = None,
    tags: Optional["capo_iot.types.tag_list.TagList"] = None,
) -> "capo_iot.types.create_fleet_metric_response.CreateFleetMetricResponse":
    """<p>Creates a fleet metric.</p> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">CreateFleetMetric</a> action.</p>

    Args:
        metric_name: <p>The name of the fleet metric to create.</p>
        query_string: <p>The search query string.</p>
        aggregation_type: <p>The type of the aggregation query.</p>
        period: <p>The time in seconds between fleet metric emissions. Range [60(1 min), 86400(1 day)] and must be multiple of 60.</p>
        aggregation_field: <p>The field to aggregate.</p>
        description: <p>The fleet metric description.</p>
        query_version: <p>The query version.</p>
        index_name: <p>The name of the index to search.</p>
        unit: <p>Used to support unit transformation such as milliseconds to seconds. The unit must be supported by <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html">CW metric</a>. Default to null.</p>
        tags: <p>Metadata, which can be used to manage the fleet metric.</p>

    Raises:
        capo_iot.errors.index_not_ready_exception.IndexNotReadyException: <p>The index is not ready.</p>
        capo_iot.errors.internal_failure_exception.InternalFailureException: <p>An unexpected error has occurred.</p>
        capo_iot.errors.invalid_aggregation_exception.InvalidAggregationException: <p>The aggregation is invalid.</p>
        capo_iot.errors.invalid_query_exception.InvalidQueryException: <p>The query is invalid.</p>
        capo_iot.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
        capo_iot.errors.limit_exceeded_exception.LimitExceededException: <p>A limit has been exceeded.</p>
        capo_iot.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource already exists.</p>
        capo_iot.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_iot.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is temporarily unavailable.</p>
        capo_iot.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
        capo_iot.errors.unauthorized_exception.UnauthorizedException: <p>You are not authorized to perform this operation.</p>
        capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iot.types.create_fleet_metric_request.CreateFleetMetricRequest]",
    ) -> AsyncOperationResponse[
        "capo_iot.types.create_fleet_metric_response.CreateFleetMetricResponse"
    ]:
        import capo_iot._operations.aws_iot_service.create_fleet_metric

        (
            output,
            http_response,
        ) = await capo_iot._operations.aws_iot_service.create_fleet_metric.async_create_fleet_metric(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateFleetMetric")
    )
    input_: capo_iot.types.create_fleet_metric_request.CreateFleetMetricRequest = {
        "metric_name": metric_name,
        "query_string": query_string,
        "aggregation_type": aggregation_type,
        "period": period,
        "aggregation_field": aggregation_field,
    }
    if description is not None:
        input_["description"] = description
    if query_version is not None:
        input_["query_version"] = query_version
    if index_name is not None:
        input_["index_name"] = index_name
    if unit is not None:
        input_["unit"] = unit
    if tags is not None:
        input_["tags"] = tags

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