diff --git a/.changelog/24113a10aa884c7dbef8b7c9989da291.json b/.changelog/24113a10aa884c7dbef8b7c9989da291.json new file mode 100644 index 00000000000..21ec1c7670d --- /dev/null +++ b/.changelog/24113a10aa884c7dbef8b7c9989da291.json @@ -0,0 +1,8 @@ +{ + "id": "24113a10-aa88-4c7d-bef8-b7c9989da291", + "type": "feature", + "description": "**BREAKFIX**: Correct nullability of InitialCapacityConfig's WorkerCount field. The type of this value has changed from int64 to *int64. Due to this field being marked required, with an enforced minimum of 1, but a default of 0, the former type would result in automatic failure behavior without caller intervention. Calling code will need to be updated accordingly.", + "modules": [ + "service/emrserverless" + ] +} \ No newline at end of file diff --git a/.changelog/d4bc92a6c4064c22bd2b44f9a82587ce.json b/.changelog/d4bc92a6c4064c22bd2b44f9a82587ce.json new file mode 100644 index 00000000000..e4421e9f0e2 --- /dev/null +++ b/.changelog/d4bc92a6c4064c22bd2b44f9a82587ce.json @@ -0,0 +1,8 @@ +{ + "id": "d4bc92a6-c406-4c22-bd2b-44f9a82587ce", + "type": "feature", + "description": "**BREAKFIX**: Correct nullability of GetExperimentResultsInput's Period field. The type of this value has changed from int64 to *int64. Due to the nature of default value serialization, the former type could cause unexpected/incorrect behavior when set to its zero value. Calling code will need to be updated accordingly.", + "modules": [ + "service/evidently" + ] +} \ No newline at end of file diff --git a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/RemoveDefaults.java b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/RemoveDefaults.java index 65842ac6a91..8f4aaecf299 100644 --- a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/RemoveDefaults.java +++ b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/RemoveDefaults.java @@ -3,27 +3,36 @@ import software.amazon.smithy.go.codegen.GoSettings; import software.amazon.smithy.go.codegen.integration.GoIntegration; import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.MemberShape; import software.amazon.smithy.model.shapes.Shape; -import software.amazon.smithy.model.shapes.AbstractShapeBuilder; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.DefaultTrait; import software.amazon.smithy.model.transform.ModelTransformer; import software.amazon.smithy.utils.MapUtils; -import software.amazon.smithy.utils.SetUtils; -import software.amazon.smithy.utils.ToSmithyBuilder; +import java.util.Arrays; +import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; public class RemoveDefaults implements GoIntegration { - private static final Map> toRemove = MapUtils.of( - ShapeId.from("com.amazonaws.s3control#AWSS3ControlServiceV20180820"), SetUtils.of( - ShapeId.from("com.amazonaws.s3control#PublicAccessBlockConfiguration$BlockPublicAcls"), - ShapeId.from("com.amazonaws.s3control#PublicAccessBlockConfiguration$IgnorePublicAcls"), - ShapeId.from("com.amazonaws.s3control#PublicAccessBlockConfiguration$BlockPublicPolicy"), - ShapeId.from("com.amazonaws.s3control#PublicAccessBlockConfiguration$RestrictPublicBuckets") - ) - ); + private static final Map> toRemove = MapUtils.ofEntries( + serviceToShapeIds("com.amazonaws.s3control#AWSS3ControlServiceV20180820", + "com.amazonaws.s3control#PublicAccessBlockConfiguration$BlockPublicAcls", + "com.amazonaws.s3control#PublicAccessBlockConfiguration$IgnorePublicAcls", + "com.amazonaws.s3control#PublicAccessBlockConfiguration$BlockPublicPolicy", + "com.amazonaws.s3control#PublicAccessBlockConfiguration$RestrictPublicBuckets"), + serviceToShapeIds("com.amazonaws.evidently#Evidently", + "com.amazonaws.evidently#ResultsPeriod"), + serviceToShapeIds("com.amazonaws.amplifyuibuilder#AmplifyUIBuilder", + "smithy.go.synthetic#ListPlaceIndexesInput$MaxResults", + "smithy.go.synthetic#SearchPlaceIndexForSuggestionsInput$MaxResults", + "com.amazonaws.location#PlaceIndexSearchResultLimit"), + serviceToShapeIds("com.amazonaws.paymentcryptographydata#PaymentCryptographyDataPlane", + "com.amazonaws.paymentcryptographydata#IntegerRangeBetween4And12"), + serviceToShapeIds("com.amazonaws.emrserverless#AwsToledoWebService", + "com.amazonaws.emrserverless#WorkerCounts")); private boolean mustPreprocess(ShapeId service) { return toRemove.containsKey(service); @@ -38,11 +47,41 @@ public Model preprocessModel(Model model, GoSettings settings) { } private Model removeDefaults(Model model, Set fromShapes) { - return ModelTransformer.create().mapShapes(model, it -> - fromShapes.contains(it.getId()) - ? withoutDefault(it) - : it - ); + Set removedRootDefaults = new HashSet<>(); + Model removedRootDefaultsModel = ModelTransformer.create().mapShapes(model, (shape) -> { + if (shouldRemoveRootDefault(shape, fromShapes)) { + removedRootDefaults.add(shape.getId()); + return withoutDefault(shape); + } else { + return shape; + } + }); + return ModelTransformer.create().mapShapes(removedRootDefaultsModel, (shape) -> { + if (shouldRemoveMemberDefault(shape, removedRootDefaults, fromShapes)) { + return withoutDefault(shape); + } else { + return shape; + } + }); + } + + private boolean shouldRemoveRootDefault(Shape shape, Set removeDefaultsFrom) { + return !shape.isMemberShape() + && removeDefaultsFrom.contains(shape.getId()) + && shape.hasTrait(DefaultTrait.class); + } + + private boolean shouldRemoveMemberDefault( + Shape shape, + Set removedRootDefaults, + Set removeDefaultsFrom + ) { + if (!shape.isMemberShape()) { + return false; + } + MemberShape member = shape.asMemberShape().get(); + return (removedRootDefaults.contains(member.getTarget()) || removeDefaultsFrom.contains(member.getId())) + && member.hasTrait(DefaultTrait.class); } private Shape withoutDefault(Shape shape) { @@ -50,4 +89,10 @@ private Shape withoutDefault(Shape shape) { .removeTrait(DefaultTrait.ID) .build(); } + + private static Map.Entry> serviceToShapeIds(String serviceId, String... shapeIds) { + return Map.entry( + ShapeId.from(serviceId), + Arrays.stream(shapeIds).map(ShapeId::from).collect(Collectors.toSet())); + } } \ No newline at end of file diff --git a/service/emrserverless/deserializers.go b/service/emrserverless/deserializers.go index 30bc060ea42..5ac385d5b6c 100644 --- a/service/emrserverless/deserializers.go +++ b/service/emrserverless/deserializers.go @@ -3121,7 +3121,7 @@ func awsRestjson1_deserializeDocumentInitialCapacityConfig(v **types.InitialCapa if err != nil { return err } - sv.WorkerCount = i64 + sv.WorkerCount = ptr.Int64(i64) } default: diff --git a/service/emrserverless/serializers.go b/service/emrserverless/serializers.go index 2dbedae0d56..5a43ba18c3c 100644 --- a/service/emrserverless/serializers.go +++ b/service/emrserverless/serializers.go @@ -1509,9 +1509,9 @@ func awsRestjson1_serializeDocumentInitialCapacityConfig(v *types.InitialCapacit } } - { + if v.WorkerCount != nil { ok := object.Key("workerCount") - ok.Long(v.WorkerCount) + ok.Long(*v.WorkerCount) } return nil diff --git a/service/emrserverless/types/types.go b/service/emrserverless/types/types.go index 23ad4ef3ed9..7bc4dd18568 100644 --- a/service/emrserverless/types/types.go +++ b/service/emrserverless/types/types.go @@ -286,7 +286,7 @@ type InitialCapacityConfig struct { // The number of workers in the initial capacity configuration. // // This member is required. - WorkerCount int64 + WorkerCount *int64 // The resource configuration of the initial capacity configuration. WorkerConfiguration *WorkerResourceConfig diff --git a/service/emrserverless/validators.go b/service/emrserverless/validators.go index d15e9bc7679..eb58a8b81f2 100644 --- a/service/emrserverless/validators.go +++ b/service/emrserverless/validators.go @@ -440,6 +440,9 @@ func validateInitialCapacityConfig(v *types.InitialCapacityConfig) error { return nil } invalidParams := smithy.InvalidParamsError{Context: "InitialCapacityConfig"} + if v.WorkerCount == nil { + invalidParams.Add(smithy.NewErrParamRequired("WorkerCount")) + } if v.WorkerConfiguration != nil { if err := validateWorkerResourceConfig(v.WorkerConfiguration); err != nil { invalidParams.AddNested("WorkerConfiguration", err.(smithy.InvalidParamsError)) diff --git a/service/evidently/api_op_GetExperimentResults.go b/service/evidently/api_op_GetExperimentResults.go index 0cd2ea6f507..5274d365ff9 100644 --- a/service/evidently/api_op_GetExperimentResults.go +++ b/service/evidently/api_op_GetExperimentResults.go @@ -69,7 +69,7 @@ type GetExperimentResultsInput struct { EndTime *time.Time // In seconds, the amount of time to aggregate results together. - Period int64 + Period *int64 // The names of the report types that you want to see. Currently, BayesianInference // is the only valid value. diff --git a/service/evidently/serializers.go b/service/evidently/serializers.go index 9e707ef1d58..3e8cb487b4c 100644 --- a/service/evidently/serializers.go +++ b/service/evidently/serializers.go @@ -1319,9 +1319,9 @@ func awsRestjson1_serializeOpDocumentGetExperimentResultsInput(v *GetExperimentR } } - if v.Period != 0 { + if v.Period != nil { ok := object.Key("period") - ok.Long(v.Period) + ok.Long(*v.Period) } if v.ReportNames != nil {