getTopPathStatisticsByTraffic method

Future<GetTopPathStatisticsByTrafficResponse> getTopPathStatisticsByTraffic({
  1. required int limit,
  2. required int numberOfTopTrafficBotsPerPath,
  3. required Scope scope,
  4. required TimeWindow timeWindow,
  5. required String webAclArn,
  6. String? botCategory,
  7. String? botName,
  8. String? botOrganization,
  9. String? nextMarker,
  10. String? uriPathPrefix,
})

Retrieves aggregated statistics about the top URI paths accessed by bot traffic for a specified web ACL and time window. You can use this operation to analyze which paths on your web application receive the most bot traffic and identify the specific bots accessing those paths. The operation supports filtering by bot category, organization, or name, and allows you to drill down into specific path prefixes to view detailed URI-level statistics.

May throw WAFFeatureNotIncludedInPricingPlanException. May throw WAFInternalErrorException. May throw WAFInvalidOperationException. May throw WAFInvalidParameterException. May throw WAFNonexistentItemException.

Parameter limit : The maximum number of path statistics to return. Valid values are 1 to 100.

Parameter numberOfTopTrafficBotsPerPath : The maximum number of top bots to include in the statistics for each path. Valid values are 1 to 10.

Parameter scope : Specifies whether the web ACL is for an Amazon Web Services CloudFront distribution or for a regional application. A regional application can be an Application Load Balancer, an AppSync GraphQL API, an Amazon Cognito user pool, an Amazon Web Services App Runner service, or an Amazon Web Services Verified Access instance.

Parameter timeWindow : The time window for which you want to retrieve path statistics. The time window must be within the data retention period for your web ACL.

Parameter webAclArn : The Amazon Resource Name (ARN) of the web ACL for which you want to retrieve path statistics.

Parameter botCategory : Filters the results to include only traffic from bots in the specified category. For example, you can filter by ai to see only AI crawler traffic, or search_engine to see only search engine bot traffic. When you apply this filter, the Source field is populated in the response.

Parameter botName : Filters the results to include only traffic from the specified bot. For example, you can filter by gptbot or googlebot. When you apply this filter, the Source field is populated in the response.

Parameter botOrganization : Filters the results to include only traffic from bots belonging to the specified organization. For example, you can filter by openai or google. When you apply this filter, the Source field is populated in the response.

Parameter nextMarker : When you request a list of objects with a Limit setting, if the number of objects that are still available for retrieval exceeds the limit, WAF returns a NextMarker value in the response. To retrieve the next batch of objects, provide the marker from the prior call in your next request.

Parameter uriPathPrefix : A URI path prefix to filter the results. When you specify this parameter, the operation returns statistics for individual URIs within the specified path prefix. For example, if you specify /api, the response includes statistics for paths like /api/v1/users and /api/v2/orders. If you don't specify this parameter, the operation returns top-level path statistics.

Implementation

Future<GetTopPathStatisticsByTrafficResponse> getTopPathStatisticsByTraffic({
  required int limit,
  required int numberOfTopTrafficBotsPerPath,
  required Scope scope,
  required TimeWindow timeWindow,
  required String webAclArn,
  String? botCategory,
  String? botName,
  String? botOrganization,
  String? nextMarker,
  String? uriPathPrefix,
}) async {
  _s.validateNumRange(
    'limit',
    limit,
    1,
    100,
    isRequired: true,
  );
  _s.validateNumRange(
    'numberOfTopTrafficBotsPerPath',
    numberOfTopTrafficBotsPerPath,
    1,
    10,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSWAF_20190729.GetTopPathStatisticsByTraffic'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Limit': limit,
      'NumberOfTopTrafficBotsPerPath': numberOfTopTrafficBotsPerPath,
      'Scope': scope.value,
      'TimeWindow': timeWindow,
      'WebAclArn': webAclArn,
      if (botCategory != null) 'BotCategory': botCategory,
      if (botName != null) 'BotName': botName,
      if (botOrganization != null) 'BotOrganization': botOrganization,
      if (nextMarker != null) 'NextMarker': nextMarker,
      if (uriPathPrefix != null) 'UriPathPrefix': uriPathPrefix,
    },
  );

  return GetTopPathStatisticsByTrafficResponse.fromJson(jsonResponse.body);
}