Skip to content

list_billing_view_segments

list_billing_view_segments(
    *,
    config_overrides: Optional[BillingClientConfig] = None,
    time_range: Optional[BillingViewSegmentTimeRange] = None,
    arn: Optional[BillingViewArn] = None,
    max_results: Optional[BillingViewsMaxResults] = None,
    next_token: Optional[PageToken] = None,
) -> ListBillingViewSegmentsResponse

Lists the segments of a billing view over a given time period. Each segment identifies the billing domain (PRO_FORMA or BILLABLE) and the account relationships that apply during its time range.

If you don't provide an arn, the response includes segments for the caller's PRIMARY billing view.

If a mid-period change occurs, the response includes multiple segments, each with its own time range. The response omits hidden segments, so the segments it returns might not cover the entire requested time period.

Parameters:

  • time_range (Optional[BillingViewSegmentTimeRange], default: None ) –

    The billing period to query. If you don't provide a time range, the current billing period, which is the calendar month in UTC, is used.

  • arn (Optional[BillingViewArn], default: None ) –

    The Amazon Resource Name (ARN) that uniquely identifies the billing view to query. If you don't provide an ARN, the caller's PRIMARY billing view is used. The ARN must reference a primary billing view. Custom billing views aren't supported.

  • max_results (Optional[BillingViewsMaxResults], default: None ) –

    The number of entries a paginated response contains. Valid values range from 1 to 100. The default is 100.

  • next_token (Optional[PageToken], default: None ) –

    The pagination token that is used on subsequent calls to list billing view segments.

Raises:

Examples:

Invoke ListBillingViewSegments

>>> client.list_billing_view_segments(time_range={'beginDateInclusive': 1719792000, 'endDateExclusive': 1722470400})
Error example for ListBillingViewSegments
>>> client.list_billing_view_segments(time_range={'beginDateInclusive': 1722470400, 'endDateExclusive': 1719792000})
Source code in docs_src/capo_billing/_services/billing.py
def list_billing_view_segments(
    self,
    *,
    config_overrides: Optional[BillingClientConfig] = None,
    time_range: Optional[
        "capo_billing.types.billing_view_segment_time_range.BillingViewSegmentTimeRange"
    ] = None,
    arn: Optional["capo_billing.types.billing_view_arn.BillingViewArn"] = None,
    max_results: Optional[
        "capo_billing.types.billing_views_max_results.BillingViewsMaxResults"
    ] = None,
    next_token: Optional["capo_billing.types.page_token.PageToken"] = None,
) -> "capo_billing.types.list_billing_view_segments_response.ListBillingViewSegmentsResponse":
    """<p>Lists the segments of a billing view over a given time period. Each segment identifies the billing domain (<code>PRO_FORMA</code> or <code>BILLABLE</code>) and the account relationships that apply during its time range.</p> <p>If you don't provide an <code>arn</code>, the response includes segments for the caller's <code>PRIMARY</code> billing view.</p> <p>If a mid-period change occurs, the response includes multiple segments, each with its own time range. The response omits hidden segments, so the segments it returns might not cover the entire requested time period.</p>

    Args:
        time_range: <p> The billing period to query. If you don't provide a time range, the current billing period, which is the calendar month in UTC, is used. </p>
        arn: <p> The Amazon Resource Name (ARN) that uniquely identifies the billing view to query. If you don't provide an ARN, the caller's <code>PRIMARY</code> billing view is used. The ARN must reference a primary billing view. Custom billing views aren't supported. </p>
        max_results: <p> The number of entries a paginated response contains. Valid values range from 1 to 100. The default is 100. </p>
        next_token: <p> The pagination token that is used on subsequent calls to list billing view segments. </p>

    Raises:
        capo_billing.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_billing.errors.billing_view_health_status_exception.BillingViewHealthStatusException: <p> Exception thrown when a billing view's health status prevents an operation from being performed. This may occur if the billing view is in a state other than <code>HEALTHY</code>.</p>
        capo_billing.errors.internal_server_exception.InternalServerException: <p>The request processing failed because of an unknown error, exception, or failure. </p>
        capo_billing.errors.resource_not_found_exception.ResourceNotFoundException: <p> The specified ARN in the request doesn't exist. </p>
        capo_billing.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. </p>
        capo_billing.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service. </p>
        capo_billing.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Invoke ListBillingViewSegments

        >>> client.list_billing_view_segments(time_range={'beginDateInclusive': 1719792000, 'endDateExclusive': 1722470400})
        Error example for ListBillingViewSegments

        >>> client.list_billing_view_segments(time_range={'beginDateInclusive': 1722470400, 'endDateExclusive': 1719792000})
    """

    def _handler(
        req: "OperationRequest[capo_billing.types.list_billing_view_segments_request.ListBillingViewSegmentsRequest]",
    ) -> OperationResponse[
        "capo_billing.types.list_billing_view_segments_response.ListBillingViewSegmentsResponse"
    ]:
        import capo_billing._operations.aws_billing.list_billing_view_segments

        output, http_response = (
            capo_billing._operations.aws_billing.list_billing_view_segments.list_billing_view_segments(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListBillingViewSegments")
    )
    input_: capo_billing.types.list_billing_view_segments_request.ListBillingViewSegmentsRequest = {}
    if time_range is not None:
        input_["time_range"] = time_range
    if arn is not None:
        input_["arn"] = arn
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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