Skip to content

create_api async

create_api(
    *,
    config_overrides: Optional[AsyncApiGatewayV2ClientConfig] = None,
    api_key_selection_expression: Optional[SelectionExpression] = None,
    cors_configuration: Optional[Cors] = None,
    credentials_arn: Optional[Arn] = None,
    description: Optional[StringWithLengthBetween0And1024] = None,
    disable_schema_validation: Optional[__boolean] = None,
    disable_execute_api_endpoint: Optional[__boolean] = None,
    ip_address_type: Optional[IpAddressType] = None,
    name: Optional[StringWithLengthBetween1And128] = None,
    protocol_type: Optional[ProtocolType] = None,
    route_key: Optional[SelectionKey] = None,
    route_selection_expression: Optional[SelectionExpression] = None,
    tags: Optional[Tags] = None,
    target: Optional[UriWithLengthBetween1And2048] = None,
    version: Optional[StringWithLengthBetween1And64] = None,
) -> CreateApiResponse

Creates an Api resource.

Parameters:

  • api_key_selection_expression (Optional[SelectionExpression], default: None ) –

    An API key selection expression. Supported only for WebSocket APIs. See API Key Selection Expressions.

  • cors_configuration (Optional[Cors], default: None ) –

    A CORS configuration. Supported only for HTTP APIs. See Configuring CORS for more information.

  • credentials_arn (Optional[Arn], default: None ) –

    This property is part of quick create. It specifies the credentials required for the integration, if any. For a Lambda integration, three options are available. To specify an IAM Role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To require that the caller's identity be passed through from the request, specify arn:aws:iam::*:user/*. To use resource-based permissions on supported AWS services, specify null. Currently, this property is not used for HTTP integrations. Supported only for HTTP APIs.

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

    The description of the API.

  • disable_schema_validation (Optional[__boolean], default: None ) –

    Avoid validating models when creating a deployment. Supported only for WebSocket APIs.

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

  • ip_address_type (Optional[IpAddressType], default: None ) –

    The IP address types that can invoke the API.

  • name (Optional[StringWithLengthBetween1And128], default: None ) –

    The name of the API.

  • protocol_type (Optional[ProtocolType], default: None ) –

    The API protocol.

  • route_key (Optional[SelectionKey], default: None ) –

    This property is part of quick create. If you don't specify a routeKey, a default route of $default is created. The $default route acts as a catch-all for any request made to your API, for a particular stage. The $default route key can't be modified. You can add routes after creating the API, and you can update the route keys of additional routes. Supported only for HTTP APIs.

  • route_selection_expression (Optional[SelectionExpression], default: None ) –

    The route selection expression for the API. For HTTP APIs, the routeSelectionExpression must be ${request.method} ${request.path}. If not provided, this will be the default for HTTP APIs. This property is required for WebSocket APIs.

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

    The collection of tags. Each tag element is associated with a given resource.

  • target (Optional[UriWithLengthBetween1And2048], default: None ) –

    This property is part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be HTTP_PROXY or AWS_PROXY, respectively. Supported only for HTTP APIs.

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

    A version identifier for the API.

Raises:

  • BadRequestException –

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

  • ConflictException –

    The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request. See the accompanying error message for details.

  • NotFoundException –

    The resource specified in the request was not found. See the message field for more information.

  • TooManyRequestsException –

    A limit has been exceeded. See the accompanying error message for details.

  • UnknownServiceError –

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

