override fun install()

in services/machinelearning/common/src/aws/sdk/kotlin/services/machinelearning/internal/ResolvePredictEndpoint.kt [17:37]


    override fun install(op: SdkHttpOperation<PredictRequest, PredictResponse>) {
        op.execution.initialize.intercept { req, next ->
            val input = req.subject
            if (input.predictEndpoint == null || input.predictEndpoint.isBlank()) {
                throw MachineLearningException("Predict requires predictEnpoint to be set to a non-empty value")
            }
            // Stash the endpoint for later use by the mutate interceptor
            req.context.predictEndpoint = AwsEndpoint(input.predictEndpoint)

            next.call(req)
        }

        op.execution.mutate.intercept { req, next ->
            // This should've been set by the initialize interceptor
            val endpoint = req.context.predictEndpoint
            requireNotNull(endpoint) { "Predict endpoint wasn't set by middleware." }
            setRequestEndpoint(req, endpoint.endpoint)

            next.call(req)
        }
    }