/*******************************************************************************
* 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.Redshift;
using Amazon.Redshift.Model;
namespace Amazon.PowerShell.Cmdlets.RS
{
///
/// Creates a new cluster with the specified parameters.
///
///
///
/// To create a cluster in Virtual Private Cloud (VPC), you must provide a cluster subnet
/// group name. The cluster subnet group identifies the subnets of your VPC that Amazon
/// Redshift uses when creating the cluster. For more information about managing clusters,
/// go to Amazon
/// Redshift Clusters in the Amazon Redshift Cluster Management Guide.
///
///
[Cmdlet("New", "RSCluster", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.Redshift.Model.Cluster")]
[AWSCmdlet("Calls the Amazon Redshift CreateCluster API operation.", Operation = new[] {"CreateCluster"}, SelectReturnType = typeof(Amazon.Redshift.Model.CreateClusterResponse))]
[AWSCmdletOutput("Amazon.Redshift.Model.Cluster or Amazon.Redshift.Model.CreateClusterResponse",
"This cmdlet returns an Amazon.Redshift.Model.Cluster object.",
"The service call response (type Amazon.Redshift.Model.CreateClusterResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class NewRSClusterCmdlet : AmazonRedshiftClientCmdlet, IExecutor
{
#region Parameter AdditionalInfo
///
///
/// Reserved.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String AdditionalInfo { get; set; }
#endregion
#region Parameter AllowVersionUpgrade
///
///
/// If true
, major version upgrades can be applied during the maintenance
/// window to the Amazon Redshift engine that is running on the cluster.When a new major version of the Amazon Redshift engine is released, you can request
/// that the service automatically apply upgrades during the maintenance window to the
/// Amazon Redshift engine that is running on your cluster.Default: true
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? AllowVersionUpgrade { get; set; }
#endregion
#region Parameter AquaConfigurationStatus
///
///
/// This parameter is retired. It does not set the AQUA configuration status. Amazon Redshift
/// automatically determines whether to use AQUA (Advanced Query Accelerator).
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[AWSConstantClassSource("Amazon.Redshift.AquaConfigurationStatus")]
public Amazon.Redshift.AquaConfigurationStatus AquaConfigurationStatus { get; set; }
#endregion
#region Parameter AutomatedSnapshotRetentionPeriod
///
///
/// The number of days that automated snapshots are retained. If the value is 0, automated
/// snapshots are disabled. Even if automated snapshots are disabled, you can still create
/// manual snapshots when you want with CreateClusterSnapshot. You can't disable automated snapshots for RA3 node types. Set the automated retention
/// period from 1-35 days.Default: 1
Constraints: Must be a value from 0 to 35.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Int32? AutomatedSnapshotRetentionPeriod { get; set; }
#endregion
#region Parameter AvailabilityZone
///
///
/// The EC2 Availability Zone (AZ) in which you want Amazon Redshift to provision the
/// cluster. For example, if you have several EC2 instances running in a specific Availability
/// Zone, then you might want the cluster to be provisioned in the same zone in order
/// to decrease network latency.Default: A random, system-chosen Availability Zone in the region that is specified
/// by the endpoint.Example: us-east-2d
Constraint: The specified Availability Zone must be in the same region as the current
/// endpoint.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String AvailabilityZone { get; set; }
#endregion
#region Parameter AvailabilityZoneRelocation
///
///
/// The option to enable relocation for an Amazon Redshift cluster between Availability
/// Zones after the cluster is created.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? AvailabilityZoneRelocation { get; set; }
#endregion
#region Parameter ClusterIdentifier
///
///
/// A unique identifier for the cluster. You use this identifier to refer to the cluster
/// for any subsequent cluster operations such as deleting or modifying. The identifier
/// also appears in the Amazon Redshift console.Constraints:- Must contain from 1 to 63 alphanumeric characters or hyphens.
- Alphabetic characters must be lowercase.
- First character must be a letter.
- Cannot end with a hyphen or contain two consecutive hyphens.
- Must be unique for all clusters within an Amazon Web Services account.
Example: myexamplecluster
///
///
#if !MODULAR
[System.Management.Automation.Parameter(Position = 1, ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(Position = 1, ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String ClusterIdentifier { get; set; }
#endregion
#region Parameter ClusterParameterGroupName
///
///
/// The name of the parameter group to be associated with this cluster.Default: The default Amazon Redshift cluster parameter group. For information about
/// the default parameter group, go to Working
/// with Amazon Redshift Parameter GroupsConstraints:- Must be 1 to 255 alphanumeric characters or hyphens.
- First character must be a letter.
- Cannot end with a hyphen or contain two consecutive hyphens.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ClusterParameterGroupName { get; set; }
#endregion
#region Parameter ClusterSecurityGroup
///
///
/// A list of security groups to be associated with this cluster.Default: The default cluster security group for Amazon Redshift.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("ClusterSecurityGroups")]
public System.String[] ClusterSecurityGroup { get; set; }
#endregion
#region Parameter ClusterSubnetGroupName
///
///
/// The name of a cluster subnet group to be associated with this cluster.If this parameter is not provided the resulting cluster will be deployed outside virtual
/// private cloud (VPC).
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ClusterSubnetGroupName { get; set; }
#endregion
#region Parameter ClusterType
///
///
/// The type of the cluster. When cluster type is specified assingle-node
, the NumberOfNodes parameter is not required.multi-node
, the NumberOfNodes parameter is required.
Valid Values: multi-node
| single-node
Default: multi-node
///
///
[System.Management.Automation.Parameter(Position = 2, ValueFromPipelineByPropertyName = true)]
public System.String ClusterType { get; set; }
#endregion
#region Parameter ClusterVersion
///
///
/// The version of the Amazon Redshift engine software that you want to deploy on the
/// cluster.The version selected runs on all the nodes in the cluster.Constraints: Only version 1.0 is currently available.Example: 1.0
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ClusterVersion { get; set; }
#endregion
#region Parameter DBName
///
///
/// The name of the first database to be created when the cluster is created.To create additional databases after the cluster is created, connect to the cluster
/// with a SQL client and use SQL commands to create a database. For more information,
/// go to Create
/// a Database in the Amazon Redshift Database Developer Guide. Default: dev
Constraints:- Must contain 1 to 64 alphanumeric characters.
- Must contain only lowercase letters.
- Cannot be a word that is reserved by the service. A list of reserved words can be
/// found in Reserved
/// Words in the Amazon Redshift Database Developer Guide.
///
///
[System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)]
public System.String DBName { get; set; }
#endregion
#region Parameter DefaultIamRoleArn
///
///
/// The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster
/// when the cluster was created.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String DefaultIamRoleArn { get; set; }
#endregion
#region Parameter ElasticIp
///
///
/// The Elastic IP (EIP) address for the cluster.Constraints: The cluster must be provisioned in EC2-VPC and publicly-accessible through
/// an Internet gateway. Don't specify the Elastic IP address for a publicly accessible
/// cluster with availability zone relocation turned on. For more information about provisioning
/// clusters in EC2-VPC, go to Supported
/// Platforms to Launch Your Cluster in the Amazon Redshift Cluster Management Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ElasticIp { get; set; }
#endregion
#region Parameter Encrypted
///
///
/// If true
, the data in the cluster is encrypted at rest. Default: false
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? Encrypted { get; set; }
#endregion
#region Parameter EnhancedVpcRouting
///
///
/// An option that specifies whether to create the cluster with enhanced VPC routing enabled.
/// To create a cluster that uses enhanced VPC routing, the cluster must be in a VPC.
/// For more information, see Enhanced
/// VPC Routing in the Amazon Redshift Cluster Management Guide.If this option is true
, enhanced VPC routing is enabled. Default: false
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? EnhancedVpcRouting { get; set; }
#endregion
#region Parameter HsmClientCertificateIdentifier
///
///
/// Specifies the name of the HSM client certificate the Amazon Redshift cluster uses
/// to retrieve the data encryption keys stored in an HSM.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String HsmClientCertificateIdentifier { get; set; }
#endregion
#region Parameter HsmConfigurationIdentifier
///
///
/// Specifies the name of the HSM configuration that contains the information the Amazon
/// Redshift cluster can use to retrieve and store keys in an HSM.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String HsmConfigurationIdentifier { get; set; }
#endregion
#region Parameter IamRole
///
///
/// A list of Identity and Access Management (IAM) roles that can be used by the cluster
/// to access other Amazon Web Services services. You must supply the IAM roles in their
/// Amazon Resource Name (ARN) format. The maximum number of IAM roles that you can associate is subject to a quota. For
/// more information, go to Quotas
/// and limits in the Amazon Redshift Cluster Management Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("IamRoles")]
public System.String[] IamRole { get; set; }
#endregion
#region Parameter KmsKeyId
///
///
/// The Key Management Service (KMS) key ID of the encryption key that you want to use
/// to encrypt data in the cluster.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String KmsKeyId { get; set; }
#endregion
#region Parameter LoadSampleData
///
///
/// A flag that specifies whether to load sample data once the cluster is created.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String LoadSampleData { get; set; }
#endregion
#region Parameter MaintenanceTrackName
///
///
/// An optional parameter for the name of the maintenance track for the cluster. If you
/// don't provide a maintenance track name, the cluster is assigned to the current
/// track.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String MaintenanceTrackName { get; set; }
#endregion
#region Parameter ManualSnapshotRetentionPeriod
///
///
/// The default number of days to retain a manual snapshot. If the value is -1, the snapshot
/// is retained indefinitely. This setting doesn't change the retention period of existing
/// snapshots.The value must be either -1 or an integer between 1 and 3,653.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Int32? ManualSnapshotRetentionPeriod { get; set; }
#endregion
#region Parameter MasterUsername
///
///
/// The user name associated with the admin user account for the cluster that is being
/// created.Constraints:- Must be 1 - 128 alphanumeric characters or hyphens. The user name can't be
PUBLIC
. - Must contain only lowercase letters, numbers, underscore, plus sign, period (dot),
/// at symbol (@), or hyphen.
- The first character must be a letter.
- Must not contain a colon (:) or a slash (/).
- Cannot be a reserved word. A list of reserved words can be found in Reserved
/// Words in the Amazon Redshift Database Developer Guide.
///
///
#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 MasterUsername { get; set; }
#endregion
#region Parameter MasterUserPassword
///
///
/// The password associated with the admin user account for the cluster that is being
/// created.Constraints:- Must be between 8 and 64 characters in length.
- Must contain at least one uppercase letter.
- Must contain at least one lowercase letter.
- Must contain one number.
- Can be any printable ASCII character (ASCII code 33-126) except
'
(single
/// quote), "
(double quote), \
, /
, or @
.
///
///
#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 MasterUserPassword { get; set; }
#endregion
#region Parameter NodeType
///
///
/// The node type to be provisioned for the cluster. For information about node types,
/// go to
/// Working with Clusters in the Amazon Redshift Cluster Management Guide.
/// Valid Values: ds2.xlarge
| ds2.8xlarge
| dc1.large
/// | dc1.8xlarge
| dc2.large
| dc2.8xlarge
| ra3.xlplus
/// | ra3.4xlarge
| ra3.16xlarge
///
///
#if !MODULAR
[System.Management.Automation.Parameter(Position = 3, ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(Position = 3, ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String NodeType { get; set; }
#endregion
#region Parameter NumberOfNodes
///
///
/// The number of compute nodes in the cluster. This parameter is required when the ClusterType
/// parameter is specified as multi-node
. For information about determining how many nodes you need, go to
/// Working with Clusters in the Amazon Redshift Cluster Management Guide.
/// If you don't specify this parameter, you get a single-node cluster. When requesting
/// a multi-node cluster, you must specify the number of nodes that you want in the cluster.Default: 1
Constraints: Value must be at least 1 and no more than 100.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Int32? NumberOfNodes { get; set; }
#endregion
#region Parameter Port
///
///
/// The port number on which the cluster accepts incoming connections.The cluster is accessible only via the JDBC and ODBC connection strings. Part of the
/// connection string requires the port on which the cluster will listen for incoming
/// connections.Default: 5439
Valid Values: 1150-65535
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Int32? Port { get; set; }
#endregion
#region Parameter PreferredMaintenanceWindow
///
///
/// The weekly time range (in UTC) during which automated cluster maintenance can occur. Format: ddd:hh24:mi-ddd:hh24:mi
Default: A 30-minute window selected at random from an 8-hour block of time per region,
/// occurring on a random day of the week. For more information about the time blocks
/// for each region, see Maintenance
/// Windows in Amazon Redshift Cluster Management Guide.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
///
///
/// If true
, the cluster can be accessed from a public network.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? PubliclyAccessible { get; set; }
#endregion
#region Parameter SnapshotScheduleIdentifier
///
///
/// A unique identifier for the snapshot schedule.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String SnapshotScheduleIdentifier { get; set; }
#endregion
#region Parameter Tag
///
///
/// A list of tag instances.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Tags")]
public Amazon.Redshift.Model.Tag[] Tag { get; set; }
#endregion
#region Parameter VpcSecurityGroupId
///
///
/// A list of Virtual Private Cloud (VPC) security groups to be associated with the cluster.Default: The default VPC security group is associated with the cluster.
///
///
[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 'Cluster'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.Redshift.Model.CreateClusterResponse).
/// Specifying the name of a property of type Amazon.Redshift.Model.CreateClusterResponse 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; } = "Cluster";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the DBName parameter.
/// The -PassThru parameter is deprecated, use -Select '^DBName' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^DBName' 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.DBName), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "New-RSCluster (CreateCluster)"))
{
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.DBName;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.AdditionalInfo = this.AdditionalInfo;
context.AllowVersionUpgrade = this.AllowVersionUpgrade;
context.AquaConfigurationStatus = this.AquaConfigurationStatus;
context.AutomatedSnapshotRetentionPeriod = this.AutomatedSnapshotRetentionPeriod;
context.AvailabilityZone = this.AvailabilityZone;
context.AvailabilityZoneRelocation = this.AvailabilityZoneRelocation;
context.ClusterIdentifier = this.ClusterIdentifier;
#if MODULAR
if (this.ClusterIdentifier == null && ParameterWasBound(nameof(this.ClusterIdentifier)))
{
WriteWarning("You are passing $null as a value for parameter ClusterIdentifier 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.ClusterParameterGroupName = this.ClusterParameterGroupName;
if (this.ClusterSecurityGroup != null)
{
context.ClusterSecurityGroup = new List(this.ClusterSecurityGroup);
}
context.ClusterSubnetGroupName = this.ClusterSubnetGroupName;
context.ClusterType = this.ClusterType;
context.ClusterVersion = this.ClusterVersion;
context.DBName = this.DBName;
context.DefaultIamRoleArn = this.DefaultIamRoleArn;
context.ElasticIp = this.ElasticIp;
context.Encrypted = this.Encrypted;
context.EnhancedVpcRouting = this.EnhancedVpcRouting;
context.HsmClientCertificateIdentifier = this.HsmClientCertificateIdentifier;
context.HsmConfigurationIdentifier = this.HsmConfigurationIdentifier;
if (this.IamRole != null)
{
context.IamRole = new List(this.IamRole);
}
context.KmsKeyId = this.KmsKeyId;
context.LoadSampleData = this.LoadSampleData;
context.MaintenanceTrackName = this.MaintenanceTrackName;
context.ManualSnapshotRetentionPeriod = this.ManualSnapshotRetentionPeriod;
context.MasterUsername = this.MasterUsername;
#if MODULAR
if (this.MasterUsername == null && ParameterWasBound(nameof(this.MasterUsername)))
{
WriteWarning("You are passing $null as a value for parameter MasterUsername 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.MasterUserPassword = this.MasterUserPassword;
#if MODULAR
if (this.MasterUserPassword == null && ParameterWasBound(nameof(this.MasterUserPassword)))
{
WriteWarning("You are passing $null as a value for parameter MasterUserPassword 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.NodeType = this.NodeType;
#if MODULAR
if (this.NodeType == null && ParameterWasBound(nameof(this.NodeType)))
{
WriteWarning("You are passing $null as a value for parameter NodeType 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.NumberOfNodes = this.NumberOfNodes;
context.Port = this.Port;
context.PreferredMaintenanceWindow = this.PreferredMaintenanceWindow;
context.PubliclyAccessible = this.PubliclyAccessible;
context.SnapshotScheduleIdentifier = this.SnapshotScheduleIdentifier;
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.Redshift.Model.CreateClusterRequest();
if (cmdletContext.AdditionalInfo != null)
{
request.AdditionalInfo = cmdletContext.AdditionalInfo;
}
if (cmdletContext.AllowVersionUpgrade != null)
{
request.AllowVersionUpgrade = cmdletContext.AllowVersionUpgrade.Value;
}
if (cmdletContext.AquaConfigurationStatus != null)
{
request.AquaConfigurationStatus = cmdletContext.AquaConfigurationStatus;
}
if (cmdletContext.AutomatedSnapshotRetentionPeriod != null)
{
request.AutomatedSnapshotRetentionPeriod = cmdletContext.AutomatedSnapshotRetentionPeriod.Value;
}
if (cmdletContext.AvailabilityZone != null)
{
request.AvailabilityZone = cmdletContext.AvailabilityZone;
}
if (cmdletContext.AvailabilityZoneRelocation != null)
{
request.AvailabilityZoneRelocation = cmdletContext.AvailabilityZoneRelocation.Value;
}
if (cmdletContext.ClusterIdentifier != null)
{
request.ClusterIdentifier = cmdletContext.ClusterIdentifier;
}
if (cmdletContext.ClusterParameterGroupName != null)
{
request.ClusterParameterGroupName = cmdletContext.ClusterParameterGroupName;
}
if (cmdletContext.ClusterSecurityGroup != null)
{
request.ClusterSecurityGroups = cmdletContext.ClusterSecurityGroup;
}
if (cmdletContext.ClusterSubnetGroupName != null)
{
request.ClusterSubnetGroupName = cmdletContext.ClusterSubnetGroupName;
}
if (cmdletContext.ClusterType != null)
{
request.ClusterType = cmdletContext.ClusterType;
}
if (cmdletContext.ClusterVersion != null)
{
request.ClusterVersion = cmdletContext.ClusterVersion;
}
if (cmdletContext.DBName != null)
{
request.DBName = cmdletContext.DBName;
}
if (cmdletContext.DefaultIamRoleArn != null)
{
request.DefaultIamRoleArn = cmdletContext.DefaultIamRoleArn;
}
if (cmdletContext.ElasticIp != null)
{
request.ElasticIp = cmdletContext.ElasticIp;
}
if (cmdletContext.Encrypted != null)
{
request.Encrypted = cmdletContext.Encrypted.Value;
}
if (cmdletContext.EnhancedVpcRouting != null)
{
request.EnhancedVpcRouting = cmdletContext.EnhancedVpcRouting.Value;
}
if (cmdletContext.HsmClientCertificateIdentifier != null)
{
request.HsmClientCertificateIdentifier = cmdletContext.HsmClientCertificateIdentifier;
}
if (cmdletContext.HsmConfigurationIdentifier != null)
{
request.HsmConfigurationIdentifier = cmdletContext.HsmConfigurationIdentifier;
}
if (cmdletContext.IamRole != null)
{
request.IamRoles = cmdletContext.IamRole;
}
if (cmdletContext.KmsKeyId != null)
{
request.KmsKeyId = cmdletContext.KmsKeyId;
}
if (cmdletContext.LoadSampleData != null)
{
request.LoadSampleData = cmdletContext.LoadSampleData;
}
if (cmdletContext.MaintenanceTrackName != null)
{
request.MaintenanceTrackName = cmdletContext.MaintenanceTrackName;
}
if (cmdletContext.ManualSnapshotRetentionPeriod != null)
{
request.ManualSnapshotRetentionPeriod = cmdletContext.ManualSnapshotRetentionPeriod.Value;
}
if (cmdletContext.MasterUsername != null)
{
request.MasterUsername = cmdletContext.MasterUsername;
}
if (cmdletContext.MasterUserPassword != null)
{
request.MasterUserPassword = cmdletContext.MasterUserPassword;
}
if (cmdletContext.NodeType != null)
{
request.NodeType = cmdletContext.NodeType;
}
if (cmdletContext.NumberOfNodes != null)
{
request.NumberOfNodes = cmdletContext.NumberOfNodes.Value;
}
if (cmdletContext.Port != null)
{
request.Port = cmdletContext.Port.Value;
}
if (cmdletContext.PreferredMaintenanceWindow != null)
{
request.PreferredMaintenanceWindow = cmdletContext.PreferredMaintenanceWindow;
}
if (cmdletContext.PubliclyAccessible != null)
{
request.PubliclyAccessible = cmdletContext.PubliclyAccessible.Value;
}
if (cmdletContext.SnapshotScheduleIdentifier != null)
{
request.SnapshotScheduleIdentifier = cmdletContext.SnapshotScheduleIdentifier;
}
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.Redshift.Model.CreateClusterResponse CallAWSServiceOperation(IAmazonRedshift client, Amazon.Redshift.Model.CreateClusterRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Redshift", "CreateCluster");
try
{
#if DESKTOP
return client.CreateCluster(request);
#elif CORECLR
return client.CreateClusterAsync(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 AdditionalInfo { get; set; }
public System.Boolean? AllowVersionUpgrade { get; set; }
public Amazon.Redshift.AquaConfigurationStatus AquaConfigurationStatus { get; set; }
public System.Int32? AutomatedSnapshotRetentionPeriod { get; set; }
public System.String AvailabilityZone { get; set; }
public System.Boolean? AvailabilityZoneRelocation { get; set; }
public System.String ClusterIdentifier { get; set; }
public System.String ClusterParameterGroupName { get; set; }
public List ClusterSecurityGroup { get; set; }
public System.String ClusterSubnetGroupName { get; set; }
public System.String ClusterType { get; set; }
public System.String ClusterVersion { get; set; }
public System.String DBName { get; set; }
public System.String DefaultIamRoleArn { get; set; }
public System.String ElasticIp { get; set; }
public System.Boolean? Encrypted { get; set; }
public System.Boolean? EnhancedVpcRouting { get; set; }
public System.String HsmClientCertificateIdentifier { get; set; }
public System.String HsmConfigurationIdentifier { get; set; }
public List IamRole { get; set; }
public System.String KmsKeyId { get; set; }
public System.String LoadSampleData { get; set; }
public System.String MaintenanceTrackName { get; set; }
public System.Int32? ManualSnapshotRetentionPeriod { get; set; }
public System.String MasterUsername { get; set; }
public System.String MasterUserPassword { get; set; }
public System.String NodeType { get; set; }
public System.Int32? NumberOfNodes { get; set; }
public System.Int32? Port { get; set; }
public System.String PreferredMaintenanceWindow { get; set; }
public System.Boolean? PubliclyAccessible { get; set; }
public System.String SnapshotScheduleIdentifier { get; set; }
public List Tag { get; set; }
public List VpcSecurityGroupId { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response.Cluster;
}
}
}