Skip to content

get_statistics

get_statistics(
    query_string: QueryString,
    *,
    config_overrides: Optional[IoTClientConfig] = None,
    index_name: Optional[IndexName] = None,
    aggregation_field: Optional[AggregationField] = None,
    query_version: Optional[QueryVersion] = None,
) -> GetStatisticsResponse

Returns the count, average, sum, minimum, maximum, sum of squares, variance, and standard deviation for the specified aggregated field. If the aggregation field is of type String, only the count statistic is returned.

Requires permission to access the GetStatistics action.

Parameters:

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

    The name of the index to search. The default value is AWS_Things.

  • query_string (QueryString) –

    The query used to search. You can specify "*" for the query string to get the count of all indexed things in your Amazon Web Services account.

  • aggregation_field (Optional[AggregationField], default: None ) –

    The aggregation field name.

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

    The version of the query used to search.

Raises:

Source code in docs_src/capo_iot/_services/io_t.py
def get_statistics(
    self,
    query_string: "capo_iot.types.query_string.QueryString",
    *,
    config_overrides: Optional[IoTClientConfig] = None,
    index_name: Optional["capo_iot.types.index_name.IndexName"] = None,
    aggregation_field: Optional[
        "capo_iot.types.aggregation_field.AggregationField"
    ] = None,
    query_version: Optional["capo_iot.types.query_version.QueryVersion"] = None,
) -> "capo_iot.types.get_statistics_response.GetStatisticsResponse":
    """<p>Returns the count, average, sum, minimum, maximum, sum of squares, variance, and standard deviation for the specified aggregated field. If the aggregation field is of type <code>String</code>, only the count statistic is returned.</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">GetStatistics</a> action.</p>

    Args:
        index_name: <p>The name of the index to search. The default value is <code>AWS_Things</code>.</p>
        query_string: <p>The query used to search. You can specify "*" for the query string to get the count of all indexed things in your Amazon Web Services account.</p>
        aggregation_field: <p>The aggregation field name.</p>
        query_version: <p>The version of the query used to search.</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.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.
    """

    def _handler(
        req: "OperationRequest[capo_iot.types.get_statistics_request.GetStatisticsRequest]",
    ) -> OperationResponse[
        "capo_iot.types.get_statistics_response.GetStatisticsResponse"
    ]:
        import capo_iot._operations.aws_iot_service.get_statistics

        output, http_response = (
            capo_iot._operations.aws_iot_service.get_statistics.get_statistics(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetStatistics")
    )
    input_: capo_iot.types.get_statistics_request.GetStatisticsRequest = {
        "query_string": query_string
    }
    if index_name is not None:
        input_["index_name"] = index_name
    if aggregation_field is not None:
        input_["aggregation_field"] = aggregation_field
    if query_version is not None:
        input_["query_version"] = query_version

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output