-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add preprocessor to rename the KMS service namespace
- Loading branch information
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...s/src/main/resources/META-INF/services/software.amazon.smithy.build.ProjectionTransformer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.dwolla.smithy.ShadeNamespace |
27 changes: 27 additions & 0 deletions
27
smithy4s-preprocessors/src/main/scala/com/dwolla/smithy/ShadeNamespace.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.dwolla.smithy | ||
|
||
import cats.syntax.all._ | ||
import software.amazon.smithy.build.{ProjectionTransformer, TransformContext} | ||
import software.amazon.smithy.model.Model | ||
import software.amazon.smithy.model.shapes.Shape | ||
|
||
import java.util.stream.Collectors | ||
import scala.collection.JavaConverters._ | ||
|
||
class ShadeNamespace extends ProjectionTransformer { | ||
override def getName: String = "com.dwolla.smithy.ShadeNamespace" | ||
|
||
private val namespacesToRename: Set[String] = Set("com.amazonaws.kms") | ||
|
||
override def transform(context: TransformContext): Model = { | ||
val renames = | ||
context.getModel | ||
.shapes().collect(Collectors.toList[Shape]).asScala.toList | ||
.map(_.getId) | ||
.filter(id => namespacesToRename.contains(id.getNamespace)) | ||
.fproduct(id => id.withNamespace(s"com.dwolla.smithy_shaded.${id.getNamespace}")) | ||
.toMap.asJava | ||
|
||
context.getTransformer.renameShapes(context.getModel, renames) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters