/*******************************************************************************
* 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.DataExchange;
using Amazon.DataExchange.Model;
namespace Amazon.PowerShell.Cmdlets.DTEX
{
///
/// This operation updates the event action.
///
[Cmdlet("Update", "DTEXEventAction", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.DataExchange.Model.UpdateEventActionResponse")]
[AWSCmdlet("Calls the AWS Data Exchange UpdateEventAction API operation.", Operation = new[] {"UpdateEventAction"}, SelectReturnType = typeof(Amazon.DataExchange.Model.UpdateEventActionResponse))]
[AWSCmdletOutput("Amazon.DataExchange.Model.UpdateEventActionResponse",
"This cmdlet returns an Amazon.DataExchange.Model.UpdateEventActionResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class UpdateDTEXEventActionCmdlet : AmazonDataExchangeClientCmdlet, IExecutor
{
#region Parameter RevisionDestination_Bucket
///
///
/// The Amazon S3 bucket that is the destination for the event action.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Action_ExportRevisionToS3_RevisionDestination_Bucket")]
public System.String RevisionDestination_Bucket { get; set; }
#endregion
#region Parameter EventActionId
///
///
/// The unique identifier for the event action.
///
///
#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 EventActionId { get; set; }
#endregion
#region Parameter RevisionDestination_KeyPattern
///
///
/// A string representing the pattern for generated names of the individual assets in
/// the revision. For more information about key patterns, see Key
/// patterns when exporting revisions.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Action_ExportRevisionToS3_RevisionDestination_KeyPattern")]
public System.String RevisionDestination_KeyPattern { get; set; }
#endregion
#region Parameter Encryption_KmsKeyArn
///
///
/// The Amazon Resource Name (ARN) of the AWS KMS key you want to use to encrypt the Amazon
/// S3 objects. This parameter is required if you choose aws:kms as an encryption type.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Action_ExportRevisionToS3_Encryption_KmsKeyArn")]
public System.String Encryption_KmsKeyArn { get; set; }
#endregion
#region Parameter Encryption_Type
///
///
/// The type of server side encryption used for encrypting the objects in Amazon S3.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Action_ExportRevisionToS3_Encryption_Type")]
[AWSConstantClassSource("Amazon.DataExchange.ServerSideEncryptionTypes")]
public Amazon.DataExchange.ServerSideEncryptionTypes Encryption_Type { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is '*'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.DataExchange.Model.UpdateEventActionResponse).
/// Specifying the name of a property of type Amazon.DataExchange.Model.UpdateEventActionResponse 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; } = "*";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the EventActionId parameter.
/// The -PassThru parameter is deprecated, use -Select '^EventActionId' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^EventActionId' 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.EventActionId), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-DTEXEventAction (UpdateEventAction)"))
{
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.EventActionId;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.Encryption_KmsKeyArn = this.Encryption_KmsKeyArn;
context.Encryption_Type = this.Encryption_Type;
context.RevisionDestination_Bucket = this.RevisionDestination_Bucket;
context.RevisionDestination_KeyPattern = this.RevisionDestination_KeyPattern;
context.EventActionId = this.EventActionId;
#if MODULAR
if (this.EventActionId == null && ParameterWasBound(nameof(this.EventActionId)))
{
WriteWarning("You are passing $null as a value for parameter EventActionId 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.DataExchange.Model.UpdateEventActionRequest();
// populate Action
var requestActionIsNull = true;
request.Action = new Amazon.DataExchange.Model.Action();
Amazon.DataExchange.Model.AutoExportRevisionToS3RequestDetails requestAction_action_ExportRevisionToS3 = null;
// populate ExportRevisionToS3
var requestAction_action_ExportRevisionToS3IsNull = true;
requestAction_action_ExportRevisionToS3 = new Amazon.DataExchange.Model.AutoExportRevisionToS3RequestDetails();
Amazon.DataExchange.Model.ExportServerSideEncryption requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption = null;
// populate Encryption
var requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_EncryptionIsNull = true;
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption = new Amazon.DataExchange.Model.ExportServerSideEncryption();
System.String requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption_encryption_KmsKeyArn = null;
if (cmdletContext.Encryption_KmsKeyArn != null)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption_encryption_KmsKeyArn = cmdletContext.Encryption_KmsKeyArn;
}
if (requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption_encryption_KmsKeyArn != null)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption.KmsKeyArn = requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption_encryption_KmsKeyArn;
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_EncryptionIsNull = false;
}
Amazon.DataExchange.ServerSideEncryptionTypes requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption_encryption_Type = null;
if (cmdletContext.Encryption_Type != null)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption_encryption_Type = cmdletContext.Encryption_Type;
}
if (requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption_encryption_Type != null)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption.Type = requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption_encryption_Type;
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_EncryptionIsNull = false;
}
// determine if requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption should be set to null
if (requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_EncryptionIsNull)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption = null;
}
if (requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption != null)
{
requestAction_action_ExportRevisionToS3.Encryption = requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_Encryption;
requestAction_action_ExportRevisionToS3IsNull = false;
}
Amazon.DataExchange.Model.AutoExportRevisionDestinationEntry requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination = null;
// populate RevisionDestination
var requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestinationIsNull = true;
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination = new Amazon.DataExchange.Model.AutoExportRevisionDestinationEntry();
System.String requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination_revisionDestination_Bucket = null;
if (cmdletContext.RevisionDestination_Bucket != null)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination_revisionDestination_Bucket = cmdletContext.RevisionDestination_Bucket;
}
if (requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination_revisionDestination_Bucket != null)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination.Bucket = requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination_revisionDestination_Bucket;
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestinationIsNull = false;
}
System.String requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination_revisionDestination_KeyPattern = null;
if (cmdletContext.RevisionDestination_KeyPattern != null)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination_revisionDestination_KeyPattern = cmdletContext.RevisionDestination_KeyPattern;
}
if (requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination_revisionDestination_KeyPattern != null)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination.KeyPattern = requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination_revisionDestination_KeyPattern;
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestinationIsNull = false;
}
// determine if requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination should be set to null
if (requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestinationIsNull)
{
requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination = null;
}
if (requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination != null)
{
requestAction_action_ExportRevisionToS3.RevisionDestination = requestAction_action_ExportRevisionToS3_action_ExportRevisionToS3_RevisionDestination;
requestAction_action_ExportRevisionToS3IsNull = false;
}
// determine if requestAction_action_ExportRevisionToS3 should be set to null
if (requestAction_action_ExportRevisionToS3IsNull)
{
requestAction_action_ExportRevisionToS3 = null;
}
if (requestAction_action_ExportRevisionToS3 != null)
{
request.Action.ExportRevisionToS3 = requestAction_action_ExportRevisionToS3;
requestActionIsNull = false;
}
// determine if request.Action should be set to null
if (requestActionIsNull)
{
request.Action = null;
}
if (cmdletContext.EventActionId != null)
{
request.EventActionId = cmdletContext.EventActionId;
}
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.DataExchange.Model.UpdateEventActionResponse CallAWSServiceOperation(IAmazonDataExchange client, Amazon.DataExchange.Model.UpdateEventActionRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Data Exchange", "UpdateEventAction");
try
{
#if DESKTOP
return client.UpdateEventAction(request);
#elif CORECLR
return client.UpdateEventActionAsync(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 Encryption_KmsKeyArn { get; set; }
public Amazon.DataExchange.ServerSideEncryptionTypes Encryption_Type { get; set; }
public System.String RevisionDestination_Bucket { get; set; }
public System.String RevisionDestination_KeyPattern { get; set; }
public System.String EventActionId { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response;
}
}
}