Skip to content

create_usage_limit async

create_usage_limit(
    resource_arn: str,
    usage_type: UsageLimitUsageType,
    amount: int,
    *,
    config_overrides: Optional[AsyncRedshiftServerlessClientConfig] = None,
    period: Optional[UsageLimitPeriod] = None,
    breach_action: Optional[UsageLimitBreachAction] = None,
) -> CreateUsageLimitResponse

Creates a usage limit for a specified Amazon Redshift Serverless usage type. The usage limit is identified by the returned usage limit identifier.

Parameters:

  • resource_arn (str) –

    The Amazon Resource Name (ARN) of the Amazon Redshift Serverless resource to create the usage limit for.

  • usage_type (UsageLimitUsageType) –

    The type of Amazon Redshift Serverless usage to create a usage limit for.

  • amount (int) –

    The limit amount. If time-based, this amount is in Redshift Processing Units (RPU) consumed per hour. If data-based, this amount is in terabytes (TB) of data transferred between Regions in cross-account sharing. The value must be a positive number.

  • period (Optional[UsageLimitPeriod], default: None ) –

    The time period that the amount applies to. A weekly period begins on Sunday. The default is monthly.

  • breach_action (Optional[UsageLimitBreachAction], default: None ) –

    The action that Amazon Redshift Serverless takes when the limit is reached. The default is log.

Raises:

Source code in docs_src/capo_redshift_serverless/_services/async_redshift_serverless.py
async def create_usage_limit(
    self,
    resource_arn: str,
    usage_type: "capo_redshift_serverless.types.usage_limit_usage_type.UsageLimitUsageType",
    amount: int,
    *,
    config_overrides: Optional[AsyncRedshiftServerlessClientConfig] = None,
    period: Optional[
        "capo_redshift_serverless.types.usage_limit_period.UsageLimitPeriod"
    ] = None,
    breach_action: Optional[
        "capo_redshift_serverless.types.usage_limit_breach_action.UsageLimitBreachAction"
    ] = None,
) -> "capo_redshift_serverless.types.create_usage_limit_response.CreateUsageLimitResponse":
    """<p>Creates a usage limit for a specified Amazon Redshift Serverless usage type. The usage limit is identified by the returned usage limit identifier. </p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the Amazon Redshift Serverless resource to create the usage limit for.</p>
        usage_type: <p>The type of Amazon Redshift Serverless usage to create a usage limit for.</p>
        amount: <p>The limit amount. If time-based, this amount is in Redshift Processing Units (RPU) consumed per hour. If data-based, this amount is in terabytes (TB) of data transferred between Regions in cross-account sharing. The value must be a positive number.</p>
        period: <p>The time period that the amount applies to. A weekly period begins on Sunday. The default is monthly.</p>
        breach_action: <p>The action that Amazon Redshift Serverless takes when the limit is reached. The default is log.</p>

    Raises:
        capo_redshift_serverless.errors.conflict_exception.ConflictException: <p>The submitted action has conflicts.</p>
        capo_redshift_serverless.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_redshift_serverless.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource could not be found.</p>
        capo_redshift_serverless.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The service limit was exceeded.</p>
        capo_redshift_serverless.errors.validation_exception.ValidationException: <p>The input failed to satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_redshift_serverless.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_redshift_serverless.types.create_usage_limit_request.CreateUsageLimitRequest]",
    ) -> AsyncOperationResponse[
        "capo_redshift_serverless.types.create_usage_limit_response.CreateUsageLimitResponse"
    ]:
        import capo_redshift_serverless._operations.redshift_serverless.create_usage_limit

        (
            output,
            http_response,
        ) = await capo_redshift_serverless._operations.redshift_serverless.create_usage_limit.async_create_usage_limit(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateUsageLimit")
    )
    input_: capo_redshift_serverless.types.create_usage_limit_request.CreateUsageLimitRequest = {
        "resource_arn": resource_arn,
        "usage_type": usage_type,
        "amount": amount,
    }
    if period is not None:
        input_["period"] = period
    if breach_action is not None:
        input_["breach_action"] = breach_action

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