@@ -15,6 +15,7 @@ import software.amazon.smithy.kotlin.codegen.loadModelFromResource
1515import software.amazon.smithy.kotlin.codegen.model.*
1616import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty
1717import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigPropertyType
18+ import software.amazon.smithy.kotlin.codegen.rendering.util.RuntimeConfigProperty
1819import software.amazon.smithy.kotlin.codegen.test.*
1920import software.amazon.smithy.model.Model
2021import software.amazon.smithy.model.shapes.ServiceShape
@@ -50,6 +51,7 @@ public class Config private constructor(builder: Builder) : HttpClientConfig, Id
5051 public val endpointProvider: EndpointProvider = requireNotNull(builder.endpointProvider) { "endpointProvider is a required configuration property" }
5152 override val idempotencyTokenProvider: IdempotencyTokenProvider = builder.idempotencyTokenProvider ?: IdempotencyTokenProvider.Default
5253 override val interceptors: kotlin.collections.List<aws.smithy.kotlin.runtime.http.interceptors.HttpInterceptor> = builder.interceptors
54+ override val retryPolicy: RetryPolicy<Any?> = builder.retryPolicy ?: StandardRetryPolicy.Default
5355 override val retryStrategy: RetryStrategy = builder.retryStrategy ?: StandardRetryStrategy()
5456 override val sdkLogMode: SdkLogMode = builder.sdkLogMode
5557 override val tracer: Tracer = builder.tracer ?: DefaultTracer(LoggingTraceProbe, "${TestModelDefault .SERVICE_NAME } ")
@@ -84,6 +86,11 @@ public class Config private constructor(builder: Builder) : HttpClientConfig, Id
8486 */
8587 override var interceptors: kotlin.collections.MutableList<aws.smithy.kotlin.runtime.http.interceptors.HttpInterceptor> = kotlin.collections.mutableListOf()
8688
89+ /**
90+ * The policy to use for evaluating operation results and determining whether/how to retry.
91+ */
92+ override var retryPolicy: RetryPolicy<Any?>? = null
93+
8794 /**
8895 * The [RetryStrategy] implementation to use for service calls. All API calls will be wrapped by the
8996 * strategy.
@@ -202,6 +209,95 @@ public class Config private constructor(builder: Builder) {
202209 contents.shouldContain(expectedProps)
203210 }
204211
212+ @Test
213+ fun `it overrides props by name` () {
214+ val model = getModel()
215+ val serviceShape = model.expectShape<ServiceShape >(TestModelDefault .SERVICE_SHAPE_ID )
216+
217+ val testCtx = model.newTestContext()
218+ val writer = createWriter()
219+ val customIntegration = object : KotlinIntegration {
220+ private val overriddenLogMode = RuntimeConfigProperty .SdkLogMode .toBuilder().apply {
221+ symbol = symbol!! .toBuilder().apply {
222+ defaultValue(" SdkLogMode.LogRequest" ) // replaces SdkLogMode.Default
223+ }.build()
224+ }.build()
225+
226+ override fun additionalServiceConfigProps (ctx : CodegenContext ): List <ConfigProperty > = listOf (
227+ ConfigProperty .Int (" customProp" ),
228+ overriddenLogMode,
229+ )
230+ }
231+
232+ val renderingCtx = testCtx.toRenderingContext(writer, serviceShape)
233+ .copy(integrations = listOf (customIntegration))
234+
235+ ServiceClientConfigGenerator (serviceShape, detectDefaultProps = true ).render(renderingCtx, renderingCtx.writer)
236+ val contents = writer.toString()
237+
238+ val expectedBuilderProps = """
239+ /**
240+ * Override the default HTTP client engine used to make SDK requests (e.g. configure proxy behavior, timeouts, concurrency, etc).
241+ * NOTE: The caller is responsible for managing the lifetime of the engine when set. The SDK
242+ * client will not close it when the client is closed.
243+ */
244+ override var httpClientEngine: HttpClientEngine? = null
245+
246+ public var customProp: Int? = null
247+
248+ /**
249+ * The endpoint provider used to determine where to make service requests.
250+ */
251+ public var endpointProvider: EndpointProvider? = null
252+
253+ /**
254+ * Override the default idempotency token generator. SDK clients will generate tokens for members
255+ * that represent idempotent tokens when not explicitly set by the caller using this generator.
256+ */
257+ override var idempotencyTokenProvider: IdempotencyTokenProvider? = null
258+
259+ /**
260+ * Add an [aws.smithy.kotlin.runtime.client.Interceptor] that will have access to read and modify
261+ * the request and response objects as they are processed by the SDK.
262+ * Interceptors added using this method are executed in the order they are configured and are always
263+ * later than any added automatically by the SDK.
264+ */
265+ override var interceptors: kotlin.collections.MutableList<aws.smithy.kotlin.runtime.http.interceptors.HttpInterceptor> = kotlin.collections.mutableListOf()
266+
267+ /**
268+ * The policy to use for evaluating operation results and determining whether/how to retry.
269+ */
270+ override var retryPolicy: RetryPolicy<Any?>? = null
271+
272+ /**
273+ * The [RetryStrategy] implementation to use for service calls. All API calls will be wrapped by the
274+ * strategy.
275+ */
276+ override var retryStrategy: RetryStrategy? = null
277+
278+ /**
279+ * Configure events that will be logged. By default clients will not output
280+ * raw requests or responses. Use this setting to opt-in to additional debug logging.
281+ *
282+ * This can be used to configure logging of requests, responses, retries, etc of SDK clients.
283+ *
284+ * **NOTE**: Logging of raw requests or responses may leak sensitive information! It may also have
285+ * performance considerations when dumping the request/response body. This is primarily a tool for
286+ * debug purposes.
287+ */
288+ override var sdkLogMode: SdkLogMode = SdkLogMode.LogRequest
289+
290+ /**
291+ * The tracer that is responsible for creating trace spans and wiring them up to a tracing backend (e.g.,
292+ * a trace probe). By default, this will create a standard tracer that uses the service name for the root
293+ * trace span and delegates to a logging trace probe (i.e.,
294+ * `DefaultTracer(LoggingTraceProbe, "<service-name>")`).
295+ */
296+ override var tracer: Tracer? = null
297+ """
298+ contents.shouldContain(expectedBuilderProps)
299+ }
300+
205301 @Test
206302 fun `it finds idempotency token via resources` () {
207303 val model = """
0 commit comments