/
api_op_UpdateMethodResponse.go
271 lines (224 loc) · 9.62 KB
/
api_op_UpdateMethodResponse.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
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package apigateway
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
"github.com/aws/aws-sdk-go-v2/private/protocol"
)
// A request to update an existing MethodResponse resource.
type UpdateMethodResponseInput struct {
_ struct{} `type:"structure"`
// [Required] The HTTP verb of the Method resource.
//
// HttpMethod is a required field
HttpMethod *string `location:"uri" locationName:"http_method" type:"string" required:"true"`
// A list of update operations to be applied to the specified resource and in
// the order specified in this list.
PatchOperations []PatchOperation `locationName:"patchOperations" type:"list"`
// [Required] The Resource identifier for the MethodResponse resource.
//
// ResourceId is a required field
ResourceId *string `location:"uri" locationName:"resource_id" type:"string" required:"true"`
// [Required] The string identifier of the associated RestApi.
//
// RestApiId is a required field
RestApiId *string `location:"uri" locationName:"restapi_id" type:"string" required:"true"`
// [Required] The status code for the MethodResponse resource.
//
// StatusCode is a required field
StatusCode *string `location:"uri" locationName:"status_code" type:"string" required:"true"`
}
// String returns the string representation
func (s UpdateMethodResponseInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *UpdateMethodResponseInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "UpdateMethodResponseInput"}
if s.HttpMethod == nil {
invalidParams.Add(aws.NewErrParamRequired("HttpMethod"))
}
if s.ResourceId == nil {
invalidParams.Add(aws.NewErrParamRequired("ResourceId"))
}
if s.RestApiId == nil {
invalidParams.Add(aws.NewErrParamRequired("RestApiId"))
}
if s.StatusCode == nil {
invalidParams.Add(aws.NewErrParamRequired("StatusCode"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s UpdateMethodResponseInput) MarshalFields(e protocol.FieldEncoder) error {
e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{})
if s.PatchOperations != nil {
v := s.PatchOperations
metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "patchOperations", metadata)
ls0.Start()
for _, v1 := range v {
ls0.ListAddFields(v1)
}
ls0.End()
}
if s.HttpMethod != nil {
v := *s.HttpMethod
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "http_method", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.ResourceId != nil {
v := *s.ResourceId
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "resource_id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.RestApiId != nil {
v := *s.RestApiId
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "restapi_id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.StatusCode != nil {
v := *s.StatusCode
metadata := protocol.Metadata{}
e.SetValue(protocol.PathTarget, "status_code", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
// Represents a method response of a given HTTP status code returned to the
// client. The method response is passed from the back end through the associated
// integration response that can be transformed using a mapping template.
//
// Example: A MethodResponse instance of an API
//
// Request
//
// The example request retrieves a MethodResponse of the 200 status code.
// GET /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200
// HTTP/1.1 Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com
// X-Amz-Date: 20160603T222952Z 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 200 OK status and a payload as follows:
// { "_links": { "curies": { "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/responses/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" }
//
// Method, IntegrationResponse, Integration Creating an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html)
type UpdateMethodResponseOutput struct {
_ struct{} `type:"structure"`
// Specifies the Model resources used for the response's content-type. Response
// models are represented as a key/value map, with a content-type as the key
// and a Model name as the value.
ResponseModels map[string]string `locationName:"responseModels" type:"map"`
// A key-value map specifying required or optional response parameters that
// API Gateway can send back to the caller. A key defines a method response
// header and the value specifies whether the associated method response header
// is required or not. The expression of the key must match the pattern method.response.header.{name},
// where name is a valid and unique header name. API Gateway passes certain
// integration response data to the method response headers specified here according
// to the mapping you prescribe in the API's IntegrationResponse. The integration
// response data that can be mapped include an integration response header expressed
// in integration.response.header.{name}, a static value enclosed within a pair
// of single quotes (e.g., 'application/json'), or a JSON expression from the
// back-end response payload in the form of integration.response.body.{JSON-expression},
// where JSON-expression is a valid JSON expression without the $ prefix.)
ResponseParameters map[string]bool `locationName:"responseParameters" type:"map"`
// The method response's status code.
StatusCode *string `locationName:"statusCode" type:"string"`
}
// String returns the string representation
func (s UpdateMethodResponseOutput) String() string {
return awsutil.Prettify(s)
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s UpdateMethodResponseOutput) MarshalFields(e protocol.FieldEncoder) error {
if s.ResponseModels != nil {
v := s.ResponseModels
metadata := protocol.Metadata{}
ms0 := e.Map(protocol.BodyTarget, "responseModels", metadata)
ms0.Start()
for k1, v1 := range v {
ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)})
}
ms0.End()
}
if s.ResponseParameters != nil {
v := s.ResponseParameters
metadata := protocol.Metadata{}
ms0 := e.Map(protocol.BodyTarget, "responseParameters", metadata)
ms0.Start()
for k1, v1 := range v {
ms0.MapSetValue(k1, protocol.BoolValue(v1))
}
ms0.End()
}
if s.StatusCode != nil {
v := *s.StatusCode
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "statusCode", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
const opUpdateMethodResponse = "UpdateMethodResponse"
// UpdateMethodResponseRequest returns a request value for making API operation for
// Amazon API Gateway.
//
// Updates an existing MethodResponse resource.
//
// // Example sending a request using UpdateMethodResponseRequest.
// req := client.UpdateMethodResponseRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
func (c *Client) UpdateMethodResponseRequest(input *UpdateMethodResponseInput) UpdateMethodResponseRequest {
op := &aws.Operation{
Name: opUpdateMethodResponse,
HTTPMethod: "PATCH",
HTTPPath: "/restapis/{restapi_id}/resources/{resource_id}/methods/{http_method}/responses/{status_code}",
}
if input == nil {
input = &UpdateMethodResponseInput{}
}
req := c.newRequest(op, input, &UpdateMethodResponseOutput{})
return UpdateMethodResponseRequest{Request: req, Input: input, Copy: c.UpdateMethodResponseRequest}
}
// UpdateMethodResponseRequest is the request type for the
// UpdateMethodResponse API operation.
type UpdateMethodResponseRequest struct {
*aws.Request
Input *UpdateMethodResponseInput
Copy func(*UpdateMethodResponseInput) UpdateMethodResponseRequest
}
// Send marshals and sends the UpdateMethodResponse API request.
func (r UpdateMethodResponseRequest) Send(ctx context.Context) (*UpdateMethodResponseResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &UpdateMethodResponseResponse{
UpdateMethodResponseOutput: r.Request.Data.(*UpdateMethodResponseOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// UpdateMethodResponseResponse is the response type for the
// UpdateMethodResponse API operation.
type UpdateMethodResponseResponse struct {
*UpdateMethodResponseOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// UpdateMethodResponse request.
func (r *UpdateMethodResponseResponse) SDKResponseMetdata() *aws.Response {
return r.response
}