diff --git a/cloudformation/serverless/aws-serverless-function_apievent.go b/cloudformation/serverless/aws-serverless-function_apievent.go index 35ba62d5a7..ccf32eed09 100644 --- a/cloudformation/serverless/aws-serverless-function_apievent.go +++ b/cloudformation/serverless/aws-serverless-function_apievent.go @@ -25,6 +25,16 @@ type Function_ApiEvent struct { // See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Path string `json:"Path"` + // RequestModel AWS CloudFormation Property + // Required: false + // See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api + RequestModel *Function_RequestModel `json:"RequestModel,omitempty"` + + // RequestParameters AWS CloudFormation Property + // Required: false + // See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api + RequestParameters *Function_RequestParameters `json:"RequestParameters,omitempty"` + // RestApiId AWS CloudFormation Property // Required: false // See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api diff --git a/cloudformation/serverless/aws-serverless-function_requestmodel.go b/cloudformation/serverless/aws-serverless-function_requestmodel.go new file mode 100644 index 0000000000..d393666d41 --- /dev/null +++ b/cloudformation/serverless/aws-serverless-function_requestmodel.go @@ -0,0 +1,52 @@ +// Code generated by "go generate". Please don't change this file directly. + +package serverless + +import ( + "github.com/awslabs/goformation/v6/cloudformation/policies" +) + +// Function_RequestModel AWS CloudFormation Resource (AWS::Serverless::Function.RequestModel) +// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html +type Function_RequestModel struct { + + // Model AWS CloudFormation Property + // Required: true + // See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html#sam-function-requestmodel-model + Model string `json:"Model"` + + // Required AWS CloudFormation Property + // Required: false + // See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html#sam-function-requestmodel-required + Required *bool `json:"Required,omitempty"` + + // ValidateBody AWS CloudFormation Property + // Required: false + // See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html#sam-function-requestmodel-validatebody + ValidateBody *bool `json:"ValidateBody,omitempty"` + + // ValidateParameters AWS CloudFormation Property + // Required: false + // See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html#sam-function-requestmodel-validateparameters + ValidateParameters *bool `json:"ValidateParameters,omitempty"` + + // AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy + AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"` + + // AWSCloudFormationUpdateReplacePolicy represents a CloudFormation UpdateReplacePolicy + AWSCloudFormationUpdateReplacePolicy policies.UpdateReplacePolicy `json:"-"` + + // AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource + AWSCloudFormationDependsOn []string `json:"-"` + + // AWSCloudFormationMetadata stores structured data associated with this resource + AWSCloudFormationMetadata map[string]interface{} `json:"-"` + + // AWSCloudFormationCondition stores the logical ID of the condition that must be satisfied for this resource to be created + AWSCloudFormationCondition string `json:"-"` +} + +// AWSCloudFormationType returns the AWS CloudFormation resource type +func (r *Function_RequestModel) AWSCloudFormationType() string { + return "AWS::Serverless::Function.RequestModel" +} diff --git a/cloudformation/serverless/aws-serverless-function_requestparameter.go b/cloudformation/serverless/aws-serverless-function_requestparameter.go new file mode 100644 index 0000000000..684c86e4bf --- /dev/null +++ b/cloudformation/serverless/aws-serverless-function_requestparameter.go @@ -0,0 +1,42 @@ +// Code generated by "go generate". Please don't change this file directly. + +package serverless + +import ( + "github.com/awslabs/goformation/v6/cloudformation/policies" +) + +// Function_RequestParameter AWS CloudFormation Resource (AWS::Serverless::Function.RequestParameter) +// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestparameter.html +type Function_RequestParameter struct { + + // Caching AWS CloudFormation Property + // Required: false + // See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestparameter.html#sam-function-requestparameter-caching + Caching *bool `json:"Caching,omitempty"` + + // Required AWS CloudFormation Property + // Required: false + // See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestparameter.html#sam-function-requestparameter-required + Required *bool `json:"Required,omitempty"` + + // AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy + AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"` + + // AWSCloudFormationUpdateReplacePolicy represents a CloudFormation UpdateReplacePolicy + AWSCloudFormationUpdateReplacePolicy policies.UpdateReplacePolicy `json:"-"` + + // AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource + AWSCloudFormationDependsOn []string `json:"-"` + + // AWSCloudFormationMetadata stores structured data associated with this resource + AWSCloudFormationMetadata map[string]interface{} `json:"-"` + + // AWSCloudFormationCondition stores the logical ID of the condition that must be satisfied for this resource to be created + AWSCloudFormationCondition string `json:"-"` +} + +// AWSCloudFormationType returns the AWS CloudFormation resource type +func (r *Function_RequestParameter) AWSCloudFormationType() string { + return "AWS::Serverless::Function.RequestParameter" +} diff --git a/cloudformation/serverless/function_requestparameters.go b/cloudformation/serverless/function_requestparameters.go new file mode 100644 index 0000000000..01c09754e6 --- /dev/null +++ b/cloudformation/serverless/function_requestparameters.go @@ -0,0 +1,75 @@ +// Code generated by "go generate". Please don't change this file directly. + +package serverless + +import ( + "bytes" + "encoding/json" + "io" + "sort" + + "github.com/awslabs/goformation/v6/cloudformation/utils" +) + +// Function_RequestParameters is a helper struct that can hold either a String or RequestParameter value +type Function_RequestParameters struct { + StringArray *[]string + + RequestParameterArray *[]Function_RequestParameter +} + +func (r Function_RequestParameters) value() interface{} { + ret := []interface{}{} + + if r.StringArray != nil { + ret = append(ret, r.StringArray) + } + + if r.RequestParameterArray != nil { + ret = append(ret, r.RequestParameterArray) + } + + sort.Sort(utils.ByJSONLength(ret)) // Heuristic to select best attribute + if len(ret) > 0 { + return ret[0] + } + + return nil +} + +func (r Function_RequestParameters) MarshalJSON() ([]byte, error) { + return json.Marshal(r.value()) +} + +// Hook into the marshaller +func (r *Function_RequestParameters) UnmarshalJSON(b []byte) error { + + // Unmarshal into interface{} to check it's type + var typecheck interface{} + if err := json.Unmarshal(b, &typecheck); err != nil { + return err + } + + switch val := typecheck.(type) { + + case []string: + r.StringArray = &val + + case map[string]interface{}: + val = val // This ensures val is used to stop an error + + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + case []interface{}: + + json.Unmarshal(b, &r.StringArray) + + json.Unmarshal(b, &r.RequestParameterArray) + + } + + return nil +} diff --git a/generate/sam-2016-10-31.json b/generate/sam-2016-10-31.json index 9dc36875c3..7371506715 100644 --- a/generate/sam-2016-10-31.json +++ b/generate/sam-2016-10-31.json @@ -1048,6 +1048,71 @@ "Required": false, "Type": "Auth", "UpdateType": "Immutable" + }, + "RequestModel": { + "Documentation": "https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api", + "Required": false, + "Type": "RequestModel", + "UpdateType": "Immutable" + }, + "RequestParameters": { + "Documentation": "https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api", + "Required": false, + "Type": "List", + "InclusivePrimitiveItemTypes": [ + "String" + ], + "InclusiveItemTypes": [ + "RequestParameter" + ], + "InclusiveItemPattern": true, + "UpdateType": "Immutable" + } + } + }, + "AWS::Serverless::Function.RequestModel": { + "Documentation": "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html", + "Properties": { + "Model": { + "Documentation": "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html#sam-function-requestmodel-model", + "Required": true, + "PrimitiveType": "String", + "UpdateType": "Immutable" + }, + "Required": { + "Documentation": "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html#sam-function-requestmodel-required", + "Required": false, + "PrimitiveType": "Boolean", + "UpdateType": "Immutable" + }, + "ValidateBody": { + "Documentation": "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html#sam-function-requestmodel-validatebody", + "Required": false, + "PrimitiveType": "Boolean", + "UpdateType": "Immutable" + }, + "ValidateParameters": { + "Documentation": "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestmodel.html#sam-function-requestmodel-validateparameters", + "Required": false, + "PrimitiveType": "Boolean", + "UpdateType": "Immutable" + } + } + }, + "AWS::Serverless::Function.RequestParameter": { + "Documentation": "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestparameter.html", + "Properties": { + "Caching": { + "Documentation": "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestparameter.html#sam-function-requestparameter-caching", + "Required": false, + "PrimitiveType": "Boolean", + "UpdateType": "Immutable" + }, + "Required": { + "Documentation": "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-requestparameter.html#sam-function-requestparameter-required", + "Required": false, + "PrimitiveType": "Boolean", + "UpdateType": "Immutable" } } }, diff --git a/schema/sam.go b/schema/sam.go index 893fdb9bb6..f5686d83fc 100644 --- a/schema/sam.go +++ b/schema/sam.go @@ -124602,6 +124602,30 @@ var SamSchema = `{ "Path": { "type": "string" }, + "RequestModel": { + "$ref": "#/definitions/AWS::Serverless::Function.RequestModel" + }, + "RequestParameters": { + "anyOf": [ + { + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "patternProperties": { + "^[a-zA-Z0-9]+$": { + "$ref": "#/definitions/AWS::Serverless::Function.RequestParameter" + } + } + } + ] + }, + "type": "array" + } + ] + }, "RestApiId": { "type": "string" } @@ -125189,6 +125213,39 @@ var SamSchema = `{ ], "type": "object" }, + "AWS::Serverless::Function.RequestModel": { + "additionalProperties": false, + "properties": { + "Model": { + "type": "string" + }, + "Required": { + "type": "boolean" + }, + "ValidateBody": { + "type": "boolean" + }, + "ValidateParameters": { + "type": "boolean" + } + }, + "required": [ + "Model" + ], + "type": "object" + }, + "AWS::Serverless::Function.RequestParameter": { + "additionalProperties": false, + "properties": { + "Caching": { + "type": "boolean" + }, + "Required": { + "type": "boolean" + } + }, + "type": "object" + }, "AWS::Serverless::Function.S3Event": { "additionalProperties": false, "properties": { diff --git a/schema/sam.schema.json b/schema/sam.schema.json index 3cf492a5cc..292a1c14e7 100644 --- a/schema/sam.schema.json +++ b/schema/sam.schema.json @@ -124597,6 +124597,30 @@ "Path": { "type": "string" }, + "RequestModel": { + "$ref": "#/definitions/AWS::Serverless::Function.RequestModel" + }, + "RequestParameters": { + "anyOf": [ + { + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "patternProperties": { + "^[a-zA-Z0-9]+$": { + "$ref": "#/definitions/AWS::Serverless::Function.RequestParameter" + } + } + } + ] + }, + "type": "array" + } + ] + }, "RestApiId": { "type": "string" } @@ -125184,6 +125208,39 @@ ], "type": "object" }, + "AWS::Serverless::Function.RequestModel": { + "additionalProperties": false, + "properties": { + "Model": { + "type": "string" + }, + "Required": { + "type": "boolean" + }, + "ValidateBody": { + "type": "boolean" + }, + "ValidateParameters": { + "type": "boolean" + } + }, + "required": [ + "Model" + ], + "type": "object" + }, + "AWS::Serverless::Function.RequestParameter": { + "additionalProperties": false, + "properties": { + "Caching": { + "type": "boolean" + }, + "Required": { + "type": "boolean" + } + }, + "type": "object" + }, "AWS::Serverless::Function.S3Event": { "additionalProperties": false, "properties": {