/******************************************************************************* * Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"). You may not use * this file except in compliance with the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * ***************************************************************************** * * AWS Tools for Windows (TM) PowerShell (TM) * */ using System; using System.Collections.Generic; using System.Linq; using System.Management.Automation; using System.Text; using Amazon.PowerShell.Common; using Amazon.Runtime; using Amazon.DatabaseMigrationService; using Amazon.DatabaseMigrationService.Model; namespace Amazon.PowerShell.Cmdlets.DMS { /// /// Starts a new premigration assessment run for one or more individual assessments of /// a migration task. /// /// /// /// The assessments that you can specify depend on the source and target database engine /// and the migration type defined for the given task. To run this operation, your migration /// task must already be created. After you run this operation, you can review the status /// of each individual assessment. You can also run the migration task manually after /// the assessment run and its individual assessments complete. /// /// [Cmdlet("Start", "DMSReplicationTaskAssessmentRun", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("Amazon.DatabaseMigrationService.Model.ReplicationTaskAssessmentRun")] [AWSCmdlet("Calls the AWS Database Migration Service StartReplicationTaskAssessmentRun API operation.", Operation = new[] {"StartReplicationTaskAssessmentRun"}, SelectReturnType = typeof(Amazon.DatabaseMigrationService.Model.StartReplicationTaskAssessmentRunResponse))] [AWSCmdletOutput("Amazon.DatabaseMigrationService.Model.ReplicationTaskAssessmentRun or Amazon.DatabaseMigrationService.Model.StartReplicationTaskAssessmentRunResponse", "This cmdlet returns an Amazon.DatabaseMigrationService.Model.ReplicationTaskAssessmentRun object.", "The service call response (type Amazon.DatabaseMigrationService.Model.StartReplicationTaskAssessmentRunResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class StartDMSReplicationTaskAssessmentRunCmdlet : AmazonDatabaseMigrationServiceClientCmdlet, IExecutor { #region Parameter AssessmentRunName /// /// /// Unique name to identify the assessment run. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowEmptyString] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public System.String AssessmentRunName { get; set; } #endregion #region Parameter Exclude /// /// /// Space-separated list of names for specific individual assessments that you want to /// exclude. These names come from the default list of individual assessments that DMS /// supports for the associated migration task. This task is specified by ReplicationTaskArn.You can't set a value for Exclude if you also set a value for IncludeOnly /// in the API operation.To identify the names of the default individual assessments that DMS supports for /// the associated migration task, run the DescribeApplicableIndividualAssessments /// operation using its own ReplicationTaskArn request parameter. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String[] Exclude { get; set; } #endregion #region Parameter IncludeOnly /// /// /// Space-separated list of names for specific individual assessments that you want to /// include. These names come from the default list of individual assessments that DMS /// supports for the associated migration task. This task is specified by ReplicationTaskArn.You can't set a value for IncludeOnly if you also set a value for Exclude /// in the API operation. To identify the names of the default individual assessments that DMS supports for /// the associated migration task, run the DescribeApplicableIndividualAssessments /// operation using its own ReplicationTaskArn request parameter. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String[] IncludeOnly { get; set; } #endregion #region Parameter ReplicationTaskArn /// /// /// Amazon Resource Name (ARN) of the migration task associated with the premigration /// assessment run that you want to start. /// /// #if !MODULAR [System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)] #else [System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, Mandatory = true)] [System.Management.Automation.AllowEmptyString] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public System.String ReplicationTaskArn { get; set; } #endregion #region Parameter ResultEncryptionMode /// /// /// Encryption mode that you can specify to encrypt the results of this assessment run. /// If you don't specify this request parameter, DMS stores the assessment run results /// without encryption. You can specify one of the options following: /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ResultEncryptionMode { get; set; } #endregion #region Parameter ResultKmsKeyArn /// /// /// ARN of a custom KMS encryption key that you specify when you set ResultEncryptionMode /// to "SSE_KMS". /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ResultKmsKeyArn { get; set; } #endregion #region Parameter ResultLocationBucket /// /// /// Amazon S3 bucket where you want DMS to store the results of this assessment run. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowEmptyString] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public System.String ResultLocationBucket { get; set; } #endregion #region Parameter ResultLocationFolder /// /// /// Folder within an Amazon S3 bucket where you want DMS to store the results of this /// assessment run. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ResultLocationFolder { get; set; } #endregion #region Parameter ServiceAccessRoleArn /// /// /// ARN of the service role needed to start the assessment run. The role must allow the /// iam:PassRole action. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowEmptyString] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public System.String ServiceAccessRoleArn { get; set; } #endregion #region Parameter Select /// /// Use the -Select parameter to control the cmdlet output. The default value is 'ReplicationTaskAssessmentRun'. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.DatabaseMigrationService.Model.StartReplicationTaskAssessmentRunResponse). /// Specifying the name of a property of type Amazon.DatabaseMigrationService.Model.StartReplicationTaskAssessmentRunResponse will result in that property being returned. /// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public string Select { get; set; } = "ReplicationTaskAssessmentRun"; #endregion #region Parameter PassThru /// /// Changes the cmdlet behavior to return the value passed to the ReplicationTaskArn parameter. /// The -PassThru parameter is deprecated, use -Select '^ReplicationTaskArn' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^ReplicationTaskArn' instead. This parameter will be removed in a future version.")] [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public SwitchParameter PassThru { get; set; } #endregion #region Parameter Force /// /// This parameter overrides confirmation prompts to force /// the cmdlet to continue its operation. This parameter should always /// be used with caution. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public SwitchParameter Force { get; set; } #endregion protected override void ProcessRecord() { this._AWSSignerType = "v4"; base.ProcessRecord(); var resourceIdentifiersText = FormatParameterValuesForConfirmationMsg(nameof(this.AssessmentRunName), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Start-DMSReplicationTaskAssessmentRun (StartReplicationTaskAssessmentRun)")) { return; } var context = new CmdletContext(); // allow for manipulation of parameters prior to loading into context PreExecutionContextLoad(context); #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute if (ParameterWasBound(nameof(this.Select))) { context.Select = CreateSelectDelegate(Select) ?? throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select)); if (this.PassThru.IsPresent) { throw new System.ArgumentException("-PassThru cannot be used when -Select is specified.", nameof(this.Select)); } } else if (this.PassThru.IsPresent) { context.Select = (response, cmdlet) => this.ReplicationTaskArn; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.AssessmentRunName = this.AssessmentRunName; #if MODULAR if (this.AssessmentRunName == null && ParameterWasBound(nameof(this.AssessmentRunName))) { WriteWarning("You are passing $null as a value for parameter AssessmentRunName which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif if (this.Exclude != null) { context.Exclude = new List(this.Exclude); } if (this.IncludeOnly != null) { context.IncludeOnly = new List(this.IncludeOnly); } context.ReplicationTaskArn = this.ReplicationTaskArn; #if MODULAR if (this.ReplicationTaskArn == null && ParameterWasBound(nameof(this.ReplicationTaskArn))) { WriteWarning("You are passing $null as a value for parameter ReplicationTaskArn which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif context.ResultEncryptionMode = this.ResultEncryptionMode; context.ResultKmsKeyArn = this.ResultKmsKeyArn; context.ResultLocationBucket = this.ResultLocationBucket; #if MODULAR if (this.ResultLocationBucket == null && ParameterWasBound(nameof(this.ResultLocationBucket))) { WriteWarning("You are passing $null as a value for parameter ResultLocationBucket which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif context.ResultLocationFolder = this.ResultLocationFolder; context.ServiceAccessRoleArn = this.ServiceAccessRoleArn; #if MODULAR if (this.ServiceAccessRoleArn == null && ParameterWasBound(nameof(this.ServiceAccessRoleArn))) { WriteWarning("You are passing $null as a value for parameter ServiceAccessRoleArn which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif // allow further manipulation of loaded context prior to processing PostExecutionContextLoad(context); var output = Execute(context) as CmdletOutput; ProcessOutput(output); } #region IExecutor Members public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.DatabaseMigrationService.Model.StartReplicationTaskAssessmentRunRequest(); if (cmdletContext.AssessmentRunName != null) { request.AssessmentRunName = cmdletContext.AssessmentRunName; } if (cmdletContext.Exclude != null) { request.Exclude = cmdletContext.Exclude; } if (cmdletContext.IncludeOnly != null) { request.IncludeOnly = cmdletContext.IncludeOnly; } if (cmdletContext.ReplicationTaskArn != null) { request.ReplicationTaskArn = cmdletContext.ReplicationTaskArn; } if (cmdletContext.ResultEncryptionMode != null) { request.ResultEncryptionMode = cmdletContext.ResultEncryptionMode; } if (cmdletContext.ResultKmsKeyArn != null) { request.ResultKmsKeyArn = cmdletContext.ResultKmsKeyArn; } if (cmdletContext.ResultLocationBucket != null) { request.ResultLocationBucket = cmdletContext.ResultLocationBucket; } if (cmdletContext.ResultLocationFolder != null) { request.ResultLocationFolder = cmdletContext.ResultLocationFolder; } if (cmdletContext.ServiceAccessRoleArn != null) { request.ServiceAccessRoleArn = cmdletContext.ServiceAccessRoleArn; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return output; } public ExecutorContext CreateContext() { return new CmdletContext(); } #endregion #region AWS Service Operation Call private Amazon.DatabaseMigrationService.Model.StartReplicationTaskAssessmentRunResponse CallAWSServiceOperation(IAmazonDatabaseMigrationService client, Amazon.DatabaseMigrationService.Model.StartReplicationTaskAssessmentRunRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Database Migration Service", "StartReplicationTaskAssessmentRun"); try { #if DESKTOP return client.StartReplicationTaskAssessmentRun(request); #elif CORECLR return client.StartReplicationTaskAssessmentRunAsync(request).GetAwaiter().GetResult(); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } } #endregion internal partial class CmdletContext : ExecutorContext { public System.String AssessmentRunName { get; set; } public List Exclude { get; set; } public List IncludeOnly { get; set; } public System.String ReplicationTaskArn { get; set; } public System.String ResultEncryptionMode { get; set; } public System.String ResultKmsKeyArn { get; set; } public System.String ResultLocationBucket { get; set; } public System.String ResultLocationFolder { get; set; } public System.String ServiceAccessRoleArn { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response.ReplicationTaskAssessmentRun; } } }