Skip to content

Commit 7f5567b

Browse files
chore(codegen): update to Smithy 1.12.0 (#2878)
* chore(codegen): update to Smithy 1.12.0 * chore(codegen): regenerate using Smithy 1.12.0 Some malformed request tests are applied to the restJson1 service, which results in unused client commands being generated for the non-server tests, hence the large batch of new files in the aws-restjson protocol tests.
1 parent 53b4243 commit 7f5567b

File tree

69 files changed

+8442
-642
lines changed

Some content is hidden

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

69 files changed

+8442
-642
lines changed

codegen/generic-client-test-codegen/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ plugins {
2020
}
2121

2222
dependencies {
23-
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.11.0, 1.12.0[")
23+
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.12.0, 1.13.0[")
2424
implementation(project(":smithy-aws-typescript-codegen"))
2525
}
2626

codegen/protocol-test-codegen/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ plugins {
2020
}
2121

2222
dependencies {
23-
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.11.0, 1.12.0[")
23+
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.12.0, 1.13.0[")
2424
implementation(project(":smithy-aws-typescript-codegen"))
2525
}
2626

codegen/sdk-codegen/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ import software.amazon.smithy.aws.traits.ServiceTrait
2121
import kotlin.streams.toList
2222

2323
buildscript {
24+
repositories {
25+
mavenCentral()
26+
}
2427
dependencies {
25-
"classpath"("software.amazon.smithy:smithy-aws-traits:[1.11.0,1.12.0[")
28+
"classpath"("software.amazon.smithy:smithy-aws-traits:[1.12.0,1.13.0[")
2629
}
2730
}
2831

codegen/smithy-aws-typescript-codegen/build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ buildscript {
2525
mavenCentral()
2626
}
2727
dependencies {
28-
classpath("software.amazon.smithy:smithy-model:[1.11.0, 1.12.0[")
28+
classpath("software.amazon.smithy:smithy-model:[1.12.0, 1.13.0[")
2929
}
3030
}
3131

3232
dependencies {
33-
api("software.amazon.smithy:smithy-aws-cloudformation-traits:[1.11.0, 1.12.0[")
34-
api("software.amazon.smithy:smithy-aws-traits:[1.11.0, 1.12.0[")
35-
api("software.amazon.smithy:smithy-waiters:[1.11.0, 1.12.0[")
36-
api("software.amazon.smithy:smithy-aws-iam-traits:[1.11.0, 1.12.0[")
37-
api("software.amazon.smithy:smithy-protocol-test-traits:[1.11.0, 1.12.0[")
33+
api("software.amazon.smithy:smithy-aws-cloudformation-traits:[1.12.0, 1.13.0[")
34+
api("software.amazon.smithy:smithy-aws-traits:[1.12.0, 1.13.0[")
35+
api("software.amazon.smithy:smithy-waiters:[1.12.0, 1.13.0[")
36+
api("software.amazon.smithy:smithy-aws-iam-traits:[1.12.0, 1.13.0[")
37+
api("software.amazon.smithy:smithy-protocol-test-traits:[1.12.0, 1.13.0[")
3838
api("software.amazon.smithy.typescript:smithy-typescript-codegen:0.6.0")
3939
}
4040

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,6 @@ private static boolean filterMalformedRequestTests(
327327
return true;
328328
}
329329

330-
//TODO: Fixed after Smithy 1.11.0
331-
if (testCase.getId().equals("RestJsonPathTimestampDefaultRejectsDifferent8601Formats_case14")) {
332-
return true;
333-
}
334-
335330
return false;
336331
}
337332
}

codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AwsServiceIdIntegrationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public void testSomeLibraryMethod() {
2727
Shape service = model.expectShape((ShapeId.from("smithy.example#OriginalName")));
2828
AwsServiceIdIntegration integration = new AwsServiceIdIntegration();
2929
TypeScriptSettings settings = new TypeScriptSettings();
30+
settings.setService(ShapeId.from("smithy.example#OriginalName"));
3031
SymbolProvider provider = TypeScriptCodegenPlugin.createSymbolProvider(model, settings);
3132
SymbolProvider decorated = integration.decorateSymbolProvider(settings, model, provider);
3233
Symbol symbol = decorated.toSymbol(service);

protocol_tests/aws-ec2/src/EC2Protocol.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import {
2020
GreetingWithErrorsCommandInput,
2121
GreetingWithErrorsCommandOutput,
2222
} from "./commands/GreetingWithErrorsCommand";
23+
import {
24+
HostWithPathOperationCommand,
25+
HostWithPathOperationCommandInput,
26+
HostWithPathOperationCommandOutput,
27+
} from "./commands/HostWithPathOperationCommand";
2328
import {
2429
IgnoresWrappingXmlNameCommand,
2530
IgnoresWrappingXmlNameCommandInput,
@@ -219,6 +224,35 @@ export class EC2Protocol extends EC2ProtocolClient {
219224
}
220225
}
221226

227+
public hostWithPathOperation(
228+
args: HostWithPathOperationCommandInput,
229+
options?: __HttpHandlerOptions
230+
): Promise<HostWithPathOperationCommandOutput>;
231+
public hostWithPathOperation(
232+
args: HostWithPathOperationCommandInput,
233+
cb: (err: any, data?: HostWithPathOperationCommandOutput) => void
234+
): void;
235+
public hostWithPathOperation(
236+
args: HostWithPathOperationCommandInput,
237+
options: __HttpHandlerOptions,
238+
cb: (err: any, data?: HostWithPathOperationCommandOutput) => void
239+
): void;
240+
public hostWithPathOperation(
241+
args: HostWithPathOperationCommandInput,
242+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: HostWithPathOperationCommandOutput) => void),
243+
cb?: (err: any, data?: HostWithPathOperationCommandOutput) => void
244+
): Promise<HostWithPathOperationCommandOutput> | void {
245+
const command = new HostWithPathOperationCommand(args);
246+
if (typeof optionsOrCb === "function") {
247+
this.send(command, optionsOrCb);
248+
} else if (typeof cb === "function") {
249+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
250+
this.send(command, optionsOrCb || {}, cb);
251+
} else {
252+
return this.send(command, optionsOrCb);
253+
}
254+
}
255+
222256
/**
223257
* The xmlName trait on the output structure is ignored in AWS Query.
224258
*

protocol_tests/aws-ec2/src/EC2ProtocolClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ import {
5252
EndpointWithHostLabelOperationCommandOutput,
5353
} from "./commands/EndpointWithHostLabelOperationCommand";
5454
import { GreetingWithErrorsCommandInput, GreetingWithErrorsCommandOutput } from "./commands/GreetingWithErrorsCommand";
55+
import {
56+
HostWithPathOperationCommandInput,
57+
HostWithPathOperationCommandOutput,
58+
} from "./commands/HostWithPathOperationCommand";
5559
import {
5660
IgnoresWrappingXmlNameCommandInput,
5761
IgnoresWrappingXmlNameCommandOutput,
@@ -84,6 +88,7 @@ export type ServiceInputTypes =
8488
| EndpointOperationCommandInput
8589
| EndpointWithHostLabelOperationCommandInput
8690
| GreetingWithErrorsCommandInput
91+
| HostWithPathOperationCommandInput
8792
| IgnoresWrappingXmlNameCommandInput
8893
| NestedStructuresCommandInput
8994
| NoInputAndOutputCommandInput
@@ -106,6 +111,7 @@ export type ServiceOutputTypes =
106111
| EndpointOperationCommandOutput
107112
| EndpointWithHostLabelOperationCommandOutput
108113
| GreetingWithErrorsCommandOutput
114+
| HostWithPathOperationCommandOutput
109115
| IgnoresWrappingXmlNameCommandOutput
110116
| NestedStructuresCommandOutput
111117
| NoInputAndOutputCommandOutput
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
2+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
3+
import { Command as $Command } from "@aws-sdk/smithy-client";
4+
import {
5+
FinalizeHandlerArguments,
6+
Handler,
7+
HandlerExecutionContext,
8+
HttpHandlerOptions as __HttpHandlerOptions,
9+
MetadataBearer as __MetadataBearer,
10+
MiddlewareStack,
11+
SerdeContext as __SerdeContext,
12+
} from "@aws-sdk/types";
13+
14+
import { EC2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2ProtocolClient";
15+
import {
16+
deserializeAws_ec2HostWithPathOperationCommand,
17+
serializeAws_ec2HostWithPathOperationCommand,
18+
} from "../protocols/Aws_ec2";
19+
20+
export interface HostWithPathOperationCommandInput {}
21+
export interface HostWithPathOperationCommandOutput extends __MetadataBearer {}
22+
23+
export class HostWithPathOperationCommand extends $Command<
24+
HostWithPathOperationCommandInput,
25+
HostWithPathOperationCommandOutput,
26+
EC2ProtocolClientResolvedConfig
27+
> {
28+
// Start section: command_properties
29+
// End section: command_properties
30+
31+
constructor(readonly input: HostWithPathOperationCommandInput) {
32+
// Start section: command_constructor
33+
super();
34+
// End section: command_constructor
35+
}
36+
37+
/**
38+
* @internal
39+
*/
40+
resolveMiddleware(
41+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
42+
configuration: EC2ProtocolClientResolvedConfig,
43+
options?: __HttpHandlerOptions
44+
): Handler<HostWithPathOperationCommandInput, HostWithPathOperationCommandOutput> {
45+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
46+
47+
const stack = clientStack.concat(this.middlewareStack);
48+
49+
const { logger } = configuration;
50+
const clientName = "EC2ProtocolClient";
51+
const commandName = "HostWithPathOperationCommand";
52+
const handlerExecutionContext: HandlerExecutionContext = {
53+
logger,
54+
clientName,
55+
commandName,
56+
inputFilterSensitiveLog: (input: any) => input,
57+
outputFilterSensitiveLog: (output: any) => output,
58+
};
59+
const { requestHandler } = configuration;
60+
return stack.resolve(
61+
(request: FinalizeHandlerArguments<any>) =>
62+
requestHandler.handle(request.request as __HttpRequest, options || {}),
63+
handlerExecutionContext
64+
);
65+
}
66+
67+
private serialize(input: HostWithPathOperationCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
68+
return serializeAws_ec2HostWithPathOperationCommand(input, context);
69+
}
70+
71+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<HostWithPathOperationCommandOutput> {
72+
return deserializeAws_ec2HostWithPathOperationCommand(output, context);
73+
}
74+
75+
// Start section: command_body_extra
76+
// End section: command_body_extra
77+
}

