-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…ointers (aws#1195) Adds a backfill customization to the Amazon EC2 API model so that all unboxed number and boolean shapes are correctly decorated as boxed. The API does not handle unboxed members. This causes the API client generated from the model to be unusable in many cases. The generated API client will contain breaking changes, but these breaking changes are here to fix the API client that was unusable in many ways.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"ID": "service.ec2-announcement-1616786271582723000", | ||
"SchemaVersion": 1, | ||
"Module": "service/ec2", | ||
"Type": "announcement", | ||
"Description": "This release contains a breaking change to the Amazon EC2 API client. API number(int/int64/etc) and boolean members were changed from value, to pointer type. Your applications using the EC2 API client will fail to compile after upgrading for all members that were updated. To migrate to this module you'll need to update your application to use pointers for all number and boolean members in the API client module. The SDK provides helper utilities to convert between value and pointer types. For example the [aws.Bool](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws#Bool) function to get the address from a bool literal. Similar utilities are available for all other primative types in the [aws](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws) package.", | ||
"MinVersion": "", | ||
"AffectedModules": null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"ID": "service.ec2-bugfix-1616785668377831000", | ||
"SchemaVersion": 1, | ||
"Module": "service/ec2", | ||
"Type": "bugfix", | ||
"Description": "Fix incorrectly modeled Amazon EC2 number and boolean members in structures. The Amazon EC2 API client has been updated with a breaking change to fix all structure number and boolean members to be pointer types instead of value types. Fixes [#1107](https://github.com/aws/aws-sdk-go-v2/issues/1107), [#1178](https://github.com/aws/aws-sdk-go-v2/issues/1178), and [#1190](https://github.com/aws/aws-sdk-go-v2/issues/1190). This breaking change is made within the major version of the client' module, because the client operations failed and were unusable with value type number and boolean members with the EC2 API.", | ||
"MinVersion": "v1.6.0", | ||
"AffectedModules": null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package software.amazon.smithy.aws.go.codegen.customization; | ||
|
||
import java.util.Set; | ||
import java.util.logging.Logger; | ||
import software.amazon.smithy.codegen.core.CodegenException; | ||
import software.amazon.smithy.go.codegen.CodegenUtils; | ||
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.Shape; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
import software.amazon.smithy.model.shapes.ShapeType; | ||
import software.amazon.smithy.model.traits.BoxTrait; | ||
import software.amazon.smithy.utils.SetUtils; | ||
|
||
public class BackfillEc2UnboxedToBoxedShapes implements GoIntegration { | ||
private static final Logger LOGGER = Logger.getLogger(BackfillEc2UnboxedToBoxedShapes.class.getName()); | ||
|
||
/** | ||
* Map of service shape to Set of operation shapes that need to have this | ||
* presigned url auto fill customization. | ||
*/ | ||
public static final Set<ShapeId> SERVICE_SET = SetUtils.of( | ||
ShapeId.from("com.amazonaws.ec2#AmazonEC2") | ||
); | ||
|
||
/** | ||
* /** | ||
* Updates the API model to customize all number and boolean unboxed shapes to be boxed. | ||
* | ||
* @param model API model | ||
* @param settings Go codegen settings | ||
* @return updated API model | ||
*/ | ||
@Override | ||
public Model preprocessModel(Model model, GoSettings settings) { | ||
ShapeId serviceId = settings.getService(); | ||
if (!SERVICE_SET.contains(serviceId)) { | ||
return model; | ||
} | ||
|
||
Model.Builder builder = model.toBuilder(); | ||
|
||
for (Shape shape : model.toSet()) { | ||
// Only consider number and boolean shapes that are unboxed | ||
if (shape.isMemberShape()) { | ||
continue; | ||
} | ||
if (!(CodegenUtils.isNumber(shape) || shape.getType() == ShapeType.BOOLEAN)) { | ||
continue; | ||
} | ||
if (shape.hasTrait(BoxTrait.class)) { | ||
continue; | ||
} | ||
|
||
switch (shape.getType()) { | ||
case BYTE: | ||
shape = shape.asByteShape().get().toBuilder() | ||
.addTrait(new BoxTrait()) | ||
.build(); | ||
break; | ||
case SHORT: | ||
shape = shape.asShortShape().get().toBuilder() | ||
.addTrait(new BoxTrait()) | ||
.build(); | ||
break; | ||
case INTEGER: | ||
shape = shape.asIntegerShape().get().toBuilder() | ||
.addTrait(new BoxTrait()) | ||
.build(); | ||
break; | ||
case LONG: | ||
shape = shape.asLongShape().get().toBuilder() | ||
.addTrait(new BoxTrait()) | ||
.build(); | ||
break; | ||
case FLOAT: | ||
shape = shape.asFloatShape().get().toBuilder() | ||
.addTrait(new BoxTrait()) | ||
.build(); | ||
break; | ||
case DOUBLE: | ||
shape = shape.asDoubleShape().get().toBuilder() | ||
.addTrait(new BoxTrait()) | ||
.build(); | ||
break; | ||
case BOOLEAN: | ||
shape = shape.asBooleanShape().get().toBuilder() | ||
.addTrait(new BoxTrait()) | ||
.build(); | ||
break; | ||
default: | ||
throw new CodegenException("unexpected shape type for " + shape.getId() + ", " + shape.getType()); | ||
} | ||
|
||
builder.addShape(shape); | ||
} | ||
|
||
return builder.build(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.