Skip to content

create_rest_api async

create_rest_api(
    name: String,
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    description: Optional[String] = None,
    version: Optional[String] = None,
    clone_from: Optional[String] = None,
    binary_media_types: Optional[ListOfString] = None,
    minimum_compression_size: Optional[NullableInteger] = None,
    api_key_source: Optional[ApiKeySourceType] = None,
    endpoint_configuration: Optional[EndpointConfiguration] = None,
    policy: Optional[String] = None,
    tags: Optional[MapOfStringToString] = None,
    disable_execute_api_endpoint: Optional[Boolean] = None,
    security_policy: Optional[SecurityPolicy] = None,
    endpoint_access_mode: Optional[EndpointAccessMode] = None,
) -> RestApi

Creates a new RestApi resource.

Parameters:

  • name (String) –

    The name of the RestApi.

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

    The description of the RestApi.

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

    A version identifier for the API.

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

    The ID of the RestApi that you want to clone from.

  • binary_media_types (Optional[ListOfString], default: None ) –

    The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

  • minimum_compression_size (Optional[NullableInteger], default: None ) –

    A nullable integer that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (with a null value) on an API. When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.

  • api_key_source (Optional[ApiKeySourceType], default: None ) –

    The source of the API key for metering requests according to a usage plan. Valid values are: HEADER to read the API key from the X-API-Key header of a request. AUTHORIZER to read the API key from the UsageIdentifierKey from a custom authorizer.

  • endpoint_configuration (Optional[EndpointConfiguration], default: None ) –

    The endpoint configuration of this RestApi showing the endpoint types and IP address types of the API.

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

    A stringified JSON policy document that applies to this RestApi regardless of the caller and Method configuration.

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

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

    Specifies whether clients can invoke your API by using the default execute-api endpoint. By default, clients can invoke your API with the default https://{api_id}.execute-api.{region}.amazonaws.com endpoint. To require that clients use a custom domain name to invoke your API, disable the default endpoint

  • security_policy (Optional[SecurityPolicy], default: None ) –

    The Transport Layer Security (TLS) version + cipher suite for this RestApi.

  • endpoint_access_mode (Optional[EndpointAccessMode], default: None ) –

    The endpoint access mode of the RestApi. Only available for RestApis that use security policies that start with SecurityPolicy_.

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.

  • 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/async_api_gateway.py
async def create_rest_api(
    self,
    name: "capo_api_gateway.types.string.String",
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    description: Optional["capo_api_gateway.types.string.String"] = None,
    version: Optional["capo_api_gateway.types.string.String"] = None,
    clone_from: Optional["capo_api_gateway.types.string.String"] = None,
    binary_media_types: Optional[
        "capo_api_gateway.types.list_of_string.ListOfString"
    ] = None,
    minimum_compression_size: Optional[
        "capo_api_gateway.types.nullable_integer.NullableInteger"
    ] = None,
    api_key_source: Optional[
        "capo_api_gateway.types.api_key_source_type.ApiKeySourceType"
    ] = None,
    endpoint_configuration: Optional[
        "capo_api_gateway.types.endpoint_configuration.EndpointConfiguration"
    ] = None,
    policy: Optional["capo_api_gateway.types.string.String"] = None,
    tags: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
    disable_execute_api_endpoint: Optional[
        "capo_api_gateway.types.boolean.Boolean"
    ] = None,
    security_policy: Optional[
        "capo_api_gateway.types.security_policy.SecurityPolicy"
    ] = None,
    endpoint_access_mode: Optional[
        "capo_api_gateway.types.endpoint_access_mode.EndpointAccessMode"
    ] = None,
) -> "capo_api_gateway.types.rest_api.RestApi":
    """<p>Creates a new RestApi resource.</p>

    Args:
        name: <p>The name of the RestApi.</p>
        description: <p>The description of the RestApi.</p>
        version: <p>A version identifier for the API.</p>
        clone_from: <p>The ID of the RestApi that you want to clone from.</p>
        binary_media_types: <p>The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.</p>
        minimum_compression_size: <p>A nullable integer that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (with a null value) on an API. When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.</p>
        api_key_source: <p>The source of the API key for metering requests according to a usage plan. Valid values are: <code>HEADER</code> to read the API key from the <code>X-API-Key</code> header of a request. <code>AUTHORIZER</code> to read the API key from the <code>UsageIdentifierKey</code> from a custom authorizer.</p>
        endpoint_configuration: <p>The endpoint configuration of this RestApi showing the endpoint types and IP address types of the API. </p>
        policy: <p>A stringified JSON policy document that applies to this RestApi regardless of the caller and Method configuration.</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>
        disable_execute_api_endpoint: <p>Specifies whether clients can invoke your API by using the default <code>execute-api</code> endpoint. By default, clients can invoke your API with the default <code>https://{api_id}.execute-api.{region}.amazonaws.com</code> endpoint. To require that clients use a custom domain name to invoke your API, disable the default endpoint</p>
        security_policy: <p> The Transport Layer Security (TLS) version + cipher suite for this RestApi. </p>
        endpoint_access_mode: <p> The endpoint access mode of the RestApi. Only available for RestApis that use security policies that start with <code>SecurityPolicy_</code>.</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.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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_api_gateway.types.create_rest_api_request.CreateRestApiRequest]",
    ) -> AsyncOperationResponse["capo_api_gateway.types.rest_api.RestApi"]:
        import capo_api_gateway._operations.backplane_control_service.create_rest_api

        (
            output,
            http_response,
        ) = await capo_api_gateway._operations.backplane_control_service.create_rest_api.async_create_rest_api(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateRestApi")
    )
    input_: capo_api_gateway.types.create_rest_api_request.CreateRestApiRequest = {
        "name": name
    }
    if description is not None:
        input_["description"] = description
    if version is not None:
        input_["version"] = version
    if clone_from is not None:
        input_["clone_from"] = clone_from
    if binary_media_types is not None:
        input_["binary_media_types"] = binary_media_types
    if minimum_compression_size is not None:
        input_["minimum_compression_size"] = minimum_compression_size
    if api_key_source is not None:
        input_["api_key_source"] = api_key_source
    if endpoint_configuration is not None:
        input_["endpoint_configuration"] = endpoint_configuration
    if policy is not None:
        input_["policy"] = policy
    if tags is not None:
        input_["tags"] = tags
    if disable_execute_api_endpoint is not None:
        input_["disable_execute_api_endpoint"] = disable_execute_api_endpoint
    if security_policy is not None:
        input_["security_policy"] = security_policy
    if endpoint_access_mode is not None:
        input_["endpoint_access_mode"] = endpoint_access_mode

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