Skip to content

get_percentiles

get_percentiles(
    query_string: QueryString,
    *,
    config_overrides: Optional[IoTClientConfig] = None,
    index_name: Optional[IndexName] = None,
    aggregation_field: Optional[AggregationField] = None,
    query_version: Optional[QueryVersion] = None,
    percents: Optional[PercentList] = None,
) -> GetPercentilesResponse

Groups the aggregated values that match the query into percentile groupings. The default percentile groupings are: 1,5,25,50,75,95,99, although you can specify your own when you call GetPercentiles. This function returns a value for each percentile group specified (or the default percentile groupings). The percentile group "1" contains the aggregated field value that occurs in approximately one percent of the values that match the query. The percentile group "5" contains the aggregated field value that occurs in approximately five percent of the values that match the query, and so on. The result is an approximation, the more values that match the query, the more accurate the percentile values.

Requires permission to access the GetPercentiles action.

Parameters:

Raises:

Source code in docs_src/capo_iot/_services/io_t.py
def get_percentiles(
    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,
    percents: Optional["capo_iot.types.percent_list.PercentList"] = None,
) -> "capo_iot.types.get_percentiles_response.GetPercentilesResponse":
    """<p>Groups the aggregated values that match the query into percentile groupings. The default percentile groupings are: 1,5,25,50,75,95,99, although you can specify your own when you call <code>GetPercentiles</code>. This function returns a value for each percentile group specified (or the default percentile groupings). The percentile group "1" contains the aggregated field value that occurs in approximately one percent of the values that match the query. The percentile group "5" contains the aggregated field value that occurs in approximately five percent of the values that match the query, and so on. The result is an approximation, the more values that match the query, the more accurate the percentile values.</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">GetPercentiles</a> action.</p>

    Args:
        index_name: <p>The name of the index to search.</p>
        query_string: <p>The search query string.</p>
        aggregation_field: <p>The field to aggregate.</p>
        query_version: <p>The query version.</p>
        percents: <p>The percentile groups returned.</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_percentiles_request.GetPercentilesRequest]",
    ) -> OperationResponse[
        "capo_iot.types.get_percentiles_response.GetPercentilesResponse"
    ]:
        import capo_iot._operations.aws_iot_service.get_percentiles

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetPercentiles")
    )
    input_: capo_iot.types.get_percentiles_request.GetPercentilesRequest = {
        "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
    if percents is not None:
        input_["percents"] = percents

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