/*******************************************************************************
* 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
{
///
/// Creates the replication instance using the specified parameters.
///
///
///
/// DMS requires that your account have certain roles with appropriate permissions before
/// you can create a replication instance. For information on the required roles, see
/// Creating
/// the IAM Roles to Use With the CLI and DMS API. For information on the required
/// permissions, see IAM
/// Permissions Needed to Use DMS.
///
///
[Cmdlet("New", "DMSReplicationInstance", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.DatabaseMigrationService.Model.ReplicationInstance")]
[AWSCmdlet("Calls the AWS Database Migration Service CreateReplicationInstance API operation.", Operation = new[] {"CreateReplicationInstance"}, SelectReturnType = typeof(Amazon.DatabaseMigrationService.Model.CreateReplicationInstanceResponse))]
[AWSCmdletOutput("Amazon.DatabaseMigrationService.Model.ReplicationInstance or Amazon.DatabaseMigrationService.Model.CreateReplicationInstanceResponse",
"This cmdlet returns an Amazon.DatabaseMigrationService.Model.ReplicationInstance object.",
"The service call response (type Amazon.DatabaseMigrationService.Model.CreateReplicationInstanceResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class NewDMSReplicationInstanceCmdlet : AmazonDatabaseMigrationServiceClientCmdlet, IExecutor
{
#region Parameter AllocatedStorage
///
///
/// The amount of storage (in gigabytes) to be initially allocated for the replication
/// instance.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Int32? AllocatedStorage { get; set; }
#endregion
#region Parameter AutoMinorVersionUpgrade
///
///
/// A value that indicates whether minor engine upgrades are applied automatically to
/// the replication instance during the maintenance window. This parameter defaults to
/// true
.Default: true
When AutoMinorVersionUpgrade
is enabled, DMS uses the current default
/// engine version when you create a replication instance. For example, if you set EngineVersion
/// to a lower version number than the current default version, DMS uses the default version.If AutoMinorVersionUpgrade
isn’t enabled when you create a replication
/// instance, DMS uses the engine version specified by the EngineVersion
/// parameter.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? AutoMinorVersionUpgrade { get; set; }
#endregion
#region Parameter AvailabilityZone
///
///
/// The Availability Zone where the replication instance will be created. The default
/// value is a random, system-chosen Availability Zone in the endpoint's Amazon Web Services
/// Region, for example: us-east-1d
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String AvailabilityZone { get; set; }
#endregion
#region Parameter DnsNameServer
///
///
/// A list of custom DNS name servers supported for the replication instance to access
/// your on-premise source or target database. This list overrides the default name servers
/// supported by the replication instance. You can specify a comma-separated list of internet
/// addresses for up to four on-premise DNS name servers. For example: "1.1.1.1,2.2.2.2,3.3.3.3,4.4.4.4"
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("DnsNameServers")]
public System.String DnsNameServer { get; set; }
#endregion
#region Parameter EngineVersion
///
///
/// The engine version number of the replication instance.If an engine version number is not specified when a replication instance is created,
/// the default is the latest engine version available.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String EngineVersion { get; set; }
#endregion
#region Parameter KmsKeyId
///
///
/// An KMS key identifier that is used to encrypt the data on the replication instance.If you don't specify a value for the KmsKeyId
parameter, then DMS uses
/// your default encryption key.KMS creates the default encryption key for your Amazon Web Services account. Your
/// Amazon Web Services account has a different default encryption key for each Amazon
/// Web Services Region.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String KmsKeyId { get; set; }
#endregion
#region Parameter MultiAZ
///
///
/// Specifies whether the replication instance is a Multi-AZ deployment. You can't set
/// the AvailabilityZone
parameter if the Multi-AZ parameter is set to true
.
///
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? MultiAZ { get; set; }
#endregion
#region Parameter NetworkType
///
///
/// The type of IP address protocol used by a replication instance, such as IPv4 only
/// or Dual-stack that supports both IPv4 and IPv6 addressing. IPv6 only is not yet supported.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String NetworkType { get; set; }
#endregion
#region Parameter PreferredMaintenanceWindow
///
///
/// The weekly time range during which system maintenance can occur, in Universal Coordinated
/// Time (UTC). Format: ddd:hh24:mi-ddd:hh24:mi
Default: A 30-minute window selected at random from an 8-hour block of time per Amazon
/// Web Services Region, occurring on a random day of the week.Valid Days: Mon, Tue, Wed, Thu, Fri, Sat, SunConstraints: Minimum 30-minute window.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String PreferredMaintenanceWindow { get; set; }
#endregion
#region Parameter PubliclyAccessible
///
///
/// Specifies the accessibility options for the replication instance. A value of true
/// represents an instance with a public IP address. A value of false
represents
/// an instance with a private IP address. The default value is true
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? PubliclyAccessible { get; set; }
#endregion
#region Parameter ReplicationInstanceClass
///
///
/// The compute and memory capacity of the replication instance as defined for the specified
/// replication instance class. For example to specify the instance class dms.c4.large,
/// set this parameter to "dms.c4.large"
.For more information on the settings and capacities for the available replication
/// instance classes, see Choosing the right DMS replication instance; and, Selecting
/// the best size for a replication instance.
///
///
#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 ReplicationInstanceClass { get; set; }
#endregion
#region Parameter ReplicationInstanceIdentifier
///
///
/// The replication instance identifier. This parameter is stored as a lowercase string.Constraints:- Must contain 1-63 alphanumeric characters or hyphens.
- First character must be a letter.
- Can't end with a hyphen or contain two consecutive hyphens.
Example: myrepinstance
///
///
#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 ReplicationInstanceIdentifier { get; set; }
#endregion
#region Parameter ReplicationSubnetGroupIdentifier
///
///
/// A subnet group to associate with the replication instance.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ReplicationSubnetGroupIdentifier { get; set; }
#endregion
#region Parameter ResourceIdentifier
///
///
/// A friendly name for the resource identifier at the end of the EndpointArn
/// response parameter that is returned in the created Endpoint
object. The
/// value for this parameter can have up to 31 characters. It can contain only ASCII letters,
/// digits, and hyphen ('-'). Also, it can't end with a hyphen or contain two consecutive
/// hyphens, and can only begin with a letter, such as Example-App-ARN1
.
/// For example, this value might result in the EndpointArn
value arn:aws:dms:eu-west-1:012345678901:rep:Example-App-ARN1
.
/// If you don't specify a ResourceIdentifier
value, DMS generates a default
/// identifier value for the end of EndpointArn
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ResourceIdentifier { get; set; }
#endregion
#region Parameter Tag
///
///
/// One or more tags to be assigned to the replication instance.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Tags")]
public Amazon.DatabaseMigrationService.Model.Tag[] Tag { get; set; }
#endregion
#region Parameter VpcSecurityGroupId
///
///
/// Specifies the VPC security group to be used with the replication instance. The VPC
/// security group must work with the VPC containing the replication instance.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("VpcSecurityGroupIds")]
public System.String[] VpcSecurityGroupId { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is 'ReplicationInstance'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.DatabaseMigrationService.Model.CreateReplicationInstanceResponse).
/// Specifying the name of a property of type Amazon.DatabaseMigrationService.Model.CreateReplicationInstanceResponse 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; } = "ReplicationInstance";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the ReplicationInstanceIdentifier parameter.
/// The -PassThru parameter is deprecated, use -Select '^ReplicationInstanceIdentifier' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^ReplicationInstanceIdentifier' 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.ReplicationInstanceIdentifier), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "New-DMSReplicationInstance (CreateReplicationInstance)"))
{
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.ReplicationInstanceIdentifier;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.AllocatedStorage = this.AllocatedStorage;
context.AutoMinorVersionUpgrade = this.AutoMinorVersionUpgrade;
context.AvailabilityZone = this.AvailabilityZone;
context.DnsNameServer = this.DnsNameServer;
context.EngineVersion = this.EngineVersion;
context.KmsKeyId = this.KmsKeyId;
context.MultiAZ = this.MultiAZ;
context.NetworkType = this.NetworkType;
context.PreferredMaintenanceWindow = this.PreferredMaintenanceWindow;
context.PubliclyAccessible = this.PubliclyAccessible;
context.ReplicationInstanceClass = this.ReplicationInstanceClass;
#if MODULAR
if (this.ReplicationInstanceClass == null && ParameterWasBound(nameof(this.ReplicationInstanceClass)))
{
WriteWarning("You are passing $null as a value for parameter ReplicationInstanceClass 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.ReplicationInstanceIdentifier = this.ReplicationInstanceIdentifier;
#if MODULAR
if (this.ReplicationInstanceIdentifier == null && ParameterWasBound(nameof(this.ReplicationInstanceIdentifier)))
{
WriteWarning("You are passing $null as a value for parameter ReplicationInstanceIdentifier 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.ReplicationSubnetGroupIdentifier = this.ReplicationSubnetGroupIdentifier;
context.ResourceIdentifier = this.ResourceIdentifier;
if (this.Tag != null)
{
context.Tag = new List(this.Tag);
}
if (this.VpcSecurityGroupId != null)
{
context.VpcSecurityGroupId = new List(this.VpcSecurityGroupId);
}
// 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.CreateReplicationInstanceRequest();
if (cmdletContext.AllocatedStorage != null)
{
request.AllocatedStorage = cmdletContext.AllocatedStorage.Value;
}
if (cmdletContext.AutoMinorVersionUpgrade != null)
{
request.AutoMinorVersionUpgrade = cmdletContext.AutoMinorVersionUpgrade.Value;
}
if (cmdletContext.AvailabilityZone != null)
{
request.AvailabilityZone = cmdletContext.AvailabilityZone;
}
if (cmdletContext.DnsNameServer != null)
{
request.DnsNameServers = cmdletContext.DnsNameServer;
}
if (cmdletContext.EngineVersion != null)
{
request.EngineVersion = cmdletContext.EngineVersion;
}
if (cmdletContext.KmsKeyId != null)
{
request.KmsKeyId = cmdletContext.KmsKeyId;
}
if (cmdletContext.MultiAZ != null)
{
request.MultiAZ = cmdletContext.MultiAZ.Value;
}
if (cmdletContext.NetworkType != null)
{
request.NetworkType = cmdletContext.NetworkType;
}
if (cmdletContext.PreferredMaintenanceWindow != null)
{
request.PreferredMaintenanceWindow = cmdletContext.PreferredMaintenanceWindow;
}
if (cmdletContext.PubliclyAccessible != null)
{
request.PubliclyAccessible = cmdletContext.PubliclyAccessible.Value;
}
if (cmdletContext.ReplicationInstanceClass != null)
{
request.ReplicationInstanceClass = cmdletContext.ReplicationInstanceClass;
}
if (cmdletContext.ReplicationInstanceIdentifier != null)
{
request.ReplicationInstanceIdentifier = cmdletContext.ReplicationInstanceIdentifier;
}
if (cmdletContext.ReplicationSubnetGroupIdentifier != null)
{
request.ReplicationSubnetGroupIdentifier = cmdletContext.ReplicationSubnetGroupIdentifier;
}
if (cmdletContext.ResourceIdentifier != null)
{
request.ResourceIdentifier = cmdletContext.ResourceIdentifier;
}
if (cmdletContext.Tag != null)
{
request.Tags = cmdletContext.Tag;
}
if (cmdletContext.VpcSecurityGroupId != null)
{
request.VpcSecurityGroupIds = cmdletContext.VpcSecurityGroupId;
}
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.CreateReplicationInstanceResponse CallAWSServiceOperation(IAmazonDatabaseMigrationService client, Amazon.DatabaseMigrationService.Model.CreateReplicationInstanceRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Database Migration Service", "CreateReplicationInstance");
try
{
#if DESKTOP
return client.CreateReplicationInstance(request);
#elif CORECLR
return client.CreateReplicationInstanceAsync(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.Int32? AllocatedStorage { get; set; }
public System.Boolean? AutoMinorVersionUpgrade { get; set; }
public System.String AvailabilityZone { get; set; }
public System.String DnsNameServer { get; set; }
public System.String EngineVersion { get; set; }
public System.String KmsKeyId { get; set; }
public System.Boolean? MultiAZ { get; set; }
public System.String NetworkType { get; set; }
public System.String PreferredMaintenanceWindow { get; set; }
public System.Boolean? PubliclyAccessible { get; set; }
public System.String ReplicationInstanceClass { get; set; }
public System.String ReplicationInstanceIdentifier { get; set; }
public System.String ReplicationSubnetGroupIdentifier { get; set; }
public System.String ResourceIdentifier { get; set; }
public List Tag { get; set; }
public List VpcSecurityGroupId { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response.ReplicationInstance;
}
}
}