All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.sdk.kotlin.services.supplychain.DefaultSupplyChainClient.kt Maven / Gradle / Ivy

There is a newer version: 1.3.35
Show newest version
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.supplychain

import aws.sdk.kotlin.runtime.http.ApiMetadata
import aws.sdk.kotlin.runtime.http.AwsUserAgentMetadata
import aws.sdk.kotlin.runtime.http.interceptors.AwsSpanInterceptor
import aws.sdk.kotlin.runtime.http.interceptors.BusinessMetricsInterceptor
import aws.sdk.kotlin.runtime.http.middleware.AwsRetryHeaderMiddleware
import aws.sdk.kotlin.runtime.http.middleware.RecursionDetection
import aws.sdk.kotlin.runtime.http.middleware.UserAgent
import aws.sdk.kotlin.services.supplychain.auth.SupplyChainAuthSchemeProviderAdapter
import aws.sdk.kotlin.services.supplychain.auth.SupplyChainIdentityProviderConfigAdapter
import aws.sdk.kotlin.services.supplychain.endpoints.internal.EndpointResolverAdapter
import aws.sdk.kotlin.services.supplychain.model.*
import aws.sdk.kotlin.services.supplychain.serde.*
import aws.smithy.kotlin.runtime.auth.AuthSchemeId
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningAttributes
import aws.smithy.kotlin.runtime.auth.awssigning.DefaultAwsSigner
import aws.smithy.kotlin.runtime.awsprotocol.AwsAttributes
import aws.smithy.kotlin.runtime.client.SdkClientOption
import aws.smithy.kotlin.runtime.collections.attributesOf
import aws.smithy.kotlin.runtime.collections.putIfAbsent
import aws.smithy.kotlin.runtime.collections.putIfAbsentNotNull
import aws.smithy.kotlin.runtime.http.SdkHttpClient
import aws.smithy.kotlin.runtime.http.auth.AuthScheme
import aws.smithy.kotlin.runtime.http.auth.SigV4AuthScheme
import aws.smithy.kotlin.runtime.http.operation.OperationAuthConfig
import aws.smithy.kotlin.runtime.http.operation.OperationMetrics
import aws.smithy.kotlin.runtime.http.operation.SdkHttpOperation
import aws.smithy.kotlin.runtime.http.operation.context
import aws.smithy.kotlin.runtime.http.operation.roundTrip
import aws.smithy.kotlin.runtime.http.operation.telemetry
import aws.smithy.kotlin.runtime.io.SdkManagedGroup
import aws.smithy.kotlin.runtime.io.addIfManaged
import aws.smithy.kotlin.runtime.operation.ExecutionContext

internal class DefaultSupplyChainClient(override val config: SupplyChainClient.Config) : SupplyChainClient {
    private val managedResources = SdkManagedGroup()
    private val client = SdkHttpClient(config.httpClient)
    private val identityProviderConfig = SupplyChainIdentityProviderConfigAdapter(config)
    private val configuredAuthSchemes = with(config.authSchemes.associateBy(AuthScheme::schemeId).toMutableMap()){
        getOrPut(AuthSchemeId.AwsSigV4){
            SigV4AuthScheme(DefaultAwsSigner, "scn")
        }
        toMap()
    }
    private val authSchemeAdapter = SupplyChainAuthSchemeProviderAdapter(config)
    private val telemetryScope = "aws.sdk.kotlin.services.supplychain"
    private val opMetrics = OperationMetrics(telemetryScope, config.telemetryProvider)

    init {
        managedResources.addIfManaged(config.httpClient)
        managedResources.addIfManaged(config.credentialsProvider)
    }

    private val awsUserAgentMetadata = AwsUserAgentMetadata.fromEnvironment(ApiMetadata(ServiceId, SdkVersion), config.applicationId)

    /**
     * CreateBillOfMaterialsImportJob creates an import job for the Product Bill Of Materials (BOM) entity. For information on the product_bom entity, see the AWS Supply Chain User Guide.
     *
     * The CSV file must be located in an Amazon S3 location accessible to AWS Supply Chain. It is recommended to use the same Amazon S3 bucket created during your AWS Supply Chain instance creation.
     *
     * @sample aws.sdk.kotlin.services.supplychain.samples.CreateBillOfMaterialsImportJob.sample
     */
    override suspend fun createBillOfMaterialsImportJob(input: CreateBillOfMaterialsImportJobRequest): CreateBillOfMaterialsImportJobResponse {
        val op = SdkHttpOperation.build {
            serializeWith = CreateBillOfMaterialsImportJobOperationSerializer()
            deserializeWith = CreateBillOfMaterialsImportJobOperationDeserializer()
            operationName = "CreateBillOfMaterialsImportJob"
            serviceName = ServiceId
            telemetry {
                provider = config.telemetryProvider
                scope = telemetryScope
                metrics = opMetrics
                attributes = attributesOf {
                    "rpc.system" to "aws-api"
                }
            }
            execution.auth = OperationAuthConfig(authSchemeAdapter, configuredAuthSchemes, identityProviderConfig)
            execution.endpointResolver = EndpointResolverAdapter(config)
            execution.retryStrategy = config.retryStrategy
            execution.retryPolicy = config.retryPolicy
        }
        mergeServiceDefaults(op.context)
        op.install(AwsRetryHeaderMiddleware())
        op.interceptors.add(AwsSpanInterceptor)
        op.interceptors.add(BusinessMetricsInterceptor())
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.interceptors.addAll(config.interceptors)
        return op.roundTrip(client, input)
    }

