/*******************************************************************************
* 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.OpsWorks;
using Amazon.OpsWorks.Model;
namespace Amazon.PowerShell.Cmdlets.OPS
{
///
/// Updates a specified stack.
///
///
/// Required Permissions: To use this action, an IAM user must have a Manage permissions
/// level for the stack, or an attached policy that explicitly grants permissions. For
/// more information on user permissions, see Managing
/// User Permissions.
///
///
[Cmdlet("Update", "OPSStack", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("None")]
[AWSCmdlet("Calls the AWS OpsWorks UpdateStack API operation.", Operation = new[] {"UpdateStack"}, SelectReturnType = typeof(Amazon.OpsWorks.Model.UpdateStackResponse))]
[AWSCmdletOutput("None or Amazon.OpsWorks.Model.UpdateStackResponse",
"This cmdlet does not generate any output." +
"The service response (type Amazon.OpsWorks.Model.UpdateStackResponse) can be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class UpdateOPSStackCmdlet : AmazonOpsWorksClientCmdlet, IExecutor
{
#region Parameter AgentVersion
///
///
/// The default AWS OpsWorks Stacks agent version. You have the following options:- Auto-update - Set this parameter to
LATEST
. AWS OpsWorks Stacks automatically
/// installs new agent versions on the stack's instances as soon as they are available. - Fixed version - Set this parameter to your preferred agent version. To update the
/// agent version, you must edit the stack configuration and specify a new version. AWS
/// OpsWorks Stacks then automatically installs that version on the stack's instances.
The default setting is LATEST
. To specify an agent version, you must
/// use the complete version number, not the abbreviated number shown on the console.
/// For a list of available agent version numbers, call DescribeAgentVersions.
/// AgentVersion cannot be set to Chef 12.2.You can also specify an agent version when you create or update an instance, which
/// overrides the stack's default setting.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String AgentVersion { get; set; }
#endregion
#region Parameter Attribute
///
///
/// One or more user-defined key-value pairs to be added to the stack attributes.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Attributes")]
public System.Collections.Hashtable Attribute { get; set; }
#endregion
#region Parameter ChefConfiguration_BerkshelfVersion
///
///
/// The Berkshelf version.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ChefConfiguration_BerkshelfVersion { get; set; }
#endregion
#region Parameter CustomJson
///
///
/// A string that contains user-defined, custom JSON. It can be used to override the corresponding
/// default stack configuration JSON values or to pass data to recipes. The string should
/// be in the following format:"{\"key1\": \"value1\", \"key2\": \"value2\",...}"
For more information about custom JSON, see Use
/// Custom JSON to Modify the Stack Configuration Attributes.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String CustomJson { get; set; }
#endregion
#region Parameter DefaultAvailabilityZone
///
///
/// The stack's default Availability Zone, which must be in the stack's region. For more
/// information, see Regions
/// and Endpoints. If you also specify a value for DefaultSubnetId
, the
/// subnet must be in the same zone. For more information, see CreateStack.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String DefaultAvailabilityZone { get; set; }
#endregion
#region Parameter DefaultInstanceProfileArn
///
///
/// The ARN of an IAM profile that is the default profile for all of the stack's EC2 instances.
/// For more information about IAM ARNs, see Using
/// Identifiers.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String DefaultInstanceProfileArn { get; set; }
#endregion
#region Parameter DefaultOs
///
///
/// The stack's operating system, which must be set to one of the following:- A supported Linux operating system: An Amazon Linux version, such as
Amazon
/// Linux 2018.03
, Amazon Linux 2017.09
, Amazon Linux 2017.03
,
/// Amazon Linux 2016.09
, Amazon Linux 2016.03
, Amazon
/// Linux 2015.09
, or Amazon Linux 2015.03
. - A supported Ubuntu operating system, such as
Ubuntu 16.04 LTS
, Ubuntu
/// 14.04 LTS
, or Ubuntu 12.04 LTS
. CentOS Linux 7
Red Hat Enterprise Linux 7
- A supported Windows operating system, such as
Microsoft Windows Server 2012
/// R2 Base
, Microsoft Windows Server 2012 R2 with SQL Server Express
,
/// Microsoft Windows Server 2012 R2 with SQL Server Standard
, or Microsoft
/// Windows Server 2012 R2 with SQL Server Web
. - A custom AMI:
Custom
. You specify the custom AMI you want to use when
/// you create instances. For more information about how to use custom AMIs with OpsWorks,
/// see Using
/// Custom AMIs.
The default option is the stack's current operating system. For more information about
/// supported operating systems, see AWS
/// OpsWorks Stacks Operating Systems.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String DefaultOs { get; set; }
#endregion
#region Parameter DefaultRootDeviceType
///
///
/// The default root device type. This value is used by default for all instances in the
/// stack, but you can override it when you create an instance. For more information,
/// see Storage
/// for the Root Device.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[AWSConstantClassSource("Amazon.OpsWorks.RootDeviceType")]
public Amazon.OpsWorks.RootDeviceType DefaultRootDeviceType { get; set; }
#endregion
#region Parameter DefaultSshKeyName
///
///
/// A default Amazon EC2 key-pair name. The default value is none
. If you
/// specify a key-pair name, AWS OpsWorks Stacks installs the public key on the instance
/// and you can use the private key with an SSH client to log in to the instance. For
/// more information, see
/// Using SSH to Communicate with an Instance and
/// Managing SSH Access. You can override this setting by specifying a different key
/// pair, or no key pair, when you
/// create an instance.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String DefaultSshKeyName { get; set; }
#endregion
#region Parameter DefaultSubnetId
///
///
/// The stack's default VPC subnet ID. This parameter is required if you specify a value
/// for the VpcId
parameter. All instances are launched into this subnet
/// unless you specify otherwise when you create the instance. If you also specify a value
/// for DefaultAvailabilityZone
, the subnet must be in that zone. For information
/// on default values and when this parameter is required, see the VpcId
/// parameter description.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String DefaultSubnetId { get; set; }
#endregion
#region Parameter HostnameTheme
///
///
/// The stack's new host name theme, with spaces replaced by underscores. The theme is
/// used to generate host names for the stack's instances. By default, HostnameTheme
/// is set to Layer_Dependent
, which creates host names by appending integers
/// to the layer's short name. The other themes are:Baked_Goods
Clouds
Europe_Cities
Fruits
Greek_Deities_and_Titans
Legendary_creatures_from_Japan
Planets_and_Moons
Roman_Deities
Scottish_Islands
US_Cities
Wild_Cats
To obtain a generated host name, call GetHostNameSuggestion
, which returns
/// a host name based on the current theme.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String HostnameTheme { get; set; }
#endregion
#region Parameter ChefConfiguration_ManageBerkshelf
///
///
/// Whether to enable Berkshelf.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? ChefConfiguration_ManageBerkshelf { get; set; }
#endregion
#region Parameter ConfigurationManager_Name
///
///
/// The name. This parameter must be set to "Chef".
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ConfigurationManager_Name { get; set; }
#endregion
#region Parameter Name
///
///
/// The stack's new name.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Name { get; set; }
#endregion
#region Parameter CustomCookbooksSource_Password
///
///
/// When included in a request, the parameter depends on the repository type.- For Amazon S3 bundles, set
Password
to the appropriate IAM secret access
/// key. - For HTTP bundles and Subversion repositories, set
Password
to the password.
For more information on how to safely handle IAM credentials, see https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html.In responses, AWS OpsWorks Stacks returns *****FILTERED*****
instead
/// of the actual value.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String CustomCookbooksSource_Password { get; set; }
#endregion
#region Parameter CustomCookbooksSource_Revision
///
///
/// The application's version. AWS OpsWorks Stacks enables you to easily deploy new versions
/// of an application. One of the simplest approaches is to have branches or revisions
/// in your repository that represent different versions that can potentially be deployed.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String CustomCookbooksSource_Revision { get; set; }
#endregion
#region Parameter ServiceRoleArn
///
///
/// Do not use this parameter. You cannot update a stack's service role.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ServiceRoleArn { get; set; }
#endregion
#region Parameter CustomCookbooksSource_SshKey
///
///
/// In requests, the repository's SSH key.In responses, AWS OpsWorks Stacks returns *****FILTERED*****
instead
/// of the actual value.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String CustomCookbooksSource_SshKey { get; set; }
#endregion
#region Parameter StackId
///
///
/// The stack ID.
///
///
#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 StackId { get; set; }
#endregion
#region Parameter CustomCookbooksSource_Type
///
///
/// The repository type.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[AWSConstantClassSource("Amazon.OpsWorks.SourceType")]
public Amazon.OpsWorks.SourceType CustomCookbooksSource_Type { get; set; }
#endregion
#region Parameter CustomCookbooksSource_Url
///
///
/// The source URL. The following is an example of an Amazon S3 source URL: https://s3.amazonaws.com/opsworks-demo-bucket/opsworks_cookbook_demo.tar.gz
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String CustomCookbooksSource_Url { get; set; }
#endregion
#region Parameter UseCustomCookbook
///
///
/// Whether the stack uses custom cookbooks.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("UseCustomCookbooks")]
public System.Boolean? UseCustomCookbook { get; set; }
#endregion
#region Parameter UseOpsworksSecurityGroup
///
///
/// Whether to associate the AWS OpsWorks Stacks built-in security groups with the stack's
/// layers.AWS OpsWorks Stacks provides a standard set of built-in security groups, one for each
/// layer, which are associated with layers by default. UseOpsworksSecurityGroups
/// allows you to provide your own custom security groups instead of using the built-in
/// groups. UseOpsworksSecurityGroups
has the following settings: - True - AWS OpsWorks Stacks automatically associates the appropriate built-in security
/// group with each layer (default setting). You can associate additional security groups
/// with a layer after you create it, but you cannot delete the built-in security group.
- False - AWS OpsWorks Stacks does not associate built-in security groups with layers.
/// You must create appropriate EC2 security groups and associate a security group with
/// each layer that you create. However, you can still manually associate a built-in security
/// group with a layer on. Custom security groups are required only for those layers that
/// need custom settings.
For more information, see Create
/// a New Stack.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("UseOpsworksSecurityGroups")]
public System.Boolean? UseOpsworksSecurityGroup { get; set; }
#endregion
#region Parameter CustomCookbooksSource_Username
///
///
/// This parameter depends on the repository type.- For Amazon S3 bundles, set
Username
to the appropriate IAM access key
/// ID. - For HTTP bundles, Git repositories, and Subversion repositories, set
Username
/// to the user name.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String CustomCookbooksSource_Username { get; set; }
#endregion
#region Parameter ConfigurationManager_Version
///
///
/// The Chef version. This parameter must be set to 12, 11.10, or 11.4 for Linux stacks,
/// and to 12.2 for Windows stacks. The default value for Linux stacks is 11.4.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ConfigurationManager_Version { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The cmdlet doesn't have a return value by default.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.OpsWorks.Model.UpdateStackResponse).
/// 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; } = "*";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the StackId parameter.
/// The -PassThru parameter is deprecated, use -Select '^StackId' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^StackId' 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.StackId), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-OPSStack (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.StackId;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.AgentVersion = this.AgentVersion;
if (this.Attribute != null)
{
context.Attribute = new Dictionary(StringComparer.Ordinal);
foreach (var hashKey in this.Attribute.Keys)
{
context.Attribute.Add((String)hashKey, (String)(this.Attribute[hashKey]));
}
}
context.ChefConfiguration_BerkshelfVersion = this.ChefConfiguration_BerkshelfVersion;
context.ChefConfiguration_ManageBerkshelf = this.ChefConfiguration_ManageBerkshelf;
context.ConfigurationManager_Name = this.ConfigurationManager_Name;
context.ConfigurationManager_Version = this.ConfigurationManager_Version;
context.CustomCookbooksSource_Password = this.CustomCookbooksSource_Password;
context.CustomCookbooksSource_Revision = this.CustomCookbooksSource_Revision;
context.CustomCookbooksSource_SshKey = this.CustomCookbooksSource_SshKey;
context.CustomCookbooksSource_Type = this.CustomCookbooksSource_Type;
context.CustomCookbooksSource_Url = this.CustomCookbooksSource_Url;
context.CustomCookbooksSource_Username = this.CustomCookbooksSource_Username;
context.CustomJson = this.CustomJson;
context.DefaultAvailabilityZone = this.DefaultAvailabilityZone;
context.DefaultInstanceProfileArn = this.DefaultInstanceProfileArn;
context.DefaultOs = this.DefaultOs;
context.DefaultRootDeviceType = this.DefaultRootDeviceType;
context.DefaultSshKeyName = this.DefaultSshKeyName;
context.DefaultSubnetId = this.DefaultSubnetId;
context.HostnameTheme = this.HostnameTheme;
context.Name = this.Name;
context.ServiceRoleArn = this.ServiceRoleArn;
context.StackId = this.StackId;
#if MODULAR
if (this.StackId == null && ParameterWasBound(nameof(this.StackId)))
{
WriteWarning("You are passing $null as a value for parameter StackId 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.UseCustomCookbook = this.UseCustomCookbook;
context.UseOpsworksSecurityGroup = this.UseOpsworksSecurityGroup;
// 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.OpsWorks.Model.UpdateStackRequest();
if (cmdletContext.AgentVersion != null)
{
request.AgentVersion = cmdletContext.AgentVersion;
}
if (cmdletContext.Attribute != null)
{
request.Attributes = cmdletContext.Attribute;
}
// populate ChefConfiguration
var requestChefConfigurationIsNull = true;
request.ChefConfiguration = new Amazon.OpsWorks.Model.ChefConfiguration();
System.String requestChefConfiguration_chefConfiguration_BerkshelfVersion = null;
if (cmdletContext.ChefConfiguration_BerkshelfVersion != null)
{
requestChefConfiguration_chefConfiguration_BerkshelfVersion = cmdletContext.ChefConfiguration_BerkshelfVersion;
}
if (requestChefConfiguration_chefConfiguration_BerkshelfVersion != null)
{
request.ChefConfiguration.BerkshelfVersion = requestChefConfiguration_chefConfiguration_BerkshelfVersion;
requestChefConfigurationIsNull = false;
}
System.Boolean? requestChefConfiguration_chefConfiguration_ManageBerkshelf = null;
if (cmdletContext.ChefConfiguration_ManageBerkshelf != null)
{
requestChefConfiguration_chefConfiguration_ManageBerkshelf = cmdletContext.ChefConfiguration_ManageBerkshelf.Value;
}
if (requestChefConfiguration_chefConfiguration_ManageBerkshelf != null)
{
request.ChefConfiguration.ManageBerkshelf = requestChefConfiguration_chefConfiguration_ManageBerkshelf.Value;
requestChefConfigurationIsNull = false;
}
// determine if request.ChefConfiguration should be set to null
if (requestChefConfigurationIsNull)
{
request.ChefConfiguration = null;
}
// populate ConfigurationManager
var requestConfigurationManagerIsNull = true;
request.ConfigurationManager = new Amazon.OpsWorks.Model.StackConfigurationManager();
System.String requestConfigurationManager_configurationManager_Name = null;
if (cmdletContext.ConfigurationManager_Name != null)
{
requestConfigurationManager_configurationManager_Name = cmdletContext.ConfigurationManager_Name;
}
if (requestConfigurationManager_configurationManager_Name != null)
{
request.ConfigurationManager.Name = requestConfigurationManager_configurationManager_Name;
requestConfigurationManagerIsNull = false;
}
System.String requestConfigurationManager_configurationManager_Version = null;
if (cmdletContext.ConfigurationManager_Version != null)
{
requestConfigurationManager_configurationManager_Version = cmdletContext.ConfigurationManager_Version;
}
if (requestConfigurationManager_configurationManager_Version != null)
{
request.ConfigurationManager.Version = requestConfigurationManager_configurationManager_Version;
requestConfigurationManagerIsNull = false;
}
// determine if request.ConfigurationManager should be set to null
if (requestConfigurationManagerIsNull)
{
request.ConfigurationManager = null;
}
// populate CustomCookbooksSource
var requestCustomCookbooksSourceIsNull = true;
request.CustomCookbooksSource = new Amazon.OpsWorks.Model.Source();
System.String requestCustomCookbooksSource_customCookbooksSource_Password = null;
if (cmdletContext.CustomCookbooksSource_Password != null)
{
requestCustomCookbooksSource_customCookbooksSource_Password = cmdletContext.CustomCookbooksSource_Password;
}
if (requestCustomCookbooksSource_customCookbooksSource_Password != null)
{
request.CustomCookbooksSource.Password = requestCustomCookbooksSource_customCookbooksSource_Password;
requestCustomCookbooksSourceIsNull = false;
}
System.String requestCustomCookbooksSource_customCookbooksSource_Revision = null;
if (cmdletContext.CustomCookbooksSource_Revision != null)
{
requestCustomCookbooksSource_customCookbooksSource_Revision = cmdletContext.CustomCookbooksSource_Revision;
}
if (requestCustomCookbooksSource_customCookbooksSource_Revision != null)
{
request.CustomCookbooksSource.Revision = requestCustomCookbooksSource_customCookbooksSource_Revision;
requestCustomCookbooksSourceIsNull = false;
}
System.String requestCustomCookbooksSource_customCookbooksSource_SshKey = null;
if (cmdletContext.CustomCookbooksSource_SshKey != null)
{
requestCustomCookbooksSource_customCookbooksSource_SshKey = cmdletContext.CustomCookbooksSource_SshKey;
}
if (requestCustomCookbooksSource_customCookbooksSource_SshKey != null)
{
request.CustomCookbooksSource.SshKey = requestCustomCookbooksSource_customCookbooksSource_SshKey;
requestCustomCookbooksSourceIsNull = false;
}
Amazon.OpsWorks.SourceType requestCustomCookbooksSource_customCookbooksSource_Type = null;
if (cmdletContext.CustomCookbooksSource_Type != null)
{
requestCustomCookbooksSource_customCookbooksSource_Type = cmdletContext.CustomCookbooksSource_Type;
}
if (requestCustomCookbooksSource_customCookbooksSource_Type != null)
{
request.CustomCookbooksSource.Type = requestCustomCookbooksSource_customCookbooksSource_Type;
requestCustomCookbooksSourceIsNull = false;
}
System.String requestCustomCookbooksSource_customCookbooksSource_Url = null;
if (cmdletContext.CustomCookbooksSource_Url != null)
{
requestCustomCookbooksSource_customCookbooksSource_Url = cmdletContext.CustomCookbooksSource_Url;
}
if (requestCustomCookbooksSource_customCookbooksSource_Url != null)
{
request.CustomCookbooksSource.Url = requestCustomCookbooksSource_customCookbooksSource_Url;
requestCustomCookbooksSourceIsNull = false;
}
System.String requestCustomCookbooksSource_customCookbooksSource_Username = null;
if (cmdletContext.CustomCookbooksSource_Username != null)
{
requestCustomCookbooksSource_customCookbooksSource_Username = cmdletContext.CustomCookbooksSource_Username;
}
if (requestCustomCookbooksSource_customCookbooksSource_Username != null)
{
request.CustomCookbooksSource.Username = requestCustomCookbooksSource_customCookbooksSource_Username;
requestCustomCookbooksSourceIsNull = false;
}
// determine if request.CustomCookbooksSource should be set to null
if (requestCustomCookbooksSourceIsNull)
{
request.CustomCookbooksSource = null;
}
if (cmdletContext.CustomJson != null)
{
request.CustomJson = cmdletContext.CustomJson;
}
if (cmdletContext.DefaultAvailabilityZone != null)
{
request.DefaultAvailabilityZone = cmdletContext.DefaultAvailabilityZone;
}
if (cmdletContext.DefaultInstanceProfileArn != null)
{
request.DefaultInstanceProfileArn = cmdletContext.DefaultInstanceProfileArn;
}
if (cmdletContext.DefaultOs != null)
{
request.DefaultOs = cmdletContext.DefaultOs;
}
if (cmdletContext.DefaultRootDeviceType != null)
{
request.DefaultRootDeviceType = cmdletContext.DefaultRootDeviceType;
}
if (cmdletContext.DefaultSshKeyName != null)
{
request.DefaultSshKeyName = cmdletContext.DefaultSshKeyName;
}
if (cmdletContext.DefaultSubnetId != null)
{
request.DefaultSubnetId = cmdletContext.DefaultSubnetId;
}
if (cmdletContext.HostnameTheme != null)
{
request.HostnameTheme = cmdletContext.HostnameTheme;
}
if (cmdletContext.Name != null)
{
request.Name = cmdletContext.Name;
}
if (cmdletContext.ServiceRoleArn != null)
{
request.ServiceRoleArn = cmdletContext.ServiceRoleArn;
}
if (cmdletContext.StackId != null)
{
request.StackId = cmdletContext.StackId;
}
if (cmdletContext.UseCustomCookbook != null)
{
request.UseCustomCookbooks = cmdletContext.UseCustomCookbook.Value;
}
if (cmdletContext.UseOpsworksSecurityGroup != null)
{
request.UseOpsworksSecurityGroups = cmdletContext.UseOpsworksSecurityGroup.Value;
}
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.OpsWorks.Model.UpdateStackResponse CallAWSServiceOperation(IAmazonOpsWorks client, Amazon.OpsWorks.Model.UpdateStackRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS OpsWorks", "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 System.String AgentVersion { get; set; }
public Dictionary Attribute { get; set; }
public System.String ChefConfiguration_BerkshelfVersion { get; set; }
public System.Boolean? ChefConfiguration_ManageBerkshelf { get; set; }
public System.String ConfigurationManager_Name { get; set; }
public System.String ConfigurationManager_Version { get; set; }
public System.String CustomCookbooksSource_Password { get; set; }
public System.String CustomCookbooksSource_Revision { get; set; }
public System.String CustomCookbooksSource_SshKey { get; set; }
public Amazon.OpsWorks.SourceType CustomCookbooksSource_Type { get; set; }
public System.String CustomCookbooksSource_Url { get; set; }
public System.String CustomCookbooksSource_Username { get; set; }
public System.String CustomJson { get; set; }
public System.String DefaultAvailabilityZone { get; set; }
public System.String DefaultInstanceProfileArn { get; set; }
public System.String DefaultOs { get; set; }
public Amazon.OpsWorks.RootDeviceType DefaultRootDeviceType { get; set; }
public System.String DefaultSshKeyName { get; set; }
public System.String DefaultSubnetId { get; set; }
public System.String HostnameTheme { get; set; }
public System.String Name { get; set; }
public System.String ServiceRoleArn { get; set; }
public System.String StackId { get; set; }
public System.Boolean? UseCustomCookbook { get; set; }
public System.Boolean? UseOpsworksSecurityGroup { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => null;
}
}
}