Class: AWSCDK::APIGateway::ModelProps

Inherits:
ModelOptions
  • Object
show all
Defined in:
api_gateway/model_props.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema:, content_type: nil, description: nil, model_name: nil, rest_api:) ⇒ ModelProps

Returns a new instance of ModelProps.

Parameters:

  • schema (AWSCDK::APIGateway::JsonSchema)

    The schema to use to transform data to one or more output formats.

  • content_type (String, nil) (defaults to: nil)

    The content type for the model.

  • description (String, nil) (defaults to: nil)

    A description that identifies this model.

  • model_name (String, nil) (defaults to: nil)

    A name for the model.

  • rest_api (AWSCDK::APIGateway::IRestAPI)

    The rest API that this model is part of.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'api_gateway/model_props.rb', line 11

def initialize(schema:, content_type: nil, description: nil, model_name: nil, rest_api:)
  @schema = schema.is_a?(Hash) ? ::AWSCDK::APIGateway::JsonSchema.new(**schema.transform_keys(&:to_sym)) : schema
  Jsii::Type.check_type(@schema, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5Kc29uU2NoZW1hIn0=")), "schema")
  @content_type = content_type
  Jsii::Type.check_type(@content_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "contentType") unless @content_type.nil?
  @description = description
  Jsii::Type.check_type(@description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless @description.nil?
  @model_name = model_name
  Jsii::Type.check_type(@model_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "modelName") unless @model_name.nil?
  @rest_api = rest_api
  Jsii::Type.check_type(@rest_api, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5JUmVzdEFwaSJ9")), "restApi")
end

Instance Attribute Details

#content_typeString? (readonly)

Note:

Default: 'application/json'

The content type for the model.

You can also force a content type in the request or response model mapping.

Returns:

  • (String, nil)


37
38
39
# File 'api_gateway/model_props.rb', line 37

def content_type
  @content_type
end

#descriptionString? (readonly)

Note:

Default: None

A description that identifies this model.

Returns:

  • (String, nil)


42
43
44
# File 'api_gateway/model_props.rb', line 42

def description
  @description
end

#model_nameString? (readonly)

Note:

Default: If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the model name. For more information, see Name Type.

A name for the model.

Important If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.

Returns:

  • (String, nil)


53
54
55
# File 'api_gateway/model_props.rb', line 53

def model_name
  @model_name
end

#rest_apiAWSCDK::APIGateway::IRestAPI (readonly)

The rest API that this model is part of.

The reason we need the RestApi object itself and not just the ID is because the model is being tracked by the top-level RestApi object for the purpose of calculating its hash to determine the ID of the deployment. This allows us to automatically update the deployment when the model of the REST API changes.



62
63
64
# File 'api_gateway/model_props.rb', line 62

def rest_api
  @rest_api
end

#schemaAWSCDK::APIGateway::JsonSchema (readonly)

The schema to use to transform data to one or more output formats.

Specify null ({}) if you don't want to specify a schema.



29
30
31
# File 'api_gateway/model_props.rb', line 29

def schema
  @schema
end

Class Method Details

.jsii_propertiesObject



64
65
66
67
68
69
70
71
72
# File 'api_gateway/model_props.rb', line 64

def self.jsii_properties
  {
    :schema => "schema",
    :content_type => "contentType",
    :description => "description",
    :model_name => "modelName",
    :rest_api => "restApi",
  }
end

Instance Method Details

#to_jsiiObject



74
75
76
77
78
79
80
81
82
83
84
85
# File 'api_gateway/model_props.rb', line 74

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "schema" => @schema,
    "contentType" => @content_type,
    "description" => @description,
    "modelName" => @model_name,
    "restApi" => @rest_api,
  })
  result.compact
end