-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smithy4s Kinesis Client #36
Merged
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
3924f80
Update to ProjectMatrix
etspaceman 98db831
Add crossScalaVersions
etspaceman 7644a51
Add scalacOptions manually, generate workflows
etspaceman 3829370
Merge remote-tracking branch 'origin/main' into smithy4sclient
etspaceman 50576b9
Fix scalaVersion derivation
etspaceman 2361949
Cleanup PR
etspaceman 3cb8201
Clean up build
etspaceman cddb952
Delete ci.yml
etspaceman a50981b
Delete clean.yml
etspaceman 66d97da
Ignore .sbt files
etspaceman cc11871
Fix class name
etspaceman 120aeca
Workaround for kinesis-mock bugs, fixed localstack integration
etspaceman 7e8722f
Note, bump memory
etspaceman c6652a0
Scaladoc
etspaceman 1aaf41a
NoOpLogger default, markdowns
etspaceman 7600912
Merge remote-tracking branch 'origin/main' into smithy4sclient
etspaceman 635a7f9
Updates
etspaceman 5f8385f
Better pretty rules
etspaceman 2122036
Merge remote-tracking branch 'origin/main' into smithy4sclient
etspaceman 4431a22
WIP on using kinesis spec with transformers
etspaceman fb4cdfe
Cleanup
etspaceman 2d56736
More cleanup
etspaceman d200414
Merge remote-tracking branch 'origin/main' into smithy4sclient
etspaceman 71d7199
Fixes
etspaceman 9f0721a
Remove scala 2.12, project matrix
etspaceman 315a933
Mergify plugin
etspaceman 3714d04
fix build for some reason
etspaceman d244cb5
Remove scoverage, bring back scala 2.12/matrix
etspaceman 94cbdd5
Fix for mergify labels
etspaceman 4493101
Fixes
etspaceman a052373
remove compat dep
etspaceman 4041601
Fix mima
etspaceman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ | ||
preprocessors.KinesisSpecTransformer |
86 changes: 86 additions & 0 deletions
86
preprocessors/src/main/scala/preprocessors/KinesisSpecTransformer.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,86 @@ | ||
package preprocessors | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
import java.util.function | ||
import java.util.function.BiFunction | ||
|
||
import software.amazon.smithy.build.ProjectionTransformer | ||
import software.amazon.smithy.build.TransformContext | ||
import software.amazon.smithy.model.Model | ||
import software.amazon.smithy.model.shapes.IntegerShape | ||
import software.amazon.smithy.model.shapes.MemberShape | ||
import software.amazon.smithy.model.shapes.Shape | ||
import software.amazon.smithy.model.shapes.ShapeId | ||
import software.amazon.smithy.model.shapes.StructureShape | ||
import software.amazon.smithy.model.traits.LengthTrait | ||
import software.amazon.smithy.model.traits.RangeTrait | ||
import software.amazon.smithy.model.traits.Trait | ||
|
||
final class KinesisSpecTransformer extends ProjectionTransformer { | ||
def getName() = "KinesisSpecTransformer" | ||
|
||
private val metricsNameListShapeId = | ||
ShapeId.fromParts("com.amazonaws.kinesis", "MetricsNameList") | ||
|
||
private val putRecordsOutputShapeId = | ||
ShapeId.fromParts("com.amazonaws.kinesis", "PutRecordsOutput") | ||
|
||
private val nonNegativeIntegerObjectShape = | ||
IntegerShape | ||
.builder() | ||
.id( | ||
ShapeId.fromParts("com.amazonaws.kinesis", "NonNegativeIntegerObject") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Counterpart to PositiveIntegerObject |
||
) | ||
.addTrait(RangeTrait.builder().min(java.math.BigDecimal.ZERO).build()) | ||
.build() | ||
|
||
val traitTransform: BiFunction[Shape, Trait, Trait] = | ||
(shape: Shape, `trait`: Trait) => | ||
if ( | ||
`trait`.toShapeId() == LengthTrait.ID && | ||
shape.toShapeId() == metricsNameListShapeId | ||
) { | ||
LengthTrait.builder().min(0).max(7).build() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually this is 1-7. Set to 0-7 |
||
} else `trait` | ||
|
||
val shapeTransform: function.Function[Shape, Shape] = (shape: Shape) => | ||
if (shape.toShapeId() == putRecordsOutputShapeId) { | ||
val members = | ||
shape.getAllMembers().asScala.toList.map { case (memberName, member) => | ||
if (memberName == "FailedRecordCount") | ||
MemberShape | ||
.builder() | ||
.target(nonNegativeIntegerObjectShape.getId()) | ||
.id(member.getId()) | ||
.build() | ||
else member | ||
} | ||
|
||
StructureShape | ||
.builder() | ||
.members(members.asJavaCollection) | ||
.id(putRecordsOutputShapeId) | ||
.traits(shape.getAllTraits().values()) | ||
.build() | ||
} else shape | ||
|
||
def transform(context: TransformContext): Model = { | ||
val withMappedTraits = | ||
context | ||
.getTransformer() | ||
.mapTraits(context.getModel(), traitTransform) | ||
|
||
val newShapes = withMappedTraits | ||
.shapes() | ||
.toList() | ||
.asScala | ||
.toList :+ nonNegativeIntegerObjectShape | ||
|
||
val withNewShapes = | ||
context.getTransformer().replaceShapes(withMappedTraits, newShapes.asJava) | ||
|
||
context.getTransformer().mapShapes(withNewShapes, shapeTransform) | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"imports": ["./kcl-http4s/src/main/smithy"], | ||
"mavenDependencies": [ | ||
"software.amazon.smithy:smithy-rules-engine:1.27.2", | ||
"com.disneystreaming.smithy4s:smithy4s-protocol:0.17.3", | ||
"com.disneystreaming.smithy:aws-kinesis-spec:2023.02.10", | ||
"com.disneystreaming.alloy:alloy-core:0.1.11" | ||
] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brought in sbt-projectmatrix to work through having a subset of scala versions supported here (Smithy4s AWS does not have a 2.12 offering)