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

commonMain.aws.sdk.kotlin.services.mgn.DefaultMgnClient.kt Maven / Gradle / Ivy

// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.mgn

import aws.sdk.kotlin.runtime.client.AwsClientOption
import aws.sdk.kotlin.runtime.http.ApiMetadata
import aws.sdk.kotlin.runtime.http.AwsUserAgentMetadata
import aws.sdk.kotlin.runtime.http.middleware.AwsRetryMiddleware
import aws.sdk.kotlin.runtime.http.middleware.RecursionDetection
import aws.sdk.kotlin.runtime.http.middleware.ResolveAwsEndpoint
import aws.sdk.kotlin.runtime.http.middleware.UserAgent
import aws.sdk.kotlin.runtime.http.retries.AwsDefaultRetryPolicy
import aws.sdk.kotlin.services.mgn.model.*
import aws.sdk.kotlin.services.mgn.transform.*
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningAttributes
import aws.smithy.kotlin.runtime.auth.awssigning.middleware.AwsSigningMiddleware
import aws.smithy.kotlin.runtime.client.ExecutionContext
import aws.smithy.kotlin.runtime.client.SdkClientOption
import aws.smithy.kotlin.runtime.http.SdkHttpClient
import aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngine
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.sdkHttpClient
import aws.smithy.kotlin.runtime.io.Closeable
import aws.smithy.kotlin.runtime.util.putIfAbsent


const val ServiceId: String = "mgn"
const val ServiceApiVersion: String = "2020-02-26"
const val SdkVersion: String = "0.16.7-beta"

internal class DefaultMgnClient(override val config: MgnClient.Config) : MgnClient {
    private val client: SdkHttpClient
    init {
        val httpClientEngine = config.httpClientEngine ?: DefaultHttpEngine()
        client = sdkHttpClient(httpClientEngine, manageEngine = config.httpClientEngine == null)
    }
    private val awsUserAgentMetadata = AwsUserAgentMetadata.fromEnvironment(ApiMetadata(ServiceId, SdkVersion))

