Skip to content

get_revenue_statistics

get_revenue_statistics(
    statistic_type: RankingStatisticType,
    time_window: TimeWindow,
    scope: Scope,
    currency: Currency,
    *,
    config_overrides: Optional[WAFV2ClientConfig] = None,
    group_by: Optional[GroupByType] = None,
    filters: Optional[MonetizationFilterList] = None,
    next_marker: Optional[NextMarker] = None,
    limit: Optional[PathStatisticsLimit] = None,
    sort_by: Optional[RankingSortBy] = None,
    sort_order: Optional[SortOrder] = None,
) -> GetRevenueStatisticsResponse

Retrieves ranked monetization statistics. Use the StatisticType parameter to specify the ranking: TOP_SOURCES_BY_REVENUE for top sources by revenue, or TOP_PATHS_BY_REVENUE for top content paths by revenue. This operation is only available for CLOUDFRONT scope. The maximum supported time window is 90 days. When no CurrencyMode filter is provided, results default to REAL. To retrieve test data, include a CurrencyMode filter with the value TEST.

Parameters:

  • statistic_type (RankingStatisticType) –

    TOP_SOURCES_BY_REVENUE ranks revenue from AI bot traffic, grouped by the dimension you specify in the GroupBy parameter (NAME, CATEGORY, INTENT, ORGANIZATION, or WEBACL); GroupBy is required for this statistic type. TOP_PATHS_BY_REVENUE ranks revenue by path.

  • time_window (TimeWindow) –

    The time range for the query. Specify start and end timestamps.

  • scope (Scope) –

    Specifies whether this is for a Amazon CloudFront distribution (CLOUDFRONT) or for a regional application (REGIONAL).

  • currency (Currency) –

    The currency for the revenue amounts in the response.

  • group_by (Optional[GroupByType], default: None ) –

    The dimension to group results by: NAME, CATEGORY, INTENT, ORGANIZATION, or WEBACL. Required when StatisticType is TOP_SOURCES_BY_REVENUE. Not required for TOP_PATHS_BY_REVENUE, where results are grouped by content path. If StatisticType is TOP_SOURCES_BY_REVENUE and GroupBy is omitted, the request is rejected with a WAFInvalidParameterException.

  • filters (Optional[MonetizationFilterList], default: None ) –

    Optional filters to narrow the results.

  • next_marker (Optional[NextMarker], default: None ) –

    When you get a paginated response, this marker indicates that additional results are available. Use it in a subsequent request to retrieve the next page of results.

  • limit (Optional[PathStatisticsLimit], default: None ) –

    The maximum number of results to return.

  • sort_by (Optional[RankingSortBy], default: None ) –

    The field to sort results by: REVENUE, PERCENTAGE, or NAME.

  • sort_order (Optional[SortOrder], default: None ) –

    The sort order: ASC for ascending or DESC for descending.

Raises:

  • WAFInternalErrorException –

    Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your request.

  • WAFInvalidOperationException –

    The operation isn't valid.

  • WAFInvalidParameterException –

    The operation failed because WAF didn't recognize a parameter in the request. For example:

    • You specified a parameter name or value that isn't valid.

    • Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested.

    • You tried to update a WebACL with a DefaultAction that isn't among the types available at DefaultAction.

    • Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.

  • WAFNonexistentItemException –

    WAF couldn’t perform the operation because your resource doesn't exist. If you've just created a resource that you're using in this operation, you might just need to wait a few minutes. It can take from a few seconds to a number of minutes for changes to propagate.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_wafv2/_services/wafv2.py
