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/aws-sdk-go-v2/service/apigateway/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Sets up a method's integration.
15func (c *Client) PutIntegration(ctx context.Context, params *PutIntegrationInput, optFns ...func(*Options)) (*PutIntegrationOutput, error) {
16	if params == nil {
17		params = &PutIntegrationInput{}
18	}
19
20	result, metadata, err := c.invokeOperation(ctx, "PutIntegration", params, optFns, addOperationPutIntegrationMiddlewares)
21	if err != nil {
22		return nil, err
23	}
24
25	out := result.(*PutIntegrationOutput)
26	out.ResultMetadata = metadata
27	return out, nil
28}
29
30// Sets up a method's integration.
31type PutIntegrationInput struct {
32
33	// [Required] Specifies a put integration request's HTTP method.
34	//
35	// This member is required.
36	HttpMethod *string
37
38	// [Required] Specifies a put integration request's resource ID.
39	//
40	// This member is required.
41	ResourceId *string
42
43	// [Required] The string identifier of the associated RestApi.
44	//
45	// This member is required.
46	RestApiId *string
47
48	// [Required] Specifies a put integration input's type.
49	//
50	// This member is required.
51	Type types.IntegrationType
52
53	// A list of request parameters whose values API Gateway caches. To be valid values
54	// for cacheKeyParameters, these parameters must also be specified for
55	// MethodrequestParameters.
56	CacheKeyParameters []string
57
58	// Specifies a group of related cached parameters. By default, API Gateway uses the
59	// resource ID as the cacheNamespace. You can specify the same cacheNamespace
60	// across resources to return the same cached data for requests to different
61	// resources.
62	CacheNamespace *string
63
64	// The (id
65	// (https://docs.aws.amazon.com/apigateway/api-reference/resource/vpc-link/#id)) of
66	// the VpcLink used for the integration when connectionType=VPC_LINK and undefined,
67	// otherwise.
68	ConnectionId *string
69
70	// The type of the network connection to the integration endpoint. The valid value
71	// is INTERNET for connections through the public routable internet or VPC_LINK for
72	// private connections between API Gateway and a network load balancer in a VPC.
73	// The default value is INTERNET.
74	ConnectionType types.ConnectionType
75
76	// Specifies how to handle request payload content type conversions. Supported
77	// values are CONVERT_TO_BINARY and CONVERT_TO_TEXT, with the following
78	// behaviors:
79	//
80	// * CONVERT_TO_BINARY: Converts a request payload from a
81	// Base64-encoded string to the corresponding binary blob.
82	//
83	// * CONVERT_TO_TEXT:
84	// Converts a request payload from a binary blob to a Base64-encoded string.
85	//
86	// If
87	// this property is not defined, the request payload will be passed through from
88	// the method request to integration request without modification, provided that
89	// the passthroughBehavior is configured to support payload pass-through.
90	ContentHandling types.ContentHandlingStrategy
91
92	// Specifies whether credentials are required for a put integration.
93	Credentials *string
94
95	// Specifies a put integration HTTP method. When the integration type is HTTP or
96	// AWS, this field is required.
97	IntegrationHttpMethod *string
98
99	// Specifies the pass-through behavior for incoming requests based on the
100	// Content-Type header in the request, and the available mapping templates
101	// specified as the requestTemplates property on the Integration resource. There
102	// are three valid values: WHEN_NO_MATCH, WHEN_NO_TEMPLATES, and NEVER.
103	//
104	// *
105	// WHEN_NO_MATCH passes the request body for unmapped content types through to the
106	// integration back end without transformation.
107	//
108	// * NEVER rejects unmapped content
109	// types with an HTTP 415 'Unsupported Media Type' response.
110	//
111	// * WHEN_NO_TEMPLATES
112	// allows pass-through when the integration has NO content types mapped to
113	// templates. However if there is at least one content type defined, unmapped
114	// content types will be rejected with the same 415 response.
115	PassthroughBehavior *string
116
117	// A key-value map specifying request parameters that are passed from the method
118	// request to the back end. The key is an integration request parameter name and
119	// the associated value is a method request parameter value or static value that
120	// must be enclosed within single quotes and pre-encoded as required by the back
121	// end. The method request parameter value must match the pattern of
122	// method.request.{location}.{name}, where location is querystring, path, or header
123	// and name must be a valid and unique method request parameter name.
124	RequestParameters map[string]string
125
126	// Represents a map of Velocity templates that are applied on the request payload
127	// based on the value of the Content-Type header sent by the client. The content
128	// type value is the key in this map, and the template (as a String) is the value.
129	RequestTemplates map[string]string
130
131	// Custom timeout between 50 and 29,000 milliseconds. The default value is 29,000
132	// milliseconds or 29 seconds.
133	TimeoutInMillis *int32
134
135	TlsConfig *types.TlsConfig
136
137	// Specifies Uniform Resource Identifier (URI) of the integration endpoint.
138	//
139	// * For
140	// HTTP or HTTP_PROXY integrations, the URI must be a fully formed, encoded HTTP(S)
141	// URL according to the RFC-3986 specification
142	// (https://en.wikipedia.org/wiki/Uniform_Resource_Identifier), for either standard
143	// integration, where connectionType is not VPC_LINK, or private integration, where
144	// connectionType is VPC_LINK. For a private HTTP integration, the URI is not used
145	// for routing.
146	//
147	// * For AWS or AWS_PROXY integrations, the URI is of the form
148	// arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}.
149	// Here, {Region} is the API Gateway region (e.g., us-east-1); {service} is the
150	// name of the integrated AWS service (e.g., s3); and {subdomain} is a designated
151	// subdomain supported by certain AWS service for fast host-name lookup. action can
152	// be used for an AWS service action-based API, using an
153	// Action={name}&{p1}={v1}&p2={v2}... query string. The ensuing {service_api}
154	// refers to a supported action {name} plus any required input parameters.
155	// Alternatively, path can be used for an AWS service path-based API. The ensuing
156	// service_api refers to the path to an AWS service resource, including the region
157	// of the integrated AWS service, if applicable. For example, for integration with
158	// the S3 API of GetObject
159	// (https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html), the uri
160	// can be either
161	// arn:aws:apigateway:us-west-2:s3:action/GetObject&Bucket={bucket}&Key={key} or
162	// arn:aws:apigateway:us-west-2:s3:path/{bucket}/{key}
163	Uri *string
164}
165
166// Represents an HTTP, HTTP_PROXY, AWS, AWS_PROXY, or Mock integration. In the API
167// Gateway console, the built-in Lambda integration is an AWS integration. Creating
168// an API
169// (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html)
170type PutIntegrationOutput struct {
171
172	// A list of request parameters whose values API Gateway caches. To be valid values
173	// for cacheKeyParameters, these parameters must also be specified for
174	// MethodrequestParameters.
175	CacheKeyParameters []string
176
177	// Specifies a group of related cached parameters. By default, API Gateway uses the
178	// resource ID as the cacheNamespace. You can specify the same cacheNamespace
179	// across resources to return the same cached data for requests to different
180	// resources.
181	CacheNamespace *string
182
183	// The (id
184	// (https://docs.aws.amazon.com/apigateway/api-reference/resource/vpc-link/#id)) of
185	// the VpcLink used for the integration when connectionType=VPC_LINK and undefined,
186	// otherwise.
187	ConnectionId *string
188
189	// The type of the network connection to the integration endpoint. The valid value
190	// is INTERNET for connections through the public routable internet or VPC_LINK for
191	// private connections between API Gateway and a network load balancer in a VPC.
192	// The default value is INTERNET.
193	ConnectionType types.ConnectionType
194
195	// Specifies how to handle request payload content type conversions. Supported
196	// values are CONVERT_TO_BINARY and CONVERT_TO_TEXT, with the following
197	// behaviors:
198	//
199	// * CONVERT_TO_BINARY: Converts a request payload from a
200	// Base64-encoded string to the corresponding binary blob.
201	//
202	// * CONVERT_TO_TEXT:
203	// Converts a request payload from a binary blob to a Base64-encoded string.
204	//
205	// If
206	// this property is not defined, the request payload will be passed through from
207	// the method request to integration request without modification, provided that
208	// the passthroughBehavior is configured to support payload pass-through.
209	ContentHandling types.ContentHandlingStrategy
210
211	// Specifies the credentials required for the integration, if any. For AWS
212	// integrations, three options are available. To specify an IAM Role for API
213	// Gateway to assume, use the role's Amazon Resource Name (ARN). To require that
214	// the caller's identity be passed through from the request, specify the string
215	// arn:aws:iam::\*:user/\*. To use resource-based permissions on supported AWS
216	// services, specify null.
217	Credentials *string
218
219	// Specifies the integration's HTTP method type.
220	HttpMethod *string
221
222	// Specifies the integration's responses.
223	// Example: Get integration responses of a
224	// method
225	//
226	// Request
227	//
228	//     GET
229	// /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200
230	// HTTP/1.1 Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com
231	// X-Amz-Date: 20160607T191449Z Authorization: AWS4-HMAC-SHA256
232	// Credential={access_key_ID}/20160607/us-east-1/apigateway/aws4_request,
233	// SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
234	//
235	// Response
236	//
237	// The
238	// successful response returns 200 OK status and a payload as follows: { "_links":
239	// { "curies": { "href":
240	// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html",
241	// "name": "integrationresponse", "templated": true }, "self": { "href":
242	// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200",
243	// "title": "200" }, "integrationresponse:delete": { "href":
244	// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200"
245	// }, "integrationresponse:update": { "href":
246	// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200"
247	// } }, "responseParameters": { "method.response.header.Content-Type":
248	// "'application/xml'" }, "responseTemplates": { "application/json":
249	// "$util.urlDecode(\"%3CkinesisStreams%3E#foreach($stream in
250	// $input.path('$.StreamNames'))%3Cstream%3E%3Cname%3E$stream%3C/name%3E%3C/stream%3E#end%3C/kinesisStreams%3E\")\n"
251	// }, "statusCode": "200" }Creating an API
252	// (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html)
253	IntegrationResponses map[string]types.IntegrationResponse
254
255	// Specifies how the method request body of an unmapped content type will be passed
256	// through the integration request to the back end without transformation. A
257	// content type is unmapped if no mapping template is defined in the integration or
258	// the content type does not match any of the mapped content types, as specified in
259	// requestTemplates. The valid value is one of the following:
260	//
261	// * WHEN_NO_MATCH:
262	// passes the method request body through the integration request to the back end
263	// without transformation when the method request content type does not match any
264	// content type associated with the mapping templates defined in the integration
265	// request.
266	//
267	// * WHEN_NO_TEMPLATES: passes the method request body through the
268	// integration request to the back end without transformation when no mapping
269	// template is defined in the integration request. If a template is defined when
270	// this option is selected, the method request of an unmapped content-type will be
271	// rejected with an HTTP 415 Unsupported Media Type response.
272	//
273	// * NEVER: rejects the
274	// method request with an HTTP 415 Unsupported Media Type response when either the
275	// method request content type does not match any content type associated with the
276	// mapping templates defined in the integration request or no mapping template is
277	// defined in the integration request.
278	PassthroughBehavior *string
279
280	// A key-value map specifying request parameters that are passed from the method
281	// request to the back end. The key is an integration request parameter name and
282	// the associated value is a method request parameter value or static value that
283	// must be enclosed within single quotes and pre-encoded as required by the back
284	// end. The method request parameter value must match the pattern of
285	// method.request.{location}.{name}, where location is querystring, path, or header
286	// and name must be a valid and unique method request parameter name.
287	RequestParameters map[string]string
288
289	// Represents a map of Velocity templates that are applied on the request payload
290	// based on the value of the Content-Type header sent by the client. The content
291	// type value is the key in this map, and the template (as a String) is the value.
292	RequestTemplates map[string]string
293
294	// Custom timeout between 50 and 29,000 milliseconds. The default value is 29,000
295	// milliseconds or 29 seconds.
296	TimeoutInMillis int32
297
298	// Specifies the TLS configuration for an integration.
299	TlsConfig *types.TlsConfig
300
301	// Specifies an API method integration type. The valid value is one of the
302	// following:
303	//
304	// * AWS: for integrating the API method request with an AWS service
305	// action, including the Lambda function-invoking action. With the Lambda
306	// function-invoking action, this is referred to as the Lambda custom integration.
307	// With any other AWS service action, this is known as AWS integration.
308	//
309	// *
310	// AWS_PROXY: for integrating the API method request with the Lambda
311	// function-invoking action with the client request passed through as-is. This
312	// integration is also referred to as the Lambda proxy integration.
313	//
314	// * HTTP: for
315	// integrating the API method request with an HTTP endpoint, including a private
316	// HTTP endpoint within a VPC. This integration is also referred to as the HTTP
317	// custom integration.
318	//
319	// * HTTP_PROXY: for integrating the API method request with
320	// an HTTP endpoint, including a private HTTP endpoint within a VPC, with the
321	// client request passed through as-is. This is also referred to as the HTTP proxy
322	// integration.
323	//
324	// * MOCK: for integrating the API method request with API Gateway as
325	// a "loop-back" endpoint without invoking any backend.
326	//
327	// For the HTTP and HTTP
328	// proxy integrations, each integration can specify a protocol (http/https), port
329	// and path. Standard 80 and 443 ports are supported as well as custom ports above
330	// 1024. An HTTP or HTTP proxy integration with a connectionType of VPC_LINK is
331	// referred to as a private integration and uses a VpcLink to connect API Gateway
332	// to a network load balancer of a VPC.
333	Type types.IntegrationType
334
335	// Specifies Uniform Resource Identifier (URI) of the integration endpoint.
336	//
337	// * For
338	// HTTP or HTTP_PROXY integrations, the URI must be a fully formed, encoded HTTP(S)
339	// URL according to the RFC-3986 specification
340	// (https://en.wikipedia.org/wiki/Uniform_Resource_Identifier), for either standard
341	// integration, where connectionType is not VPC_LINK, or private integration, where
342	// connectionType is VPC_LINK. For a private HTTP integration, the URI is not used
343	// for routing.
344	//
345	// * For AWS or AWS_PROXY integrations, the URI is of the form
346	// arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}.
347	// Here, {Region} is the API Gateway region (e.g., us-east-1); {service} is the
348	// name of the integrated AWS service (e.g., s3); and {subdomain} is a designated
349	// subdomain supported by certain AWS service for fast host-name lookup. action can
350	// be used for an AWS service action-based API, using an
351	// Action={name}&{p1}={v1}&p2={v2}... query string. The ensuing {service_api}
352	// refers to a supported action {name} plus any required input parameters.
353	// Alternatively, path can be used for an AWS service path-based API. The ensuing
354	// service_api refers to the path to an AWS service resource, including the region
355	// of the integrated AWS service, if applicable. For example, for integration with
356	// the S3 API of GetObject
357	// (https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html), the uri
358	// can be either
359	// arn:aws:apigateway:us-west-2:s3:action/GetObject&Bucket={bucket}&Key={key} or
360	// arn:aws:apigateway:us-west-2:s3:path/{bucket}/{key}
361	Uri *string
362
363	// Metadata pertaining to the operation's result.
364	ResultMetadata middleware.Metadata
365}
366
367func addOperationPutIntegrationMiddlewares(stack *middleware.Stack, options Options) (err error) {
368	err = stack.Serialize.Add(&awsRestjson1_serializeOpPutIntegration{}, middleware.After)
369	if err != nil {
370		return err
371	}
372	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpPutIntegration{}, middleware.After)
373	if err != nil {
374		return err
375	}
376	if err = addSetLoggerMiddleware(stack, options); err != nil {
377		return err
378	}
379	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
380		return err
381	}
382	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
383		return err
384	}
385	if err = addResolveEndpointMiddleware(stack, options); err != nil {
386		return err
387	}
388	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
389		return err
390	}
391	if err = addRetryMiddlewares(stack, options); err != nil {
392		return err
393	}
394	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
395		return err
396	}
397	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
398		return err
399	}
400	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
401		return err
402	}
403	if err = addClientUserAgent(stack); err != nil {
404		return err
405	}
406	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
407		return err
408	}
409	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
410		return err
411	}
412	if err = addOpPutIntegrationValidationMiddleware(stack); err != nil {
413		return err
414	}
415	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutIntegration(options.Region), middleware.Before); err != nil {
416		return err
417	}
418	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
419		return err
420	}
421	if err = addResponseErrorMiddleware(stack); err != nil {
422		return err
423	}
424	if err = addAcceptHeader(stack); err != nil {
425		return err
426	}
427	if err = addRequestResponseLogging(stack, options); err != nil {
428		return err
429	}
430	return nil
431}
432
433func newServiceMetadataMiddleware_opPutIntegration(region string) *awsmiddleware.RegisterServiceMetadata {
434	return &awsmiddleware.RegisterServiceMetadata{
435		Region:        region,
436		ServiceID:     ServiceID,
437		SigningName:   "apigateway",
438		OperationName: "PutIntegration",
439	}
440}
441