Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
isaiahvita committed Jan 16, 2024
1 parent 34be8dd commit 69f9681
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import software.amazon.smithy.aws.go.codegen.AwsSignatureVersion4;
import software.amazon.smithy.aws.go.codegen.AwsSignatureVersion4aUtils;
import software.amazon.smithy.aws.traits.ServiceTrait;
import software.amazon.smithy.aws.traits.auth.SigV4ATrait;
import software.amazon.smithy.aws.traits.auth.SigV4Trait;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.go.codegen.GoDelegator;
Expand All @@ -21,7 +23,9 @@
import software.amazon.smithy.go.codegen.integration.RuntimeClientPlugin;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.model.traits.AuthTrait;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SetUtils;

/**
* This integration configures the CloudFront Key Value Store client for Signature Version 4a
Expand All @@ -47,26 +51,61 @@ public List<RuntimeClientPlugin> getClientPlugins() {
return runtimeClientPlugins;
}

@Override
public Model preprocessModel(Model model, GoSettings settings) {
ServiceShape service = settings.getService(model);
if (!isCFKVSService(model, service)) {
return model;
}

if (settings.getService(model).hasTrait(SigV4ATrait.class)) {
return model;
}

var v4a = SigV4ATrait.builder()
.name(service.expectTrait(SigV4Trait.class).getName())
.build();

return model.toBuilder()
.addShape(
service.toBuilder()
.addTrait(v4a)
.addTrait(new AuthTrait(SetUtils.of(SigV4ATrait.ID, SigV4Trait.ID)))
.build()
)
.build();
}

@Override
public void processFinalizedModel(GoSettings settings, Model model) {
if (!isCFKVSService(model, model.expectShape(settings.getService(), ServiceShape.class))) {
return;
}
runtimeClientPlugins.add(
RuntimeClientPlugin.builder()
.configFields(
ListUtils.of(
ConfigField.builder()
.name(AwsSignatureVersion4aUtils.V4A_SIGNER_INTERFACE_NAME)
.type(SymbolUtils.createValueSymbolBuilder(
AwsSignatureVersion4aUtils.V4A_SIGNER_INTERFACE_NAME)
.build())
.documentation("Signature Version 4a (SigV4a) Signer")
.build()
)
)
.build()
);
RuntimeClientPlugin.builder()
.configFields(
ListUtils.of(
ConfigField.builder()
.name(AwsSignatureVersion4aUtils.V4A_SIGNER_INTERFACE_NAME)
.type(SymbolUtils.createValueSymbolBuilder(
AwsSignatureVersion4aUtils.V4A_SIGNER_INTERFACE_NAME)
.build())
.documentation("Signature Version 4a (SigV4a) Signer")
.build()
)
)
.build());
runtimeClientPlugins.add(
RuntimeClientPlugin.builder()
.servicePredicate(CloudFrontKVSSigV4a::isCFKVSService)
.addConfigFieldResolver(
ConfigFieldResolver.builder()
.location(ConfigFieldResolver.Location.CLIENT)
.target(ConfigFieldResolver.Target.INITIALIZATION)
.resolver(SymbolUtils.createValueSymbolBuilder(
AwsSignatureVersion4aUtils.SIGNER_RESOLVER).build())
.build())
.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ private boolean isBackfillService(ServiceShape service) {
final String serviceId = sdkId.replace("-", "").replace(" ", "").toLowerCase();
return (
serviceId.equalsIgnoreCase("s3") ||
serviceId.equalsIgnoreCase("eventbridge") ||
serviceId.equalsIgnoreCase("cloudfrontkeyvaluestore")
serviceId.equalsIgnoreCase("eventbridge")
);
};

Expand Down
10 changes: 6 additions & 4 deletions service/cloudfrontkeyvaluestore/api_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions service/cloudfrontkeyvaluestore/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions service/cloudfrontkeyvaluestore/options.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 69f9681

Please sign in to comment.