/******************************************************************************* * 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.Neptune; using Amazon.Neptune.Model; namespace Amazon.PowerShell.Cmdlets.NPT { /// /// Modify a setting for a DB cluster. You can change one or more database configuration /// parameters by specifying these parameters and the new values in the request. /// [Cmdlet("Edit", "NPTDBCluster", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("Amazon.Neptune.Model.DBCluster")] [AWSCmdlet("Calls the Amazon Neptune ModifyDBCluster API operation.", Operation = new[] {"ModifyDBCluster"}, SelectReturnType = typeof(Amazon.Neptune.Model.ModifyDBClusterResponse))] [AWSCmdletOutput("Amazon.Neptune.Model.DBCluster or Amazon.Neptune.Model.ModifyDBClusterResponse", "This cmdlet returns an Amazon.Neptune.Model.DBCluster object.", "The service call response (type Amazon.Neptune.Model.ModifyDBClusterResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class EditNPTDBClusterCmdlet : AmazonNeptuneClientCmdlet, IExecutor { #region Parameter AllowMajorVersionUpgrade /// /// /// A value that indicates whether upgrades between different major versions are allowed.Constraints: You must set the allow-major-version-upgrade flag when providing an EngineVersion /// parameter that uses a different major version than the DB cluster's current version. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? AllowMajorVersionUpgrade { get; set; } #endregion #region Parameter ApplyImmediately /// /// /// A value that specifies whether the modifications in this request and any pending modifications /// are asynchronously applied as soon as possible, regardless of the PreferredMaintenanceWindow /// setting for the DB cluster. If this parameter is set to false, changes /// to the DB cluster are applied during the next maintenance window.The ApplyImmediately parameter only affects NewDBClusterIdentifier /// values. If you set the ApplyImmediately parameter value to false, then /// changes to NewDBClusterIdentifier values are applied during the next /// maintenance window. All other changes are applied immediately, regardless of the value /// of the ApplyImmediately parameter.Default: false /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? ApplyImmediately { get; set; } #endregion #region Parameter BackupRetentionPeriod /// /// /// The number of days for which automated backups are retained. You must specify a minimum /// value of 1.Default: 1Constraints: /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? BackupRetentionPeriod { get; set; } #endregion #region Parameter CopyTagsToSnapshot /// /// /// If set to true, tags are copied to any snapshot of the DB cluster /// that is created. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? CopyTagsToSnapshot { get; set; } #endregion #region Parameter DBClusterIdentifier /// /// /// The DB cluster identifier for the cluster being modified. This parameter is not case-sensitive.Constraints: /// /// #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 DBClusterIdentifier { get; set; } #endregion #region Parameter DBClusterParameterGroupName /// /// /// The name of the DB cluster parameter group to use for the DB cluster. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String DBClusterParameterGroupName { get; set; } #endregion #region Parameter DBInstanceParameterGroupName /// /// /// The name of the DB parameter group to apply to all instances of the DB cluster. When you apply a parameter group using DBInstanceParameterGroupName, /// parameter changes aren't applied during the next maintenance window but instead are /// applied immediately.Default: The existing name settingConstraints: /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String DBInstanceParameterGroupName { get; set; } #endregion #region Parameter DeletionProtection /// /// /// A value that indicates whether the DB cluster has deletion protection enabled. The /// database can't be deleted when deletion protection is enabled. By default, deletion /// protection is disabled. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? DeletionProtection { get; set; } #endregion #region Parameter CloudwatchLogsExportConfiguration_DisableLogType /// /// /// The list of log types to disable. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("CloudwatchLogsExportConfiguration_DisableLogTypes")] public System.String[] CloudwatchLogsExportConfiguration_DisableLogType { get; set; } #endregion #region Parameter EnableIAMDatabaseAuthentication /// /// /// True to enable mapping of Amazon Identity and Access Management (IAM) accounts to /// database accounts, and otherwise false.Default: false /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? EnableIAMDatabaseAuthentication { get; set; } #endregion #region Parameter CloudwatchLogsExportConfiguration_EnableLogType /// /// /// The list of log types to enable. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("CloudwatchLogsExportConfiguration_EnableLogTypes")] public System.String[] CloudwatchLogsExportConfiguration_EnableLogType { get; set; } #endregion #region Parameter EngineVersion /// /// /// The version number of the database engine to which you want to upgrade. Changing this /// parameter results in an outage. The change is applied during the next maintenance /// window unless the ApplyImmediately parameter is set to true.For a list of valid engine versions, see Engine /// Releases for Amazon Neptune, or call DescribeDBEngineVersions. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String EngineVersion { get; set; } #endregion #region Parameter MasterUserPassword /// /// /// Not supported by Neptune. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String MasterUserPassword { get; set; } #endregion #region Parameter ServerlessV2ScalingConfiguration_MaxCapacity /// /// /// The maximum number of Neptune capacity units (NCUs) for a DB instance in a Neptune /// Serverless cluster. You can specify NCU values in half-step increments, such as 40, /// 40.5, 41, and so on. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Double? ServerlessV2ScalingConfiguration_MaxCapacity { get; set; } #endregion #region Parameter ServerlessV2ScalingConfiguration_MinCapacity /// /// /// The minimum number of Neptune capacity units (NCUs) for a DB instance in a Neptune /// Serverless cluster. You can specify NCU values in half-step increments, such as 8, /// 8.5, 9, and so on. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Double? ServerlessV2ScalingConfiguration_MinCapacity { get; set; } #endregion #region Parameter NewDBClusterIdentifier /// /// /// The new DB cluster identifier for the DB cluster when renaming a DB cluster. This /// value is stored as a lowercase string.Constraints:Example: my-cluster2 /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String NewDBClusterIdentifier { get; set; } #endregion #region Parameter OptionGroupName /// /// /// Not supported by Neptune. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String OptionGroupName { get; set; } #endregion #region Parameter Port /// /// /// The port number on which the DB cluster accepts connections.Constraints: Value must be 1150-65535Default: The same port as the original DB cluster. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? Port { get; set; } #endregion #region Parameter PreferredBackupWindow /// /// /// The daily time range during which automated backups are created if automated backups /// are enabled, using the BackupRetentionPeriod parameter.The default is a 30-minute window selected at random from an 8-hour block of time /// for each Amazon Region.Constraints: /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String PreferredBackupWindow { 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:miThe default is a 30-minute window selected at random from an 8-hour block of time /// for each Amazon Region, occurring on a random day of the week.Valid Days: Mon, Tue, Wed, Thu, Fri, Sat, Sun.Constraints: Minimum 30-minute window. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String PreferredMaintenanceWindow { get; set; } #endregion #region Parameter VpcSecurityGroupId /// /// /// A list of VPC security groups that the DB cluster will belong to. /// /// [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 'DBCluster'. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.Neptune.Model.ModifyDBClusterResponse). /// Specifying the name of a property of type Amazon.Neptune.Model.ModifyDBClusterResponse 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; } = "DBCluster"; #endregion #region Parameter PassThru /// /// Changes the cmdlet behavior to return the value passed to the DBClusterIdentifier parameter. /// The -PassThru parameter is deprecated, use -Select '^DBClusterIdentifier' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^DBClusterIdentifier' 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.DBClusterIdentifier), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Edit-NPTDBCluster (ModifyDBCluster)")) { 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.DBClusterIdentifier; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.AllowMajorVersionUpgrade = this.AllowMajorVersionUpgrade; context.ApplyImmediately = this.ApplyImmediately; context.BackupRetentionPeriod = this.BackupRetentionPeriod; if (this.CloudwatchLogsExportConfiguration_DisableLogType != null) { context.CloudwatchLogsExportConfiguration_DisableLogType = new List(this.CloudwatchLogsExportConfiguration_DisableLogType); } if (this.CloudwatchLogsExportConfiguration_EnableLogType != null) { context.CloudwatchLogsExportConfiguration_EnableLogType = new List(this.CloudwatchLogsExportConfiguration_EnableLogType); } context.CopyTagsToSnapshot = this.CopyTagsToSnapshot; context.DBClusterIdentifier = this.DBClusterIdentifier; #if MODULAR if (this.DBClusterIdentifier == null && ParameterWasBound(nameof(this.DBClusterIdentifier))) { WriteWarning("You are passing $null as a value for parameter DBClusterIdentifier 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.DBClusterParameterGroupName = this.DBClusterParameterGroupName; context.DBInstanceParameterGroupName = this.DBInstanceParameterGroupName; context.DeletionProtection = this.DeletionProtection; context.EnableIAMDatabaseAuthentication = this.EnableIAMDatabaseAuthentication; context.EngineVersion = this.EngineVersion; context.MasterUserPassword = this.MasterUserPassword; context.NewDBClusterIdentifier = this.NewDBClusterIdentifier; context.OptionGroupName = this.OptionGroupName; context.Port = this.Port; context.PreferredBackupWindow = this.PreferredBackupWindow; context.PreferredMaintenanceWindow = this.PreferredMaintenanceWindow; context.ServerlessV2ScalingConfiguration_MaxCapacity = this.ServerlessV2ScalingConfiguration_MaxCapacity; context.ServerlessV2ScalingConfiguration_MinCapacity = this.ServerlessV2ScalingConfiguration_MinCapacity; 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.Neptune.Model.ModifyDBClusterRequest(); if (cmdletContext.AllowMajorVersionUpgrade != null) { request.AllowMajorVersionUpgrade = cmdletContext.AllowMajorVersionUpgrade.Value; } if (cmdletContext.ApplyImmediately != null) { request.ApplyImmediately = cmdletContext.ApplyImmediately.Value; } if (cmdletContext.BackupRetentionPeriod != null) { request.BackupRetentionPeriod = cmdletContext.BackupRetentionPeriod.Value; } // populate CloudwatchLogsExportConfiguration var requestCloudwatchLogsExportConfigurationIsNull = true; request.CloudwatchLogsExportConfiguration = new Amazon.Neptune.Model.CloudwatchLogsExportConfiguration(); List requestCloudwatchLogsExportConfiguration_cloudwatchLogsExportConfiguration_DisableLogType = null; if (cmdletContext.CloudwatchLogsExportConfiguration_DisableLogType != null) { requestCloudwatchLogsExportConfiguration_cloudwatchLogsExportConfiguration_DisableLogType = cmdletContext.CloudwatchLogsExportConfiguration_DisableLogType; } if (requestCloudwatchLogsExportConfiguration_cloudwatchLogsExportConfiguration_DisableLogType != null) { request.CloudwatchLogsExportConfiguration.DisableLogTypes = requestCloudwatchLogsExportConfiguration_cloudwatchLogsExportConfiguration_DisableLogType; requestCloudwatchLogsExportConfigurationIsNull = false; } List requestCloudwatchLogsExportConfiguration_cloudwatchLogsExportConfiguration_EnableLogType = null; if (cmdletContext.CloudwatchLogsExportConfiguration_EnableLogType != null) { requestCloudwatchLogsExportConfiguration_cloudwatchLogsExportConfiguration_EnableLogType = cmdletContext.CloudwatchLogsExportConfiguration_EnableLogType; } if (requestCloudwatchLogsExportConfiguration_cloudwatchLogsExportConfiguration_EnableLogType != null) { request.CloudwatchLogsExportConfiguration.EnableLogTypes = requestCloudwatchLogsExportConfiguration_cloudwatchLogsExportConfiguration_EnableLogType; requestCloudwatchLogsExportConfigurationIsNull = false; } // determine if request.CloudwatchLogsExportConfiguration should be set to null if (requestCloudwatchLogsExportConfigurationIsNull) { request.CloudwatchLogsExportConfiguration = null; } if (cmdletContext.CopyTagsToSnapshot != null) { request.CopyTagsToSnapshot = cmdletContext.CopyTagsToSnapshot.Value; } if (cmdletContext.DBClusterIdentifier != null) { request.DBClusterIdentifier = cmdletContext.DBClusterIdentifier; } if (cmdletContext.DBClusterParameterGroupName != null) { request.DBClusterParameterGroupName = cmdletContext.DBClusterParameterGroupName; } if (cmdletContext.DBInstanceParameterGroupName != null) { request.DBInstanceParameterGroupName = cmdletContext.DBInstanceParameterGroupName; } if (cmdletContext.DeletionProtection != null) { request.DeletionProtection = cmdletContext.DeletionProtection.Value; } if (cmdletContext.EnableIAMDatabaseAuthentication != null) { request.EnableIAMDatabaseAuthentication = cmdletContext.EnableIAMDatabaseAuthentication.Value; } if (cmdletContext.EngineVersion != null) { request.EngineVersion = cmdletContext.EngineVersion; } if (cmdletContext.MasterUserPassword != null) { request.MasterUserPassword = cmdletContext.MasterUserPassword; } if (cmdletContext.NewDBClusterIdentifier != null) { request.NewDBClusterIdentifier = cmdletContext.NewDBClusterIdentifier; } if (cmdletContext.OptionGroupName != null) { request.OptionGroupName = cmdletContext.OptionGroupName; } if (cmdletContext.Port != null) { request.Port = cmdletContext.Port.Value; } if (cmdletContext.PreferredBackupWindow != null) { request.PreferredBackupWindow = cmdletContext.PreferredBackupWindow; } if (cmdletContext.PreferredMaintenanceWindow != null) { request.PreferredMaintenanceWindow = cmdletContext.PreferredMaintenanceWindow; } // populate ServerlessV2ScalingConfiguration var requestServerlessV2ScalingConfigurationIsNull = true; request.ServerlessV2ScalingConfiguration = new Amazon.Neptune.Model.ServerlessV2ScalingConfiguration(); System.Double? requestServerlessV2ScalingConfiguration_serverlessV2ScalingConfiguration_MaxCapacity = null; if (cmdletContext.ServerlessV2ScalingConfiguration_MaxCapacity != null) { requestServerlessV2ScalingConfiguration_serverlessV2ScalingConfiguration_MaxCapacity = cmdletContext.ServerlessV2ScalingConfiguration_MaxCapacity.Value; } if (requestServerlessV2ScalingConfiguration_serverlessV2ScalingConfiguration_MaxCapacity != null) { request.ServerlessV2ScalingConfiguration.MaxCapacity = requestServerlessV2ScalingConfiguration_serverlessV2ScalingConfiguration_MaxCapacity.Value; requestServerlessV2ScalingConfigurationIsNull = false; } System.Double? requestServerlessV2ScalingConfiguration_serverlessV2ScalingConfiguration_MinCapacity = null; if (cmdletContext.ServerlessV2ScalingConfiguration_MinCapacity != null) { requestServerlessV2ScalingConfiguration_serverlessV2ScalingConfiguration_MinCapacity = cmdletContext.ServerlessV2ScalingConfiguration_MinCapacity.Value; } if (requestServerlessV2ScalingConfiguration_serverlessV2ScalingConfiguration_MinCapacity != null) { request.ServerlessV2ScalingConfiguration.MinCapacity = requestServerlessV2ScalingConfiguration_serverlessV2ScalingConfiguration_MinCapacity.Value; requestServerlessV2ScalingConfigurationIsNull = false; } // determine if request.ServerlessV2ScalingConfiguration should be set to null if (requestServerlessV2ScalingConfigurationIsNull) { request.ServerlessV2ScalingConfiguration = null; } 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.Neptune.Model.ModifyDBClusterResponse CallAWSServiceOperation(IAmazonNeptune client, Amazon.Neptune.Model.ModifyDBClusterRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Neptune", "ModifyDBCluster"); try { #if DESKTOP return client.ModifyDBCluster(request); #elif CORECLR return client.ModifyDBClusterAsync(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.Boolean? AllowMajorVersionUpgrade { get; set; } public System.Boolean? ApplyImmediately { get; set; } public System.Int32? BackupRetentionPeriod { get; set; } public List CloudwatchLogsExportConfiguration_DisableLogType { get; set; } public List CloudwatchLogsExportConfiguration_EnableLogType { get; set; } public System.Boolean? CopyTagsToSnapshot { get; set; } public System.String DBClusterIdentifier { get; set; } public System.String DBClusterParameterGroupName { get; set; } public System.String DBInstanceParameterGroupName { get; set; } public System.Boolean? DeletionProtection { get; set; } public System.Boolean? EnableIAMDatabaseAuthentication { get; set; } public System.String EngineVersion { get; set; } public System.String MasterUserPassword { get; set; } public System.String NewDBClusterIdentifier { get; set; } public System.String OptionGroupName { get; set; } public System.Int32? Port { get; set; } public System.String PreferredBackupWindow { get; set; } public System.String PreferredMaintenanceWindow { get; set; } public System.Double? ServerlessV2ScalingConfiguration_MaxCapacity { get; set; } public System.Double? ServerlessV2ScalingConfiguration_MinCapacity { get; set; } public List VpcSecurityGroupId { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response.DBCluster; } } }