|
1 | 1 | package aws.sdk.kotlin.codegen.businessmetrics |
2 | 2 |
|
3 | 3 | import aws.sdk.kotlin.codegen.AwsRuntimeTypes |
| 4 | +import software.amazon.smithy.aws.traits.auth.SigV4ATrait |
| 5 | +import software.amazon.smithy.aws.traits.auth.SigV4Trait |
| 6 | +import software.amazon.smithy.kotlin.codegen.KotlinSettings |
4 | 7 | import software.amazon.smithy.kotlin.codegen.core.KotlinWriter |
5 | 8 | import software.amazon.smithy.kotlin.codegen.core.RuntimeTypes |
6 | 9 | import software.amazon.smithy.kotlin.codegen.core.withBlock |
7 | 10 | import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration |
8 | 11 | import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolGenerator |
9 | 12 | import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolMiddleware |
| 13 | +import software.amazon.smithy.model.Model |
| 14 | +import software.amazon.smithy.model.knowledge.ServiceIndex |
10 | 15 | import software.amazon.smithy.model.shapes.OperationShape |
11 | 16 |
|
12 | 17 | /** |
13 | 18 | * Renders the addition of some of the credentials related business metrics. |
14 | 19 | */ |
15 | 20 | class CredentialsBusinessMetricsIntegration : KotlinIntegration { |
| 21 | + override fun enabledForService(model: Model, settings: KotlinSettings): Boolean { |
| 22 | + val serviceIndex = ServiceIndex.of(model) |
| 23 | + val schemes = serviceIndex.getAuthSchemes(settings.service) |
| 24 | + |
| 25 | + return schemes.values.any { |
| 26 | + it.javaClass == SigV4ATrait::class.java || it.javaClass == SigV4Trait::class.java |
| 27 | + } |
| 28 | + } |
| 29 | + |
16 | 30 | override fun customizeMiddleware( |
17 | 31 | ctx: ProtocolGenerator.GenerationContext, |
18 | 32 | resolved: List<ProtocolMiddleware>, |
|
0 commit comments