From 55240ac8dc5a587e0eb9a70f59b8b1c2682e77d5 Mon Sep 17 00:00:00 2001 From: Ran Vaknin Date: Tue, 24 Sep 2024 06:56:53 +0000 Subject: [PATCH 1/4] fix(sdk-codegen): update errorType and correct imports in ProcessAwsQueryWaiters --- .../codegen/ProcessAwsQueryWaiters.java | 107 ++++++++++++++++++ ....codegen.integration.TypeScriptIntegration | 1 + 2 files changed, 108 insertions(+) create mode 100644 codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java new file mode 100644 index 000000000000..3f1108f909a3 --- /dev/null +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java @@ -0,0 +1,107 @@ +/* + * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.smithy.aws.typescript.codegen; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import software.amazon.smithy.aws.traits.protocols.AwsQueryErrorTrait; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.knowledge.TopDownIndex; +import software.amazon.smithy.model.node.ObjectNode; +import software.amazon.smithy.model.shapes.OperationShape; +import software.amazon.smithy.model.shapes.ServiceShape; +import software.amazon.smithy.model.shapes.Shape; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.ErrorTrait; +import software.amazon.smithy.model.transform.ModelTransformer; +import software.amazon.smithy.typescript.codegen.TypeScriptSettings; +import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration; +import software.amazon.smithy.utils.SmithyInternalApi; +import software.amazon.smithy.waiters.Acceptor; +import software.amazon.smithy.waiters.Matcher; +import software.amazon.smithy.waiters.WaitableTrait; +import software.amazon.smithy.waiters.Waiter; + + +@SmithyInternalApi +public final class ProcessAwsQueryWaiters implements TypeScriptIntegration { + + @Override + public Model preprocessModel(Model model, TypeScriptSettings settings) { + Map errorCodeToShapeId = new HashMap<>(); + + ServiceShape serviceShape = settings.getService(model); + TopDownIndex topDownIndex = TopDownIndex.of(model); + for (OperationShape operationShape : topDownIndex.getContainedOperations(serviceShape)) { + for (ShapeId errorShapeId : operationShape.getErrors()) { + Shape errorShape = model.expectShape(errorShapeId); + if (errorShape.hasTrait(ErrorTrait.class) && errorShape.hasTrait(AwsQueryErrorTrait.class)) { + AwsQueryErrorTrait awsQueryTrait = errorShape.expectTrait(AwsQueryErrorTrait.class); + errorCodeToShapeId.put(awsQueryTrait.getCode(), errorShape.getId().getName()); + } + } + } + + List modifiedShapes = new ArrayList<>(); + + for (OperationShape operationShape : topDownIndex.getContainedOperations(serviceShape)) { + OperationShape.Builder operationBuilder = operationShape.toBuilder(); + if (operationShape.hasTrait(WaitableTrait.class)) { + operationBuilder.removeTrait(WaitableTrait.ID); + WaitableTrait waiterTrait = operationShape.expectTrait(WaitableTrait.class); + WaitableTrait.Builder waitableTraitBuilder = (WaitableTrait.Builder) waiterTrait.toBuilder(); + for (Map.Entry entry : waiterTrait.getWaiters().entrySet()) { + String name = entry.getKey(); + Waiter waiter = entry.getValue(); + Waiter.Builder waiterBuilder = (Waiter.Builder) waiter.toBuilder(); + waiterBuilder.clearAcceptors(); + for (Acceptor acceptor : waiter.getAcceptors()) { + ObjectNode acceptorNode = acceptor.toNode().expectObjectNode(); + Matcher matcher = acceptor.getMatcher(); + if (matcher instanceof Matcher.ErrorTypeMember) { + ObjectNode matcherNode = matcher.toNode().expectObjectNode(); + + String errorCode = matcherNode.expectStringMember("errorType").getValue(); + if (errorCodeToShapeId.containsKey(errorCode)) { + matcherNode = matcherNode.toBuilder() + .withMember("errorType", errorCodeToShapeId.get(errorCode)) + .build(); + + acceptorNode = acceptorNode.toBuilder() + .withMember("matcher", matcherNode) + .build(); + } + } + waiterBuilder.addAcceptor(Acceptor.fromNode(acceptorNode)); + } + waitableTraitBuilder.put(name, waiterBuilder.build()); + } + operationBuilder.addTrait(waitableTraitBuilder.build()); + } + modifiedShapes.add(operationBuilder.build()); + } + + if (!modifiedShapes.isEmpty()) { + ModelTransformer transformer = ModelTransformer.create(); + model = transformer.replaceShapes(model, modifiedShapes); + } + + return model; + } +} diff --git a/codegen/smithy-aws-typescript-codegen/src/main/resources/META-INF/services/software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration b/codegen/smithy-aws-typescript-codegen/src/main/resources/META-INF/services/software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration index 9eca961da6eb..bbd08fcd1b31 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/resources/META-INF/services/software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration +++ b/codegen/smithy-aws-typescript-codegen/src/main/resources/META-INF/services/software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration @@ -27,6 +27,7 @@ software.amazon.smithy.aws.typescript.codegen.AddDocumentClientPlugin software.amazon.smithy.aws.typescript.codegen.AddEndpointDiscoveryPlugin software.amazon.smithy.aws.typescript.codegen.AddHttpChecksumDependency software.amazon.smithy.aws.typescript.codegen.AddSigv4aPlugin +software.amazon.smithy.aws.typescript.codegen.ProcessAwsQueryWaiters software.amazon.smithy.aws.typescript.codegen.auth.http.integration.AwsSdkCustomizeHttpBearerTokenAuth software.amazon.smithy.aws.typescript.codegen.auth.http.integration.SupportSigV4Auth software.amazon.smithy.aws.typescript.codegen.auth.http.integration.AwsSdkCustomizeSigV4Auth From c24d2ceb0d175c33476190839d8275117ed9361d Mon Sep 17 00:00:00 2001 From: Ran Vaknin Date: Tue, 24 Sep 2024 07:15:24 +0000 Subject: [PATCH 2/4] fix(sdk-codegen): fix linting --- .../smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java | 1 - 1 file changed, 1 deletion(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java index 3f1108f909a3..35a5225c3c41 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java @@ -19,7 +19,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import software.amazon.smithy.aws.traits.protocols.AwsQueryErrorTrait; import software.amazon.smithy.model.Model; import software.amazon.smithy.model.knowledge.TopDownIndex; From b2b55c045f7481b53b80ef46dbcf6ea96cada713 Mon Sep 17 00:00:00 2001 From: Ran Vaknin Date: Tue, 24 Sep 2024 19:07:52 +0000 Subject: [PATCH 3/4] fix(sdk-codegen): fix copyright header --- .../typescript/codegen/ProcessAwsQueryWaiters.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java index 35a5225c3c41..7acae8b9929d 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/ProcessAwsQueryWaiters.java @@ -1,16 +1,6 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ package software.amazon.smithy.aws.typescript.codegen; From a1d76d251c2dba2021b2db7efba3f95398c98303 Mon Sep 17 00:00:00 2001 From: Ran Vaknin Date: Wed, 25 Sep 2024 00:58:38 +0000 Subject: [PATCH 4/4] fix(sdk-codegen): regenerated clients --- .../src/waiters/waitForDBInstanceDeleted.ts | 2 +- .../waiters/waitForLoadBalancerAvailable.ts | 2 +- .../src/waiters/waitForLoadBalancerExists.ts | 2 +- .../waiters/waitForLoadBalancersDeleted.ts | 2 +- .../src/waiters/waitForTargetDeregistered.ts | 2 +- .../waiters/waitForInstanceDeregistered.ts | 2 +- .../src/waiters/waitForInstanceInService.ts | 2 +- .../src/waiters/waitForCacheClusterDeleted.ts | 2 +- .../src/waiters/waitForPolicyExists.ts | 2 +- .../src/waiters/waitForRoleExists.ts | 2 +- .../src/waiters/waitForUserExists.ts | 2 +- .../src/waiters/waitForDBInstanceDeleted.ts | 2 +- .../src/waiters/waitForDBInstanceDeleted.ts | 2 +- .../src/waiters/waitForDBSnapshotDeleted.ts | 2 +- .../src/waiters/waitForClusterAvailable.ts | 2 +- .../src/waiters/waitForClusterDeleted.ts | 2 +- .../commands/DeleteObjectTaggingCommand.ts | 22 ++--- .../src/commands/DeleteObjectsCommand.ts | 44 +++++----- .../src/commands/GetObjectTaggingCommand.ts | 38 ++++---- .../src/commands/PutObjectCommand.ts | 86 +++++++++---------- .../src/commands/UploadPartCopyCommand.ts | 26 +++--- 21 files changed, 124 insertions(+), 124 deletions(-) diff --git a/clients/client-docdb/src/waiters/waitForDBInstanceDeleted.ts b/clients/client-docdb/src/waiters/waitForDBInstanceDeleted.ts index 7ae3ec0424a8..a35502d8b9f0 100644 --- a/clients/client-docdb/src/waiters/waitForDBInstanceDeleted.ts +++ b/clients/client-docdb/src/waiters/waitForDBInstanceDeleted.ts @@ -83,7 +83,7 @@ const checkState = async (client: DocDBClient, input: DescribeDBInstancesCommand } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "DBInstanceNotFound") { + if (exception.name && exception.name == "DBInstanceNotFoundFault") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancerAvailable.ts b/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancerAvailable.ts index 78e74c15de5a..5c1658dcaa9f 100644 --- a/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancerAvailable.ts +++ b/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancerAvailable.ts @@ -47,7 +47,7 @@ const checkState = async ( } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "LoadBalancerNotFound") { + if (exception.name && exception.name == "LoadBalancerNotFoundException") { return { state: WaiterState.RETRY, reason }; } } diff --git a/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancerExists.ts b/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancerExists.ts index 0a6bd555efa4..23d1a4f6e8de 100644 --- a/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancerExists.ts +++ b/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancerExists.ts @@ -18,7 +18,7 @@ const checkState = async ( return { state: WaiterState.SUCCESS, reason }; } catch (exception) { reason = exception; - if (exception.name && exception.name == "LoadBalancerNotFound") { + if (exception.name && exception.name == "LoadBalancerNotFoundException") { return { state: WaiterState.RETRY, reason }; } } diff --git a/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancersDeleted.ts b/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancersDeleted.ts index 1266d742f87f..130a08eab9ab 100644 --- a/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancersDeleted.ts +++ b/clients/client-elastic-load-balancing-v2/src/waiters/waitForLoadBalancersDeleted.ts @@ -33,7 +33,7 @@ const checkState = async ( } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "LoadBalancerNotFound") { + if (exception.name && exception.name == "LoadBalancerNotFoundException") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-elastic-load-balancing-v2/src/waiters/waitForTargetDeregistered.ts b/clients/client-elastic-load-balancing-v2/src/waiters/waitForTargetDeregistered.ts index 8f2c54f02eae..7782622bfb4f 100644 --- a/clients/client-elastic-load-balancing-v2/src/waiters/waitForTargetDeregistered.ts +++ b/clients/client-elastic-load-balancing-v2/src/waiters/waitForTargetDeregistered.ts @@ -30,7 +30,7 @@ const checkState = async ( } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "InvalidTarget") { + if (exception.name && exception.name == "InvalidTargetException") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-elastic-load-balancing/src/waiters/waitForInstanceDeregistered.ts b/clients/client-elastic-load-balancing/src/waiters/waitForInstanceDeregistered.ts index dae5a6f864f6..c052bb87e66c 100644 --- a/clients/client-elastic-load-balancing/src/waiters/waitForInstanceDeregistered.ts +++ b/clients/client-elastic-load-balancing/src/waiters/waitForInstanceDeregistered.ts @@ -33,7 +33,7 @@ const checkState = async ( } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "InvalidInstance") { + if (exception.name && exception.name == "InvalidEndPointException") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-elastic-load-balancing/src/waiters/waitForInstanceInService.ts b/clients/client-elastic-load-balancing/src/waiters/waitForInstanceInService.ts index 5898257b0c0c..0fa6599a941b 100644 --- a/clients/client-elastic-load-balancing/src/waiters/waitForInstanceInService.ts +++ b/clients/client-elastic-load-balancing/src/waiters/waitForInstanceInService.ts @@ -33,7 +33,7 @@ const checkState = async ( } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "InvalidInstance") { + if (exception.name && exception.name == "InvalidEndPointException") { return { state: WaiterState.RETRY, reason }; } } diff --git a/clients/client-elasticache/src/waiters/waitForCacheClusterDeleted.ts b/clients/client-elasticache/src/waiters/waitForCacheClusterDeleted.ts index 4ce3a28b2fc8..1be977922a10 100644 --- a/clients/client-elasticache/src/waiters/waitForCacheClusterDeleted.ts +++ b/clients/client-elasticache/src/waiters/waitForCacheClusterDeleted.ts @@ -117,7 +117,7 @@ const checkState = async ( } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "CacheClusterNotFound") { + if (exception.name && exception.name == "CacheClusterNotFoundFault") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-iam/src/waiters/waitForPolicyExists.ts b/clients/client-iam/src/waiters/waitForPolicyExists.ts index 6585d06ec529..50170bdfc20a 100644 --- a/clients/client-iam/src/waiters/waitForPolicyExists.ts +++ b/clients/client-iam/src/waiters/waitForPolicyExists.ts @@ -12,7 +12,7 @@ const checkState = async (client: IAMClient, input: GetPolicyCommandInput): Prom return { state: WaiterState.SUCCESS, reason }; } catch (exception) { reason = exception; - if (exception.name && exception.name == "NoSuchEntity") { + if (exception.name && exception.name == "NoSuchEntityException") { return { state: WaiterState.RETRY, reason }; } } diff --git a/clients/client-iam/src/waiters/waitForRoleExists.ts b/clients/client-iam/src/waiters/waitForRoleExists.ts index b2cff6f3dfff..f197ffebee34 100644 --- a/clients/client-iam/src/waiters/waitForRoleExists.ts +++ b/clients/client-iam/src/waiters/waitForRoleExists.ts @@ -12,7 +12,7 @@ const checkState = async (client: IAMClient, input: GetRoleCommandInput): Promis return { state: WaiterState.SUCCESS, reason }; } catch (exception) { reason = exception; - if (exception.name && exception.name == "NoSuchEntity") { + if (exception.name && exception.name == "NoSuchEntityException") { return { state: WaiterState.RETRY, reason }; } } diff --git a/clients/client-iam/src/waiters/waitForUserExists.ts b/clients/client-iam/src/waiters/waitForUserExists.ts index 915c409d529f..d559f1db7d3d 100644 --- a/clients/client-iam/src/waiters/waitForUserExists.ts +++ b/clients/client-iam/src/waiters/waitForUserExists.ts @@ -12,7 +12,7 @@ const checkState = async (client: IAMClient, input: GetUserCommandInput): Promis return { state: WaiterState.SUCCESS, reason }; } catch (exception) { reason = exception; - if (exception.name && exception.name == "NoSuchEntity") { + if (exception.name && exception.name == "NoSuchEntityException") { return { state: WaiterState.RETRY, reason }; } } diff --git a/clients/client-neptune/src/waiters/waitForDBInstanceDeleted.ts b/clients/client-neptune/src/waiters/waitForDBInstanceDeleted.ts index 1b0287692184..3364b69bee26 100644 --- a/clients/client-neptune/src/waiters/waitForDBInstanceDeleted.ts +++ b/clients/client-neptune/src/waiters/waitForDBInstanceDeleted.ts @@ -83,7 +83,7 @@ const checkState = async (client: NeptuneClient, input: DescribeDBInstancesComma } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "DBInstanceNotFound") { + if (exception.name && exception.name == "DBInstanceNotFoundFault") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-rds/src/waiters/waitForDBInstanceDeleted.ts b/clients/client-rds/src/waiters/waitForDBInstanceDeleted.ts index 543689186495..0cb70d9ff45e 100644 --- a/clients/client-rds/src/waiters/waitForDBInstanceDeleted.ts +++ b/clients/client-rds/src/waiters/waitForDBInstanceDeleted.ts @@ -75,7 +75,7 @@ const checkState = async (client: RDSClient, input: DescribeDBInstancesCommandIn } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "DBInstanceNotFound") { + if (exception.name && exception.name == "DBInstanceNotFoundFault") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-rds/src/waiters/waitForDBSnapshotDeleted.ts b/clients/client-rds/src/waiters/waitForDBSnapshotDeleted.ts index 7c748db95e85..ff90b2d5a8ee 100644 --- a/clients/client-rds/src/waiters/waitForDBSnapshotDeleted.ts +++ b/clients/client-rds/src/waiters/waitForDBSnapshotDeleted.ts @@ -75,7 +75,7 @@ const checkState = async (client: RDSClient, input: DescribeDBSnapshotsCommandIn } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "DBSnapshotNotFound") { + if (exception.name && exception.name == "DBSnapshotNotFoundFault") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-redshift/src/waiters/waitForClusterAvailable.ts b/clients/client-redshift/src/waiters/waitForClusterAvailable.ts index 28e36445c4c4..b1746bef5931 100644 --- a/clients/client-redshift/src/waiters/waitForClusterAvailable.ts +++ b/clients/client-redshift/src/waiters/waitForClusterAvailable.ts @@ -41,7 +41,7 @@ const checkState = async (client: RedshiftClient, input: DescribeClustersCommand } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "ClusterNotFound") { + if (exception.name && exception.name == "ClusterNotFoundFault") { return { state: WaiterState.RETRY, reason }; } } diff --git a/clients/client-redshift/src/waiters/waitForClusterDeleted.ts b/clients/client-redshift/src/waiters/waitForClusterDeleted.ts index 472d416311ac..a6416163d4f0 100644 --- a/clients/client-redshift/src/waiters/waitForClusterDeleted.ts +++ b/clients/client-redshift/src/waiters/waitForClusterDeleted.ts @@ -39,7 +39,7 @@ const checkState = async (client: RedshiftClient, input: DescribeClustersCommand } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "ClusterNotFound") { + if (exception.name && exception.name == "ClusterNotFoundFault") { return { state: WaiterState.SUCCESS, reason }; } } diff --git a/clients/client-s3/src/commands/DeleteObjectTaggingCommand.ts b/clients/client-s3/src/commands/DeleteObjectTaggingCommand.ts index d64a89337d23..e14facf9d3a9 100644 --- a/clients/client-s3/src/commands/DeleteObjectTaggingCommand.ts +++ b/clients/client-s3/src/commands/DeleteObjectTaggingCommand.ts @@ -82,39 +82,39 @@ export interface DeleteObjectTaggingCommandOutput extends DeleteObjectTaggingOut *

Base exception class for all service exceptions from S3 service.

* * @public - * @example To remove tag set from an object version + * @example To remove tag set from an object * ```javascript - * // The following example removes tag set associated with the specified object version. The request specifies both the object key and object version. + * // The following example removes tag set associated with the specified object. If the bucket is versioning enabled, the operation removes tag set from the latest object version. * const input = { * "Bucket": "examplebucket", - * "Key": "HappyFace.jpg", - * "VersionId": "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI" + * "Key": "HappyFace.jpg" * }; * const command = new DeleteObjectTaggingCommand(input); * const response = await client.send(command); * /* response == * { - * "VersionId": "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI" + * "VersionId": "null" * } * *\/ - * // example id: to-remove-tag-set-from-an-object-version-1483145285913 + * // example id: to-remove-tag-set-from-an-object-1483145342862 * ``` * - * @example To remove tag set from an object + * @example To remove tag set from an object version * ```javascript - * // The following example removes tag set associated with the specified object. If the bucket is versioning enabled, the operation removes tag set from the latest object version. + * // The following example removes tag set associated with the specified object version. The request specifies both the object key and object version. * const input = { * "Bucket": "examplebucket", - * "Key": "HappyFace.jpg" + * "Key": "HappyFace.jpg", + * "VersionId": "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI" * }; * const command = new DeleteObjectTaggingCommand(input); * const response = await client.send(command); * /* response == * { - * "VersionId": "null" + * "VersionId": "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI" * } * *\/ - * // example id: to-remove-tag-set-from-an-object-1483145342862 + * // example id: to-remove-tag-set-from-an-object-version-1483145285913 * ``` * */ diff --git a/clients/client-s3/src/commands/DeleteObjectsCommand.ts b/clients/client-s3/src/commands/DeleteObjectsCommand.ts index 57727ddec80d..a41f2e1d2762 100644 --- a/clients/client-s3/src/commands/DeleteObjectsCommand.ts +++ b/clients/client-s3/src/commands/DeleteObjectsCommand.ts @@ -213,18 +213,20 @@ export interface DeleteObjectsCommandOutput extends DeleteObjectsOutput, __Metad *

