Skip to content

Commit

Permalink
Also remove endpoints-related constructs from the API
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis committed Sep 13, 2023
1 parent 51d6df8 commit f88aaa5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ 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) {
Expand All @@ -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()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
Expand Down Expand Up @@ -51,7 +52,10 @@ 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.build.visibility.structure,
paramsSymbol
) {
renderFields()
renderCompanionObject()
write("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
Expand All @@ -33,7 +34,8 @@ class EndpointProviderGenerator(
fun render() {
renderDocumentation()
writer.write(
"public fun interface #T: #T<#T>",
"#L fun interface #T: #T<#T>",
settings.build.visibility.structure,
providerSymbol,
RuntimeTypes.SmithyClient.Endpoints.EndpointProvider,
paramsSymbol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
*/
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
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.*

Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit f88aaa5

Please sign in to comment.