From d33177d26f9453afd88f8003f4ad06312d7c9945 Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 11 Oct 2024 17:31:46 +0000 Subject: [PATCH] fix(client-s3): correct shape type of two shapes from union to structure --- .../GetBucketLifecycleConfigurationCommand.ts | 2 +- .../commands/GetBucketReplicationCommand.ts | 2 +- .../PutBucketLifecycleConfigurationCommand.ts | 2 +- .../commands/PutBucketReplicationCommand.ts | 2 +- clients/client-s3/src/models/models_0.ts | 145 ++---------------- clients/client-s3/src/models/models_1.ts | 2 - .../client-s3/src/protocols/Aws_restXml.ts | 126 +++++---------- codegen/sdk-codegen/aws-models/s3.json | 4 +- 8 files changed, 52 insertions(+), 233 deletions(-) diff --git a/clients/client-s3/src/commands/GetBucketLifecycleConfigurationCommand.ts b/clients/client-s3/src/commands/GetBucketLifecycleConfigurationCommand.ts index a794e79620b3b..2c147d18db10f 100644 --- a/clients/client-s3/src/commands/GetBucketLifecycleConfigurationCommand.ts +++ b/clients/client-s3/src/commands/GetBucketLifecycleConfigurationCommand.ts @@ -113,7 +113,7 @@ export interface GetBucketLifecycleConfigurationCommandOutput * // }, * // ID: "STRING_VALUE", * // Prefix: "STRING_VALUE", - * // Filter: { // LifecycleRuleFilter Union: only one key present + * // Filter: { // LifecycleRuleFilter * // Prefix: "STRING_VALUE", * // Tag: { // Tag * // Key: "STRING_VALUE", // required diff --git a/clients/client-s3/src/commands/GetBucketReplicationCommand.ts b/clients/client-s3/src/commands/GetBucketReplicationCommand.ts index ce59e93a4690a..6bd7801297e3a 100644 --- a/clients/client-s3/src/commands/GetBucketReplicationCommand.ts +++ b/clients/client-s3/src/commands/GetBucketReplicationCommand.ts @@ -82,7 +82,7 @@ export interface GetBucketReplicationCommandOutput extends GetBucketReplicationO * // ID: "STRING_VALUE", * // Priority: Number("int"), * // Prefix: "STRING_VALUE", - * // Filter: { // ReplicationRuleFilter Union: only one key present + * // Filter: { // ReplicationRuleFilter * // Prefix: "STRING_VALUE", * // Tag: { // Tag * // Key: "STRING_VALUE", // required diff --git a/clients/client-s3/src/commands/PutBucketLifecycleConfigurationCommand.ts b/clients/client-s3/src/commands/PutBucketLifecycleConfigurationCommand.ts index b7875795e033e..12cf746492154 100644 --- a/clients/client-s3/src/commands/PutBucketLifecycleConfigurationCommand.ts +++ b/clients/client-s3/src/commands/PutBucketLifecycleConfigurationCommand.ts @@ -144,7 +144,7 @@ export interface PutBucketLifecycleConfigurationCommandOutput * }, * ID: "STRING_VALUE", * Prefix: "STRING_VALUE", - * Filter: { // LifecycleRuleFilter Union: only one key present + * Filter: { // LifecycleRuleFilter * Prefix: "STRING_VALUE", * Tag: { // Tag * Key: "STRING_VALUE", // required diff --git a/clients/client-s3/src/commands/PutBucketReplicationCommand.ts b/clients/client-s3/src/commands/PutBucketReplicationCommand.ts index ab5541dfaa1d6..641379180e0fc 100644 --- a/clients/client-s3/src/commands/PutBucketReplicationCommand.ts +++ b/clients/client-s3/src/commands/PutBucketReplicationCommand.ts @@ -120,7 +120,7 @@ export interface PutBucketReplicationCommandOutput extends __MetadataBearer {} * ID: "STRING_VALUE", * Priority: Number("int"), * Prefix: "STRING_VALUE", - * Filter: { // ReplicationRuleFilter Union: only one key present + * Filter: { // ReplicationRuleFilter * Prefix: "STRING_VALUE", * Tag: { // Tag * Key: "STRING_VALUE", // required diff --git a/clients/client-s3/src/models/models_0.ts b/clients/client-s3/src/models/models_0.ts index 03b2fd9f5dcb4..1e283d3511368 100644 --- a/clients/client-s3/src/models/models_0.ts +++ b/clients/client-s3/src/models/models_0.ts @@ -1,6 +1,5 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client"; - import { StreamingBlobTypes } from "@smithy/types"; import { S3ServiceException as __BaseException } from "./S3ServiceException"; @@ -6874,18 +6873,7 @@ export interface LifecycleRuleAndOperator { * And specified. If the Filter element is left empty, the Lifecycle Rule applies to all objects in the bucket.

