15
15
16
16
package software .amazon .smithy .aws .typescript .codegen ;
17
17
18
+ import static software .amazon .smithy .aws .typescript .codegen .AwsTraitsUtils .isSigV4Service ;
18
19
import static software .amazon .smithy .typescript .codegen .integration .RuntimeClientPlugin .Convention .HAS_CONFIG ;
19
20
import static software .amazon .smithy .typescript .codegen .integration .RuntimeClientPlugin .Convention .HAS_MIDDLEWARE ;
20
21
24
25
import java .util .Set ;
25
26
import java .util .function .Consumer ;
26
27
import software .amazon .smithy .aws .traits .ServiceTrait ;
27
- import software .amazon .smithy .aws .traits .auth .SigV4Trait ;
28
28
import software .amazon .smithy .codegen .core .SymbolProvider ;
29
29
import software .amazon .smithy .model .Model ;
30
30
import software .amazon .smithy .model .knowledge .TopDownIndex ;
@@ -56,7 +56,7 @@ public void addConfigInterfaceFields(
56
56
TypeScriptWriter writer
57
57
) {
58
58
ServiceShape service = settings .getService (model );
59
- if (!serviceUsesAwsAuth (service )) {
59
+ if (!isSigV4Service (service )) {
60
60
return ;
61
61
}
62
62
if (!areAllOptionalAuthOperations (model , service )) {
@@ -71,13 +71,13 @@ public List<RuntimeClientPlugin> getClientPlugins() {
71
71
return ListUtils .of (
72
72
RuntimeClientPlugin .builder ()
73
73
.withConventions (AwsDependency .MIDDLEWARE_SIGNING .dependency , "AwsAuth" , HAS_CONFIG )
74
- .servicePredicate ((m , s ) -> serviceUsesAwsAuth (s ) && !areAllOptionalAuthOperations (m , s ))
74
+ .servicePredicate ((m , s ) -> isSigV4Service (s ) && !areAllOptionalAuthOperations (m , s ))
75
75
.build (),
76
76
RuntimeClientPlugin .builder ()
77
77
.withConventions (AwsDependency .MIDDLEWARE_SIGNING .dependency , "AwsAuth" , HAS_MIDDLEWARE )
78
78
// See operationUsesAwsAuth() below for AwsAuth Middleware customizations.
79
79
.servicePredicate (
80
- (m , s ) -> !testServiceId (s , "STS" ) && serviceUsesAwsAuth (s ) && !hasOptionalAuthOperation (m , s )
80
+ (m , s ) -> !testServiceId (s , "STS" ) && isSigV4Service (s ) && !hasOptionalAuthOperation (m , s )
81
81
).build (),
82
82
RuntimeClientPlugin .builder ()
83
83
.withConventions (AwsDependency .MIDDLEWARE_SIGNING .dependency , "AwsAuth" , HAS_MIDDLEWARE )
@@ -94,7 +94,7 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
94
94
LanguageTarget target
95
95
) {
96
96
ServiceShape service = settings .getService (model );
97
- if (!serviceUsesAwsAuth (service ) || areAllOptionalAuthOperations (model , service )) {
97
+ if (!isSigV4Service (service ) || areAllOptionalAuthOperations (model , service )) {
98
98
return Collections .emptyMap ();
99
99
}
100
100
switch (target ) {
@@ -124,10 +124,6 @@ private static boolean testServiceId(Shape serviceShape, String expectedId) {
124
124
return serviceShape .getTrait (ServiceTrait .class ).map (ServiceTrait ::getSdkId ).orElse ("" ).equals (expectedId );
125
125
}
126
126
127
- private static boolean serviceUsesAwsAuth (Shape serviceShape ) {
128
- return serviceShape .hasTrait (SigV4Trait .class );
129
- }
130
-
131
127
private static boolean operationUsesAwsAuth (Model model , ServiceShape service , OperationShape operation ) {
132
128
// STS doesn't need auth for AssumeRoleWithWebIdentity, AssumeRoleWithSAML.
133
129
// Remove when optionalAuth model update is published in 0533102932.
@@ -139,7 +135,7 @@ private static boolean operationUsesAwsAuth(Model model, ServiceShape service, O
139
135
}
140
136
141
137
// optionalAuth trait doesn't require authentication.
142
- if (serviceUsesAwsAuth (service ) && hasOptionalAuthOperation (model , service )) {
138
+ if (isSigV4Service (service ) && hasOptionalAuthOperation (model , service )) {
143
139
return !operation .hasTrait (OptionalAuthTrait .class );
144
140
}
145
141
return false ;
0 commit comments