1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package apigateway
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Adds a MethodResponse to an existing Method resource.
14func (c *Client) PutMethodResponse(ctx context.Context, params *PutMethodResponseInput, optFns ...func(*Options)) (*PutMethodResponseOutput, error) {
15	if params == nil {
16		params = &PutMethodResponseInput{}
17	}
18
19	result, metadata, err := c.invokeOperation(ctx, "PutMethodResponse", params, optFns, addOperationPutMethodResponseMiddlewares)
20	if err != nil {
21		return nil, err
22	}
23
24	out := result.(*PutMethodResponseOutput)
25	out.ResultMetadata = metadata
26	return out, nil
27}
28
29// Request to add a MethodResponse to an existing Method resource.
30type PutMethodResponseInput struct {
31
32	// [Required] The HTTP verb of the Method resource.
33	//
34	// This member is required.
35	HttpMethod *string
36
37	// [Required] The Resource identifier for the Method resource.
38	//
39	// This member is required.
40	ResourceId *string
41
42	// [Required] The string identifier of the associated RestApi.
43	//
44	// This member is required.
45	RestApiId *string
46
47	// [Required] The method response's status code.
48	//
49	// This member is required.
50	StatusCode *string
51
52	// Specifies the Model resources used for the response's content type. Response
53	// models are represented as a key/value map, with a content type as the key and a
54	// Model name as the value.
55	ResponseModels map[string]string
56
57	// A key-value map specifying required or optional response parameters that API
58	// Gateway can send back to the caller. A key defines a method response header name
59	// and the associated value is a Boolean flag indicating whether the method
60	// response parameter is required or not. The method response header names must
61	// match the pattern of method.response.header.{name}, where name is a valid and
62	// unique header name. The response parameter names defined here are available in
63	// the integration response to be mapped from an integration response header
64	// expressed in integration.response.header.{name}, a static value enclosed within
65	// a pair of single quotes (e.g., 'application/json'), or a JSON expression from
66	// the back-end response payload in the form of
67	// integration.response.body.{JSON-expression}, where JSON-expression is a valid
68	// JSON expression without the $ prefix.)
69	ResponseParameters map[string]bool
70}
71
72// Represents a method response of a given HTTP status code returned to the client.
73// The method response is passed from the back end through the associated
74// integration response that can be transformed using a mapping template.
75// Example:
76// A MethodResponse instance of an API
77//
78// Request
79//
80// The example request retrieves a
81// MethodResponse of the 200 status code. GET
82// /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200 HTTP/1.1
83// Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com
84// X-Amz-Date: 20160603T222952Z Authorization: AWS4-HMAC-SHA256
85// Credential={access_key_ID}/20160603/us-east-1/apigateway/aws4_request,
86// SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
87// Response
88//
89// The
90// successful response returns 200 OK status and a payload as follows: { "_links":
91// { "curies": { "href":
92// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-response-{rel}.html",
93// "name": "methodresponse", "templated": true }, "self": { "href":
94// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200", "title":
95// "200" }, "methodresponse:delete": { "href":
96// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" },
97// "methodresponse:update": { "href":
98// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" } },
99// "responseModels": { "application/json": "Empty" }, "responseParameters": {
100// "method.response.header.Content-Type": false }, "statusCode": "200" }Method,
101// IntegrationResponse, IntegrationCreating an API
102// (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html)
103type PutMethodResponseOutput struct {
104
105	// Specifies the Model resources used for the response's content-type. Response
106	// models are represented as a key/value map, with a content-type as the key and a
107	// Model name as the value.
108	ResponseModels map[string]string
109
110	// A key-value map specifying required or optional response parameters that API
111	// Gateway can send back to the caller. A key defines a method response header and
112	// the value specifies whether the associated method response header is required or
113	// not. The expression of the key must match the pattern
114	// method.response.header.{name}, where name is a valid and unique header name. API
115	// Gateway passes certain integration response data to the method response headers
116	// specified here according to the mapping you prescribe in the API's
117	// IntegrationResponse. The integration response data that can be mapped include an
118	// integration response header expressed in integration.response.header.{name}, a
119	// static value enclosed within a pair of single quotes (e.g., 'application/json'),
120	// or a JSON expression from the back-end response payload in the form of
121	// integration.response.body.{JSON-expression}, where JSON-expression is a valid
122	// JSON expression without the $ prefix.)
123	ResponseParameters map[string]bool
124
125	// The method response's status code.
126	StatusCode *string
127
128	// Metadata pertaining to the operation's result.
129	ResultMetadata middleware.Metadata
130}
131
132func addOperationPutMethodResponseMiddlewares(stack *middleware.Stack, options Options) (err error) {
133	err = stack.Serialize.Add(&awsRestjson1_serializeOpPutMethodResponse{}, middleware.After)
134	if err != nil {
135		return err
136	}
137	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpPutMethodResponse{}, middleware.After)
138	if err != nil {
139		return err
140	}
141	if err = addSetLoggerMiddleware(stack, options); err != nil {
142		return err
143	}
144	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
145		return err
146	}
147	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
148		return err
149	}
150	if err = addResolveEndpointMiddleware(stack, options); err != nil {
151		return err
152	}
153	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
154		return err
155	}
156	if err = addRetryMiddlewares(stack, options); err != nil {
157		return err
158	}
159	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
160		return err
161	}
162	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
163		return err
164	}
165	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
166		return err
167	}
168	if err = addClientUserAgent(stack); err != nil {
169		return err
170	}
171	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
172		return err
173	}
174	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
175		return err
176	}
177	if err = addOpPutMethodResponseValidationMiddleware(stack); err != nil {
178		return err
179	}
180	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutMethodResponse(options.Region), middleware.Before); err != nil {
181		return err
182	}
183	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
184		return err
185	}
186	if err = addResponseErrorMiddleware(stack); err != nil {
187		return err
188	}
189	if err = addAcceptHeader(stack); err != nil {
190		return err
191	}
192	if err = addRequestResponseLogging(stack, options); err != nil {
193		return err
194	}
195	return nil
196}
197
198func newServiceMetadataMiddleware_opPutMethodResponse(region string) *awsmiddleware.RegisterServiceMetadata {
199	return &awsmiddleware.RegisterServiceMetadata{
200		Region:        region,
201		ServiceID:     ServiceID,
202		SigningName:   "apigateway",
203		OperationName: "PutMethodResponse",
204	}
205}
206