def get_revenue_statistics(
    self,
    statistic_type: "capo_wafv2.types.ranking_statistic_type.RankingStatisticType",
    time_window: "capo_wafv2.types.time_window.TimeWindow",
    scope: "capo_wafv2.types.scope.Scope",
    currency: "capo_wafv2.types.currency.Currency",
    *,
    config_overrides: Optional[WAFV2ClientConfig] = None,
    group_by: Optional["capo_wafv2.types.group_by_type.GroupByType"] = None,
    filters: Optional[
        "capo_wafv2.types.monetization_filter_list.MonetizationFilterList"
    ] = None,
    next_marker: Optional["capo_wafv2.types.next_marker.NextMarker"] = None,
    limit: Optional[
        "capo_wafv2.types.path_statistics_limit.PathStatisticsLimit"
    ] = None,
    sort_by: Optional["capo_wafv2.types.ranking_sort_by.RankingSortBy"] = None,
    sort_order: Optional["capo_wafv2.types.sort_order.SortOrder"] = None,
) -> (
    "capo_wafv2.types.get_revenue_statistics_response.GetRevenueStatisticsResponse"
):
    """<p>Retrieves ranked monetization statistics. Use the <code>StatisticType</code> parameter to specify the ranking: <code>TOP_SOURCES_BY_REVENUE</code> for top sources by revenue, or <code>TOP_PATHS_BY_REVENUE</code> for top content paths by revenue. This operation is only available for <code>CLOUDFRONT</code> scope. The maximum supported time window is 90 days. When no <code>CurrencyMode</code> filter is provided, results default to <code>REAL</code>. To retrieve test data, include a <code>CurrencyMode</code> filter with the value <code>TEST</code>.</p>

    Args:
        statistic_type: <p> <code>TOP_SOURCES_BY_REVENUE</code> ranks revenue from AI bot traffic, grouped by the dimension you specify in the <code>GroupBy</code> parameter (<code>NAME</code>, <code>CATEGORY</code>, <code>INTENT</code>, <code>ORGANIZATION</code>, or <code>WEBACL</code>); <code>GroupBy</code> is required for this statistic type. <code>TOP_PATHS_BY_REVENUE</code> ranks revenue by path.</p>
        time_window: <p>The time range for the query. Specify start and end timestamps.</p>
        scope: <p>Specifies whether this is for a Amazon CloudFront distribution (<code>CLOUDFRONT</code>) or for a regional application (<code>REGIONAL</code>).</p>
        currency: <p>The currency for the revenue amounts in the response.</p>
        group_by: <p>The dimension to group results by: <code>NAME</code>, <code>CATEGORY</code>, <code>INTENT</code>, <code>ORGANIZATION</code>, or <code>WEBACL</code>. Required when <code>StatisticType</code> is <code>TOP_SOURCES_BY_REVENUE</code>. Not required for <code>TOP_PATHS_BY_REVENUE</code>, where results are grouped by content path. If <code>StatisticType</code> is <code>TOP_SOURCES_BY_REVENUE</code> and <code>GroupBy</code> is omitted, the request is rejected with a <code>WAFInvalidParameterException</code>.</p>
        filters: <p>Optional filters to narrow the results.</p>
        next_marker: <p>When you get a paginated response, this marker indicates that additional results are available. Use it in a subsequent request to retrieve the next page of results.</p>
        limit: <p>The maximum number of results to return.</p>
        sort_by: <p>The field to sort results by: <code>REVENUE</code>, <code>PERCENTAGE</code>, or <code>NAME</code>.</p>
        sort_order: <p>The sort order: <code>ASC</code> for ascending or <code>DESC</code> for descending.</p>

    Raises:
        capo_wafv2.errors.waf_internal_error_exception.WAFInternalErrorException: <p>Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your request. </p>
        capo_wafv2.errors.waf_invalid_operation_exception.WAFInvalidOperationException: <p>The operation isn't valid. </p>
        capo_wafv2.errors.waf_invalid_parameter_exception.WAFInvalidParameterException: <p>The operation failed because WAF didn't recognize a parameter in the request. For example: </p> <ul> <li> <p>You specified a parameter name or value that isn't valid.</p> </li> <li> <p>Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested. </p> </li> <li> <p>You tried to update a <code>WebACL</code> with a <code>DefaultAction</code> that isn't among the types available at <a>DefaultAction</a>.</p> </li> <li> <p>Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.</p> </li> </ul>
        capo_wafv2.errors.waf_nonexistent_item_exception.WAFNonexistentItemException: <p>WAF couldn’t perform the operation because your resource doesn't exist. If you've just created a resource that you're using in this operation, you might just need to wait a few minutes. It can take from a few seconds to a number of minutes for changes to propagate. </p>
        capo_wafv2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_wafv2.types.get_revenue_statistics_request.GetRevenueStatisticsRequest]",
    ) -> OperationResponse[
        "capo_wafv2.types.get_revenue_statistics_response.GetRevenueStatisticsResponse"
    ]:
        import capo_wafv2._operations.awswaf_20190729.get_revenue_statistics

        output, http_response = (
            capo_wafv2._operations.awswaf_20190729.get_revenue_statistics.get_revenue_statistics(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetRevenueStatistics")
    )
    input_: capo_wafv2.types.get_revenue_statistics_request.GetRevenueStatisticsRequest = {
        "statistic_type": statistic_type,
        "time_window": time_window,
        "scope": scope,
        "currency": currency,
    }
    if group_by is not None:
        input_["group_by"] = group_by
    if filters is not None:
        input_["filters"] = filters
    if next_marker is not None:
        input_["next_marker"] = next_marker
    if limit is not None:
        input_["limit"] = limit
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if sort_order is not None:
        input_["sort_order"] = sort_order

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