Base exception class for all service exceptions from S3 service.

* * @public - * @example To delete multiple objects from a versioned bucket + * @example To delete multiple object versions from a versioned bucket * ```javascript - * // The following example deletes objects from a bucket. The bucket is versioned, and the request does not specify the object version to delete. In this case, all versions remain in the bucket and S3 adds a delete marker. + * // The following example deletes objects from a bucket. The request specifies object versions. S3 deletes specific object versions and returns the key and versions of deleted objects in the response. * const input = { * "Bucket": "examplebucket", * "Delete": { * "Objects": [ * { - * "Key": "objectkey1" + * "Key": "HappyFace.jpg", + * "VersionId": "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" * }, * { - * "Key": "objectkey2" + * "Key": "HappyFace.jpg", + * "VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" * } * ], * "Quiet": false @@ -236,35 +238,31 @@ export interface DeleteObjectsCommandOutput extends DeleteObjectsOutput, __Metad * { * "Deleted": [ * { - * "DeleteMarker": "true", - * "DeleteMarkerVersionId": "A._w1z6EFiCF5uhtQMDal9JDkID9tQ7F", - * "Key": "objectkey1" + * "Key": "HappyFace.jpg", + * "VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" * }, * { - * "DeleteMarker": "true", - * "DeleteMarkerVersionId": "iOd_ORxhkKe_e8G8_oSGxt2PjsCZKlkt", - * "Key": "objectkey2" + * "Key": "HappyFace.jpg", + * "VersionId": "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" * } * ] * } * *\/ - * // example id: to-delete-multiple-objects-from-a-versioned-bucket-1483146248805 + * // example id: to-delete-multiple-object-versions-from-a-versioned-bucket-1483147087737 * ``` * - * @example To delete multiple object versions from a versioned bucket + * @example To delete multiple objects from a versioned bucket * ```javascript - * // The following example deletes objects from a bucket. The request specifies object versions. S3 deletes specific object versions and returns the key and versions of deleted objects in the response. + * // The following example deletes objects from a bucket. The bucket is versioned, and the request does not specify the object version to delete. In this case, all versions remain in the bucket and S3 adds a delete marker. * const input = { * "Bucket": "examplebucket", * "Delete": { * "Objects": [ * { - * "Key": "HappyFace.jpg", - * "VersionId": "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" + * "Key": "objectkey1" * }, * { - * "Key": "HappyFace.jpg", - * "VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" + * "Key": "objectkey2" * } * ], * "Quiet": false @@ -276,17 +274,19 @@ export interface DeleteObjectsCommandOutput extends DeleteObjectsOutput, __Metad * { * "Deleted": [ * { - * "Key": "HappyFace.jpg", - * "VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" + * "DeleteMarker": "true", + * "DeleteMarkerVersionId": "A._w1z6EFiCF5uhtQMDal9JDkID9tQ7F", + * "Key": "objectkey1" * }, * { - * "Key": "HappyFace.jpg", - * "VersionId": "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" + * "DeleteMarker": "true", + * "DeleteMarkerVersionId": "iOd_ORxhkKe_e8G8_oSGxt2PjsCZKlkt", + * "Key": "objectkey2" * } * ] * } * *\/ - * // example id: to-delete-multiple-object-versions-from-a-versioned-bucket-1483147087737 + * // example id: to-delete-multiple-objects-from-a-versioned-bucket-1483146248805 * ``` * */ diff --git a/clients/client-s3/src/commands/GetObjectTaggingCommand.ts b/clients/client-s3/src/commands/GetObjectTaggingCommand.ts index 32326f4bc9dc..7d84170e5e3f 100644 --- a/clients/client-s3/src/commands/GetObjectTaggingCommand.ts +++ b/clients/client-s3/src/commands/GetObjectTaggingCommand.ts @@ -98,12 +98,13 @@ export interface GetObjectTaggingCommandOutput extends GetObjectTaggingOutput, _ *