protocol_tests/aws-ec2/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from "./commands/EmptyInputAndEmptyOutputCommand";
44
export * from "./commands/EndpointOperationCommand";
55
export * from "./commands/EndpointWithHostLabelOperationCommand";
66
export * from "./commands/GreetingWithErrorsCommand";
7+
export * from "./commands/HostWithPathOperationCommand";
78
export * from "./commands/IgnoresWrappingXmlNameCommand";
89
export * from "./commands/NestedStructuresCommand";
910
export * from "./commands/NoInputAndOutputCommand";

protocol_tests/aws-ec2/src/protocols/Aws_ec2.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ import {
4242
EndpointWithHostLabelOperationCommandOutput,
4343
} from "../commands/EndpointWithHostLabelOperationCommand";
4444
import { GreetingWithErrorsCommandInput, GreetingWithErrorsCommandOutput } from "../commands/GreetingWithErrorsCommand";
45+
import {
46+
HostWithPathOperationCommandInput,
47+
HostWithPathOperationCommandOutput,
48+
} from "../commands/HostWithPathOperationCommand";
4549
import {
4650
IgnoresWrappingXmlNameCommandInput,
4751
IgnoresWrappingXmlNameCommandOutput,
@@ -177,6 +181,20 @@ export const serializeAws_ec2GreetingWithErrorsCommand = async (
177181
return buildHttpRpcRequest(context, headers, "/", undefined, body);
178182
};
179183

184+
export const serializeAws_ec2HostWithPathOperationCommand = async (
185+
input: HostWithPathOperationCommandInput,
186+
context: __SerdeContext
187+
): Promise<__HttpRequest> => {
188+
const headers: __HeaderBag = {
189+
"content-type": "application/x-www-form-urlencoded",
190+
};
191+
const body = buildFormUrlencodedString({
192+
Action: "HostWithPathOperation",
193+
Version: "2020-01-08",
194+
});
195+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
196+
};
197+
180198
export const serializeAws_ec2IgnoresWrappingXmlNameCommand = async (
181199
input: IgnoresWrappingXmlNameCommandInput,
182200
context: __SerdeContext
@@ -605,6 +623,49 @@ const deserializeAws_ec2GreetingWithErrorsCommandError = async (
605623
return Promise.reject(Object.assign(new Error(message), response));
606624
};
607625

626+
export const deserializeAws_ec2HostWithPathOperationCommand = async (
627+
output: __HttpResponse,
628+
context: __SerdeContext
629+
): Promise<HostWithPathOperationCommandOutput> => {
630+
if (output.statusCode >= 300) {
631+
return deserializeAws_ec2HostWithPathOperationCommandError(output, context);
632+
}
633+
await collectBody(output.body, context);
634+
const response: HostWithPathOperationCommandOutput = {
635+
$metadata: deserializeMetadata(output),
636+
};
637+
return Promise.resolve(response);
638+
};
639+
640+
const deserializeAws_ec2HostWithPathOperationCommandError = async (
641+
output: __HttpResponse,
642+
context: __SerdeContext
643+
): Promise<HostWithPathOperationCommandOutput> => {
644+
const parsedOutput: any = {
645+
...output,
646+
body: await parseBody(output.body, context),
647+
};
648+
let response: __SmithyException & __MetadataBearer & { [key: string]: any };
649+
let errorCode = "UnknownError";
650+
errorCode = loadEc2ErrorCode(output, parsedOutput.body);
651+
switch (errorCode) {
652+
default:
653+
const parsedBody = parsedOutput.body;
654+
errorCode = parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode;
655+
response = {
656+
...parsedBody.Errors.Error,
657+
name: `${errorCode}`,
658+
message: parsedBody.Errors.Error.message || parsedBody.Errors.Error.Message || errorCode,
659+
$fault: "client",
660+
$metadata: deserializeMetadata(output),
661+
} as any;
662+
}
663+
const message = response.message || response.Message || errorCode;
664+
response.message = message;
665+
delete response.Message;
666+
return Promise.reject(Object.assign(new Error(message), response));
667+
};
668+
608669
export const deserializeAws_ec2IgnoresWrappingXmlNameCommand = async (
609670
output: __HttpResponse,
610671
context: __SerdeContext

protocol_tests/aws-ec2/test/functional/ec2query.spec.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
2+
import { Encoder as __Encoder } from "@aws-sdk/types";
23
import { HeaderBag, HttpHandlerOptions } from "@aws-sdk/types";
34
import { Readable } from "stream";
45

56
import { EmptyInputAndEmptyOutputCommand } from "../../src/commands/EmptyInputAndEmptyOutputCommand";
67
import { EndpointOperationCommand } from "../../src/commands/EndpointOperationCommand";
78
import { EndpointWithHostLabelOperationCommand } from "../../src/commands/EndpointWithHostLabelOperationCommand";
89
import { GreetingWithErrorsCommand } from "../../src/commands/GreetingWithErrorsCommand";
10+
import { HostWithPathOperationCommand } from "../../src/commands/HostWithPathOperationCommand";
911
import { IgnoresWrappingXmlNameCommand } from "../../src/commands/IgnoresWrappingXmlNameCommand";
1012
import { NestedStructuresCommand } from "../../src/commands/NestedStructuresCommand";
1113
import { NoInputAndOutputCommand } from "../../src/commands/NoInputAndOutputCommand";
@@ -444,6 +446,38 @@ it("Ec2ComplexError:Error:GreetingWithErrors", async () => {
444446
fail("Expected an exception to be thrown from response");
445447
});
446448

449+
/**
450+
* Custom endpoints supplied by users can have paths
451+
*/
452+
it("Ec2QueryHostWithPath:Request", async () => {
453+
const client = new EC2ProtocolClient({
454+
...clientParams,
455+
endpoint: "https://example.com/custom",
456+
requestHandler: new RequestSerializationTestHandler(),
457+
});
458+
459+
const command = new HostWithPathOperationCommand({});
460+
try {
461+
await client.send(command);
462+
fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown");
463+
return;
464+
} catch (err) {
465+
if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) {
466+
fail(err);
467+
return;
468+
}
469+
const r = err.request;
470+
expect(r.method).toBe("POST");
471+
expect(r.path).toBe("/custom/");
472+
473+
expect(r.body).toBeDefined();
474+
const utf8Encoder = client.config.utf8Encoder;
475+
const bodyString = `Action=HostWithPathOperation&Version=2020-01-08`;
476+
const unequalParts: any = compareEquivalentUnknownTypeBodies(utf8Encoder, bodyString, r.body);
477+
expect(unequalParts).toBeUndefined();
478+
}
479+
});
480+
447481
/**
448482
* The xmlName trait on the output structure is ignored in the ec2 protocol
449483
*/
@@ -2291,3 +2325,20 @@ const compareEquivalentFormUrlencodedBodies = (expectedBody: string, generatedBo
22912325

22922326
return compareParts(expectedParts, generatedParts);
22932327
};
2328+
2329+
/**
2330+
* Returns a map of key names that were un-equal to value objects showing the
2331+
* discrepancies between the components.
2332+
*/
2333+
const compareEquivalentUnknownTypeBodies = (
2334+
utf8Encoder: __Encoder,
2335+
expectedBody: string,
2336+
generatedBody: string | Uint8Array
2337+
): Object => {
2338+
const expectedParts = { Value: expectedBody };
2339+
const generatedParts = {
2340+
Value: generatedBody instanceof Uint8Array ? utf8Encoder(generatedBody) : generatedBody,
2341+
};
2342+
2343+
return compareParts(expectedParts, generatedParts);
2344+
};

0 commit comments

Comments
 (0)