Skip to content

create_model

create_model(
    api_id: __string,
    *,
    config_overrides: Optional[ApiGatewayV2ClientConfig] = None,
    content_type: Optional[StringWithLengthBetween1And256] = None,
    description: Optional[StringWithLengthBetween0And1024] = None,
    name: Optional[StringWithLengthBetween1And128] = None,
    schema: Optional[StringWithLengthBetween0And32K] = None,
) -> CreateModelResponse

Creates a Model for an API.

Parameters:

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/api_gateway_v2.py
def create_model(
    self,
    api_id: "capo_apigatewayv2.types.__string.__string",
    *,
    config_overrides: Optional[ApiGatewayV2ClientConfig] = None,
    content_type: Optional[
        "capo_apigatewayv2.types.string_with_length_between1_and256.StringWithLengthBetween1And256"
    ] = None,
    description: Optional[
        "capo_apigatewayv2.types.string_with_length_between0_and1024.StringWithLengthBetween0And1024"
    ] = None,
    name: Optional[
        "capo_apigatewayv2.types.string_with_length_between1_and128.StringWithLengthBetween1And128"
    ] = None,
    schema: Optional[
        "capo_apigatewayv2.types.string_with_length_between0_and32_k.StringWithLengthBetween0And32K"
    ] = None,
) -> "capo_apigatewayv2.types.create_model_response.CreateModelResponse":
    """<p>Creates a Model for an API.</p>

    Args:
        api_id: <p>The API identifier.</p>
        content_type: <p>The content-type for the model, for example, "application/json".</p>
        description: <p>The description of the model.</p>
        name: <p>The name of the model. Must be alphanumeric.</p>
        schema: <p>The schema for the model. For application/json models, this should be JSON schema draft 4 model.</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.
    """

    def _handler(
        req: "OperationRequest[capo_apigatewayv2.types.create_model_request.CreateModelRequest]",
    ) -> OperationResponse[
        "capo_apigatewayv2.types.create_model_response.CreateModelResponse"
    ]:
        import capo_apigatewayv2._operations.api_gateway_v2.create_model

        output, http_response = (
            capo_apigatewayv2._operations.api_gateway_v2.create_model.create_model(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateModel")
    )
    input_: capo_apigatewayv2.types.create_model_request.CreateModelRequest = {
        "api_id": api_id
    }
    if content_type is not None:
        input_["content_type"] = content_type
    if description is not None:
        input_["description"] = description
    if name is not None:
        input_["name"] = name
    if schema is not None:
        input_["schema"] = schema

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output