/******************************************************************************* * 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.ElastiCache; using Amazon.ElastiCache.Model; namespace Amazon.PowerShell.Cmdlets.EC { /// /// Modifies the settings for a cluster. You can use this operation to change one or more /// cluster configuration parameters by specifying the parameters and the new values. /// [Cmdlet("Edit", "ECCacheCluster", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("Amazon.ElastiCache.Model.CacheCluster")] [AWSCmdlet("Calls the Amazon ElastiCache ModifyCacheCluster API operation.", Operation = new[] {"ModifyCacheCluster"}, SelectReturnType = typeof(Amazon.ElastiCache.Model.ModifyCacheClusterResponse))] [AWSCmdletOutput("Amazon.ElastiCache.Model.CacheCluster or Amazon.ElastiCache.Model.ModifyCacheClusterResponse", "This cmdlet returns an Amazon.ElastiCache.Model.CacheCluster object.", "The service call response (type Amazon.ElastiCache.Model.ModifyCacheClusterResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class EditECCacheClusterCmdlet : AmazonElastiCacheClientCmdlet, IExecutor { #region Parameter ApplyImmediately /// /// /// If true, this parameter causes the modifications in this request and /// any pending modifications to be applied, asynchronously and as soon as possible, regardless /// of the PreferredMaintenanceWindow setting for the cluster.If false, changes to the cluster are applied on the next maintenance /// reboot, or the next failure reboot, whichever occurs first.If you perform a ModifyCacheCluster before a pending modification is /// applied, the pending modification is replaced by the newer modification.Valid values: true | falseDefault: false /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? ApplyImmediately { get; set; } #endregion #region Parameter AuthToken /// /// /// Reserved parameter. The password used to access a password protected server. This /// parameter must be specified with the auth-token-update parameter. Password /// constraints: For more information, see AUTH password at AUTH. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String AuthToken { get; set; } #endregion #region Parameter AuthTokenUpdateStrategy /// /// /// Specifies the strategy to use to update the AUTH token. This parameter must be specified /// with the auth-token parameter. Possible values: For more information, see Authenticating /// Users with Redis AUTH /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.ElastiCache.AuthTokenUpdateStrategyType")] public Amazon.ElastiCache.AuthTokenUpdateStrategyType AuthTokenUpdateStrategy { get; set; } #endregion #region Parameter AutoMinorVersionUpgrade /// /// ///  If you are running Redis engine version 6.0 or later, set this parameter to yes if /// you want to opt-in to the next auto minor version upgrade campaign. This parameter /// is disabled for previous versions.  /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? AutoMinorVersionUpgrade { get; set; } #endregion #region Parameter AZMode /// /// /// Specifies whether the new nodes in this Memcached cluster are all created in a single /// Availability Zone or created across multiple Availability Zones.Valid values: single-az | cross-az.This option is only supported for Memcached clusters.You cannot specify single-az if the Memcached cluster already has cache /// nodes in different Availability Zones. If cross-az is specified, existing /// Memcached nodes remain in their current Availability Zone.Only newly created nodes are located in different Availability Zones. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.ElastiCache.AZMode")] public Amazon.ElastiCache.AZMode AZMode { get; set; } #endregion #region Parameter CacheClusterId /// /// /// The cluster identifier. This value is stored as a lowercase string. /// /// #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 CacheClusterId { get; set; } #endregion #region Parameter CacheNodeIdsToRemove /// /// /// A list of cache node IDs to be removed. A node ID is a numeric identifier (0001, 0002, /// etc.). This parameter is only valid when NumCacheNodes is less than the /// existing number of cache nodes. The number of cache node IDs supplied in this parameter /// must match the difference between the existing number of cache nodes in the cluster /// or pending cache nodes, whichever is greater, and the value of NumCacheNodes /// in the request.For example: If you have 3 active cache nodes, 7 pending cache nodes, and the number /// of cache nodes in this ModifyCacheCluster call is 5, you must list 2 /// (7 - 5) cache node IDs to remove. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String[] CacheNodeIdsToRemove { get; set; } #endregion #region Parameter CacheNodeType /// /// /// A valid cache node type that you want to scale this cluster up to. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String CacheNodeType { get; set; } #endregion #region Parameter CacheParameterGroupName /// /// /// The name of the cache parameter group to apply to this cluster. This change is asynchronously /// applied as soon as possible for parameters when the ApplyImmediately /// parameter is specified as true for this request. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String CacheParameterGroupName { get; set; } #endregion #region Parameter CacheSecurityGroupName /// /// /// A list of cache security group names to authorize on this cluster. This change is /// asynchronously applied as soon as possible.You can use this parameter only with clusters that are created outside of an Amazon /// Virtual Private Cloud (Amazon VPC).Constraints: Must contain no more than 255 alphanumeric characters. Must not be "Default". /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("CacheSecurityGroupNames")] public System.String[] CacheSecurityGroupName { get; set; } #endregion #region Parameter EngineVersion /// /// /// The upgraded version of the cache engine to be run on the cache nodes.Important: You can upgrade to a newer engine version (see Selecting /// a Cache Engine and Version), but you cannot downgrade to an earlier engine version. /// If you want to use an earlier engine version, you must delete the existing cluster /// and create it anew with the earlier engine version. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String EngineVersion { get; set; } #endregion #region Parameter IpDiscovery /// /// /// The network type you choose when modifying a cluster, either ipv4 | ipv6. /// IPv6 is supported for workloads using Redis engine version 6.2 onward or Memcached /// engine version 1.6.6 on all instances built on the Nitro /// system. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.ElastiCache.IpDiscovery")] public Amazon.ElastiCache.IpDiscovery IpDiscovery { get; set; } #endregion #region Parameter LogDeliveryConfiguration /// /// /// Specifies the destination, format and type of the logs. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("LogDeliveryConfigurations")] public Amazon.ElastiCache.Model.LogDeliveryConfigurationRequest[] LogDeliveryConfiguration { get; set; } #endregion #region Parameter NewAvailabilityZone /// /// /// This option is only supported on Memcached clusters.The list of Availability Zones where the new Memcached cache nodes are created.This parameter is only valid when NumCacheNodes in the request is greater /// than the sum of the number of active cache nodes and the number of cache nodes pending /// creation (which may be zero). The number of Availability Zones supplied in this list /// must match the cache nodes being added in this request.Scenarios:The Availability Zone placement of nodes pending creation cannot be modified. If you /// wish to cancel any nodes pending creation, add 0 nodes by setting NumCacheNodes /// to the number of current nodes.If cross-az is specified, existing Memcached nodes remain in their current /// Availability Zone. Only newly created nodes can be located in different Availability /// Zones. For guidance on how to move existing Memcached nodes to different Availability /// Zones, see the Availability Zone Considerations section of Cache /// Node Considerations for Memcached.Impact of new add/remove requests upon pending requests /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("NewAvailabilityZones")] public System.String[] NewAvailabilityZone { get; set; } #endregion #region Parameter NotificationTopicArn /// /// /// The Amazon Resource Name (ARN) of the Amazon SNS topic to which notifications are /// sent.The Amazon SNS topic owner must be same as the cluster owner. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String NotificationTopicArn { get; set; } #endregion #region Parameter NotificationTopicStatus /// /// /// The status of the Amazon SNS notification topic. Notifications are sent only if the /// status is active.Valid values: active | inactive /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String NotificationTopicStatus { get; set; } #endregion #region Parameter NumCacheNode /// /// /// The number of cache nodes that the cluster should have. If the value for NumCacheNodes /// is greater than the sum of the number of current cache nodes and the number of cache /// nodes pending creation (which may be zero), more nodes are added. If the value is /// less than the number of existing cache nodes, nodes are removed. If the value is equal /// to the number of current cache nodes, any pending add or remove requests are canceled.If you are removing cache nodes, you must use the CacheNodeIdsToRemove /// parameter to provide the IDs of the specific cache nodes to remove.For clusters running Redis, this value must be 1. For clusters running Memcached, /// this value must be between 1 and 40.Adding or removing Memcached cache nodes can be applied immediately or as a pending /// operation (see ApplyImmediately).A pending operation to modify the number of cache nodes in a cluster during its maintenance /// window, whether by adding or removing nodes in accordance with the scale out architecture, /// is not queued. The customer's latest request to add or remove nodes to the cluster /// overrides any previous pending operations to modify the number of cache nodes in the /// cluster. For example, a request to remove 2 nodes would override a previous pending /// operation to remove 3 nodes. Similarly, a request to add 2 nodes would override a /// previous pending operation to remove 3 nodes and vice versa. As Memcached cache nodes /// may now be provisioned in different Availability Zones with flexible cache node placement, /// a request to add nodes does not automatically override a previous pending operation /// to add nodes. The customer can modify the previous pending operation to add more nodes /// or explicitly cancel the pending request and retry the new request. To cancel pending /// operations to modify the number of cache nodes in a cluster, use the ModifyCacheCluster /// request and set NumCacheNodes equal to the number of cache nodes currently /// in the cluster. /// /// [System.Management.Automation.Parameter(Position = 1, ValueFromPipelineByPropertyName = true)] [Alias("NumCacheNodes")] public System.Int32? NumCacheNode { get; set; } #endregion #region Parameter PreferredMaintenanceWindow /// /// /// Specifies the weekly time range during which maintenance on the cluster is performed. /// It is specified as a range in the format ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC). /// The minimum maintenance window is a 60 minute period.Valid values for ddd are:Example: sun:23:00-mon:01:30 /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String PreferredMaintenanceWindow { get; set; } #endregion #region Parameter SecurityGroupId /// /// /// Specifies the VPC Security Groups associated with the cluster.This parameter can be used only with clusters that are created in an Amazon Virtual /// Private Cloud (Amazon VPC). /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("SecurityGroupIds")] public System.String[] SecurityGroupId { get; set; } #endregion #region Parameter SnapshotRetentionLimit /// /// /// The number of days for which ElastiCache retains automatic cluster snapshots before /// deleting them. For example, if you set SnapshotRetentionLimit to 5, a /// snapshot that was taken today is retained for 5 days before being deleted.If the value of SnapshotRetentionLimit is set to zero (0), backups are /// turned off. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? SnapshotRetentionLimit { get; set; } #endregion #region Parameter SnapshotWindow /// /// /// The daily time range (in UTC) during which ElastiCache begins taking a daily snapshot /// of your cluster. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String SnapshotWindow { get; set; } #endregion #region Parameter Select /// /// Use the -Select parameter to control the cmdlet output. The default value is 'CacheCluster'. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.ElastiCache.Model.ModifyCacheClusterResponse). /// Specifying the name of a property of type Amazon.ElastiCache.Model.ModifyCacheClusterResponse 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; } = "CacheCluster"; #endregion #region Parameter PassThru /// /// Changes the cmdlet behavior to return the value passed to the CacheClusterId parameter. /// The -PassThru parameter is deprecated, use -Select '^CacheClusterId' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^CacheClusterId' 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.CacheClusterId), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Edit-ECCacheCluster (ModifyCacheCluster)")) { 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.CacheClusterId; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.ApplyImmediately = this.ApplyImmediately; context.AuthToken = this.AuthToken; context.AuthTokenUpdateStrategy = this.AuthTokenUpdateStrategy; context.AutoMinorVersionUpgrade = this.AutoMinorVersionUpgrade; context.AZMode = this.AZMode; context.CacheClusterId = this.CacheClusterId; #if MODULAR if (this.CacheClusterId == null && ParameterWasBound(nameof(this.CacheClusterId))) { WriteWarning("You are passing $null as a value for parameter CacheClusterId 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.CacheNodeIdsToRemove != null) { context.CacheNodeIdsToRemove = new List(this.CacheNodeIdsToRemove); } context.CacheNodeType = this.CacheNodeType; context.CacheParameterGroupName = this.CacheParameterGroupName; if (this.CacheSecurityGroupName != null) { context.CacheSecurityGroupName = new List(this.CacheSecurityGroupName); } context.EngineVersion = this.EngineVersion; context.IpDiscovery = this.IpDiscovery; if (this.LogDeliveryConfiguration != null) { context.LogDeliveryConfiguration = new List(this.LogDeliveryConfiguration); } if (this.NewAvailabilityZone != null) { context.NewAvailabilityZone = new List(this.NewAvailabilityZone); } context.NotificationTopicArn = this.NotificationTopicArn; context.NotificationTopicStatus = this.NotificationTopicStatus; context.NumCacheNode = this.NumCacheNode; context.PreferredMaintenanceWindow = this.PreferredMaintenanceWindow; if (this.SecurityGroupId != null) { context.SecurityGroupId = new List(this.SecurityGroupId); } context.SnapshotRetentionLimit = this.SnapshotRetentionLimit; context.SnapshotWindow = this.SnapshotWindow; // 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.ElastiCache.Model.ModifyCacheClusterRequest(); if (cmdletContext.ApplyImmediately != null) { request.ApplyImmediately = cmdletContext.ApplyImmediately.Value; } if (cmdletContext.AuthToken != null) { request.AuthToken = cmdletContext.AuthToken; } if (cmdletContext.AuthTokenUpdateStrategy != null) { request.AuthTokenUpdateStrategy = cmdletContext.AuthTokenUpdateStrategy; } if (cmdletContext.AutoMinorVersionUpgrade != null) { request.AutoMinorVersionUpgrade = cmdletContext.AutoMinorVersionUpgrade.Value; } if (cmdletContext.AZMode != null) { request.AZMode = cmdletContext.AZMode; } if (cmdletContext.CacheClusterId != null) { request.CacheClusterId = cmdletContext.CacheClusterId; } if (cmdletContext.CacheNodeIdsToRemove != null) { request.CacheNodeIdsToRemove = cmdletContext.CacheNodeIdsToRemove; } if (cmdletContext.CacheNodeType != null) { request.CacheNodeType = cmdletContext.CacheNodeType; } if (cmdletContext.CacheParameterGroupName != null) { request.CacheParameterGroupName = cmdletContext.CacheParameterGroupName; } if (cmdletContext.CacheSecurityGroupName != null) { request.CacheSecurityGroupNames = cmdletContext.CacheSecurityGroupName; } if (cmdletContext.EngineVersion != null) { request.EngineVersion = cmdletContext.EngineVersion; } if (cmdletContext.IpDiscovery != null) { request.IpDiscovery = cmdletContext.IpDiscovery; } if (cmdletContext.LogDeliveryConfiguration != null) { request.LogDeliveryConfigurations = cmdletContext.LogDeliveryConfiguration; } if (cmdletContext.NewAvailabilityZone != null) { request.NewAvailabilityZones = cmdletContext.NewAvailabilityZone; } if (cmdletContext.NotificationTopicArn != null) { request.NotificationTopicArn = cmdletContext.NotificationTopicArn; } if (cmdletContext.NotificationTopicStatus != null) { request.NotificationTopicStatus = cmdletContext.NotificationTopicStatus; } if (cmdletContext.NumCacheNode != null) { request.NumCacheNodes = cmdletContext.NumCacheNode.Value; } if (cmdletContext.PreferredMaintenanceWindow != null) { request.PreferredMaintenanceWindow = cmdletContext.PreferredMaintenanceWindow; } if (cmdletContext.SecurityGroupId != null) { request.SecurityGroupIds = cmdletContext.SecurityGroupId; } if (cmdletContext.SnapshotRetentionLimit != null) { request.SnapshotRetentionLimit = cmdletContext.SnapshotRetentionLimit.Value; } if (cmdletContext.SnapshotWindow != null) { request.SnapshotWindow = cmdletContext.SnapshotWindow; } 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.ElastiCache.Model.ModifyCacheClusterResponse CallAWSServiceOperation(IAmazonElastiCache client, Amazon.ElastiCache.Model.ModifyCacheClusterRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon ElastiCache", "ModifyCacheCluster"); try { #if DESKTOP return client.ModifyCacheCluster(request); #elif CORECLR return client.ModifyCacheClusterAsync(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? ApplyImmediately { get; set; } public System.String AuthToken { get; set; } public Amazon.ElastiCache.AuthTokenUpdateStrategyType AuthTokenUpdateStrategy { get; set; } public System.Boolean? AutoMinorVersionUpgrade { get; set; } public Amazon.ElastiCache.AZMode AZMode { get; set; } public System.String CacheClusterId { get; set; } public List CacheNodeIdsToRemove { get; set; } public System.String CacheNodeType { get; set; } public System.String CacheParameterGroupName { get; set; } public List CacheSecurityGroupName { get; set; } public System.String EngineVersion { get; set; } public Amazon.ElastiCache.IpDiscovery IpDiscovery { get; set; } public List LogDeliveryConfiguration { get; set; } public List NewAvailabilityZone { get; set; } public System.String NotificationTopicArn { get; set; } public System.String NotificationTopicStatus { get; set; } public System.Int32? NumCacheNode { get; set; } public System.String PreferredMaintenanceWindow { get; set; } public List SecurityGroupId { get; set; } public System.Int32? SnapshotRetentionLimit { get; set; } public System.String SnapshotWindow { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response.CacheCluster; } } }