Skip to content

Commit

Permalink
feat(experimentalIdentityAndAuth): add traitId to HttpAuthScheme (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Yuan authored Sep 19, 2023
1 parent e6716af commit 38e2831
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@SmithyUnstableApi
public final class HttpAuthScheme implements ToSmithyBuilder<HttpAuthScheme> {
private final ShapeId schemeId;
private final ShapeId traitId;
private final ApplicationProtocol applicationProtocol;
private final Map<LanguageTarget, Consumer<TypeScriptWriter>> defaultIdentityProviders;
private final Map<LanguageTarget, Consumer<TypeScriptWriter>> defaultSigners;
Expand All @@ -38,6 +39,7 @@ public final class HttpAuthScheme implements ToSmithyBuilder<HttpAuthScheme> {
private HttpAuthScheme(Builder builder) {
this.schemeId = SmithyBuilder.requiredState(
"schemeId", builder.schemeId);
this.traitId = builder.traitId != null ? builder.traitId : schemeId;
this.applicationProtocol = SmithyBuilder.requiredState(
"applicationProtocol", builder.applicationProtocol);
this.defaultIdentityProviders = SmithyBuilder.requiredState(
Expand All @@ -60,6 +62,14 @@ public ShapeId getSchemeId() {
return schemeId;
}

/**
* Gets the trait ID.
* @return traitId
*/
public ShapeId getTraitId() {
return traitId;
}

/**
* Gets the application protocol.
* @return applicationProtocol
Expand Down Expand Up @@ -133,6 +143,7 @@ public static Builder builder() {
public Builder toBuilder() {
return builder()
.schemeId(schemeId)
.traitId(traitId)
.applicationProtocol(applicationProtocol)
.defaultIdentityProviders(defaultIdentityProviders)
.defaultSigners(defaultSigners)
Expand All @@ -146,6 +157,7 @@ public Builder toBuilder() {
*/
public static final class Builder implements SmithyBuilder<HttpAuthScheme> {
private ShapeId schemeId;
private ShapeId traitId;
private ApplicationProtocol applicationProtocol;
private BuilderRef<Map<LanguageTarget, Consumer<TypeScriptWriter>>> defaultIdentityProviders =
BuilderRef.forOrderedMap();
Expand Down Expand Up @@ -175,6 +187,16 @@ public Builder schemeId(ShapeId schemeId) {
return this;
}

/**
* Sets the traitId.
* @param traitId trait ID to set
* @return the builder
*/
public Builder traitId(ShapeId traitId) {
this.traitId = traitId;
return this;
}

/**
* Sets the applicationProtocol.
* @param applicationProtocol application protocol to set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private void generateHttpAuthOptionFunction(ShapeId shapeId, HttpAuthScheme auth
if (authScheme == null) {
return;
}
Trait trait = serviceShape.findTrait(shapeId).orElse(null);
Trait trait = serviceShape.findTrait(authScheme.getTraitId()).orElse(null);
List<HttpAuthOptionProperty> identityProperties =
authScheme.getAuthSchemeOptionParametersByType(Type.IDENTITY);
if (!identityProperties.isEmpty()) {
Expand Down

0 comments on commit 38e2831

Please sign in to comment.