    /**
     * Get status and details of a BillOfMaterialsImportJob.
     *
     * @sample aws.sdk.kotlin.services.supplychain.samples.GetBillOfMaterialsImportJob.sample
     * @sample aws.sdk.kotlin.services.supplychain.samples.GetBillOfMaterialsImportJob.sample2
     */
    override suspend fun getBillOfMaterialsImportJob(input: GetBillOfMaterialsImportJobRequest): GetBillOfMaterialsImportJobResponse {
        val op = SdkHttpOperation.build {
            serializeWith = GetBillOfMaterialsImportJobOperationSerializer()
            deserializeWith = GetBillOfMaterialsImportJobOperationDeserializer()
            operationName = "GetBillOfMaterialsImportJob"
            serviceName = ServiceId
            telemetry {
                provider = config.telemetryProvider
                scope = telemetryScope
                metrics = opMetrics
                attributes = attributesOf {
                    "rpc.system" to "aws-api"
                }
            }
            execution.auth = OperationAuthConfig(authSchemeAdapter, configuredAuthSchemes, identityProviderConfig)
            execution.endpointResolver = EndpointResolverAdapter(config)
            execution.retryStrategy = config.retryStrategy
            execution.retryPolicy = config.retryPolicy
        }
        mergeServiceDefaults(op.context)
        op.install(AwsRetryHeaderMiddleware())
        op.interceptors.add(AwsSpanInterceptor)
        op.interceptors.add(BusinessMetricsInterceptor())
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.interceptors.addAll(config.interceptors)
        return op.roundTrip(client, input)
    }

    /**
     * Send transactional data events with real-time data for analysis or monitoring.
     *
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample2
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample3
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample4
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample5
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample6
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample7
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample8
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample9
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample10
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample11
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample12
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample13
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample14
     * @sample aws.sdk.kotlin.services.supplychain.samples.SendDataIntegrationEvent.sample15
     */
    override suspend fun sendDataIntegrationEvent(input: SendDataIntegrationEventRequest): SendDataIntegrationEventResponse {
        val op = SdkHttpOperation.build {
            serializeWith = SendDataIntegrationEventOperationSerializer()
            deserializeWith = SendDataIntegrationEventOperationDeserializer()
            operationName = "SendDataIntegrationEvent"
            serviceName = ServiceId
            telemetry {
                provider = config.telemetryProvider
                scope = telemetryScope
                metrics = opMetrics
                attributes = attributesOf {
                    "rpc.system" to "aws-api"
                }
            }
            execution.auth = OperationAuthConfig(authSchemeAdapter, configuredAuthSchemes, identityProviderConfig)
            execution.endpointResolver = EndpointResolverAdapter(config)
            execution.retryStrategy = config.retryStrategy
            execution.retryPolicy = config.retryPolicy
        }
        mergeServiceDefaults(op.context)
        op.install(AwsRetryHeaderMiddleware())
        op.interceptors.add(AwsSpanInterceptor)
        op.interceptors.add(BusinessMetricsInterceptor())
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.interceptors.addAll(config.interceptors)
        return op.roundTrip(client, input)
    }

    override fun close() {
        managedResources.unshareAll()
    }

    /**
     * merge the defaults configured for the service into the execution context before firing off a request
     */
    private fun mergeServiceDefaults(ctx: ExecutionContext) {
        ctx.putIfAbsent(SdkClientOption.ClientName, config.clientName)
        ctx.putIfAbsent(SdkClientOption.LogMode, config.logMode)
        ctx.putIfAbsentNotNull(SdkClientOption.IdempotencyTokenProvider, config.idempotencyTokenProvider)
        ctx.putIfAbsentNotNull(AwsAttributes.Region, config.region)
        ctx.putIfAbsentNotNull(AwsSigningAttributes.SigningRegion, config.region)
        ctx.putIfAbsent(AwsSigningAttributes.SigningService, "scn")
        ctx.putIfAbsent(AwsSigningAttributes.CredentialsProvider, config.credentialsProvider)
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy