Skip to content

create_billing_view async

create_billing_view(
    name: BillingViewName,
    source_views: BillingViewSourceViewsList,
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
    description: Optional[BillingViewDescription] = None,
    data_filter_expression: Optional[Expression] = None,
    client_token: Optional[ClientToken] = None,
    resource_tags: Optional[ResourceTagList] = None,
) -> CreateBillingViewResponse

Creates a billing view with the specified billing view attributes.

Parameters:

  • name (BillingViewName) –

    The name of the billing view.

  • description (Optional[BillingViewDescription], default: None ) –

    The description of the billing view.

  • source_views (BillingViewSourceViewsList) –

    A list of billing views used as the data source for the custom billing view.

  • data_filter_expression (Optional[Expression], default: None ) –

    See Expression. Billing view only supports LINKED_ACCOUNT, Tags, and CostCategories.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier you specify to ensure idempotency of the request. Idempotency ensures that an API request completes no more than one time. If the original request completes successfully, any subsequent retries complete successfully without performing any further actions with an idempotent request.

  • resource_tags (Optional[ResourceTagList], default: None ) –

    A list of key value map specifying tags associated to the billing view being created.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this action.

  • BillingViewHealthStatusException –

    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 HEALTHY.

  • ConflictException –

    The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request.

  • InternalServerException –

    The request processing failed because of an unknown error, exception, or failure.

  • ResourceNotFoundException –

    The specified ARN in the request doesn't exist.

  • ServiceQuotaExceededException –

    You've reached the limit of resources you can create, or exceeded the size of an individual resource.

  • ThrottlingException –

    The request was denied due to request throttling.

  • ValidationException –

    The input fails to satisfy the constraints specified by an Amazon Web Services service.

  • UnknownServiceError –

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

Examples:

Invoke CreateBillingView

>>> await client.create_billing_view(name='Example Custom Billing View', source_views=['arn:aws:billing::123456789101:billingview/primary'], description='Custom Billing View Example', data_filter_expression={'dimensions': {'key': 'LINKED_ACCOUNT', 'values': ['000000000000']}})
Source code in docs_src/capo_billing/_services/async_billing.py
async def create_billing_view(
    self,
    name: "capo_billing.types.billing_view_name.BillingViewName",
    source_views: "capo_billing.types.billing_view_source_views_list.BillingViewSourceViewsList",
    *,
    config_overrides: Optional[AsyncBillingClientConfig] = None,
    description: Optional[
        "capo_billing.types.billing_view_description.BillingViewDescription"
    ] = None,
    data_filter_expression: Optional[
        "capo_billing.types.expression.Expression"
    ] = None,
    client_token: Optional["capo_billing.types.client_token.ClientToken"] = None,
    resource_tags: Optional[
        "capo_billing.types.resource_tag_list.ResourceTagList"
    ] = None,
) -> "capo_billing.types.create_billing_view_response.CreateBillingViewResponse":
    """<p> Creates a billing view with the specified billing view attributes. </p>

    Args:
        name: <p> The name of the billing view. </p>
        description: <p> The description of the billing view. </p>
        source_views: <p>A list of billing views used as the data source for the custom billing view.</p>
        data_filter_expression: <p> See <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_billing_Expression.html">Expression</a>. Billing view only supports <code>LINKED_ACCOUNT</code>, <code>Tags</code>, and <code>CostCategories</code>. </p>
        client_token: <p>A unique, case-sensitive identifier you specify to ensure idempotency of the request. Idempotency ensures that an API request completes no more than one time. If the original request completes successfully, any subsequent retries complete successfully without performing any further actions with an idempotent request. </p>
        resource_tags: <p>A list of key value map specifying tags associated to the billing view being created. </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.conflict_exception.ConflictException: <p> The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request. </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.service_quota_exceeded_exception.ServiceQuotaExceededException: <p> You've reached the limit of resources you can create, or exceeded the size of an individual resource. </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 CreateBillingView

        >>> await client.create_billing_view(name='Example Custom Billing View', source_views=['arn:aws:billing::123456789101:billingview/primary'], description='Custom Billing View Example', data_filter_expression={'dimensions': {'key': 'LINKED_ACCOUNT', 'values': ['000000000000']}})
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_billing.types.create_billing_view_request.CreateBillingViewRequest]",
    ) -> AsyncOperationResponse[
        "capo_billing.types.create_billing_view_response.CreateBillingViewResponse"
    ]:
        import capo_billing._operations.aws_billing.create_billing_view

        (
            output,
            http_response,
        ) = await capo_billing._operations.aws_billing.create_billing_view.async_create_billing_view(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_billing.types.create_billing_view_request.CreateBillingViewRequest",
    ) -> dict[str, Any]:
        import capo_billing.types.create_billing_view_request

        return capo_billing.types.create_billing_view_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateBillingView", redact_input=_redact_input),
    )
    input_: capo_billing.types.create_billing_view_request.CreateBillingViewRequest = {
        "name": name,
        "source_views": source_views,
    }
    if description is not None:
        input_["description"] = description
    if data_filter_expression is not None:
        input_["data_filter_expression"] = data_filter_expression
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if resource_tags is not None:
        input_["resource_tags"] = resource_tags

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