-
Notifications
You must be signed in to change notification settings - Fork 30
fix: account ID based endpoints #1245
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,13 +19,11 @@ import software.amazon.smithy.kotlin.codegen.model.isEnum | |
| import software.amazon.smithy.kotlin.codegen.model.targetOrSelf | ||
| import software.amazon.smithy.kotlin.codegen.model.traits.OperationInput | ||
| import software.amazon.smithy.kotlin.codegen.model.traits.OperationOutput | ||
| import software.amazon.smithy.kotlin.codegen.utils.doubleQuote | ||
| import software.amazon.smithy.kotlin.codegen.utils.dq | ||
| import software.amazon.smithy.kotlin.codegen.utils.getOrNull | ||
| import software.amazon.smithy.kotlin.codegen.utils.toCamelCase | ||
| import software.amazon.smithy.model.shapes.ListShape | ||
| import software.amazon.smithy.model.shapes.MapShape | ||
| import software.amazon.smithy.model.shapes.MemberShape | ||
| import software.amazon.smithy.model.shapes.Shape | ||
| import software.amazon.smithy.model.shapes.* | ||
|
|
||
| private val suffixSequence = sequenceOf("") + generateSequence(2) { it + 1 }.map(Int::toString) // "", "2", "3", etc. | ||
|
|
||
|
|
@@ -526,11 +524,20 @@ class KotlinJmespathExpressionVisitor( | |
| ".$expr" | ||
| } | ||
|
|
||
| private fun VisitedExpression.getKeys(): String { | ||
| val keys = this.shape?.targetOrSelf(ctx.model)?.allMembers | ||
| ?.keys?.joinToString(", ", "listOf(", ")") { "\"$it\"" } | ||
| return keys ?: "listOf<String>()" | ||
| } | ||
| // TODO: Support maps as objects throughout the visitor | ||
| // This visitor assumes JMESPath 'objects' will be classes. DDB assumes JMESPath 'objects' will be maps | ||
|
||
| private fun VisitedExpression.getKeys(): String = | ||
| if (this.shape?.targetOrSelf(ctx.model)?.type == ShapeType.MAP) { | ||
|
||
| "${this.identifier}?.keys?.toList()" | ||
| } else { | ||
|
||
| this | ||
| .shape | ||
| ?.targetOrSelf(ctx.model) | ||
| ?.allMembers | ||
| ?.keys | ||
| ?.joinToString(", ", "listOf(", ")") { it.doubleQuote() } | ||
| ?: "listOf<String>()" | ||
| } | ||
|
|
||
| private fun VisitedExpression.getValues(): String { | ||
| val values = this.shape?.targetOrSelf(ctx.model)?.allMembers?.keys | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,14 +18,14 @@ use smithy.waiters#waitable | |
| } | ||
| ] | ||
| }, | ||
| KeysFunctionPrimitivesIntegerEquals: { | ||
|
Contributor
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. Why was this integer primitives test removed? |
||
| KeysFunctionMapStringEquals: { | ||
| acceptors: [ | ||
| { | ||
| state: "success", | ||
| matcher: { | ||
| output: { | ||
| path: "keys(primitives)", | ||
| expected: "integer", | ||
| path: "keys(maps.strings)", | ||
| expected: "key", | ||
| comparator: "anyStringEquals" | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,12 @@ | |
|
|
||
| package com.test | ||
|
|
||
| import com.test.model.EntityMaps | ||
| import com.test.model.EntityPrimitives | ||
| import com.test.model.GetFunctionKeysEqualsRequest | ||
| import com.test.model.GetFunctionKeysEqualsResponse | ||
| import com.test.utils.successTest | ||
| import com.test.waiters.waitUntilKeysFunctionPrimitivesIntegerEquals | ||
| import com.test.waiters.waitUntilKeysFunctionMapStringEquals | ||
| import com.test.waiters.waitUntilKeysFunctionPrimitivesStringEquals | ||
| import kotlin.test.Test | ||
|
|
||
|
|
@@ -22,9 +23,9 @@ class FunctionKeysTest { | |
| ) | ||
|
|
||
| @Test | ||
| fun testKeysFunctionPrimitivesIntegerEquals() = successTest( | ||
| fun testKeysFunctionMapStringEquals() = successTest( | ||
| GetFunctionKeysEqualsRequest { name = "test" }, | ||
| WaitersTestClient::waitUntilKeysFunctionPrimitivesIntegerEquals, | ||
| GetFunctionKeysEqualsResponse { primitives = EntityPrimitives { } }, | ||
| WaitersTestClient::waitUntilKeysFunctionMapStringEquals, | ||
| GetFunctionKeysEqualsResponse { maps = EntityMaps { strings = mapOf("key" to "value") } }, | ||
| ) | ||
|
Contributor
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. Question: Why did we modify this test case instead of creating a new one? Is the previous behavior no longer valid? |
||
| } | ||
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.
Should this be a FIXME instead of a TODO? Do we have a backlog item we can link here (SDK-KT-x)?
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.
Remove note about DDB
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.
Not sure if it should be a
FIXMEbecause the JMESPath visitor has been assuming classes > maps so far and we have had no apparent problems. Other services use JMESPath but this is the first instance I've seen of maps being used as objects. It might be a DDB only quirk or an indication that we took the wrong approach to objectsThere 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.
Either way it sounds like we need a backlog item for this, to at least investigate the discrepancy
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.
Once that investigation is done we can go back and modify/create a comment here then?
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.
I think we should keep
But change it to mention the discrepancy between the smithy spec and the JMESPath spec for this function
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.
I just think every TODO should have an associated backlog task, otherwise it never gets done