Base exception class for all service exceptions from S3 service.

* * @public - * @example To retrieve tag set of an object + * @example To retrieve tag set of a specific object version * ```javascript - * // The following example retrieves tag set of an object. + * // The following example retrieves tag set of an object. The request specifies object version. * const input = { * "Bucket": "examplebucket", - * "Key": "HappyFace.jpg" + * "Key": "exampleobject", + * "VersionId": "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI" * }; * const command = new GetObjectTaggingCommand(input); * const response = await client.send(command); @@ -111,27 +112,22 @@ export interface GetObjectTaggingCommandOutput extends GetObjectTaggingOutput, _ * { * "TagSet": [ * { - * "Key": "Key4", - * "Value": "Value4" - * }, - * { - * "Key": "Key3", - * "Value": "Value3" + * "Key": "Key1", + * "Value": "Value1" * } * ], - * "VersionId": "null" + * "VersionId": "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI" * } * *\/ - * // example id: to-retrieve-tag-set-of-an-object-1481833847896 + * // example id: to-retrieve-tag-set-of-a-specific-object-version-1483400283663 * ``` * - * @example To retrieve tag set of a specific object version + * @example To retrieve tag set of an object * ```javascript - * // The following example retrieves tag set of an object. The request specifies object version. + * // The following example retrieves tag set of an object. * const input = { * "Bucket": "examplebucket", - * "Key": "exampleobject", - * "VersionId": "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI" + * "Key": "HappyFace.jpg" * }; * const command = new GetObjectTaggingCommand(input); * const response = await client.send(command); @@ -139,14 +135,18 @@ export interface GetObjectTaggingCommandOutput extends GetObjectTaggingOutput, _ * { * "TagSet": [ * { - * "Key": "Key1", - * "Value": "Value1" + * "Key": "Key4", + * "Value": "Value4" + * }, + * { + * "Key": "Key3", + * "Value": "Value3" * } * ], - * "VersionId": "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI" + * "VersionId": "null" * } * *\/ - * // example id: to-retrieve-tag-set-of-a-specific-object-version-1483400283663 + * // example id: to-retrieve-tag-set-of-an-object-1481833847896 * ``` * */ diff --git a/clients/client-s3/src/commands/PutObjectCommand.ts b/clients/client-s3/src/commands/PutObjectCommand.ts index 458c0bda99f0..db31135c3013 100644 --- a/clients/client-s3/src/commands/PutObjectCommand.ts +++ b/clients/client-s3/src/commands/PutObjectCommand.ts @@ -249,26 +249,24 @@ export interface PutObjectCommandOutput extends PutObjectOutput, __MetadataBeare *

