Skip to content

create_spending_limit

create_spending_limit(
    client_token: String64,
    device_arn: DeviceArn,
    spending_limit: str,
    *,
    config_overrides: Optional[BraketClientConfig] = None,
    time_period: Optional[TimePeriod] = None,
    tags: Optional[TagsMap] = None,
) -> CreateSpendingLimitResponse

Creates a spending limit for a specified quantum device. Spending limits help you control costs by setting maximum amounts that can be spent on quantum computing tasks within a specified time period. Simulators do not support spending limits.

Parameters:

  • client_token (String64) –

    A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, Amazon Braket ignores the request, but does not return an error.

  • device_arn (DeviceArn) –

    The Amazon Resource Name (ARN) of the quantum device to apply the spending limit to.

  • spending_limit (str) –

    The maximum amount that can be spent on the specified device, in USD.

  • time_period (Optional[TimePeriod], default: None ) –

    The time period during which the spending limit is active, including start and end dates.

  • tags (Optional[TagsMap], default: None ) –

    The tags to apply to the spending limit. Each tag consists of a key and an optional value.

Raises:

Source code in docs_src/capo_braket/_services/braket.py
def create_spending_limit(
    self,
    client_token: "capo_braket.types.string64.String64",
    device_arn: "capo_braket.types.device_arn.DeviceArn",
    spending_limit: str,
    *,
    config_overrides: Optional[BraketClientConfig] = None,
    time_period: Optional["capo_braket.types.time_period.TimePeriod"] = None,
    tags: Optional["capo_braket.types.tags_map.TagsMap"] = None,
) -> "capo_braket.types.create_spending_limit_response.CreateSpendingLimitResponse":
    """<p>Creates a spending limit for a specified quantum device. Spending limits help you control costs by setting maximum amounts that can be spent on quantum computing tasks within a specified time period. Simulators do not support spending limits.</p>

    Args:
        client_token: <p>A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, Amazon Braket ignores the request, but does not return an error.</p>
        device_arn: <p>The Amazon Resource Name (ARN) of the quantum device to apply the spending limit to.</p>
        spending_limit: <p>The maximum amount that can be spent on the specified device, in USD.</p>
        time_period: <p>The time period during which the spending limit is active, including start and end dates.</p>
        tags: <p>The tags to apply to the spending limit. Each tag consists of a key and an optional value.</p>

    Raises:
        capo_braket.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient permissions to perform this action.</p>
        capo_braket.errors.device_retired_exception.DeviceRetiredException: <p>The specified device has been retired.</p>
        capo_braket.errors.internal_service_exception.InternalServiceException: <p>The request failed because of an unknown error.</p>
        capo_braket.errors.throttling_exception.ThrottlingException: <p>The API throttling rate limit is exceeded.</p>
        capo_braket.errors.validation_exception.ValidationException: <p>The input request failed to satisfy constraints expected by Amazon Braket.</p>
        capo_braket.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_braket.types.create_spending_limit_request.CreateSpendingLimitRequest]",
    ) -> OperationResponse[
        "capo_braket.types.create_spending_limit_response.CreateSpendingLimitResponse"
    ]:
        import capo_braket._operations.braket.create_spending_limit

        output, http_response = (
            capo_braket._operations.braket.create_spending_limit.create_spending_limit(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSpendingLimit")
    )
    input_: capo_braket.types.create_spending_limit_request.CreateSpendingLimitRequest = {
        "client_token": client_token,
        "device_arn": device_arn,
        "spending_limit": spending_limit,
    }
    if time_period is not None:
        input_["time_period"] = time_period
    if tags is not None:
        input_["tags"] = tags

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