* @public */ -export type LifecycleRuleFilter = - | LifecycleRuleFilter.AndMember - | LifecycleRuleFilter.ObjectSizeGreaterThanMember - | LifecycleRuleFilter.ObjectSizeLessThanMember - | LifecycleRuleFilter.PrefixMember - | LifecycleRuleFilter.TagMember - | LifecycleRuleFilter.$UnknownMember; - -/** - * @public - */ -export namespace LifecycleRuleFilter { +export interface LifecycleRuleFilter { /** *

Prefix identifying one or more objects to which the rule applies.

* @@ -6895,53 +6883,25 @@ export namespace LifecycleRuleFilter { * * @public */ - export interface PrefixMember { - Prefix: string; - Tag?: never; - ObjectSizeGreaterThan?: never; - ObjectSizeLessThan?: never; - And?: never; - $unknown?: never; - } + Prefix?: string; /** *

This tag must exist in the object's tag set in order for the rule to apply.

* @public */ - export interface TagMember { - Prefix?: never; - Tag: Tag; - ObjectSizeGreaterThan?: never; - ObjectSizeLessThan?: never; - And?: never; - $unknown?: never; - } + Tag?: Tag; /** *

Minimum object size to which the rule applies.

* @public */ - export interface ObjectSizeGreaterThanMember { - Prefix?: never; - Tag?: never; - ObjectSizeGreaterThan: number; - ObjectSizeLessThan?: never; - And?: never; - $unknown?: never; - } + ObjectSizeGreaterThan?: number; /** *

Maximum object size to which the rule applies.

* @public */ - export interface ObjectSizeLessThanMember { - Prefix?: never; - Tag?: never; - ObjectSizeGreaterThan?: never; - ObjectSizeLessThan: number; - And?: never; - $unknown?: never; - } + ObjectSizeLessThan?: number; /** *

This is used in a Lifecycle Rule Filter to apply a logical AND to two or more @@ -6949,44 +6909,7 @@ export namespace LifecycleRuleFilter { * configured inside the And operator.

* @public */ - export interface AndMember { - Prefix?: never; - Tag?: never; - ObjectSizeGreaterThan?: never; - ObjectSizeLessThan?: never; - And: LifecycleRuleAndOperator; - $unknown?: never; - } - - /** - * @public - */ - export interface $UnknownMember { - Prefix?: never; - Tag?: never; - ObjectSizeGreaterThan?: never; - ObjectSizeLessThan?: never; - And?: never; - $unknown: [string, any]; - } - - export interface Visitor { - Prefix: (value: string) => T; - Tag: (value: Tag) => T; - ObjectSizeGreaterThan: (value: number) => T; - ObjectSizeLessThan: (value: number) => T; - And: (value: LifecycleRuleAndOperator) => T; - _: (name: string, value: any) => T; - } - - export const visit = (value: LifecycleRuleFilter, visitor: Visitor): T => { - if (value.Prefix !== undefined) return visitor.Prefix(value.Prefix); - if (value.Tag !== undefined) return visitor.Tag(value.Tag); - if (value.ObjectSizeGreaterThan !== undefined) return visitor.ObjectSizeGreaterThan(value.ObjectSizeGreaterThan); - if (value.ObjectSizeLessThan !== undefined) return visitor.ObjectSizeLessThan(value.ObjectSizeLessThan); - if (value.And !== undefined) return visitor.And(value.And); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; + And?: LifecycleRuleAndOperator; } /** @@ -8386,16 +8309,7 @@ export interface ReplicationRuleAndOperator { * an And child element.

* @public */ -export type ReplicationRuleFilter = - | ReplicationRuleFilter.AndMember - | ReplicationRuleFilter.PrefixMember - | ReplicationRuleFilter.TagMember - | ReplicationRuleFilter.$UnknownMember; - -/** - * @public - */ -export namespace ReplicationRuleFilter { +export interface ReplicationRuleFilter { /** *

An object key name prefix that identifies the subset of objects to which the rule * applies.

@@ -8406,24 +8320,14 @@ export namespace ReplicationRuleFilter { * * @public */ - export interface PrefixMember { - Prefix: string; - Tag?: never; - And?: never; - $unknown?: never; - } + Prefix?: string; /** *

A container for specifying a tag key and value.

*

The rule applies only to objects that have the tag in their tag set.

* @public */ - export interface TagMember { - Prefix?: never; - Tag: Tag; - And?: never; - $unknown?: never; - } + Tag?: Tag; /** *

A container for specifying rule filters. The filters determine the subset of objects to @@ -8441,36 +8345,7 @@ export namespace ReplicationRuleFilter { * * @public */ - export interface AndMember { - Prefix?: never; - Tag?: never; - And: ReplicationRuleAndOperator; - $unknown?: never; - } - - /** - * @public - */ - export interface $UnknownMember { - Prefix?: never; - Tag?: never; - And?: never; - $unknown: [string, any]; - } - - export interface Visitor { - Prefix: (value: string) => T; - Tag: (value: Tag) => T; - And: (value: ReplicationRuleAndOperator) => T; - _: (name: string, value: any) => T; - } - - export const visit = (value: ReplicationRuleFilter, visitor: Visitor): T => { - if (value.Prefix !== undefined) return visitor.Prefix(value.Prefix); - if (value.Tag !== undefined) return visitor.Tag(value.Tag); - if (value.And !== undefined) return visitor.And(value.And); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; + And?: ReplicationRuleAndOperator; } /** diff --git a/clients/client-s3/src/models/models_1.ts b/clients/client-s3/src/models/models_1.ts index dcfb025b0281f..5c4f9f9ea2738 100644 --- a/clients/client-s3/src/models/models_1.ts +++ b/clients/client-s3/src/models/models_1.ts @@ -1,6 +1,5 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client"; - import { StreamingBlobTypes } from "@smithy/types"; import { @@ -30,7 +29,6 @@ import { StorageClass, Tag, } from "./models_0"; - import { S3ServiceException as __BaseException } from "./S3ServiceException"; /** diff --git a/clients/client-s3/src/protocols/Aws_restXml.ts b/clients/client-s3/src/protocols/Aws_restXml.ts index 31a28098aff7e..8fd4a42d708ac 100644 --- a/clients/client-s3/src/protocols/Aws_restXml.ts +++ b/clients/client-s3/src/protocols/Aws_restXml.ts @@ -6454,39 +6454,19 @@ const se_LifecycleRuleAndOperator = (input: LifecycleRuleAndOperator, context: _ */ const se_LifecycleRuleFilter = (input: LifecycleRuleFilter, context: __SerdeContext): any => { const bn = new __XmlNode(_LRF); - LifecycleRuleFilter.visit(input, { - Prefix: (value) => { - if (input[_P] != null) { - bn.c(__XmlNode.of(_P, value).n(_P)); - } - }, - Tag: (value) => { - if (input[_Ta] != null) { - bn.c(se_Tag(value, context).n(_Ta)); - } - }, - ObjectSizeGreaterThan: (value) => { - if (input[_OSGT] != null) { - bn.c(__XmlNode.of(_OSGTB, String(value)).n(_OSGT)); - } - }, - ObjectSizeLessThan: (value) => { - if (input[_OSLT] != null) { - bn.c(__XmlNode.of(_OSLTB, String(value)).n(_OSLT)); - } - }, - And: (value) => { - if (input[_A] != null) { - bn.c(se_LifecycleRuleAndOperator(value, context).n(_A)); - } - }, - _: (name: string, value: any) => { - if (!(value instanceof __XmlNode || value instanceof __XmlText)) { - throw new Error("Unable to serialize unknown union members in XML."); - } - bn.c(new __XmlNode(name).c(value)); - }, - }); + bn.cc(input, _P); + if (input[_Ta] != null) { + bn.c(se_Tag(input[_Ta], context).n(_Ta)); + } + if (input[_OSGT] != null) { + bn.c(__XmlNode.of(_OSGTB, String(input[_OSGT])).n(_OSGT)); + } + if (input[_OSLT] != null) { + bn.c(__XmlNode.of(_OSLTB, String(input[_OSLT])).n(_OSLT)); + } + if (input[_A] != null) { + bn.c(se_LifecycleRuleAndOperator(input[_A], context).n(_A)); + } return bn; }; @@ -6985,29 +6965,13 @@ const se_ReplicationRuleAndOperator = (input: ReplicationRuleAndOperator, contex */ const se_ReplicationRuleFilter = (input: ReplicationRuleFilter, context: __SerdeContext): any => { const bn = new __XmlNode(_RRF); - ReplicationRuleFilter.visit(input, { - Prefix: (value) => { - if (input[_P] != null) { - bn.c(__XmlNode.of(_P, value).n(_P)); - } - }, - Tag: (value) => { - if (input[_Ta] != null) { - bn.c(se_Tag(value, context).n(_Ta)); - } - }, - And: (value) => { - if (input[_A] != null) { - bn.c(se_ReplicationRuleAndOperator(value, context).n(_A)); - } - }, - _: (name: string, value: any) => { - if (!(value instanceof __XmlNode || value instanceof __XmlText)) { - throw new Error("Unable to serialize unknown union members in XML."); - } - bn.c(new __XmlNode(name).c(value)); - }, - }); + bn.cc(input, _P); + if (input[_Ta] != null) { + bn.c(se_Tag(input[_Ta], context).n(_Ta)); + } + if (input[_A] != null) { + bn.c(se_ReplicationRuleAndOperator(input[_A], context).n(_A)); + } return bn; }; @@ -8472,10 +8436,8 @@ const de_LifecycleRule = (output: any, context: __SerdeContext): LifecycleRule = if (output[_P] != null) { contents[_P] = __expectString(output[_P]); } - if (output.Filter === "") { - // Pass empty tags. - } else if (output[_F] != null) { - contents[_F] = de_LifecycleRuleFilter(__expectUnion(output[_F]), context); + if (output[_F] != null) { + contents[_F] = de_LifecycleRuleFilter(output[_F], context); } if (output[_S] != null) { contents[_S] = __expectString(output[_S]); @@ -8525,32 +8487,23 @@ const de_LifecycleRuleAndOperator = (output: any, context: __SerdeContext): Life * deserializeAws_restXmlLifecycleRuleFilter */ const de_LifecycleRuleFilter = (output: any, context: __SerdeContext): LifecycleRuleFilter => { + const contents: any = {}; if (output[_P] != null) { - return { - Prefix: __expectString(output[_P]) as any, - }; + contents[_P] = __expectString(output[_P]); } if (output[_Ta] != null) { - return { - Tag: de_Tag(output[_Ta], context), - }; + contents[_Ta] = de_Tag(output[_Ta], context); } if (output[_OSGT] != null) { - return { - ObjectSizeGreaterThan: __strictParseLong(output[_OSGT]) as number, - }; + contents[_OSGT] = __strictParseLong(output[_OSGT]) as number; } if (output[_OSLT] != null) { - return { - ObjectSizeLessThan: __strictParseLong(output[_OSLT]) as number, - }; + contents[_OSLT] = __strictParseLong(output[_OSLT]) as number; } if (output[_A] != null) { - return { - And: de_LifecycleRuleAndOperator(output[_A], context), - }; + contents[_A] = de_LifecycleRuleAndOperator(output[_A], context); } - return { $unknown: Object.entries(output)[0] }; + return contents; }; /** @@ -9211,10 +9164,8 @@ const de_ReplicationRule = (output: any, context: __SerdeContext): ReplicationRu if (output[_P] != null) { contents[_P] = __expectString(output[_P]); } - if (output.Filter === "") { - // Pass empty tags. - } else if (output[_F] != null) { - contents[_F] = de_ReplicationRuleFilter(__expectUnion(output[_F]), context); + if (output[_F] != null) { + contents[_F] = de_ReplicationRuleFilter(output[_F], context); } if (output[_S] != null) { contents[_S] = __expectString(output[_S]); @@ -9254,22 +9205,17 @@ const de_ReplicationRuleAndOperator = (output: any, context: __SerdeContext): Re * deserializeAws_restXmlReplicationRuleFilter */ const de_ReplicationRuleFilter = (output: any, context: __SerdeContext): ReplicationRuleFilter => { + const contents: any = {}; if (output[_P] != null) { - return { - Prefix: __expectString(output[_P]) as any, - }; + contents[_P] = __expectString(output[_P]); } if (output[_Ta] != null) { - return { - Tag: de_Tag(output[_Ta], context), - }; + contents[_Ta] = de_Tag(output[_Ta], context); } if (output[_A] != null) { - return { - And: de_ReplicationRuleAndOperator(output[_A], context), - }; + contents[_A] = de_ReplicationRuleAndOperator(output[_A], context); } - return { $unknown: Object.entries(output)[0] }; + return contents; }; /** diff --git a/codegen/sdk-codegen/aws-models/s3.json b/codegen/sdk-codegen/aws-models/s3.json index 35e54f67cba2a..4d762ce4fa2b3 100644 --- a/codegen/sdk-codegen/aws-models/s3.json +++ b/codegen/sdk-codegen/aws-models/s3.json @@ -26031,7 +26031,7 @@ } }, "com.amazonaws.s3#LifecycleRuleFilter": { - "type": "union", + "type": "structure", "members": { "Prefix": { "target": "com.amazonaws.s3#Prefix", @@ -32240,7 +32240,7 @@ } }, "com.amazonaws.s3#ReplicationRuleFilter": { - "type": "union", + "type": "structure", "members": { "Prefix": { "target": "com.amazonaws.s3#Prefix",