Base exception class for all service exceptions from S3 service.

* * @public - * @example To upload an object (specify optional headers) + * @example To upload an object and specify optional tags * ```javascript - * // The following example uploads an object. The request specifies optional request headers to directs S3 to use specific storage class and use server-side encryption. + * // The following example uploads an object. The request specifies optional object tags. The bucket is versioned, therefore S3 returns version ID of the newly created object. * const input = { - * "Body": "HappyFace.jpg", + * "Body": "c:\\HappyFace.jpg", * "Bucket": "examplebucket", * "Key": "HappyFace.jpg", - * "ServerSideEncryption": "AES256", - * "StorageClass": "STANDARD_IA" + * "Tagging": "key1=value1&key2=value2" * }; * const command = new PutObjectCommand(input); * const response = await client.send(command); * /* response == * { * "ETag": "\"6805f2cfc46c0f04559748bb039d69ae\"", - * "ServerSideEncryption": "AES256", - * "VersionId": "CG612hodqujkf8FaaNfp8U..FIhLROcp" + * "VersionId": "psM2sYY4.o1501dSx8wMvnkOzSBB.V4a" * } * *\/ - * // example id: to-upload-an-object-(specify-optional-headers) + * // example id: to-upload-an-object-and-specify-optional-tags-1481762310955 * ``` * * @example To create an object. @@ -290,97 +288,99 @@ export interface PutObjectCommandOutput extends PutObjectOutput, __MetadataBeare * // example id: to-create-an-object-1483147613675 * ``` * - * @example To upload an object + * @example To upload object and specify user-defined metadata * ```javascript - * // The following example uploads an object to a versioning-enabled bucket. The source file is specified using Windows file syntax. S3 returns VersionId of the newly created object. + * // The following example creates an object. The request also specifies optional metadata. If the bucket is versioning enabled, S3 returns version ID in response. * const input = { - * "Body": "HappyFace.jpg", + * "Body": "filetoupload", * "Bucket": "examplebucket", - * "Key": "HappyFace.jpg" + * "Key": "exampleobject", + * "Metadata": { + * "metadata1": "value1", + * "metadata2": "value2" + * } * }; * const command = new PutObjectCommand(input); * const response = await client.send(command); * /* response == * { * "ETag": "\"6805f2cfc46c0f04559748bb039d69ae\"", - * "VersionId": "tpf3zF08nBplQK1XLOefGskR7mGDwcDk" + * "VersionId": "pSKidl4pHBiNwukdbcPXAIs.sshFFOc0" * } * *\/ - * // example id: to-upload-an-object-1481760101010 + * // example id: to-upload-object-and-specify-user-defined-metadata-1483396974757 * ``` * - * @example To upload an object and specify optional tags + * @example To upload an object * ```javascript - * // The following example uploads an object. The request specifies optional object tags. The bucket is versioned, therefore S3 returns version ID of the newly created object. + * // The following example uploads an object to a versioning-enabled bucket. The source file is specified using Windows file syntax. S3 returns VersionId of the newly created object. * const input = { - * "Body": "c:\\HappyFace.jpg", + * "Body": "HappyFace.jpg", * "Bucket": "examplebucket", - * "Key": "HappyFace.jpg", - * "Tagging": "key1=value1&key2=value2" + * "Key": "HappyFace.jpg" * }; * const command = new PutObjectCommand(input); * const response = await client.send(command); * /* response == * { * "ETag": "\"6805f2cfc46c0f04559748bb039d69ae\"", - * "VersionId": "psM2sYY4.o1501dSx8wMvnkOzSBB.V4a" + * "VersionId": "tpf3zF08nBplQK1XLOefGskR7mGDwcDk" * } * *\/ - * // example id: to-upload-an-object-and-specify-optional-tags-1481762310955 + * // example id: to-upload-an-object-1481760101010 * ``` * - * @example To upload an object and specify canned ACL. + * @example To upload an object and specify server-side encryption and object tags * ```javascript - * // The following example uploads and object. The request specifies optional canned ACL (access control list) to all READ access to authenticated users. If the bucket is versioning enabled, S3 returns version ID in response. + * // The following example uploads an object. The request specifies the optional server-side encryption option. The request also specifies optional object tags. If the bucket is versioning enabled, S3 returns version ID in response. * const input = { - * "ACL": "authenticated-read", * "Body": "filetoupload", * "Bucket": "examplebucket", - * "Key": "exampleobject" + * "Key": "exampleobject", + * "ServerSideEncryption": "AES256", + * "Tagging": "key1=value1&key2=value2" * }; * const command = new PutObjectCommand(input); * const response = await client.send(command); * /* response == * { * "ETag": "\"6805f2cfc46c0f04559748bb039d69ae\"", - * "VersionId": "Kirh.unyZwjQ69YxcQLA8z4F5j3kJJKr" + * "ServerSideEncryption": "AES256", + * "VersionId": "Ri.vC6qVlA4dEnjgRV4ZHsHoFIjqEMNt" * } * *\/ - * // example id: to-upload-an-object-and-specify-canned-acl-1483397779571 + * // example id: to-upload-an-object-and-specify-server-side-encryption-and-object-tags-1483398331831 * ``` * - * @example To upload object and specify user-defined metadata + * @example To upload an object and specify canned ACL. * ```javascript - * // The following example creates an object. The request also specifies optional metadata. If the bucket is versioning enabled, S3 returns version ID in response. + * // The following example uploads and object. The request specifies optional canned ACL (access control list) to all READ access to authenticated users. If the bucket is versioning enabled, S3 returns version ID in response. * const input = { + * "ACL": "authenticated-read", * "Body": "filetoupload", * "Bucket": "examplebucket", - * "Key": "exampleobject", - * "Metadata": { - * "metadata1": "value1", - * "metadata2": "value2" - * } + * "Key": "exampleobject" * }; * const command = new PutObjectCommand(input); * const response = await client.send(command); * /* response == * { * "ETag": "\"6805f2cfc46c0f04559748bb039d69ae\"", - * "VersionId": "pSKidl4pHBiNwukdbcPXAIs.sshFFOc0" + * "VersionId": "Kirh.unyZwjQ69YxcQLA8z4F5j3kJJKr" * } * *\/ - * // example id: to-upload-object-and-specify-user-defined-metadata-1483396974757 + * // example id: to-upload-an-object-and-specify-canned-acl-1483397779571 * ``` * - * @example To upload an object and specify server-side encryption and object tags + * @example To upload an object (specify optional headers) * ```javascript - * // The following example uploads an object. The request specifies the optional server-side encryption option. The request also specifies optional object tags. If the bucket is versioning enabled, S3 returns version ID in response. + * // The following example uploads an object. The request specifies optional request headers to directs S3 to use specific storage class and use server-side encryption. * const input = { - * "Body": "filetoupload", + * "Body": "HappyFace.jpg", * "Bucket": "examplebucket", - * "Key": "exampleobject", + * "Key": "HappyFace.jpg", * "ServerSideEncryption": "AES256", - * "Tagging": "key1=value1&key2=value2" + * "StorageClass": "STANDARD_IA" * }; * const command = new PutObjectCommand(input); * const response = await client.send(command); @@ -388,10 +388,10 @@ export interface PutObjectCommandOutput extends PutObjectOutput, __MetadataBeare * { * "ETag": "\"6805f2cfc46c0f04559748bb039d69ae\"", * "ServerSideEncryption": "AES256", - * "VersionId": "Ri.vC6qVlA4dEnjgRV4ZHsHoFIjqEMNt" + * "VersionId": "CG612hodqujkf8FaaNfp8U..FIhLROcp" * } * *\/ - * // example id: to-upload-an-object-and-specify-server-side-encryption-and-object-tags-1483398331831 + * // example id: to-upload-an-object-(specify-optional-headers) * ``` * */ diff --git a/clients/client-s3/src/commands/UploadPartCopyCommand.ts b/clients/client-s3/src/commands/UploadPartCopyCommand.ts index a330ba4d28b9..3ea96249be70 100644 --- a/clients/client-s3/src/commands/UploadPartCopyCommand.ts +++ b/clients/client-s3/src/commands/UploadPartCopyCommand.ts @@ -305,14 +305,15 @@ export interface UploadPartCopyCommandOutput extends UploadPartCopyOutput, __Met *