Source code in docs_src/capo_apigatewayv2/_services/async_api_gateway_v2.py
async def create_api(
    self,
    *,
    config_overrides: Optional[AsyncApiGatewayV2ClientConfig] = None,
    api_key_selection_expression: Optional[
        "capo_apigatewayv2.types.selection_expression.SelectionExpression"
    ] = None,
    cors_configuration: Optional["capo_apigatewayv2.types.cors.Cors"] = None,
    credentials_arn: Optional["capo_apigatewayv2.types.arn.Arn"] = None,
    description: Optional[
        "capo_apigatewayv2.types.string_with_length_between0_and1024.StringWithLengthBetween0And1024"
    ] = None,
    disable_schema_validation: Optional[
        "capo_apigatewayv2.types.__boolean.__boolean"
    ] = None,
    disable_execute_api_endpoint: Optional[
        "capo_apigatewayv2.types.__boolean.__boolean"
    ] = None,
    ip_address_type: Optional[
        "capo_apigatewayv2.types.ip_address_type.IpAddressType"
    ] = None,
    name: Optional[
        "capo_apigatewayv2.types.string_with_length_between1_and128.StringWithLengthBetween1And128"
    ] = None,
    protocol_type: Optional[
        "capo_apigatewayv2.types.protocol_type.ProtocolType"
    ] = None,
    route_key: Optional[
        "capo_apigatewayv2.types.selection_key.SelectionKey"
    ] = None,
    route_selection_expression: Optional[
        "capo_apigatewayv2.types.selection_expression.SelectionExpression"
    ] = None,
    tags: Optional["capo_apigatewayv2.types.tags.Tags"] = None,
    target: Optional[
        "capo_apigatewayv2.types.uri_with_length_between1_and2048.UriWithLengthBetween1And2048"
    ] = None,
    version: Optional[
        "capo_apigatewayv2.types.string_with_length_between1_and64.StringWithLengthBetween1And64"
    ] = None,
) -> "capo_apigatewayv2.types.create_api_response.CreateApiResponse":
    """<p>Creates an Api resource.</p>

    Args:
        api_key_selection_expression: <p>An API key selection expression. Supported only for WebSocket APIs. See <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions">API Key Selection Expressions</a>.</p>
        cors_configuration: <p>A CORS configuration. Supported only for HTTP APIs. See <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html">Configuring CORS</a> for more information.</p>
        credentials_arn: <p>This property is part of quick create. It specifies the credentials required for the integration, if any. For a Lambda integration, three options are available. To specify an IAM Role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To require that the caller's identity be passed through from the request, specify arn:aws:iam::*:user/*. To use resource-based permissions on supported AWS services, specify null. Currently, this property is not used for HTTP integrations. Supported only for HTTP APIs.</p>
        description: <p>The description of the API.</p>
        disable_schema_validation: <p>Avoid validating models when creating a deployment. Supported only for WebSocket APIs.</p>
        disable_execute_api_endpoint: <p>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.</p>
        ip_address_type: <p>The IP address types that can invoke the API.</p>
        name: <p>The name of the API.</p>
        protocol_type: <p>The API protocol.</p>
        route_key: <p>This property is part of quick create. If you don't specify a routeKey, a default route of $default is created. The $default route acts as a catch-all for any request made to your API, for a particular stage. The $default route key can't be modified. You can add routes after creating the API, and you can update the route keys of additional routes. Supported only for HTTP APIs.</p>
        route_selection_expression: <p>The route selection expression for the API. For HTTP APIs, the routeSelectionExpression must be ${request.method} ${request.path}. If not provided, this will be the default for HTTP APIs. This property is required for WebSocket APIs.</p>
        tags: <p>The collection of tags. Each tag element is associated with a given resource.</p>
        target: <p>This property is part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be HTTP_PROXY or AWS_PROXY, respectively. Supported only for HTTP APIs.</p>
        version: <p>A version identifier for the API.</p>

    Raises:
        capo_apigatewayv2.errors.bad_request_exception.BadRequestException: <p>The request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.</p>
        capo_apigatewayv2.errors.conflict_exception.ConflictException: <p>The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request. See the accompanying error message for details.</p>
        capo_apigatewayv2.errors.not_found_exception.NotFoundException: <p>The resource specified in the request was not found. See the message field for more information.</p>
        capo_apigatewayv2.errors.too_many_requests_exception.TooManyRequestsException: <p>A limit has been exceeded. See the accompanying error message for details.</p>
        capo_apigatewayv2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_apigatewayv2.types.create_api_request.CreateApiRequest]",
    ) -> AsyncOperationResponse[
        "capo_apigatewayv2.types.create_api_response.CreateApiResponse"
    ]:
        import capo_apigatewayv2._operations.api_gateway_v2.create_api

        (
            output,
            http_response,
        ) = await capo_apigatewayv2._operations.api_gateway_v2.create_api.async_create_api(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateApi")
    )
    input_: capo_apigatewayv2.types.create_api_request.CreateApiRequest = {}
    if api_key_selection_expression is not None:
        input_["api_key_selection_expression"] = api_key_selection_expression
    if cors_configuration is not None:
        input_["cors_configuration"] = cors_configuration
    if credentials_arn is not None:
        input_["credentials_arn"] = credentials_arn
    if description is not None:
        input_["description"] = description
    if disable_schema_validation is not None:
        input_["disable_schema_validation"] = disable_schema_validation
    if disable_execute_api_endpoint is not None:
        input_["disable_execute_api_endpoint"] = disable_execute_api_endpoint
    if ip_address_type is not None:
        input_["ip_address_type"] = ip_address_type
    if name is not None:
        input_["name"] = name
    if protocol_type is not None:
        input_["protocol_type"] = protocol_type
    if route_key is not None:
        input_["route_key"] = route_key
    if route_selection_expression is not None:
        input_["route_selection_expression"] = route_selection_expression
    if tags is not None:
        input_["tags"] = tags
    if target is not None:
        input_["target"] = target
    if version is not None:
        input_["version"] = version

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