diff --git a/.changes/b6288fbe-a409-473c-a6ac-12c3c310b963.json b/.changes/b6288fbe-a409-473c-a6ac-12c3c310b963.json new file mode 100644 index 000000000..28a725e54 --- /dev/null +++ b/.changes/b6288fbe-a409-473c-a6ac-12c3c310b963.json @@ -0,0 +1,5 @@ +{ + "id": "b6288fbe-a409-473c-a6ac-12c3c310b963", + "type": "misc", + "description": "Generate internal-only clients with `internal` visibility" +} \ No newline at end of file diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/KotlinSettings.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/KotlinSettings.kt index c23bb0415..59558ae83 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/KotlinSettings.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/KotlinSettings.kt @@ -14,6 +14,7 @@ import software.amazon.smithy.model.node.StringNode import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.ShapeId +import java.lang.IllegalArgumentException import java.util.Optional import java.util.logging.Logger import kotlin.streams.toList @@ -25,6 +26,7 @@ private const val PACKAGE_NAME = "name" private const val PACKAGE_VERSION = "version" private const val PACKAGE_DESCRIPTION = "description" private const val BUILD_SETTINGS = "build" +private const val API_SETTINGS = "api" // Optional specification of sdkId for models that provide them, otherwise Service's shape id name is used private const val SDK_ID = "sdkId" @@ -37,6 +39,7 @@ data class KotlinSettings( val pkg: PackageSettings, val sdkId: String, val build: BuildSettings = BuildSettings.Default, + val api: ApiSettings = ApiSettings.Default, ) { /** @@ -91,11 +94,13 @@ data class KotlinSettings( // Load the sdk id from configurations that define it, fall back to service name for those that don't. val sdkId = config.getStringMemberOrDefault(SDK_ID, serviceId.name) val build = config.getObjectMember(BUILD_SETTINGS) + val api = config.getObjectMember(API_SETTINGS) return KotlinSettings( serviceId, PackageSettings(packageName, version, desc), sdkId, BuildSettings.fromNode(build), + ApiSettings.fromNode(api), ) } } @@ -170,8 +175,7 @@ data class BuildSettings( fun fromNode(node: Optional): BuildSettings = node.map { val generateFullProject = node.get().getBooleanMemberOrDefault(ROOT_PROJECT, false) val generateBuildFiles = node.get().getBooleanMemberOrDefault(GENERATE_DEFAULT_BUILD_FILES, true) - val generateMultiplatformProject = - node.get().getBooleanMemberOrDefault(GENERATE_MULTIPLATFORM_MODULE, false) + val generateMultiplatformProject = node.get().getBooleanMemberOrDefault(GENERATE_MULTIPLATFORM_MODULE, false) val annotations = node.get().getArrayMember(ANNOTATIONS).map { it.elements.mapNotNull { node -> node.asStringNode().map { stringNode -> @@ -193,3 +197,45 @@ data class BuildSettings( class UnresolvableProtocolException(message: String) : CodegenException(message) private fun Optional.orNull(): T? = if (isPresent) get() else null + +/** + * The visibility of code-generated classes, objects, interfaces, etc. + * Valid values are `public` and `internal`. `private` not supported because codegen would not compile with private classes. + */ +enum class Visibility(val value: String) { + PUBLIC("public"), + INTERNAL("internal"), + ; + + override fun toString(): String = value + + companion object { + public fun fromValue(value: String): Visibility = when (value.lowercase()) { + "public" -> PUBLIC + "internal" -> INTERNAL + else -> throw IllegalArgumentException("$value is not a valid Visibility value, expected $PUBLIC or $INTERNAL") + } + } +} + +/** + * Contains API settings for a Kotlin project + * @param visibility Enum representing the visibility of code-generated classes, objects, interfaces, etc. + */ +data class ApiSettings( + val visibility: Visibility = Visibility.PUBLIC, +) { + companion object { + const val VISIBILITY = "visibility" + + fun fromNode(node: Optional): ApiSettings = node.map { + val visibility = Visibility.fromValue(node.get().getStringMemberOrDefault(VISIBILITY, "public")) + ApiSettings(visibility) + }.orElse(Default) + + /** + * Default build settings + */ + val Default: ApiSettings = ApiSettings() + } +} diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ExceptionBaseClassGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ExceptionBaseClassGenerator.kt index 018f3d04b..4dc69ab2f 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ExceptionBaseClassGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ExceptionBaseClassGenerator.kt @@ -34,8 +34,9 @@ object ExceptionBaseClassGenerator { val name = clientName(ctx.settings.sdkId) writer.dokka("Base class for all service related exceptions thrown by the $name client") writer.withBlock( - "public open class #T : #T {", + "#L open class #T : #T {", "}", + ctx.settings.api.visibility, serviceException, baseException, ) { diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ServiceClientGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ServiceClientGenerator.kt index ef105bae4..6151cbacc 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ServiceClientGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ServiceClientGenerator.kt @@ -70,8 +70,8 @@ class ServiceClientGenerator(private val ctx: RenderingContext) { fun render() { writer.write("\n\n") - writer.write("public const val ServiceId: String = #S", ctx.settings.sdkId) - writer.write("public const val SdkVersion: String = #S", ctx.settings.pkg.version) + writer.write("#L const val ServiceId: String = #S", ctx.settings.api.visibility, ctx.settings.sdkId) + writer.write("#L const val SdkVersion: String = #S", ctx.settings.api.visibility, ctx.settings.pkg.version) writer.write("\n\n") writer.putContext("service.name", ctx.settings.sdkId) @@ -82,7 +82,11 @@ class ServiceClientGenerator(private val ctx: RenderingContext) { writer.renderDocumentation(service) writer.renderAnnotations(service) - writer.openBlock("public interface ${serviceSymbol.name} : #T {", RuntimeTypes.SmithyClient.SdkClient) + writer.openBlock( + "#L interface ${serviceSymbol.name} : #T {", + ctx.settings.api.visibility, + RuntimeTypes.SmithyClient.SdkClient, + ) .call { // allow access to client's Config writer.dokka("${serviceSymbol.name}'s configuration") @@ -198,7 +202,12 @@ class ServiceClientGenerator(private val ctx: RenderingContext) { write("Any resources created on your behalf will be shared between clients, and will only be closed when ALL clients using them are closed.") write("If you provide a resource (e.g. [HttpClientEngine]) to the SDK, you are responsible for managing the lifetime of that resource.") } - writer.withBlock("public fun #1T.withConfig(block: #1T.Config.Builder.() -> Unit): #1T {", "}", serviceSymbol) { + writer.withBlock( + "#1L fun #2T.withConfig(block: #2T.Config.Builder.() -> Unit): #2T {", + "}", + ctx.settings.api.visibility, + serviceSymbol, + ) { write("val newConfig = config.toBuilder().apply(block).build()") write("return Default#L(newConfig)", serviceSymbol.name) } @@ -219,7 +228,8 @@ class ServiceClientGenerator(private val ctx: RenderingContext) { writer.renderDocumentation(op) writer.renderAnnotations(op) writer.write( - "public suspend inline fun #T.#L(crossinline block: #T.Builder.() -> Unit): #T = #L(#T.Builder().apply(block).build())", + "#L suspend inline fun #T.#L(crossinline block: #T.Builder.() -> Unit): #T = #L(#T.Builder().apply(block).build())", + ctx.settings.api.visibility, serviceSymbol, operationName, inputSymbol, diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/StructureGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/StructureGenerator.kt index 85d54f13f..632d42902 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/StructureGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/StructureGenerator.kt @@ -52,7 +52,11 @@ class StructureGenerator( * Renders a normal (non-error) Smithy structure to a Kotlin class */ private fun renderStructure() { - writer.openBlock("public class #T private constructor(builder: Builder) {", symbol) + writer.openBlock( + "#L class #T private constructor(builder: Builder) {", + ctx.settings.api.visibility, + symbol, + ) .call { renderImmutableProperties() } .write("") .call { renderCompanionObject() } @@ -299,7 +303,11 @@ class StructureGenerator( val exceptionBaseClass = ExceptionBaseClassGenerator.baseExceptionSymbol(ctx.settings) writer.addImport(exceptionBaseClass) - writer.openBlock("public class #T private constructor(builder: Builder) : ${exceptionBaseClass.name}() {", symbol) + writer.openBlock( + "#L class #T private constructor(builder: Builder) : ${exceptionBaseClass.name}() {", + ctx.settings.api.visibility, + symbol, + ) .write("") .call { renderImmutableProperties() } .write("") diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/auth/AuthSchemeParametersGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/auth/AuthSchemeParametersGenerator.kt index f1ffa4fa2..57193f19e 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/auth/AuthSchemeParametersGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/auth/AuthSchemeParametersGenerator.kt @@ -48,7 +48,12 @@ class AuthSchemeParametersGenerator : AbstractConfigGenerator() { val implSymbol = getImplementationSymbol(ctx.settings) ctx.delegator.useSymbolWriter(symbol) { writer -> - writer.withBlock("public interface #T {", "}", symbol) { + writer.withBlock( + "#L interface #T {", + "}", + ctx.settings.api.visibility, + symbol, + ) { dokka("The name of the operation currently being invoked.") write("public val operationName: String") } diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/auth/AuthSchemeProviderGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/auth/AuthSchemeProviderGenerator.kt index 5c265b824..8f4b59cc6 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/auth/AuthSchemeProviderGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/auth/AuthSchemeProviderGenerator.kt @@ -54,7 +54,8 @@ open class AuthSchemeProviderGenerator { write("See [#T] for the default SDK behavior of this interface.", getDefaultSymbol(ctx.settings)) } writer.write( - "public interface #T : #T<#T>", + "#L interface #T : #T<#T>", + ctx.settings.api.visibility, symbol, RuntimeTypes.Auth.Identity.AuthSchemeProvider, paramsSymbol, @@ -64,8 +65,9 @@ open class AuthSchemeProviderGenerator { private fun renderDefaultImpl(ctx: ProtocolGenerator.GenerationContext, writer: KotlinWriter) { // FIXME - probably can't remain an object writer.withBlock( - "public object #T : #T {", + "#L object #T : #T {", "}", + ctx.settings.api.visibility, getDefaultSymbol(ctx.settings), getSymbol(ctx.settings), ) { diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/DefaultEndpointProviderGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/DefaultEndpointProviderGenerator.kt index bbb06cd9d..63eea544d 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/DefaultEndpointProviderGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/DefaultEndpointProviderGenerator.kt @@ -62,6 +62,7 @@ class DefaultEndpointProviderGenerator( private val defaultProviderSymbol: Symbol, private val interfaceSymbol: Symbol, private val paramsSymbol: Symbol, + private val settings: KotlinSettings, private val externalFunctions: Map = emptyMap(), private val propertyRenderers: Map = emptyMap(), ) : ExpressionRenderer { @@ -78,7 +79,13 @@ class DefaultEndpointProviderGenerator( fun render() { renderDocumentation() - writer.withBlock("public class #T: #T {", "}", defaultProviderSymbol, interfaceSymbol) { + writer.withBlock( + "#L class #T: #T {", + "}", + settings.api.visibility, + defaultProviderSymbol, + interfaceSymbol, + ) { renderResolve() } } diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointDelegator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointDelegator.kt index be3e29469..5d2eca98f 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointDelegator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointDelegator.kt @@ -33,12 +33,12 @@ interface EndpointDelegator { val defaultProviderSymbol = DefaultEndpointProviderGenerator.getSymbol(ctx.settings) ctx.delegator.useFileWriter(providerSymbol) { - EndpointProviderGenerator(it, providerSymbol, paramsSymbol).render() + EndpointProviderGenerator(it, ctx.settings, providerSymbol, paramsSymbol).render() } if (rules != null) { ctx.delegator.useFileWriter(defaultProviderSymbol) { - DefaultEndpointProviderGenerator(it, rules, defaultProviderSymbol, providerSymbol, paramsSymbol).render() + DefaultEndpointProviderGenerator(it, rules, defaultProviderSymbol, providerSymbol, paramsSymbol, ctx.settings).render() } } } @@ -49,7 +49,7 @@ interface EndpointDelegator { fun generateEndpointParameters(ctx: ProtocolGenerator.GenerationContext, rules: EndpointRuleSet?) { val paramsSymbol = EndpointParametersGenerator.getSymbol(ctx.settings) ctx.delegator.useFileWriter(paramsSymbol) { - EndpointParametersGenerator(it, rules, paramsSymbol).render() + EndpointParametersGenerator(it, ctx.settings, rules, paramsSymbol).render() } } diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointParametersGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointParametersGenerator.kt index 34d08ab67..517757ab6 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointParametersGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointParametersGenerator.kt @@ -22,6 +22,7 @@ private const val DEFAULT_DEPRECATED_MESSAGE = */ class EndpointParametersGenerator( private val writer: KotlinWriter, + private val settings: KotlinSettings, rules: EndpointRuleSet?, private val paramsSymbol: Symbol, ) { @@ -51,7 +52,12 @@ class EndpointParametersGenerator( fun render() { renderDocumentation() // FIXME - this should probably be an interface - writer.withBlock("public class #T private constructor(builder: Builder) {", "}", paramsSymbol) { + writer.withBlock( + "#L class #T private constructor(builder: Builder) {", + "}", + settings.api.visibility, + paramsSymbol, + ) { renderFields() renderCompanionObject() write("") diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointProviderGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointProviderGenerator.kt index c1cc9633c..3ffa2155a 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointProviderGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointProviderGenerator.kt @@ -18,6 +18,7 @@ import software.amazon.smithy.kotlin.codegen.model.buildSymbol */ class EndpointProviderGenerator( private val writer: KotlinWriter, + private val settings: KotlinSettings, private val providerSymbol: Symbol, private val paramsSymbol: Symbol, ) { @@ -33,7 +34,8 @@ class EndpointProviderGenerator( fun render() { renderDocumentation() writer.write( - "public fun interface #T: #T<#T>", + "#L fun interface #T: #T<#T>", + settings.api.visibility, providerSymbol, RuntimeTypes.SmithyClient.Endpoints.EndpointProvider, paramsSymbol, diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/discovery/EndpointDiscovererGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/discovery/EndpointDiscovererGenerator.kt index ee29c9c53..6167cd972 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/discovery/EndpointDiscovererGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/discovery/EndpointDiscovererGenerator.kt @@ -43,7 +43,12 @@ class EndpointDiscovererGenerator(private val ctx: CodegenContext, private val d calls. """.trimIndent(), ) - withBlock("public class #T {", "}", symbol) { + withBlock( + "#L class #T {", + "}", + ctx.settings.api.visibility, + symbol, + ) { write( "private val cache = #T(10.#T, #T.System)", RuntimeTypes.Core.Utils.ReadThroughCache, diff --git a/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/KotlinSettingsTest.kt b/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/KotlinSettingsTest.kt index bfecad4b4..3893b4e46 100644 --- a/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/KotlinSettingsTest.kt +++ b/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/KotlinSettingsTest.kt @@ -5,11 +5,13 @@ package software.amazon.smithy.kotlin.codegen +import org.junit.jupiter.api.assertThrows import software.amazon.smithy.codegen.core.CodegenException import software.amazon.smithy.kotlin.codegen.test.TestModelDefault import software.amazon.smithy.kotlin.codegen.test.toSmithyModel import software.amazon.smithy.model.node.Node import software.amazon.smithy.model.shapes.ShapeId +import java.lang.IllegalArgumentException import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -184,4 +186,109 @@ class KotlinSettingsTest { Node.parse(contents).expectObjectNode(), ) } + + @Test + fun `supports internal visibility`() { + val model = javaClass.getResource("simple-service.smithy")!!.toSmithyModel() + + val contents = """ + { + "package": { + "name": "aws.sdk.kotlin.runtime.protocoltest.awsrestjson", + "version": "1.0.0" + }, + "build": { + "optInAnnotations": ["foo", "bar"] + }, + "api": { + "visibility": "internal" + } + } + """.trimIndent() + + val settings = KotlinSettings.from( + model, + Node.parse(contents).expectObjectNode(), + ) + + assertEquals(Visibility.INTERNAL, settings.api.visibility) + } + + @Test + fun `defaults to public visibility`() { + val model = javaClass.getResource("simple-service.smithy")!!.toSmithyModel() + + val contents = """ + { + "package": { + "name": "aws.sdk.kotlin.runtime.protocoltest.awsrestjson", + "version": "1.0.0" + }, + "build": { + "optInAnnotations": ["foo", "bar"] + } + } + """.trimIndent() + + val settings = KotlinSettings.from( + model, + Node.parse(contents).expectObjectNode(), + ) + + assertEquals(Visibility.PUBLIC, settings.api.visibility) + } + + @Test + fun `supports public visibility`() { + val model = javaClass.getResource("simple-service.smithy")!!.toSmithyModel() + + val contents = """ + { + "package": { + "name": "aws.sdk.kotlin.runtime.protocoltest.awsrestjson", + "version": "1.0.0" + }, + "build": { + "optInAnnotations": ["foo", "bar"] + }, + "api": { + "visibility": "public" + } + } + """.trimIndent() + + val settings = KotlinSettings.from( + model, + Node.parse(contents).expectObjectNode(), + ) + + assertEquals(Visibility.PUBLIC, settings.api.visibility) + } + + @Test + fun `throws on unsupported visibility values`() { + val model = javaClass.getResource("simple-service.smithy")!!.toSmithyModel() + + val contents = """ + { + "package": { + "name": "aws.sdk.kotlin.runtime.protocoltest.awsrestjson", + "version": "1.0.0" + }, + "build": { + "optInAnnotations": ["foo", "bar"] + }, + "api": { + "visibility": "I don't know, just make it visible" + } + } + """.trimIndent() + + assertThrows { + KotlinSettings.from( + model, + Node.parse(contents).expectObjectNode(), + ) + } + } } diff --git a/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/DefaultEndpointProviderGeneratorTest.kt b/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/DefaultEndpointProviderGeneratorTest.kt index 7599bd2cc..a2e411c40 100644 --- a/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/DefaultEndpointProviderGeneratorTest.kt +++ b/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/DefaultEndpointProviderGeneratorTest.kt @@ -4,6 +4,7 @@ */ package software.amazon.smithy.kotlin.codegen.rendering.endpoints +import software.amazon.smithy.kotlin.codegen.KotlinSettings import software.amazon.smithy.kotlin.codegen.core.KotlinWriter import software.amazon.smithy.kotlin.codegen.model.buildSymbol import software.amazon.smithy.kotlin.codegen.test.TestModelDefault @@ -11,6 +12,7 @@ import software.amazon.smithy.kotlin.codegen.test.assertBalancedBracesAndParens import software.amazon.smithy.kotlin.codegen.test.formatForTest import software.amazon.smithy.kotlin.codegen.test.shouldContainOnlyOnceWithDiff import software.amazon.smithy.model.node.Node +import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rulesengine.language.EndpointRuleSet import kotlin.test.* @@ -142,7 +144,13 @@ class DefaultEndpointProviderGeneratorTest { name = "DefaultEndpointProvider" namespace = TestModelDefault.NAMESPACE } - DefaultEndpointProviderGenerator(writer, rules, defaultSymbol, interfaceSymbol, paramsSymbol).render() + val settings = KotlinSettings( + service = ShapeId.from("com.test#Test"), + pkg = KotlinSettings.PackageSettings("name", "version"), + sdkId = "testSdkId", + ) + + DefaultEndpointProviderGenerator(writer, rules, defaultSymbol, interfaceSymbol, paramsSymbol, settings).render() generatedClass = writer.toString() } diff --git a/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointParametersGeneratorTest.kt b/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointParametersGeneratorTest.kt index 476c7c5c8..db585ec37 100644 --- a/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointParametersGeneratorTest.kt +++ b/codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/endpoints/EndpointParametersGeneratorTest.kt @@ -4,6 +4,7 @@ */ package software.amazon.smithy.kotlin.codegen.rendering.endpoints +import software.amazon.smithy.kotlin.codegen.KotlinSettings import software.amazon.smithy.kotlin.codegen.core.KotlinWriter import software.amazon.smithy.kotlin.codegen.model.buildSymbol import software.amazon.smithy.kotlin.codegen.test.TestModelDefault @@ -11,6 +12,7 @@ import software.amazon.smithy.kotlin.codegen.test.assertBalancedBracesAndParens import software.amazon.smithy.kotlin.codegen.test.formatForTest import software.amazon.smithy.kotlin.codegen.test.shouldContainOnlyOnceWithDiff import software.amazon.smithy.model.node.Node +import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rulesengine.language.EndpointRuleSet import kotlin.test.* @@ -83,7 +85,12 @@ class EndpointParametersGeneratorTest { name = "EndpointParameters" namespace = TestModelDefault.NAMESPACE } - EndpointParametersGenerator(writer, rules, paramsSymbol).render() + val settings = KotlinSettings( + service = ShapeId.from("com.test#Test"), + pkg = KotlinSettings.PackageSettings("name", "version"), + sdkId = "testSdkId", + ) + EndpointParametersGenerator(writer, settings, rules, paramsSymbol).render() generatedClass = writer.toString() }