/*******************************************************************************
* 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.AppStream;
using Amazon.AppStream.Model;
namespace Amazon.PowerShell.Cmdlets.APS
{
///
/// Updates the specified fields for the specified stack.
///
[Cmdlet("Update", "APSStack", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.AppStream.Model.Stack")]
[AWSCmdlet("Calls the Amazon AppStream UpdateStack API operation.", Operation = new[] {"UpdateStack"}, SelectReturnType = typeof(Amazon.AppStream.Model.UpdateStackResponse))]
[AWSCmdletOutput("Amazon.AppStream.Model.Stack or Amazon.AppStream.Model.UpdateStackResponse",
"This cmdlet returns an Amazon.AppStream.Model.Stack object.",
"The service call response (type Amazon.AppStream.Model.UpdateStackResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class UpdateAPSStackCmdlet : AmazonAppStreamClientCmdlet, IExecutor
{
#region Parameter AccessEndpoint
///
///
/// The list of interface VPC endpoint (interface endpoint) objects. Users of the stack
/// can connect to AppStream 2.0 only through the specified endpoints.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("AccessEndpoints")]
public Amazon.AppStream.Model.AccessEndpoint[] AccessEndpoint { get; set; }
#endregion
#region Parameter AttributesToDelete
///
///
/// The stack attributes to delete.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String[] AttributesToDelete { get; set; }
#endregion
#region Parameter Description
///
///
/// The description to display.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Description { get; set; }
#endregion
#region Parameter DisplayName
///
///
/// The stack name to display.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String DisplayName { get; set; }
#endregion
#region Parameter EmbedHostDomain
///
///
/// The domains where AppStream 2.0 streaming sessions can be embedded in an iframe. You
/// must approve the domains that you want to host embedded AppStream 2.0 streaming sessions.
///
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("EmbedHostDomains")]
public System.String[] EmbedHostDomain { get; set; }
#endregion
#region Parameter ApplicationSettings_Enabled
///
///
/// Enables or disables persistent application settings for users during their streaming
/// sessions.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? ApplicationSettings_Enabled { get; set; }
#endregion
#region Parameter FeedbackURL
///
///
/// The URL that users are redirected to after they choose the Send Feedback link. If
/// no URL is specified, no Send Feedback link is displayed.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String FeedbackURL { get; set; }
#endregion
#region Parameter Name
///
///
/// The name of the stack.
///
///
#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 Name { get; set; }
#endregion
#region Parameter StreamingExperienceSettings_PreferredProtocol
///
///
/// The preferred protocol that you want to use while streaming your application.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[AWSConstantClassSource("Amazon.AppStream.PreferredProtocol")]
public Amazon.AppStream.PreferredProtocol StreamingExperienceSettings_PreferredProtocol { get; set; }
#endregion
#region Parameter RedirectURL
///
///
/// The URL that users are redirected to after their streaming session ends.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String RedirectURL { get; set; }
#endregion
#region Parameter ApplicationSettings_SettingsGroup
///
///
/// The path prefix for the S3 bucket where users’ persistent application settings are
/// stored. You can allow the same persistent application settings to be used across multiple
/// stacks by specifying the same settings group for each stack.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ApplicationSettings_SettingsGroup { get; set; }
#endregion
#region Parameter StorageConnector
///
///
/// The storage connectors to enable.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("StorageConnectors")]
public Amazon.AppStream.Model.StorageConnector[] StorageConnector { get; set; }
#endregion
#region Parameter UserSetting
///
///
/// The actions that are enabled or disabled for users during their streaming sessions.
/// By default, these actions are enabled.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("UserSettings")]
public Amazon.AppStream.Model.UserSetting[] UserSetting { get; set; }
#endregion
#region Parameter DeleteStorageConnector
///
///
/// Deletes the storage connectors currently enabled for the stack.
///
/// This parameter is deprecated.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[System.ObsoleteAttribute("This property is deprecated")]
[Alias("DeleteStorageConnectors")]
public System.Boolean? DeleteStorageConnector { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is 'Stack'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.AppStream.Model.UpdateStackResponse).
/// Specifying the name of a property of type Amazon.AppStream.Model.UpdateStackResponse 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; } = "Stack";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the Name parameter.
/// The -PassThru parameter is deprecated, use -Select '^Name' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^Name' 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.Name), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-APSStack (UpdateStack)"))
{
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.Name;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
if (this.AccessEndpoint != null)
{
context.AccessEndpoint = new List(this.AccessEndpoint);
}
context.ApplicationSettings_Enabled = this.ApplicationSettings_Enabled;
context.ApplicationSettings_SettingsGroup = this.ApplicationSettings_SettingsGroup;
if (this.AttributesToDelete != null)
{
context.AttributesToDelete = new List(this.AttributesToDelete);
}
#pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.DeleteStorageConnector = this.DeleteStorageConnector;
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.Description = this.Description;
context.DisplayName = this.DisplayName;
if (this.EmbedHostDomain != null)
{
context.EmbedHostDomain = new List(this.EmbedHostDomain);
}
context.FeedbackURL = this.FeedbackURL;
context.Name = this.Name;
#if MODULAR
if (this.Name == null && ParameterWasBound(nameof(this.Name)))
{
WriteWarning("You are passing $null as a value for parameter Name 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.RedirectURL = this.RedirectURL;
if (this.StorageConnector != null)
{
context.StorageConnector = new List(this.StorageConnector);
}
context.StreamingExperienceSettings_PreferredProtocol = this.StreamingExperienceSettings_PreferredProtocol;
if (this.UserSetting != null)
{
context.UserSetting = new List(this.UserSetting);
}
// 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.AppStream.Model.UpdateStackRequest();
if (cmdletContext.AccessEndpoint != null)
{
request.AccessEndpoints = cmdletContext.AccessEndpoint;
}
// populate ApplicationSettings
var requestApplicationSettingsIsNull = true;
request.ApplicationSettings = new Amazon.AppStream.Model.ApplicationSettings();
System.Boolean? requestApplicationSettings_applicationSettings_Enabled = null;
if (cmdletContext.ApplicationSettings_Enabled != null)
{
requestApplicationSettings_applicationSettings_Enabled = cmdletContext.ApplicationSettings_Enabled.Value;
}
if (requestApplicationSettings_applicationSettings_Enabled != null)
{
request.ApplicationSettings.Enabled = requestApplicationSettings_applicationSettings_Enabled.Value;
requestApplicationSettingsIsNull = false;
}
System.String requestApplicationSettings_applicationSettings_SettingsGroup = null;
if (cmdletContext.ApplicationSettings_SettingsGroup != null)
{
requestApplicationSettings_applicationSettings_SettingsGroup = cmdletContext.ApplicationSettings_SettingsGroup;
}
if (requestApplicationSettings_applicationSettings_SettingsGroup != null)
{
request.ApplicationSettings.SettingsGroup = requestApplicationSettings_applicationSettings_SettingsGroup;
requestApplicationSettingsIsNull = false;
}
// determine if request.ApplicationSettings should be set to null
if (requestApplicationSettingsIsNull)
{
request.ApplicationSettings = null;
}
if (cmdletContext.AttributesToDelete != null)
{
request.AttributesToDelete = cmdletContext.AttributesToDelete;
}
#pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
if (cmdletContext.DeleteStorageConnector != null)
{
request.DeleteStorageConnectors = cmdletContext.DeleteStorageConnector.Value;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
if (cmdletContext.Description != null)
{
request.Description = cmdletContext.Description;
}
if (cmdletContext.DisplayName != null)
{
request.DisplayName = cmdletContext.DisplayName;
}
if (cmdletContext.EmbedHostDomain != null)
{
request.EmbedHostDomains = cmdletContext.EmbedHostDomain;
}
if (cmdletContext.FeedbackURL != null)
{
request.FeedbackURL = cmdletContext.FeedbackURL;
}
if (cmdletContext.Name != null)
{
request.Name = cmdletContext.Name;
}
if (cmdletContext.RedirectURL != null)
{
request.RedirectURL = cmdletContext.RedirectURL;
}
if (cmdletContext.StorageConnector != null)
{
request.StorageConnectors = cmdletContext.StorageConnector;
}
// populate StreamingExperienceSettings
var requestStreamingExperienceSettingsIsNull = true;
request.StreamingExperienceSettings = new Amazon.AppStream.Model.StreamingExperienceSettings();
Amazon.AppStream.PreferredProtocol requestStreamingExperienceSettings_streamingExperienceSettings_PreferredProtocol = null;
if (cmdletContext.StreamingExperienceSettings_PreferredProtocol != null)
{
requestStreamingExperienceSettings_streamingExperienceSettings_PreferredProtocol = cmdletContext.StreamingExperienceSettings_PreferredProtocol;
}
if (requestStreamingExperienceSettings_streamingExperienceSettings_PreferredProtocol != null)
{
request.StreamingExperienceSettings.PreferredProtocol = requestStreamingExperienceSettings_streamingExperienceSettings_PreferredProtocol;
requestStreamingExperienceSettingsIsNull = false;
}
// determine if request.StreamingExperienceSettings should be set to null
if (requestStreamingExperienceSettingsIsNull)
{
request.StreamingExperienceSettings = null;
}
if (cmdletContext.UserSetting != null)
{
request.UserSettings = cmdletContext.UserSetting;
}
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.AppStream.Model.UpdateStackResponse CallAWSServiceOperation(IAmazonAppStream client, Amazon.AppStream.Model.UpdateStackRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon AppStream", "UpdateStack");
try
{
#if DESKTOP
return client.UpdateStack(request);
#elif CORECLR
return client.UpdateStackAsync(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 List AccessEndpoint { get; set; }
public System.Boolean? ApplicationSettings_Enabled { get; set; }
public System.String ApplicationSettings_SettingsGroup { get; set; }
public List AttributesToDelete { get; set; }
[System.ObsoleteAttribute]
public System.Boolean? DeleteStorageConnector { get; set; }
public System.String Description { get; set; }
public System.String DisplayName { get; set; }
public List EmbedHostDomain { get; set; }
public System.String FeedbackURL { get; set; }
public System.String Name { get; set; }
public System.String RedirectURL { get; set; }
public List StorageConnector { get; set; }
public Amazon.AppStream.PreferredProtocol StreamingExperienceSettings_PreferredProtocol { get; set; }
public List UserSetting { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response.Stack;
}
}
}