Base exception class for all service exceptions from S3 service.

* * @public - * @example To upload a part by copying data from an existing object as data source + * @example To upload a part by copying byte range from an existing object as data source * ```javascript - * // The following example uploads a part of a multipart upload by copying data from an existing object as data source. + * // The following example uploads a part of a multipart upload by copying a specified byte range from an existing object as data source. * const input = { * "Bucket": "examplebucket", * "CopySource": "/bucketname/sourceobjectkey", + * "CopySourceRange": "bytes=1-100000", * "Key": "examplelargeobject", - * "PartNumber": "1", + * "PartNumber": "2", * "UploadId": "exampleuoh_10OhKhT7YukE9bjzTPRiuaCotmZM_pFngJFir9OZNrSr5cWa3cq3LZSUsfjI4FI7PkP91We7Nrw--" * }; * const command = new UploadPartCopyCommand(input); @@ -320,23 +321,22 @@ export interface UploadPartCopyCommandOutput extends UploadPartCopyOutput, __Met * /* response == * { * "CopyPartResult": { - * "ETag": "\"b0c6f0e7e054ab8fa2536a2677f8734d\"", - * "LastModified": "2016-12-29T21:24:43.000Z" + * "ETag": "\"65d16d19e65a7508a51f043180edcc36\"", + * "LastModified": "2016-12-29T21:44:28.000Z" * } * } * *\/ - * // example id: to-upload-a-part-by-copying-data-from-an-existing-object-as-data-source-1483046746348 + * // example id: to-upload-a-part-by-copying-byte-range-from-an-existing-object-as-data-source-1483048068594 * ``` * - * @example To upload a part by copying byte range from an existing object as data source + * @example To upload a part by copying data from an existing object as data source * ```javascript - * // The following example uploads a part of a multipart upload by copying a specified byte range from an existing object as data source. + * // The following example uploads a part of a multipart upload by copying data from an existing object as data source. * const input = { * "Bucket": "examplebucket", * "CopySource": "/bucketname/sourceobjectkey", - * "CopySourceRange": "bytes=1-100000", * "Key": "examplelargeobject", - * "PartNumber": "2", + * "PartNumber": "1", * "UploadId": "exampleuoh_10OhKhT7YukE9bjzTPRiuaCotmZM_pFngJFir9OZNrSr5cWa3cq3LZSUsfjI4FI7PkP91We7Nrw--" * }; * const command = new UploadPartCopyCommand(input); @@ -344,12 +344,12 @@ export interface UploadPartCopyCommandOutput extends UploadPartCopyOutput, __Met * /* response == * { * "CopyPartResult": { - * "ETag": "\"65d16d19e65a7508a51f043180edcc36\"", - * "LastModified": "2016-12-29T21:44:28.000Z" + * "ETag": "\"b0c6f0e7e054ab8fa2536a2677f8734d\"", + * "LastModified": "2016-12-29T21:24:43.000Z" * } * } * *\/ - * // example id: to-upload-a-part-by-copying-byte-range-from-an-existing-object-as-data-source-1483048068594 + * // example id: to-upload-a-part-by-copying-data-from-an-existing-object-as-data-source-1483046746348 * ``` * */