From 446c0d92f212a0a13ac6179c5665fa06af89ee7c Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 14 May 2024 16:07:26 +0000 Subject: [PATCH] feat(cbor): create cbor class stubs --- .../cbor/CborMemberDeserVisitor.java | 28 +++++++ .../protocols/cbor/CborMemberSerVisitor.java | 28 +++++++ .../protocols/cbor/CborShapeDeserVisitor.java | 46 ++++++++++++ .../protocols/cbor/CborShapeSerVisitor.java | 46 ++++++++++++ .../protocols/cbor/SmithyRpcV2Cbor.java | 75 +++++++++++++++++++ 5 files changed, 223 insertions(+) create mode 100644 smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberDeserVisitor.java create mode 100644 smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberSerVisitor.java create mode 100644 smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborShapeDeserVisitor.java create mode 100644 smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborShapeSerVisitor.java create mode 100644 smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/SmithyRpcV2Cbor.java diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberDeserVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberDeserVisitor.java new file mode 100644 index 00000000000..b6eef575150 --- /dev/null +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberDeserVisitor.java @@ -0,0 +1,28 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.typescript.codegen.protocols.cbor; + +import software.amazon.smithy.model.traits.TimestampFormatTrait; +import software.amazon.smithy.typescript.codegen.integration.DocumentMemberDeserVisitor; +import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator; + +public class CborMemberDeserVisitor extends DocumentMemberDeserVisitor { + + /** + * Constructor. + * + * @param context The generation context. + * @param dataSource The in-code location of the data to provide an output of + * ({@code output.foo}, {@code entry}, etc.) + * @param defaultTimestampFormat The default timestamp format used in absence + * of a TimestampFormat trait. + */ + public CborMemberDeserVisitor(ProtocolGenerator.GenerationContext context, + String dataSource, + TimestampFormatTrait.Format defaultTimestampFormat) { + super(context, dataSource, defaultTimestampFormat); + } +} diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberSerVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberSerVisitor.java new file mode 100644 index 00000000000..271923454fa --- /dev/null +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberSerVisitor.java @@ -0,0 +1,28 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.typescript.codegen.protocols.cbor; + +import software.amazon.smithy.model.traits.TimestampFormatTrait; +import software.amazon.smithy.typescript.codegen.integration.DocumentMemberSerVisitor; +import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator; + +public class CborMemberSerVisitor extends DocumentMemberSerVisitor { + + /** + * Constructor. + * + * @param context The generation context. + * @param dataSource The in-code location of the data to provide an input of + * ({@code input.foo}, {@code entry}, etc.) + * @param defaultTimestampFormat The default timestamp format used in absence + * of a TimestampFormat trait. + */ + public CborMemberSerVisitor(ProtocolGenerator.GenerationContext context, + String dataSource, + TimestampFormatTrait.Format defaultTimestampFormat) { + super(context, dataSource, defaultTimestampFormat); + } +} diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborShapeDeserVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborShapeDeserVisitor.java new file mode 100644 index 00000000000..4e42c75a0b3 --- /dev/null +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborShapeDeserVisitor.java @@ -0,0 +1,46 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.typescript.codegen.protocols.cbor; + +import software.amazon.smithy.model.shapes.CollectionShape; +import software.amazon.smithy.model.shapes.DocumentShape; +import software.amazon.smithy.model.shapes.MapShape; +import software.amazon.smithy.model.shapes.StructureShape; +import software.amazon.smithy.model.shapes.UnionShape; +import software.amazon.smithy.typescript.codegen.integration.DocumentShapeDeserVisitor; +import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator; + +public class CborShapeDeserVisitor extends DocumentShapeDeserVisitor { + + public CborShapeDeserVisitor(ProtocolGenerator.GenerationContext context) { + super(context); + } + + @Override + protected void deserializeCollection(ProtocolGenerator.GenerationContext context, CollectionShape shape) { + + } + + @Override + protected void deserializeDocument(ProtocolGenerator.GenerationContext context, DocumentShape shape) { + + } + + @Override + protected void deserializeMap(ProtocolGenerator.GenerationContext context, MapShape shape) { + + } + + @Override + protected void deserializeStructure(ProtocolGenerator.GenerationContext context, StructureShape shape) { + + } + + @Override + protected void deserializeUnion(ProtocolGenerator.GenerationContext context, UnionShape shape) { + + } +} diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborShapeSerVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborShapeSerVisitor.java new file mode 100644 index 00000000000..b5c928b116b --- /dev/null +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/CborShapeSerVisitor.java @@ -0,0 +1,46 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.typescript.codegen.protocols.cbor; + +import software.amazon.smithy.model.shapes.CollectionShape; +import software.amazon.smithy.model.shapes.DocumentShape; +import software.amazon.smithy.model.shapes.MapShape; +import software.amazon.smithy.model.shapes.StructureShape; +import software.amazon.smithy.model.shapes.UnionShape; +import software.amazon.smithy.typescript.codegen.integration.DocumentShapeSerVisitor; +import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator; + +public class CborShapeSerVisitor extends DocumentShapeSerVisitor { + + public CborShapeSerVisitor(ProtocolGenerator.GenerationContext context) { + super(context); + } + + @Override + protected void serializeCollection(ProtocolGenerator.GenerationContext context, CollectionShape shape) { + + } + + @Override + protected void serializeDocument(ProtocolGenerator.GenerationContext context, DocumentShape shape) { + + } + + @Override + protected void serializeMap(ProtocolGenerator.GenerationContext context, MapShape shape) { + + } + + @Override + protected void serializeStructure(ProtocolGenerator.GenerationContext context, StructureShape shape) { + + } + + @Override + protected void serializeUnion(ProtocolGenerator.GenerationContext context, UnionShape shape) { + + } +} diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/SmithyRpcV2Cbor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/SmithyRpcV2Cbor.java new file mode 100644 index 00000000000..00692201d6c --- /dev/null +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/protocols/cbor/SmithyRpcV2Cbor.java @@ -0,0 +1,75 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.typescript.codegen.protocols.cbor; + +import java.util.Set; +import software.amazon.smithy.model.shapes.OperationShape; +import software.amazon.smithy.model.shapes.Shape; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.shapes.StructureShape; +import software.amazon.smithy.typescript.codegen.integration.HttpRpcProtocolGenerator; +import software.amazon.smithy.utils.SmithyInternalApi; + + +/** + * Generator for Smithy RPCv2 CBOR. + */ +@SmithyInternalApi +public class SmithyRpcV2Cbor extends HttpRpcProtocolGenerator { + + public SmithyRpcV2Cbor() { + super(true); + } + + @Override + protected String getDocumentContentType() { + return ""; + } + + @Override + protected void generateDocumentBodyShapeSerializers(GenerationContext generationContext, Set set) { + + } + + @Override + protected void generateDocumentBodyShapeDeserializers(GenerationContext generationContext, Set set) { + + } + + @Override + protected String getOperationPath(GenerationContext generationContext, OperationShape operationShape) { + return ""; + } + + @Override + protected void serializeInputDocument(GenerationContext generationContext, + OperationShape operationShape, + StructureShape structureShape) { + + } + + @Override + protected void writeErrorCodeParser(GenerationContext generationContext) { + + } + + @Override + protected void deserializeOutputDocument(GenerationContext generationContext, + OperationShape operationShape, + StructureShape structureShape) { + + } + + @Override + public ShapeId getProtocol() { + return null; + } + + @Override + public void generateProtocolTests(GenerationContext generationContext) { + + } +}