-
Notifications
You must be signed in to change notification settings - Fork 598
/
api_op_PutMethod.go
381 lines (346 loc) · 18.9 KB
/
api_op_PutMethod.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
// Code generated by smithy-go-codegen DO NOT EDIT.
package apigateway
import (
"context"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/service/apigateway/types"
smithy "github.com/awslabs/smithy-go"
"github.com/awslabs/smithy-go/middleware"
smithyhttp "github.com/awslabs/smithy-go/transport/http"
)
// Add a method to an existing Resource () resource.
func (c *Client) PutMethod(ctx context.Context, params *PutMethodInput, optFns ...func(*Options)) (*PutMethodOutput, error) {
stack := middleware.NewStack("PutMethod", smithyhttp.NewStackRequest)
options := c.options.Copy()
for _, fn := range optFns {
fn(&options)
}
addawsRestjson1_serdeOpPutMethodMiddlewares(stack)
awsmiddleware.AddRequestInvocationIDMiddleware(stack)
smithyhttp.AddContentLengthMiddleware(stack)
AddResolveEndpointMiddleware(stack, options)
v4.AddComputePayloadSHA256Middleware(stack)
retry.AddRetryMiddlewares(stack, options)
addHTTPSignerV4Middleware(stack, options)
awsmiddleware.AddAttemptClockSkewMiddleware(stack)
addClientUserAgent(stack)
smithyhttp.AddErrorCloseResponseBodyMiddleware(stack)
smithyhttp.AddCloseResponseBodyMiddleware(stack)
addOpPutMethodValidationMiddleware(stack)
stack.Initialize.Add(newServiceMetadataMiddleware_opPutMethod(options.Region), middleware.Before)
addRequestIDRetrieverMiddleware(stack)
addResponseErrorMiddleware(stack)
addAcceptHeader(stack)
for _, fn := range options.APIOptions {
if err := fn(stack); err != nil {
return nil, err
}
}
handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack)
result, metadata, err := handler.Handle(ctx, params)
if err != nil {
return nil, &smithy.OperationError{
ServiceID: ServiceID,
OperationName: "PutMethod",
Err: err,
}
}
out := result.(*PutMethodOutput)
out.ResultMetadata = metadata
return out, nil
}
// Request to add a method to an existing Resource () resource.
type PutMethodInput struct {
// [Required] The string identifier of the associated RestApi ().
//
// This member is required.
RestApiId *string
Name *string
// [Required] The Resource () identifier for the new Method () resource.
//
// This member is required.
ResourceId *string
Template *bool
// [Required] Specifies the method request's HTTP method type.
//
// This member is required.
HttpMethod *string
Title *string
TemplateSkipList []*string
// Specifies the Model () resources used for the request's content type. Request
// models are represented as a key/value map, with a content type as the key and a
// Model () name as the value.
RequestModels map[string]*string
// A human-friendly operation identifier for the method. For example, you can
// assign the operationName of ListPets for the GET /pets method in the PetStore
// example.
OperationName *string
// A list of authorization scopes configured on the method. The scopes are used
// with a COGNITO_USER_POOLS authorizer to authorize the method invocation. The
// authorization works by matching the method scopes against the scopes parsed from
// the access token in the incoming request. The method invocation is authorized if
// any method scopes matches a claimed scope in the access token. Otherwise, the
// invocation is not authorized. When the method scope is configured, the client
// must provide an access token instead of an identity token for authorization
// purposes.
AuthorizationScopes []*string
// [Required] The method's authorization type. Valid values are NONE for open
// access, AWS_IAM for using AWS IAM permissions, CUSTOM for using a custom
// authorizer, or COGNITO_USER_POOLS for using a Cognito user pool.
//
// This member is required.
AuthorizationType *string
// Specifies whether the method required a valid ApiKey ().
ApiKeyRequired *bool
// Specifies the identifier of an Authorizer () to use on this Method, if the type
// is CUSTOM or COGNITO_USER_POOLS. The authorizer identifier is generated by API
// Gateway when you created the authorizer.
AuthorizerId *string
// The identifier of a RequestValidator () for validating the method request.
RequestValidatorId *string
// A key-value map defining required or optional method request parameters that can
// be accepted by API Gateway. A key defines a method request parameter name
// matching the pattern of method.request.{location}.{name}, where location is
// querystring, path, or header and name is a valid and unique parameter name. The
// value associated with the key is a Boolean flag indicating whether the parameter
// is required (true) or optional (false). The method request parameter names
// defined here are available in Integration () to be mapped to integration request
// parameters or body-mapping templates.
RequestParameters map[string]*bool
}
// Represents a client-facing interface by which the client calls the API to access
// back-end resources. A Method resource is integrated with an Integration ()
// resource. Both consist of a request and one or more responses. The method
// request takes the client input that is passed to the back end through the
// integration request. A method response returns the output from the back end to
// the client through an integration response. A method request is embodied in a
// Method resource, whereas an integration request is embodied in an Integration ()
// resource. On the other hand, a method response is represented by a
// MethodResponse () resource, whereas an integration response is represented by an
// IntegrationResponse () resource.
// Example: Retrive the GET method on a specified
// resource
//
// Request
//
// The following example request retrieves the information about
// the GET method on an API resource (3kzxbg5sa2) of an API (fugvjdxtri). GET
// /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET HTTP/1.1 Content-Type:
// application/json Host: apigateway.us-east-1.amazonaws.com X-Amz-Date:
// 20160603T210259Z Authorization: AWS4-HMAC-SHA256
// Credential={access_key_ID}/20160603/us-east-1/apigateway/aws4_request,
// SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
// Response
//
// The
// successful response returns a 200 OK status code and a payload similar to the
// following: { "_links": { "curies": [ { "href":
// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-{rel}.html",
// "name": "integration", "templated": true }, { "href":
// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html",
// "name": "integrationresponse", "templated": true }, { "href":
// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-{rel}.html",
// "name": "method", "templated": true }, { "href":
// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-response-{rel}.html",
// "name": "methodresponse", "templated": true } ], "self": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET", "name": "GET", "title":
// "GET" }, "integration:put": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" },
// "method:delete": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET" }, "method:integration":
// { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" },
// "method:responses": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200", "name":
// "200", "title": "200" }, "method:update": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET" }, "methodresponse:put":
// { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/{status_code}",
// "templated": true } }, "apiKeyRequired": true, "authorizationType": "NONE",
// "httpMethod": "GET", "_embedded": { "method:integration": { "_links": { "self":
// { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" },
// "integration:delete": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" },
// "integration:responses": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200",
// "name": "200", "title": "200" }, "integration:update": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" },
// "integrationresponse:put": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/{status_code}",
// "templated": true } }, "cacheKeyParameters": [], "cacheNamespace": "3kzxbg5sa2",
// "credentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole", "httpMethod":
// "POST", "passthroughBehavior": "WHEN_NO_MATCH", "requestParameters": {
// "integration.request.header.Content-Type": "'application/x-amz-json-1.1'" },
// "requestTemplates": { "application/json": "{\n}" }, "type": "AWS", "uri":
// "arn:aws:apigateway:us-east-1:kinesis:action/ListStreams", "_embedded": {
// "integration:responses": { "_links": { "self": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200",
// "name": "200", "title": "200" }, "integrationresponse:delete": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200"
// }, "integrationresponse:update": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200"
// } }, "responseParameters": { "method.response.header.Content-Type":
// "'application/xml'" }, "responseTemplates": { "application/json":
// "$util.urlDecode(\"%3CkinesisStreams%3E%23foreach(%24stream%20in%20%24input.path(%27%24.StreamNames%27))%3Cstream%3E%3Cname%3E%24stream%3C%2Fname%3E%3C%2Fstream%3E%23end%3C%2FkinesisStreams%3E\")"
// }, "statusCode": "200" } } }, "method:responses": { "_links": { "self": {
// "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200",
// "name": "200", "title": "200" }, "methodresponse:delete": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" },
// "methodresponse:update": { "href":
// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" } },
// "responseModels": { "application/json": "Empty" }, "responseParameters": {
// "method.response.header.Content-Type": false }, "statusCode": "200" } } } In the
// example above, the response template for the 200 OK response maps the JSON
// output from the ListStreams action in the back end to an XML output. The mapping
// template is URL-encoded as
// %3CkinesisStreams%3E%23foreach(%24stream%20in%20%24input.path(%27%24.StreamNames%27))%3Cstream%3E%3Cname%3E%24stream%3C%2Fname%3E%3C%2Fstream%3E%23end%3C%2FkinesisStreams%3E
// and the output is decoded using the $util.urlDecode()
// (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#util-templat-reference)
// helper function. MethodResponse (), Integration (), IntegrationResponse (),
// Resource (), Set up an API's method
// (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings.html)
type PutMethodOutput struct {
// A key-value map defining required or optional method request parameters that can
// be accepted by API Gateway. A key is a method request parameter name matching
// the pattern of method.request.{location}.{name}, where location is querystring,
// path, or header and name is a valid and unique parameter name. The value
// associated with the key is a Boolean flag indicating whether the parameter is
// required (true) or optional (false). The method request parameter names defined
// here are available in Integration () to be mapped to integration request
// parameters or templates.
RequestParameters map[string]*bool
// The method's authorization type. Valid values are NONE for open access, AWS_IAM
// for using AWS IAM permissions, CUSTOM for using a custom authorizer, or
// COGNITO_USER_POOLS for using a Cognito user pool.
AuthorizationType *string
// The method's HTTP verb.
HttpMethod *string
// Gets a method response associated with a given HTTP status code. The collection
// of method responses are encapsulated in a key-value map, where the key is a
// response's HTTP status code and the value is a MethodResponse () resource that
// specifies the response returned to the caller from the back end through the
// integration response.
// Example: Get a 200 OK response of a GET method
//
// Request
//
//
// GET /restapis/uojnr9hd57/resources/0cjtch/methods/GET/responses/200 HTTP/1.1
// Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com
// Content-Length: 117 X-Amz-Date: 20160613T215008Z Authorization: AWS4-HMAC-SHA256
// Credential={access_key_ID}/20160613/us-east-1/apigateway/aws4_request,
// SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
//
// Response
//
// The
// successful response returns a 200 OK status code and a payload similar to the
// following: { "_links": { "curies": { "href":
// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-response-{rel}.html",
// "name": "methodresponse", "templated": true }, "self": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/responses/200", "title":
// "200" }, "methodresponse:delete": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/responses/200" },
// "methodresponse:update": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/responses/200" } },
// "responseModels": { "application/json": "Empty" }, "responseParameters": {
// "method.response.header.operator": false, "method.response.header.operand_2":
// false, "method.response.header.operand_1": false }, "statusCode": "200" }AWS CLI
// (https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-method-response.html)
MethodResponses map[string]*types.MethodResponse
// The identifier of a RequestValidator () for request validation.
RequestValidatorId *string
// The identifier of an Authorizer () to use on this method. The authorizationType
// must be CUSTOM.
AuthorizerId *string
// Gets the method's integration responsible for passing the client-submitted
// request to the back end and performing necessary transformations to make the
// request compliant with the back end.
// Example:
//
// Request
//
// GET
// /restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration HTTP/1.1
// Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com
// Content-Length: 117 X-Amz-Date: 20160613T213210Z Authorization: AWS4-HMAC-SHA256
// Credential={access_key_ID}/20160613/us-east-1/apigateway/aws4_request,
// SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
//
// Response
//
// The
// successful response returns a 200 OK status code and a payload similar to the
// following: { "_links": { "curies": [ { "href":
// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-{rel}.html",
// "name": "integration", "templated": true }, { "href":
// "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html",
// "name": "integrationresponse", "templated": true } ], "self": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration" },
// "integration:delete": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration" },
// "integration:responses": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/200",
// "name": "200", "title": "200" }, "integration:update": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration" },
// "integrationresponse:put": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/{status_code}",
// "templated": true } }, "cacheKeyParameters": [], "cacheNamespace": "0cjtch",
// "credentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole", "httpMethod":
// "POST", "passthroughBehavior": "WHEN_NO_MATCH", "requestTemplates": {
// "application/json": "{\n \"a\": \"$input.params('operand1')\",\n \"b\":
// \"$input.params('operand2')\", \n \"op\": \"$input.params('operator')\" \n}" },
// "type": "AWS", "uri":
// "arn:aws:apigateway:us-west-2:lambda:path//2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations",
// "_embedded": { "integration:responses": { "_links": { "self": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/200",
// "name": "200", "title": "200" }, "integrationresponse:delete": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/200" },
// "integrationresponse:update": { "href":
// "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/200" }
// }, "responseParameters": { "method.response.header.operator":
// "integration.response.body.op", "method.response.header.operand_2":
// "integration.response.body.b", "method.response.header.operand_1":
// "integration.response.body.a" }, "responseTemplates": { "application/json":
// "#set($res = $input.path('$'))\n{\n \"result\": \"$res.a, $res.b, $res.op =>
// $res.c\",\n \"a\" : \"$res.a\",\n \"b\" : \"$res.b\",\n \"op\" : \"$res.op\",\n
// \"c\" : \"$res.c\"\n}" }, "selectionPattern": "", "statusCode": "200" } } }AWS
// CLI
// (https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-integration.html)
MethodIntegration *types.Integration
// A human-friendly operation identifier for the method. For example, you can
// assign the operationName of ListPets for the GET /pets method in the PetStore
// example.
OperationName *string
// A boolean flag specifying whether a valid ApiKey () is required to invoke this
// method.
ApiKeyRequired *bool
// A list of authorization scopes configured on the method. The scopes are used
// with a COGNITO_USER_POOLS authorizer to authorize the method invocation. The
// authorization works by matching the method scopes against the scopes parsed from
// the access token in the incoming request. The method invocation is authorized if
// any method scopes matches a claimed scope in the access token. Otherwise, the
// invocation is not authorized. When the method scope is configured, the client
// must provide an access token instead of an identity token for authorization
// purposes.
AuthorizationScopes []*string
// A key-value map specifying data schemas, represented by Model () resources, (as
// the mapped value) of the request payloads of given content types (as the mapping
// key).
RequestModels map[string]*string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
}
func addawsRestjson1_serdeOpPutMethodMiddlewares(stack *middleware.Stack) {
stack.Serialize.Add(&awsRestjson1_serializeOpPutMethod{}, middleware.After)
stack.Deserialize.Add(&awsRestjson1_deserializeOpPutMethod{}, middleware.After)
}
func newServiceMetadataMiddleware_opPutMethod(region string) awsmiddleware.RegisterServiceMetadata {
return awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
SigningName: "apigateway",
OperationName: "PutMethod",
}
}