Skip to content

create_stage

create_stage(
    rest_api_id: String,
    stage_name: String,
    deployment_id: String,
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    description: Optional[String] = None,
    cache_cluster_enabled: Optional[Boolean] = None,
    cache_cluster_size: Optional[CacheClusterSize] = None,
    variables: Optional[MapOfStringToString] = None,
    documentation_version: Optional[String] = None,
    canary_settings: Optional[CanarySettings] = None,
    tracing_enabled: Optional[Boolean] = None,
    tags: Optional[MapOfStringToString] = None,
) -> Stage

Creates a new Stage resource that references a pre-existing Deployment for the API.

Parameters:

  • rest_api_id (String) –

    The string identifier of the associated RestApi.

  • stage_name (String) –

    The name for the Stage resource. Stage names can only contain alphanumeric characters, hyphens, and underscores. Maximum length is 128 characters.

  • deployment_id (String) –

    The identifier of the Deployment resource for the Stage resource.

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

    The description of the Stage resource.

  • cache_cluster_enabled (Optional[Boolean], default: None ) –

    Whether cache clustering is enabled for the stage.

  • cache_cluster_size (Optional[CacheClusterSize], default: None ) –

    The stage's cache capacity in GB. For more information about choosing a cache size, see Enabling API caching to enhance responsiveness.

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

    A map that defines the stage variables for the new Stage resource. Variable names can have alphanumeric and underscore characters, and the values must match [A-Za-z0-9-._~:/?#&=,]+.

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

    The version of the associated API documentation.

  • canary_settings (Optional[CanarySettings], default: None ) –

    The canary deployment settings of this stage.

  • tracing_enabled (Optional[Boolean], default: None ) –

    Specifies whether active tracing with X-ray is enabled for the Stage.

  • 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_stage(
    self,
    rest_api_id: "capo_api_gateway.types.string.String",
    stage_name: "capo_api_gateway.types.string.String",
    deployment_id: "capo_api_gateway.types.string.String",
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    description: Optional["capo_api_gateway.types.string.String"] = None,
    cache_cluster_enabled: Optional[
        "capo_api_gateway.types.boolean.Boolean"
    ] = None,
    cache_cluster_size: Optional[
        "capo_api_gateway.types.cache_cluster_size.CacheClusterSize"
    ] = None,
    variables: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
    documentation_version: Optional["capo_api_gateway.types.string.String"] = None,
    canary_settings: Optional[
        "capo_api_gateway.types.canary_settings.CanarySettings"
    ] = None,
    tracing_enabled: Optional["capo_api_gateway.types.boolean.Boolean"] = None,
    tags: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
) -> "capo_api_gateway.types.stage.Stage":
    """<p>Creates a new Stage resource that references a pre-existing Deployment for the API. </p>

    Args:
        rest_api_id: <p>The string identifier of the associated RestApi.</p>
        stage_name: <p>The name for the Stage resource. Stage names can only contain alphanumeric characters, hyphens, and underscores. Maximum length is 128 characters.</p>
        deployment_id: <p>The identifier of the Deployment resource for the Stage resource.</p>
        description: <p>The description of the Stage resource.</p>
        cache_cluster_enabled: <p>Whether cache clustering is enabled for the stage.</p>
        cache_cluster_size: <p>The stage's cache capacity in GB. For more information about choosing a cache size, see <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html">Enabling API caching to enhance responsiveness</a>.</p>
        variables: <p>A map that defines the stage variables for the new Stage resource. Variable names can have alphanumeric and underscore characters, and the values must match <code>[A-Za-z0-9-._~:/?#&=,]+</code>.</p>
        documentation_version: <p>The version of the associated API documentation.</p>
        canary_settings: <p>The canary deployment settings of this stage.</p>
        tracing_enabled: <p>Specifies whether active tracing with X-ray is enabled for the Stage.</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_stage_request.CreateStageRequest]",
    ) -> OperationResponse["capo_api_gateway.types.stage.Stage"]:
        import capo_api_gateway._operations.backplane_control_service.create_stage

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateStage")
    )
    input_: capo_api_gateway.types.create_stage_request.CreateStageRequest = {
        "rest_api_id": rest_api_id,
        "stage_name": stage_name,
        "deployment_id": deployment_id,
    }
    if description is not None:
        input_["description"] = description
    if cache_cluster_enabled is not None:
        input_["cache_cluster_enabled"] = cache_cluster_enabled
    if cache_cluster_size is not None:
        input_["cache_cluster_size"] = cache_cluster_size
    if variables is not None:
        input_["variables"] = variables
    if documentation_version is not None:
        input_["documentation_version"] = documentation_version
    if canary_settings is not None:
        input_["canary_settings"] = canary_settings
    if tracing_enabled is not None:
        input_["tracing_enabled"] = tracing_enabled
    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