Skip to content

create_usage_plan

create_usage_plan(
    name: String,
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    description: Optional[String] = None,
    api_stages: Optional[ListOfApiStage] = None,
    throttle: Optional[ThrottleSettings] = None,
    quota: Optional[QuotaSettings] = None,
    tags: Optional[MapOfStringToString] = None,
) -> UsagePlan

Creates a usage plan with the throttle and quota limits, as well as the associated API stages, specified in the payload.

Parameters:

  • name (String) –

    The name of the usage plan.

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

    The description of the usage plan.

  • api_stages (Optional[ListOfApiStage], default: None ) –

    The associated API stages of the usage plan.

  • throttle (Optional[ThrottleSettings], default: None ) –

    The throttling limits of the usage plan.

  • quota (Optional[QuotaSettings], default: None ) –

    The quota of the usage plan.

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

    The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with aws:. The tag value can be up to 256 characters.

Raises:

  • BadRequestException –

    The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.

  • ConflictException –

    The request configuration has conflicts. For details, see the accompanying error message.

  • LimitExceededException –

    The request exceeded the rate limit. Retry after the specified time period.

  • NotFoundException –

    The requested resource is not found. Make sure that the request URI is correct.

  • TooManyRequestsException –

    The request has reached its throttling limit. Retry after the specified time period.

  • UnauthorizedException –

    The request is denied because the caller has insufficient permissions.

  • UnknownServiceError –

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

Source code in docs_src/capo_api_gateway/_services/api_gateway.py
def create_usage_plan(
    self,
    name: "capo_api_gateway.types.string.String",
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    description: Optional["capo_api_gateway.types.string.String"] = None,
    api_stages: Optional[
        "capo_api_gateway.types.list_of_api_stage.ListOfApiStage"
    ] = None,
    throttle: Optional[
        "capo_api_gateway.types.throttle_settings.ThrottleSettings"
    ] = None,
    quota: Optional["capo_api_gateway.types.quota_settings.QuotaSettings"] = None,
    tags: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
) -> "capo_api_gateway.types.usage_plan.UsagePlan":
    """<p>Creates a usage plan with the throttle and quota limits, as well as the associated API stages, specified in the payload. </p>

    Args:
        name: <p>The name of the usage plan.</p>
        description: <p>The description of the usage plan.</p>
        api_stages: <p>The associated API stages of the usage plan.</p>
        throttle: <p>The throttling limits of the usage plan.</p>
        quota: <p>The quota of the usage plan.</p>
        tags: <p>The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with <code>aws:</code>. The tag value can be up to 256 characters.</p>

    Raises:
        capo_api_gateway.errors.bad_request_exception.BadRequestException: <p>The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.</p>
        capo_api_gateway.errors.conflict_exception.ConflictException: <p>The request configuration has conflicts. For details, see the accompanying error message.</p>
        capo_api_gateway.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeded the rate limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.not_found_exception.NotFoundException: <p>The requested resource is not found. Make sure that the request URI is correct.</p>
        capo_api_gateway.errors.too_many_requests_exception.TooManyRequestsException: <p>The request has reached its throttling limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.unauthorized_exception.UnauthorizedException: <p>The request is denied because the caller has insufficient permissions.</p>
        capo_api_gateway.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_api_gateway.types.create_usage_plan_request.CreateUsagePlanRequest]",
    ) -> OperationResponse["capo_api_gateway.types.usage_plan.UsagePlan"]:
        import capo_api_gateway._operations.backplane_control_service.create_usage_plan

        output, http_response = (
            capo_api_gateway._operations.backplane_control_service.create_usage_plan.create_usage_plan(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateUsagePlan")
    )
    input_: capo_api_gateway.types.create_usage_plan_request.CreateUsagePlanRequest = {
        "name": name
    }
    if description is not None:
        input_["description"] = description
    if api_stages is not None:
        input_["api_stages"] = api_stages
    if throttle is not None:
        input_["throttle"] = throttle
    if quota is not None:
        input_["quota"] = quota
    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