Skip to content

get_sampled_requests async

get_sampled_requests(
    web_acl_id: ResourceId,
    rule_id: ResourceId,
    time_window: TimeWindow,
    max_items: GetSampledRequestsMaxItems,
    *,
    config_overrides: Optional[AsyncWAFRegionalClientConfig] = None,
) -> GetSampledRequestsResponse

This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.

For the latest version of AWS WAF, use the AWS WAFV2 API and see the AWS WAF Developer Guide. With the latest version, AWS WAF has a single set of endpoints for regional and global use.

Gets detailed information about a specified number of requests--a sample--that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource received during a time range that you choose. You can specify a sample size of up to 500 requests, and you can specify any time range in the previous three hours.

GetSampledRequests returns a time range, which is usually the time range that you specified. However, if your resource (such as a CloudFront distribution) received 5,000 requests before the specified time range elapsed, GetSampledRequests returns an updated time range. This new time range indicates the actual period during which AWS WAF selected the requests in the sample.

Parameters:

  • web_acl_id (ResourceId) –

    The WebACLId of the WebACL for which you want GetSampledRequests to return a sample of requests.

  • rule_id (ResourceId) –

    RuleId is one of three values:

    • The RuleId of the Rule or the RuleGroupId of the RuleGroup for which you want GetSampledRequests to return a sample of requests.

    • Default_Action, which causes GetSampledRequests to return a sample of the requests that didn't match any of the rules in the specified WebACL.

  • time_window (TimeWindow) –

    The start date and time and the end date and time of the range for which you want GetSampledRequests to return a sample of requests. You must specify the times in Coordinated Universal Time (UTC) format. UTC format includes the special designator, Z. For example, "2016-09-27T14:50Z". You can specify any time range in the previous three hours.

  • max_items (GetSampledRequestsMaxItems) –

    The number of requests that you want AWS WAF to return from among the first 5,000 requests that your AWS resource received during the time range. If your resource received fewer requests than the value of MaxItems, GetSampledRequests returns information about all of them.

Raises:

Source code in docs_src/capo_waf_regional/_services/async_waf_regional.py
async def get_sampled_requests(
    self,
    web_acl_id: "capo_waf_regional.types.resource_id.ResourceId",
    rule_id: "capo_waf_regional.types.resource_id.ResourceId",
    time_window: "capo_waf_regional.types.time_window.TimeWindow",
    max_items: "capo_waf_regional.types.get_sampled_requests_max_items.GetSampledRequestsMaxItems",
    *,
    config_overrides: Optional[AsyncWAFRegionalClientConfig] = None,
) -> "capo_waf_regional.types.get_sampled_requests_response.GetSampledRequestsResponse":
    """<note> <p>This is <b>AWS WAF Classic</b> documentation. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html">AWS WAF Classic</a> in the developer guide.</p> <p> <b>For the latest version of AWS WAF</b>, use the AWS WAFV2 API and see the <a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html">AWS WAF Developer Guide</a>. With the latest version, AWS WAF has a single set of endpoints for regional and global use. </p> </note> <p>Gets detailed information about a specified number of requests--a sample--that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource received during a time range that you choose. You can specify a sample size of up to 500 requests, and you can specify any time range in the previous three hours.</p> <p> <code>GetSampledRequests</code> returns a time range, which is usually the time range that you specified. However, if your resource (such as a CloudFront distribution) received 5,000 requests before the specified time range elapsed, <code>GetSampledRequests</code> returns an updated time range. This new time range indicates the actual period during which AWS WAF selected the requests in the sample.</p>

    Args:
        web_acl_id: <p>The <code>WebACLId</code> of the <code>WebACL</code> for which you want <code>GetSampledRequests</code> to return a sample of requests.</p>
        rule_id: <p> <code>RuleId</code> is one of three values:</p> <ul> <li> <p>The <code>RuleId</code> of the <code>Rule</code> or the <code>RuleGroupId</code> of the <code>RuleGroup</code> for which you want <code>GetSampledRequests</code> to return a sample of requests.</p> </li> <li> <p> <code>Default_Action</code>, which causes <code>GetSampledRequests</code> to return a sample of the requests that didn't match any of the rules in the specified <code>WebACL</code>.</p> </li> </ul>
        time_window: <p>The start date and time and the end date and time of the range for which you want <code>GetSampledRequests</code> to return a sample of requests. You must specify the times in Coordinated Universal Time (UTC) format. UTC format includes the special designator, <code>Z</code>. For example, <code>"2016-09-27T14:50Z"</code>. You can specify any time range in the previous three hours.</p>
        max_items: <p>The number of requests that you want AWS WAF to return from among the first 5,000 requests that your AWS resource received during the time range. If your resource received fewer requests than the value of <code>MaxItems</code>, <code>GetSampledRequests</code> returns information about all of them. </p>

    Raises:
        capo_waf_regional.errors.waf_internal_error_exception.WAFInternalErrorException: <p>The operation failed because of a system problem, even though the request was valid. Retry your request.</p>
        capo_waf_regional.errors.waf_nonexistent_item_exception.WAFNonexistentItemException: <p>The operation failed because the referenced object doesn't exist.</p>
        capo_waf_regional.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_waf_regional.types.get_sampled_requests_request.GetSampledRequestsRequest]",
    ) -> AsyncOperationResponse[
        "capo_waf_regional.types.get_sampled_requests_response.GetSampledRequestsResponse"
    ]:
        import capo_waf_regional._operations.awswaf_regional_20161128.get_sampled_requests

        (
            output,
            http_response,
        ) = await capo_waf_regional._operations.awswaf_regional_20161128.get_sampled_requests.async_get_sampled_requests(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetSampledRequests")
    )
    input_: capo_waf_regional.types.get_sampled_requests_request.GetSampledRequestsRequest = {
        "web_acl_id": web_acl_id,
        "rule_id": rule_id,
        "time_window": time_window,
        "max_items": max_items,
    }

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