Skip to content

Commit 50b27f1

Browse files
authored
chore: codegen for RPC code with DRYness (#837)
1 parent c3086ef commit 50b27f1

File tree

125 files changed

+12275
-42246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+12275
-42246
lines changed

clients/client-acm-pca/protocols/Aws_json1_1.ts

Lines changed: 63 additions & 180 deletions
Large diffs are not rendered by default.

clients/client-acm/protocols/Aws_json1_1.ts

Lines changed: 49 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import {
106106
import { SmithyException as __SmithyException } from "@aws-sdk/smithy-client";
107107
import {
108108
Endpoint as __Endpoint,
109+
HeaderBag as __HeaderBag,
109110
MetadataBearer as __MetadataBearer,
110111
ResponseMetadata as __ResponseMetadata,
111112
SerdeContext as __SerdeContext
@@ -115,273 +116,182 @@ export async function serializeAws_json1_1AddTagsToCertificateCommand(
115116
input: AddTagsToCertificateCommandInput,
116117
context: __SerdeContext
117118
): Promise<__HttpRequest> {
118-
const headers: any = {};
119+
const headers: __HeaderBag = {};
119120
headers["Content-Type"] = "application/x-amz-json-1.1";
120121
headers["X-Amz-Target"] = "CertificateManager.AddTagsToCertificate";
121122
let body: any = {};
122123
body = JSON.stringify(
123124
serializeAws_json1_1AddTagsToCertificateRequest(input, context)
124125
);
125-
return new __HttpRequest({
126-
...context.endpoint,
127-
protocol: "https",
128-
method: "POST",
129-
path: "/",
130-
headers: headers,
131-
body: body
132-
});
126+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
133127
}
134128

135129
export async function serializeAws_json1_1DeleteCertificateCommand(
136130
input: DeleteCertificateCommandInput,
137131
context: __SerdeContext
138132
): Promise<__HttpRequest> {
139-
const headers: any = {};
133+
const headers: __HeaderBag = {};
140134
headers["Content-Type"] = "application/x-amz-json-1.1";
141135
headers["X-Amz-Target"] = "CertificateManager.DeleteCertificate";
142136
let body: any = {};
143137
body = JSON.stringify(
144138
serializeAws_json1_1DeleteCertificateRequest(input, context)
145139
);
146-
return new __HttpRequest({
147-
...context.endpoint,
148-
protocol: "https",
149-
method: "POST",
150-
path: "/",
151-
headers: headers,
152-
body: body
153-
});
140+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
154141
}
155142

156143
export async function serializeAws_json1_1DescribeCertificateCommand(
157144
input: DescribeCertificateCommandInput,
158145
context: __SerdeContext
159146
): Promise<__HttpRequest> {
160-
const headers: any = {};
147+
const headers: __HeaderBag = {};
161148
headers["Content-Type"] = "application/x-amz-json-1.1";
162149
headers["X-Amz-Target"] = "CertificateManager.DescribeCertificate";
163150
let body: any = {};
164151
body = JSON.stringify(
165152
serializeAws_json1_1DescribeCertificateRequest(input, context)
166153
);
167-
return new __HttpRequest({
168-
...context.endpoint,
169-
protocol: "https",
170-
method: "POST",
171-
path: "/",
172-
headers: headers,
173-
body: body
174-
});
154+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
175155
}
176156

177157
export async function serializeAws_json1_1ExportCertificateCommand(
178158
input: ExportCertificateCommandInput,
179159
context: __SerdeContext
180160
): Promise<__HttpRequest> {
181-
const headers: any = {};
161+
const headers: __HeaderBag = {};
182162
headers["Content-Type"] = "application/x-amz-json-1.1";
183163
headers["X-Amz-Target"] = "CertificateManager.ExportCertificate";
184164
let body: any = {};
185165
body = JSON.stringify(
186166
serializeAws_json1_1ExportCertificateRequest(input, context)
187167
);
188-
return new __HttpRequest({
189-
...context.endpoint,
190-
protocol: "https",
191-
method: "POST",
192-
path: "/",
193-
headers: headers,
194-
body: body
195-
});
168+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
196169
}
197170

198171
export async function serializeAws_json1_1GetCertificateCommand(
199172
input: GetCertificateCommandInput,
200173
context: __SerdeContext
201174
): Promise<__HttpRequest> {
202-
const headers: any = {};
175+
const headers: __HeaderBag = {};
203176
headers["Content-Type"] = "application/x-amz-json-1.1";
204177
headers["X-Amz-Target"] = "CertificateManager.GetCertificate";
205178
let body: any = {};
206179
body = JSON.stringify(
207180
serializeAws_json1_1GetCertificateRequest(input, context)
208181
);
209-
return new __HttpRequest({
210-
...context.endpoint,
211-
protocol: "https",
212-
method: "POST",
213-
path: "/",
214-
headers: headers,
215-
body: body
216-
});
182+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
217183
}
218184

219185
export async function serializeAws_json1_1ImportCertificateCommand(
220186
input: ImportCertificateCommandInput,
221187
context: __SerdeContext
222188
): Promise<__HttpRequest> {
223-
const headers: any = {};
189+
const headers: __HeaderBag = {};
224190
headers["Content-Type"] = "application/x-amz-json-1.1";
225191
headers["X-Amz-Target"] = "CertificateManager.ImportCertificate";
226192
let body: any = {};
227193
body = JSON.stringify(
228194
serializeAws_json1_1ImportCertificateRequest(input, context)
229195
);
230-
return new __HttpRequest({
231-
...context.endpoint,
232-
protocol: "https",
233-
method: "POST",
234-
path: "/",
235-
headers: headers,
236-
body: body
237-
});
196+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
238197
}
239198

240199
export async function serializeAws_json1_1ListCertificatesCommand(
241200
input: ListCertificatesCommandInput,
242201
context: __SerdeContext
243202
): Promise<__HttpRequest> {
244-
const headers: any = {};
203+
const headers: __HeaderBag = {};
245204
headers["Content-Type"] = "application/x-amz-json-1.1";
246205
headers["X-Amz-Target"] = "CertificateManager.ListCertificates";
247206
let body: any = {};
248207
body = JSON.stringify(
249208
serializeAws_json1_1ListCertificatesRequest(input, context)
250209
);
251-
return new __HttpRequest({
252-
...context.endpoint,
253-
protocol: "https",
254-
method: "POST",
255-
path: "/",
256-
headers: headers,
257-
body: body
258-
});
210+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
259211
}
260212

261213
export async function serializeAws_json1_1ListTagsForCertificateCommand(
262214
input: ListTagsForCertificateCommandInput,
263215
context: __SerdeContext
264216
): Promise<__HttpRequest> {
265-
const headers: any = {};
217+
const headers: __HeaderBag = {};
266218
headers["Content-Type"] = "application/x-amz-json-1.1";
267219
headers["X-Amz-Target"] = "CertificateManager.ListTagsForCertificate";
268220
let body: any = {};
269221
body = JSON.stringify(
270222
serializeAws_json1_1ListTagsForCertificateRequest(input, context)
271223
);
272-
return new __HttpRequest({
273-
...context.endpoint,
274-
protocol: "https",
275-
method: "POST",
276-
path: "/",
277-
headers: headers,
278-
body: body
279-
});
224+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
280225
}
281226

282227
export async function serializeAws_json1_1RemoveTagsFromCertificateCommand(
283228
input: RemoveTagsFromCertificateCommandInput,
284229
context: __SerdeContext
285230
): Promise<__HttpRequest> {
286-
const headers: any = {};
231+
const headers: __HeaderBag = {};
287232
headers["Content-Type"] = "application/x-amz-json-1.1";
288233
headers["X-Amz-Target"] = "CertificateManager.RemoveTagsFromCertificate";
289234
let body: any = {};
290235
body = JSON.stringify(
291236
serializeAws_json1_1RemoveTagsFromCertificateRequest(input, context)
292237
);
293-
return new __HttpRequest({
294-
...context.endpoint,
295-
protocol: "https",
296-
method: "POST",
297-
path: "/",
298-
headers: headers,
299-
body: body
300-
});
238+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
301239
}
302240

303241
export async function serializeAws_json1_1RenewCertificateCommand(
304242
input: RenewCertificateCommandInput,
305243
context: __SerdeContext
306244
): Promise<__HttpRequest> {
307-
const headers: any = {};
245+
const headers: __HeaderBag = {};
308246
headers["Content-Type"] = "application/x-amz-json-1.1";
309247
headers["X-Amz-Target"] = "CertificateManager.RenewCertificate";
310248
let body: any = {};
311249
body = JSON.stringify(
312250
serializeAws_json1_1RenewCertificateRequest(input, context)
313251
);
314-
return new __HttpRequest({
315-
...context.endpoint,
316-
protocol: "https",
317-
method: "POST",
318-
path: "/",
319-
headers: headers,
320-
body: body
321-
});
252+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
322253
}
323254

324255
export async function serializeAws_json1_1RequestCertificateCommand(
325256
input: RequestCertificateCommandInput,
326257
context: __SerdeContext
327258
): Promise<__HttpRequest> {
328-
const headers: any = {};
259+
const headers: __HeaderBag = {};
329260
headers["Content-Type"] = "application/x-amz-json-1.1";
330261
headers["X-Amz-Target"] = "CertificateManager.RequestCertificate";
331262
let body: any = {};
332263
body = JSON.stringify(
333264
serializeAws_json1_1RequestCertificateRequest(input, context)
334265
);
335-
return new __HttpRequest({
336-
...context.endpoint,
337-
protocol: "https",
338-
method: "POST",
339-
path: "/",
340-
headers: headers,
341-
body: body
342-
});
266+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
343267
}
344268

345269
export async function serializeAws_json1_1ResendValidationEmailCommand(
346270
input: ResendValidationEmailCommandInput,
347271
context: __SerdeContext
348272
): Promise<__HttpRequest> {
349-
const headers: any = {};
273+
const headers: __HeaderBag = {};
350274
headers["Content-Type"] = "application/x-amz-json-1.1";
351275
headers["X-Amz-Target"] = "CertificateManager.ResendValidationEmail";
352276
let body: any = {};
353277
body = JSON.stringify(
354278
serializeAws_json1_1ResendValidationEmailRequest(input, context)
355279
);
356-
return new __HttpRequest({
357-
...context.endpoint,
358-
protocol: "https",
359-
method: "POST",
360-
path: "/",
361-
headers: headers,
362-
body: body
363-
});
280+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
364281
}
365282

366283
export async function serializeAws_json1_1UpdateCertificateOptionsCommand(
367284
input: UpdateCertificateOptionsCommandInput,
368285
context: __SerdeContext
369286
): Promise<__HttpRequest> {
370-
const headers: any = {};
287+
const headers: __HeaderBag = {};
371288
headers["Content-Type"] = "application/x-amz-json-1.1";
372289
headers["X-Amz-Target"] = "CertificateManager.UpdateCertificateOptions";
373290
let body: any = {};
374291
body = JSON.stringify(
375292
serializeAws_json1_1UpdateCertificateOptionsRequest(input, context)
376293
);
377-
return new __HttpRequest({
378-
...context.endpoint,
379-
protocol: "https",
380-
method: "POST",
381-
path: "/",
382-
headers: headers,
383-
body: body
384-
});
294+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
385295
}
386296

387297
export async function deserializeAws_json1_1AddTagsToCertificateCommand(
@@ -2594,6 +2504,28 @@ const collectBodyString = (
25942504
);
25952505
};
25962506

2507+
const buildHttpRpcRequest = (
2508+
context: __SerdeContext,
2509+
headers: __HeaderBag,
2510+
path: string,
2511+
resolvedHostname: string | undefined,
2512+
body: any
2513+
): __HttpRequest => {
2514+
const contents: any = {
2515+
...context.endpoint,
2516+
protocol: "https",
2517+
method: "POST",
2518+
path: path,
2519+
headers: headers
2520+
};
2521+
if (resolvedHostname !== undefined) {
2522+
contents.hostname = resolvedHostname;
2523+
}
2524+
if (body !== undefined) {
2525+
contents.body = body;
2526+
}
2527+
return new __HttpRequest(contents);
2528+
};
25972529
const parseBody = (streamBody: any, context: __SerdeContext): any => {
25982530
return collectBodyString(streamBody, context).then(encoded => {
25992531
if (encoded.length) {

0 commit comments

Comments
 (0)