/******************************************************************************* * 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.OpenSearchService; using Amazon.OpenSearchService.Model; namespace Amazon.PowerShell.Cmdlets.OS { /// /// Reschedules a planned domain configuration change for a later time. This change can /// be a scheduled service /// software update or a blue/green /// Auto-Tune enhancement. /// [Cmdlet("Update", "OSScheduledAction", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("Amazon.OpenSearchService.Model.ScheduledAction")] [AWSCmdlet("Calls the Amazon OpenSearch Service UpdateScheduledAction API operation.", Operation = new[] {"UpdateScheduledAction"}, SelectReturnType = typeof(Amazon.OpenSearchService.Model.UpdateScheduledActionResponse))] [AWSCmdletOutput("Amazon.OpenSearchService.Model.ScheduledAction or Amazon.OpenSearchService.Model.UpdateScheduledActionResponse", "This cmdlet returns an Amazon.OpenSearchService.Model.ScheduledAction object.", "The service call response (type Amazon.OpenSearchService.Model.UpdateScheduledActionResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class UpdateOSScheduledActionCmdlet : AmazonOpenSearchServiceClientCmdlet, IExecutor { #region Parameter ActionID /// /// /// The unique identifier of the action to reschedule. To retrieve this ID, send a ListScheduledActions /// request. /// /// #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 ActionID { get; set; } #endregion #region Parameter ActionType /// /// /// The type of action to reschedule. Can be one of SERVICE_SOFTWARE_UPDATE, /// JVM_HEAP_SIZE_TUNING, or JVM_YOUNG_GEN_TUNING. To retrieve /// this value, send a ListScheduledActions /// request. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] [AWSConstantClassSource("Amazon.OpenSearchService.ActionType")] public Amazon.OpenSearchService.ActionType ActionType { get; set; } #endregion #region Parameter DesiredStartTime /// /// /// The time to implement the change, in Coordinated Universal Time (UTC). Only specify /// this parameter if you set ScheduleAt to TIMESTAMP. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int64? DesiredStartTime { get; set; } #endregion #region Parameter DomainName /// /// /// The name of the domain to reschedule an action for. /// /// #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 DomainName { get; set; } #endregion #region Parameter ScheduleAt /// /// /// When to schedule the action. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] [AWSConstantClassSource("Amazon.OpenSearchService.ScheduleAt")] public Amazon.OpenSearchService.ScheduleAt ScheduleAt { get; set; } #endregion #region Parameter Select /// /// Use the -Select parameter to control the cmdlet output. The default value is 'ScheduledAction'. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.OpenSearchService.Model.UpdateScheduledActionResponse). /// Specifying the name of a property of type Amazon.OpenSearchService.Model.UpdateScheduledActionResponse 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; } = "ScheduledAction"; #endregion #region Parameter PassThru /// /// Changes the cmdlet behavior to return the value passed to the DomainName parameter. /// The -PassThru parameter is deprecated, use -Select '^DomainName' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^DomainName' 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.DomainName), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-OSScheduledAction (UpdateScheduledAction)")) { 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.DomainName; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.ActionID = this.ActionID; #if MODULAR if (this.ActionID == null && ParameterWasBound(nameof(this.ActionID))) { WriteWarning("You are passing $null as a value for parameter ActionID 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.ActionType = this.ActionType; #if MODULAR if (this.ActionType == null && ParameterWasBound(nameof(this.ActionType))) { WriteWarning("You are passing $null as a value for parameter ActionType 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.DesiredStartTime = this.DesiredStartTime; context.DomainName = this.DomainName; #if MODULAR if (this.DomainName == null && ParameterWasBound(nameof(this.DomainName))) { WriteWarning("You are passing $null as a value for parameter DomainName 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.ScheduleAt = this.ScheduleAt; #if MODULAR if (this.ScheduleAt == null && ParameterWasBound(nameof(this.ScheduleAt))) { WriteWarning("You are passing $null as a value for parameter ScheduleAt which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif // allow further manipulation of loaded context prior to processing PostExecutionContextLoad(context); var output = Execute(context) as CmdletOutput; ProcessOutput(output); } #region IExecutor Members public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.OpenSearchService.Model.UpdateScheduledActionRequest(); if (cmdletContext.ActionID != null) { request.ActionID = cmdletContext.ActionID; } if (cmdletContext.ActionType != null) { request.ActionType = cmdletContext.ActionType; } if (cmdletContext.DesiredStartTime != null) { request.DesiredStartTime = cmdletContext.DesiredStartTime.Value; } if (cmdletContext.DomainName != null) { request.DomainName = cmdletContext.DomainName; } if (cmdletContext.ScheduleAt != null) { request.ScheduleAt = cmdletContext.ScheduleAt; } 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.OpenSearchService.Model.UpdateScheduledActionResponse CallAWSServiceOperation(IAmazonOpenSearchService client, Amazon.OpenSearchService.Model.UpdateScheduledActionRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon OpenSearch Service", "UpdateScheduledAction"); try { #if DESKTOP return client.UpdateScheduledAction(request); #elif CORECLR return client.UpdateScheduledActionAsync(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 ActionID { get; set; } public Amazon.OpenSearchService.ActionType ActionType { get; set; } public System.Int64? DesiredStartTime { get; set; } public System.String DomainName { get; set; } public Amazon.OpenSearchService.ScheduleAt ScheduleAt { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response.ScheduledAction; } } }