    /**
     * Allows the user to set the SourceServer.LifeCycle.state property for specific Source Server IDs to one of the following: READY_FOR_TEST or READY_FOR_CUTOVER. This command only works if the Source Server is already launchable (dataReplicationInfo.lagDuration is not null.)
     */
    override suspend fun changeServerLifeCycleState(input: ChangeServerLifeCycleStateRequest): ChangeServerLifeCycleStateResponse {
        val op = SdkHttpOperation.build {
            serializer = ChangeServerLifeCycleStateOperationSerializer()
            deserializer = ChangeServerLifeCycleStateOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "ChangeServerLifeCycleState"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Creates a new ReplicationConfigurationTemplate.
     */
    override suspend fun createLaunchConfigurationTemplate(input: CreateLaunchConfigurationTemplateRequest): CreateLaunchConfigurationTemplateResponse {
        val op = SdkHttpOperation.build {
            serializer = CreateLaunchConfigurationTemplateOperationSerializer()
            deserializer = CreateLaunchConfigurationTemplateOperationDeserializer()
            context {
                expectedHttpStatus = 201
                service = serviceName
                operationName = "CreateLaunchConfigurationTemplate"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Creates a new ReplicationConfigurationTemplate.
     */
    override suspend fun createReplicationConfigurationTemplate(input: CreateReplicationConfigurationTemplateRequest): CreateReplicationConfigurationTemplateResponse {
        val op = SdkHttpOperation.build {
            serializer = CreateReplicationConfigurationTemplateOperationSerializer()
            deserializer = CreateReplicationConfigurationTemplateOperationDeserializer()
            context {
                expectedHttpStatus = 201
                service = serviceName
                operationName = "CreateReplicationConfigurationTemplate"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Deletes a single Job by ID.
     */
    override suspend fun deleteJob(input: DeleteJobRequest): DeleteJobResponse {
        val op = SdkHttpOperation.build {
            serializer = DeleteJobOperationSerializer()
            deserializer = DeleteJobOperationDeserializer()
            context {
                expectedHttpStatus = 204
                service = serviceName
                operationName = "DeleteJob"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Creates a new ReplicationConfigurationTemplate.
     */
    override suspend fun deleteLaunchConfigurationTemplate(input: DeleteLaunchConfigurationTemplateRequest): DeleteLaunchConfigurationTemplateResponse {
        val op = SdkHttpOperation.build {
            serializer = DeleteLaunchConfigurationTemplateOperationSerializer()
            deserializer = DeleteLaunchConfigurationTemplateOperationDeserializer()
            context {
                expectedHttpStatus = 204
                service = serviceName
                operationName = "DeleteLaunchConfigurationTemplate"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Deletes a single Replication Configuration Template by ID
     */
    override suspend fun deleteReplicationConfigurationTemplate(input: DeleteReplicationConfigurationTemplateRequest): DeleteReplicationConfigurationTemplateResponse {
        val op = SdkHttpOperation.build {
            serializer = DeleteReplicationConfigurationTemplateOperationSerializer()
            deserializer = DeleteReplicationConfigurationTemplateOperationDeserializer()
            context {
                expectedHttpStatus = 204
                service = serviceName
                operationName = "DeleteReplicationConfigurationTemplate"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Deletes a single source server by ID.
     */
    override suspend fun deleteSourceServer(input: DeleteSourceServerRequest): DeleteSourceServerResponse {
        val op = SdkHttpOperation.build {
            serializer = DeleteSourceServerOperationSerializer()
            deserializer = DeleteSourceServerOperationDeserializer()
            context {
                expectedHttpStatus = 204
                service = serviceName
                operationName = "DeleteSourceServer"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Deletes a given vCenter client by ID.
     */
    override suspend fun deleteVcenterClient(input: DeleteVcenterClientRequest): DeleteVcenterClientResponse {
        val op = SdkHttpOperation.build {
            serializer = DeleteVcenterClientOperationSerializer()
            deserializer = DeleteVcenterClientOperationDeserializer()
            context {
                expectedHttpStatus = 204
                service = serviceName
                operationName = "DeleteVcenterClient"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Retrieves detailed job log items with paging.
     */
    override suspend fun describeJobLogItems(input: DescribeJobLogItemsRequest): DescribeJobLogItemsResponse {
        val op = SdkHttpOperation.build {
            serializer = DescribeJobLogItemsOperationSerializer()
            deserializer = DescribeJobLogItemsOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "DescribeJobLogItems"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Returns a list of Jobs. Use the JobsID and fromDate and toData filters to limit which jobs are returned. The response is sorted by creationDataTime - latest date first. Jobs are normally created by the StartTest, StartCutover, and TerminateTargetInstances APIs. Jobs are also created by DiagnosticLaunch and TerminateDiagnosticInstances, which are APIs available only to *Support* and only used in response to relevant support tickets.
     */
    override suspend fun describeJobs(input: DescribeJobsRequest): DescribeJobsResponse {
        val op = SdkHttpOperation.build {
            serializer = DescribeJobsOperationSerializer()
            deserializer = DescribeJobsOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "DescribeJobs"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Creates a new ReplicationConfigurationTemplate.
     */
    override suspend fun describeLaunchConfigurationTemplates(input: DescribeLaunchConfigurationTemplatesRequest): DescribeLaunchConfigurationTemplatesResponse {
        val op = SdkHttpOperation.build {
            serializer = DescribeLaunchConfigurationTemplatesOperationSerializer()
            deserializer = DescribeLaunchConfigurationTemplatesOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "DescribeLaunchConfigurationTemplates"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Lists all ReplicationConfigurationTemplates, filtered by Source Server IDs.
     */
    override suspend fun describeReplicationConfigurationTemplates(input: DescribeReplicationConfigurationTemplatesRequest): DescribeReplicationConfigurationTemplatesResponse {
        val op = SdkHttpOperation.build {
            serializer = DescribeReplicationConfigurationTemplatesOperationSerializer()
            deserializer = DescribeReplicationConfigurationTemplatesOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "DescribeReplicationConfigurationTemplates"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Retrieves all SourceServers or multiple SourceServers by ID.
     */
    override suspend fun describeSourceServers(input: DescribeSourceServersRequest): DescribeSourceServersResponse {
        val op = SdkHttpOperation.build {
            serializer = DescribeSourceServersOperationSerializer()
            deserializer = DescribeSourceServersOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "DescribeSourceServers"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Returns a list of the installed vCenter clients.
     */
    override suspend fun describeVcenterClients(input: DescribeVcenterClientsRequest): DescribeVcenterClientsResponse {
        val op = SdkHttpOperation.build {
            serializer = DescribeVcenterClientsOperationSerializer()
            deserializer = DescribeVcenterClientsOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "DescribeVcenterClients"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Disconnects specific Source Servers from Application Migration Service. Data replication is stopped immediately. All AWS resources created by Application Migration Service for enabling the replication of these source servers will be terminated / deleted within 90 minutes. Launched Test or Cutover instances will NOT be terminated. If the agent on the source server has not been prevented from communicating with the Application Migration Service service, then it will receive a command to uninstall itself (within approximately 10 minutes). The following properties of the SourceServer will be changed immediately: dataReplicationInfo.dataReplicationState will be set to DISCONNECTED; The totalStorageBytes property for each of dataReplicationInfo.replicatedDisks will be set to zero; dataReplicationInfo.lagDuration and dataReplicationInfo.lagDuration will be nullified.
     */
    override suspend fun disconnectFromService(input: DisconnectFromServiceRequest): DisconnectFromServiceResponse {
        val op = SdkHttpOperation.build {
            serializer = DisconnectFromServiceOperationSerializer()
            deserializer = DisconnectFromServiceOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "DisconnectFromService"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Finalizes the cutover immediately for specific Source Servers. All AWS resources created by Application Migration Service for enabling the replication of these source servers will be terminated / deleted within 90 minutes. Launched Test or Cutover instances will NOT be terminated. The AWS Replication Agent will receive a command to uninstall itself (within 10 minutes). The following properties of the SourceServer will be changed immediately: dataReplicationInfo.dataReplicationState will be changed to DISCONNECTED; The SourceServer.lifeCycle.state will be changed to CUTOVER; The totalStorageBytes property fo each of dataReplicationInfo.replicatedDisks will be set to zero; dataReplicationInfo.lagDuration and dataReplicationInfo.lagDuration will be nullified.
     */
    override suspend fun finalizeCutover(input: FinalizeCutoverRequest): FinalizeCutoverResponse {
        val op = SdkHttpOperation.build {
            serializer = FinalizeCutoverOperationSerializer()
            deserializer = FinalizeCutoverOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "FinalizeCutover"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Lists all LaunchConfigurations available, filtered by Source Server IDs.
     */
    override suspend fun getLaunchConfiguration(input: GetLaunchConfigurationRequest): GetLaunchConfigurationResponse {
        val op = SdkHttpOperation.build {
            serializer = GetLaunchConfigurationOperationSerializer()
            deserializer = GetLaunchConfigurationOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "GetLaunchConfiguration"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Lists all ReplicationConfigurations, filtered by Source Server ID.
     */
    override suspend fun getReplicationConfiguration(input: GetReplicationConfigurationRequest): GetReplicationConfigurationResponse {
        val op = SdkHttpOperation.build {
            serializer = GetReplicationConfigurationOperationSerializer()
            deserializer = GetReplicationConfigurationOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "GetReplicationConfiguration"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Initialize Application Migration Service.
     */
    override suspend fun initializeService(input: InitializeServiceRequest): InitializeServiceResponse {
        val op = SdkHttpOperation.build {
            serializer = InitializeServiceOperationSerializer()
            deserializer = InitializeServiceOperationDeserializer()
            context {
                expectedHttpStatus = 204
                service = serviceName
                operationName = "InitializeService"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * List all tags for your Application Migration Service resources.
     */
    override suspend fun listTagsForResource(input: ListTagsForResourceRequest): ListTagsForResourceResponse {
        val op = SdkHttpOperation.build {
            serializer = ListTagsForResourceOperationSerializer()
            deserializer = ListTagsForResourceOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "ListTagsForResource"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Archives specific Source Servers by setting the SourceServer.isArchived property to true for specified SourceServers by ID. This command only works for SourceServers with a lifecycle. state which equals DISCONNECTED or CUTOVER.
     */
    override suspend fun markAsArchived(input: MarkAsArchivedRequest): MarkAsArchivedResponse {
        val op = SdkHttpOperation.build {
            serializer = MarkAsArchivedOperationSerializer()
            deserializer = MarkAsArchivedOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "MarkAsArchived"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Causes the data replication initiation sequence to begin immediately upon next Handshake for specified SourceServer IDs, regardless of when the previous initiation started. This command will not work if the SourceServer is not stalled or is in a DISCONNECTED or STOPPED state.
     */
    override suspend fun retryDataReplication(input: RetryDataReplicationRequest): RetryDataReplicationResponse {
        val op = SdkHttpOperation.build {
            serializer = RetryDataReplicationOperationSerializer()
            deserializer = RetryDataReplicationOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "RetryDataReplication"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Launches a Cutover Instance for specific Source Servers. This command starts a LAUNCH job whose initiatedBy property is StartCutover and changes the SourceServer.lifeCycle.state property to CUTTING_OVER.
     */
    override suspend fun startCutover(input: StartCutoverRequest): StartCutoverResponse {
        val op = SdkHttpOperation.build {
            serializer = StartCutoverOperationSerializer()
            deserializer = StartCutoverOperationDeserializer()
            context {
                expectedHttpStatus = 202
                service = serviceName
                operationName = "StartCutover"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Starts replication for SNAPSHOT_SHIPPING agents.
     */
    override suspend fun startReplication(input: StartReplicationRequest): StartReplicationResponse {
        val op = SdkHttpOperation.build {
            serializer = StartReplicationOperationSerializer()
            deserializer = StartReplicationOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "StartReplication"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Launches a Test Instance for specific Source Servers. This command starts a LAUNCH job whose initiatedBy property is StartTest and changes the SourceServer.lifeCycle.state property to TESTING.
     */
    override suspend fun startTest(input: StartTestRequest): StartTestResponse {
        val op = SdkHttpOperation.build {
            serializer = StartTestOperationSerializer()
            deserializer = StartTestOperationDeserializer()
            context {
                expectedHttpStatus = 202
                service = serviceName
                operationName = "StartTest"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Adds or overwrites only the specified tags for the specified Application Migration Service resource or resources. When you specify an existing tag key, the value is overwritten with the new value. Each resource can have a maximum of 50 tags. Each tag consists of a key and optional value.
     */
    override suspend fun tagResource(input: TagResourceRequest): TagResourceResponse {
        val op = SdkHttpOperation.build {
            serializer = TagResourceOperationSerializer()
            deserializer = TagResourceOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "TagResource"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Starts a job that terminates specific launched EC2 Test and Cutover instances. This command will not work for any Source Server with a lifecycle.state of TESTING, CUTTING_OVER, or CUTOVER.
     */
    override suspend fun terminateTargetInstances(input: TerminateTargetInstancesRequest): TerminateTargetInstancesResponse {
        val op = SdkHttpOperation.build {
            serializer = TerminateTargetInstancesOperationSerializer()
            deserializer = TerminateTargetInstancesOperationDeserializer()
            context {
                expectedHttpStatus = 202
                service = serviceName
                operationName = "TerminateTargetInstances"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Deletes the specified set of tags from the specified set of Application Migration Service resources.
     */
    override suspend fun untagResource(input: UntagResourceRequest): UntagResourceResponse {
        val op = SdkHttpOperation.build {
            serializer = UntagResourceOperationSerializer()
            deserializer = UntagResourceOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "UntagResource"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Updates multiple LaunchConfigurations by Source Server ID.
     */
    override suspend fun updateLaunchConfiguration(input: UpdateLaunchConfigurationRequest): UpdateLaunchConfigurationResponse {
        val op = SdkHttpOperation.build {
            serializer = UpdateLaunchConfigurationOperationSerializer()
            deserializer = UpdateLaunchConfigurationOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "UpdateLaunchConfiguration"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Creates a new ReplicationConfigurationTemplate.
     */
    override suspend fun updateLaunchConfigurationTemplate(input: UpdateLaunchConfigurationTemplateRequest): UpdateLaunchConfigurationTemplateResponse {
        val op = SdkHttpOperation.build {
            serializer = UpdateLaunchConfigurationTemplateOperationSerializer()
            deserializer = UpdateLaunchConfigurationTemplateOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "UpdateLaunchConfigurationTemplate"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Allows you to update multiple ReplicationConfigurations by Source Server ID.
     */
    override suspend fun updateReplicationConfiguration(input: UpdateReplicationConfigurationRequest): UpdateReplicationConfigurationResponse {
        val op = SdkHttpOperation.build {
            serializer = UpdateReplicationConfigurationOperationSerializer()
            deserializer = UpdateReplicationConfigurationOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "UpdateReplicationConfiguration"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Updates multiple ReplicationConfigurationTemplates by ID.
     */
    override suspend fun updateReplicationConfigurationTemplate(input: UpdateReplicationConfigurationTemplateRequest): UpdateReplicationConfigurationTemplateResponse {
        val op = SdkHttpOperation.build {
            serializer = UpdateReplicationConfigurationTemplateOperationSerializer()
            deserializer = UpdateReplicationConfigurationTemplateOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "UpdateReplicationConfigurationTemplate"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    /**
     * Allows you to change between the AGENT_BASED replication type and the SNAPSHOT_SHIPPING replication type.
     */
    override suspend fun updateSourceServerReplicationType(input: UpdateSourceServerReplicationTypeRequest): UpdateSourceServerReplicationTypeResponse {
        val op = SdkHttpOperation.build {
            serializer = UpdateSourceServerReplicationTypeOperationSerializer()
            deserializer = UpdateSourceServerReplicationTypeOperationDeserializer()
            context {
                expectedHttpStatus = 200
                service = serviceName
                operationName = "UpdateSourceServerReplicationType"
            }
        }
        mergeServiceDefaults(op.context)
        op.install(ResolveAwsEndpoint(ServiceId, config.endpointResolver))
        op.install(AwsRetryMiddleware(config.retryStrategy, AwsDefaultRetryPolicy))
        op.install(UserAgent(awsUserAgentMetadata))
        op.install(RecursionDetection())
        op.install(
            AwsSigningMiddleware {
                this.signer = config.signer
                this.credentialsProvider = config.credentialsProvider
                this.service = "mgn"
            }
        )
        return op.roundTrip(client, input)
    }

    override fun close() {
        client.close()
        (config.credentialsProvider as? Closeable)?.close()
    }

    /**
     * merge the defaults configured for the service into the execution context before firing off a request
     */
    private suspend fun mergeServiceDefaults(ctx: ExecutionContext) {
        ctx.putIfAbsent(AwsClientOption.Region, config.region)
        ctx.putIfAbsent(SdkClientOption.ServiceName, serviceName)
        ctx.putIfAbsent(SdkClientOption.LogMode, config.sdkLogMode)
        ctx.putIfAbsent(AwsSigningAttributes.SigningService, "mgn")
        ctx.putIfAbsent(AwsSigningAttributes.Signer, config.signer)
        ctx.putIfAbsent(AwsSigningAttributes.SigningRegion, config.region)
        ctx.putIfAbsent(AwsSigningAttributes.CredentialsProvider, config.credentialsProvider)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy