Skip to content

Commit

Permalink
mark every HLL/DDBM API experimental (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianbotsf authored Oct 4, 2024
1 parent e080cea commit 5a1c004
Show file tree
Hide file tree
Showing 85 changed files with 438 additions and 3 deletions.
1 change: 1 addition & 0 deletions hll/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ val sdkVersion: String by project
val libraries = libs

val optinAnnotations = listOf(
"aws.smithy.kotlin.runtime.ExperimentalApi",
"aws.smithy.kotlin.runtime.InternalApi",
"aws.sdk.kotlin.runtime.InternalSdkApi",
"kotlin.RequiresOptIn",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ internal class DataTypeGenerator(
private val structure: Structure,
) : CodeGenerator by generator {
fun generate() {
write("@#T", Types.Smithy.ExperimentalApi)
withBlock("public interface #T {", "}", structure.type) {
write("@#T", Types.Smithy.ExperimentalApi)
write("public companion object { }") // leave room for future expansion
blankLine()
members { write("public val #L: #T", name, type) }
Expand All @@ -83,6 +85,7 @@ internal class DataTypeGenerator(
BuilderRenderer(this, structure.type, implType, structure.members, builderCtx).render()

blankLine()
write("@#T", Types.Smithy.ExperimentalApi)
withBlock(
"public fun #1L#2T.toBuilder(): #3L#4L = #3L#4L().apply {",
"}",
Expand All @@ -95,6 +98,7 @@ internal class DataTypeGenerator(
}

blankLine()
write("@#T", Types.Smithy.ExperimentalApi)
withBlock(
"public fun #1L#2T.copy(block: #3L#4L.() -> Unit): #2T =",
"",
Expand All @@ -107,6 +111,7 @@ internal class DataTypeGenerator(
}

blankLine()
write("@#T", Types.Smithy.ExperimentalApi)
withBlock(
"public fun #L#L(block: #L#L.() -> Unit): #T =",
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ internal class OperationsTypeRenderer(
write("operations after mapping objects to items and vice versa")
write("@param T The type of objects which will be read from and/or written to this #L", entityName)
}

write("@#T", Types.Smithy.ExperimentalApi)
writeInline("public interface #T ", interfaceType)

parentType?.let { writeInline(": #T ", parentType) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ internal class PaginatorRenderer(

private fun renderItemsPaginator() {
val jvmName = "${op.methodName}${paginationInfo.items.name.capitalizeFirstChar}"
write("@#T", Types.Smithy.ExperimentalApi)
write("@#T(#S)", Types.Kotlin.Jvm.JvmName, jvmName)
withBlock("public fun <T> #T.items(): #T =", "", pageFlowType, itemFlowType) {
withBlock("#T { page ->", "}", Types.Kotlinx.Coroutines.Flow.transform) {
Expand All @@ -123,6 +124,7 @@ internal class PaginatorRenderer(
}

private fun renderPaginatorWithDsl() {
write("@#T", Types.Smithy.ExperimentalApi)
writeInline("public inline fun <T> ")

extensionOf?.let { writeInline("#T.", extensionOf) }
Expand All @@ -139,6 +141,7 @@ internal class PaginatorRenderer(
}

private fun renderPaginatorWithRequest() {
write("@#T", Types.Smithy.ExperimentalApi)
writeInline("public fun <T> ")

extensionOf?.let { writeInline("#T.", extensionOf) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ internal class SchemaRenderer(
}

private fun renderItemConverter() {
write("@#T", Types.Smithy.ExperimentalApi)
withBlock("#Lobject #L : #T by #T(", ")", ctx.attributes.visibility, converterName, MapperTypes.Items.itemConverter(classType), MapperTypes.Items.SimpleItemConverter) {
if (shouldRenderBuilder) {
write("builderFactory = ::#L,", builderName)
Expand All @@ -127,6 +128,7 @@ internal class SchemaRenderer(
*/
private fun renderValueConverter() {
// TODO Offer alternate serialization options besides AttributeValue.M?
write("@#T", Types.Smithy.ExperimentalApi)
write(
"#Lval #L : #T = #T.#T(#T)",
ctx.attributes.visibility,
Expand Down Expand Up @@ -275,6 +277,7 @@ internal class SchemaRenderer(
MapperTypes.Items.itemSchemaPartitionKey(classType, partitionKeyProp.typeRef)
}

write("@#T", Types.Smithy.ExperimentalApi)
withBlock("#Lobject #L : #T {", "}", ctx.attributes.visibility, schemaName, schemaType) {
write("override val converter : #1T = #1T", itemConverter)
write("override val partitionKey: #T = #T(#S)", MapperTypes.Items.keySpec(partitionKeyProp.keySpec), partitionKeyProp.keySpecType, partitionKeyProp.name)
Expand Down Expand Up @@ -305,6 +308,7 @@ internal class SchemaRenderer(
docs("Returns a reference to a table named [name] containing items representing [#T]", classType)

val fnName = "get${className}Table"
write("@#T", Types.Smithy.ExperimentalApi)
write(
"#Lfun #T.#L(name: String): #T = #L(name, #L)",
ctx.attributes.visibility,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ package aws.sdk.kotlin.hll.dynamodbmapper.plugins

import aws.sdk.kotlin.hll.codegen.rendering.RenderOptions
import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.AnnotationsProcessorOptions
import aws.smithy.kotlin.runtime.ExperimentalApi
import com.google.devtools.ksp.gradle.KspExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.create

@ExperimentalApi
public class SchemaGeneratorPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
val extension = createExtension()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package aws.sdk.kotlin.hll.dynamodbmapper.plugins

import aws.sdk.kotlin.hll.codegen.rendering.Visibility
import aws.sdk.kotlin.hll.codegen.rendering.Visibility.PUBLIC
import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.DestinationPackage
import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.GenerateBuilderClasses
import aws.smithy.kotlin.runtime.ExperimentalApi

internal const val SCHEMA_GENERATOR_PLUGIN_EXTENSION = "dynamoDbMapper"

@ExperimentalApi
public open class SchemaGeneratorPluginExtension {
/**
* Determines when a builder class should be generated for user classes. Defaults to "WHEN_REQUIRED".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ class SchemaGeneratorPluginTest {
fun testGenerateBuilderOption() {
val pluginConfiguration = """
import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.GenerateBuilderClasses
import aws.smithy.kotlin.runtime.ExperimentalApi
@OptIn(ExperimentalApi::class)
dynamoDbMapper {
generateBuilderClasses = GenerateBuilderClasses.ALWAYS
}
Expand Down Expand Up @@ -233,6 +236,9 @@ class SchemaGeneratorPluginTest {
fun testVisibilityOption() {
val pluginConfiguration = """
import aws.sdk.kotlin.hll.codegen.rendering.Visibility
import aws.smithy.kotlin.runtime.ExperimentalApi
@OptIn(ExperimentalApi::class)
dynamoDbMapper {
visibility = Visibility.INTERNAL
}
Expand Down Expand Up @@ -260,6 +266,9 @@ class SchemaGeneratorPluginTest {
@Test
fun testGenerateGetTableFunctionOption() {
val pluginConfiguration = """
import aws.smithy.kotlin.runtime.ExperimentalApi
@OptIn(ExperimentalApi::class)
dynamoDbMapper {
generateGetTableExtension = false
}
Expand Down Expand Up @@ -288,6 +297,9 @@ class SchemaGeneratorPluginTest {
fun testRelativeDestinationPackage() {
val pluginConfiguration = """
import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.DestinationPackage
import aws.smithy.kotlin.runtime.ExperimentalApi
@OptIn(ExperimentalApi::class)
dynamoDbMapper {
destinationPackage = DestinationPackage.Relative("hello.moto")
}
Expand All @@ -312,6 +324,9 @@ class SchemaGeneratorPluginTest {
fun testAbsoluteDestinationPackage() {
val pluginConfiguration = """
import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.DestinationPackage
import aws.smithy.kotlin.runtime.ExperimentalApi
@OptIn(ExperimentalApi::class)
dynamoDbMapper {
destinationPackage = DestinationPackage.Absolute("absolutely.my.`package`")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemConverter
import aws.sdk.kotlin.hll.dynamodbmapper.items.SimpleItemConverter
import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.IntConverter
import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.StringConverter
import aws.smithy.kotlin.runtime.ExperimentalApi
import org.example.CustomUser

@OptIn(ExperimentalApi::class)
public object MyCustomUserConverter : ItemConverter<CustomUser> by SimpleItemConverter(
builderFactory = { CustomUser() },
build = { this },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
*/
package org.example

import aws.smithy.kotlin.runtime.ExperimentalApi
import org.example.dynamodbmapper.generatedschemas.ListsConverter
import kotlin.test.Test
import kotlin.test.assertEquals

@OptIn(ExperimentalApi::class)
public class ListsTest {
@Test
fun converterTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
*/
package org.example

import aws.smithy.kotlin.runtime.ExperimentalApi
import org.example.dynamodbmapper.generatedschemas.MapsConverter
import kotlin.test.Test
import kotlin.test.assertEquals

@OptIn(ExperimentalApi::class)
public class MapsTest {
@Test
fun converterTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
*/
package org.example

import aws.smithy.kotlin.runtime.ExperimentalApi
import aws.smithy.kotlin.runtime.content.Document
import aws.smithy.kotlin.runtime.net.url.Url
import aws.smithy.kotlin.runtime.time.Instant
import org.example.dynamodbmapper.generatedschemas.PrimitivesConverter
import kotlin.test.Test
import kotlin.test.assertEquals

@OptIn(ExperimentalApi::class)
public class PrimitivesTest {
@Test
fun converterTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
*/
package org.example

import aws.smithy.kotlin.runtime.ExperimentalApi
import org.example.dynamodbmapper.generatedschemas.SetsConverter
import kotlin.test.Test
import kotlin.test.assertEquals

@OptIn(ExperimentalApi::class)
public class SetsTest {
@Test
fun converterTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ package org.example

import aws.sdk.kotlin.hll.dynamodbmapper.model.itemOf
import aws.sdk.kotlin.services.dynamodb.model.AttributeValue
import aws.smithy.kotlin.runtime.ExperimentalApi
import org.example.dynamodbmapper.generatedschemas.UserConverter
import kotlin.test.Test
import kotlin.test.assertEquals

@OptIn(ExperimentalApi::class)
class UserTest {
@Test
fun testConversion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import aws.sdk.kotlin.hll.dynamodbmapper.model.Table
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.Interceptor
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.InterceptorAny
import aws.sdk.kotlin.services.dynamodb.DynamoDbClient
import aws.smithy.kotlin.runtime.ExperimentalApi

/**
* A high-level client for DynamoDB which maps custom data types into DynamoDB attributes and vice versa.
*/
@ExperimentalApi
public interface DynamoDbMapper {
@ExperimentalApi
public companion object {
/**
* Instantiate a new [Config] object
Expand Down Expand Up @@ -109,6 +112,7 @@ public interface DynamoDbMapper {
* @param client The low-level DynamoDB client to use for underlying calls to the service
* @param config A DSL configuration block
*/
@ExperimentalApi
public fun DynamoDbMapper(
client: DynamoDbClient,
config: DynamoDbMapper.Config.Builder.() -> Unit = { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
*/
package aws.sdk.kotlin.hll.dynamodbmapper.annotations

import aws.smithy.kotlin.runtime.ExperimentalApi

/**
* Indicates that an operation invocation method (e.g., `query`) does not provide automatic pagination. While desirable
* in advanced scenarios, the typical use case should favor the paginated equivalent (e.g., `queryPaginated`).
*/
@ExperimentalApi
@RequiresOptIn(message = "This method does not provide automatic pagination over results and should only be used in advanced scenarios. Where possible, consider using the paginated equivalent. To explicitly opt into using this method, annotate the call site with `@OptIn(ManualPagination::class)`.")
public annotation class ManualPagination(val paginatedEquivalent: String)
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
package aws.sdk.kotlin.hll.dynamodbmapper.expressions

import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.AndExprImpl
import aws.smithy.kotlin.runtime.ExperimentalApi

/**
* Represents an `AND` expression as described in
* [DynamoDB's **logical evaluations** documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations).
* This expression will be true if `(operand[0] && operand[1] && ... && operand[n - 1])`.
*/
@ExperimentalApi
public interface AndExpr : BooleanExpr {
/**
* A list of 2 or more [BooleanExpr] conditions which are ANDed together
Expand All @@ -24,4 +26,5 @@ public interface AndExpr : BooleanExpr {
* Creates a new [AndExpr] with the given [operands]
* @param operands A list of 2 or more [BooleanExpr] conditions which are ANDed together
*/
@ExperimentalApi
public fun AndExpr(operands: List<BooleanExpr>): AndExpr = AndExprImpl(operands)
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions
import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.AttrPathIndexImpl
import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.AttrPathNameImpl
import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.AttributePathImpl
import aws.smithy.kotlin.runtime.ExperimentalApi

/**
* Represents an element in an [AttributePath]
*/
@ExperimentalApi
public sealed interface AttrPathElement {
/**
* Represents the name of a top-level attribute or a key in a map
*/
@ExperimentalApi
public interface Name : AttrPathElement {
/**
* The name or key of this element
Expand All @@ -25,6 +28,7 @@ public sealed interface AttrPathElement {
/**
* Represents an index into a list/set
*/
@ExperimentalApi
public interface Index : AttrPathElement {
/**
* The index (starting at `0`)
Expand All @@ -42,6 +46,7 @@ public sealed interface AttrPathElement {
*
* See [Filter] for more information about creating references to attributes.
*/
@ExperimentalApi
public interface AttributePath : Expression {
/**
* The [AttrPathElement] for this path
Expand All @@ -63,6 +68,7 @@ public interface AttributePath : Expression {
* @param parent The parent [AttributePath] (if any) of this element. If [parent] is `null` then this instance
* represents a top-level attribute.
*/
@ExperimentalApi
public fun AttributePath(name: String, parent: AttributePath? = null): AttributePath =
AttributePathImpl(AttrPathNameImpl(name), parent)

Expand All @@ -71,5 +77,6 @@ public fun AttributePath(name: String, parent: AttributePath? = null): Attribute
* @param index The index (starting at `0`) of this element
* @param parent The parent [AttributePath] of this element
*/
@ExperimentalApi
public fun AttributePath(index: Int, parent: AttributePath): AttributePath =
AttributePathImpl(AttrPathIndexImpl(index), parent)
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
*/
package aws.sdk.kotlin.hll.dynamodbmapper.expressions

import aws.smithy.kotlin.runtime.ExperimentalApi

/**
* Represents a
* [DynamoDB attribute data type](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes)
* @param abbreviation The DynamoDB type name
*/
@ExperimentalApi
public enum class AttributeType(public val abbreviation: kotlin.String) {
/**
* Binary data type, denoted in DynamoDB as `B`
Expand Down
Loading

0 comments on commit 5a1c004

Please sign in to comment.