/******************************************************************************* * 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.CodePipeline; using Amazon.CodePipeline.Model; namespace Amazon.PowerShell.Cmdlets.CP { /// /// Represents the success of a third party job as returned to the pipeline by a job worker. /// Used for partner actions only. /// [Cmdlet("Write", "CPThirdPartyJobSuccessResult", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("None")] [AWSCmdlet("Calls the AWS CodePipeline PutThirdPartyJobSuccessResult API operation.", Operation = new[] {"PutThirdPartyJobSuccessResult"}, SelectReturnType = typeof(Amazon.CodePipeline.Model.PutThirdPartyJobSuccessResultResponse))] [AWSCmdletOutput("None or Amazon.CodePipeline.Model.PutThirdPartyJobSuccessResultResponse", "This cmdlet does not generate any output." + "The service response (type Amazon.CodePipeline.Model.PutThirdPartyJobSuccessResultResponse) can be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class WriteCPThirdPartyJobSuccessResultCmdlet : AmazonCodePipelineClientCmdlet, IExecutor { #region Parameter CurrentRevision_ChangeIdentifier /// /// /// The change identifier for the current revision. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String CurrentRevision_ChangeIdentifier { get; set; } #endregion #region Parameter ContinuationToken /// /// /// A token generated by a job worker, such as a CodeDeploy deployment ID, that a successful /// job provides to identify a partner action in progress. Future jobs use this token /// to identify the running instance of the action. It can be reused to return more information /// about the progress of the partner action. When the action is complete, no continuation /// token should be supplied. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ContinuationToken { get; set; } #endregion #region Parameter CurrentRevision_Created /// /// /// The date and time when the most recent revision of the artifact was created, in timestamp /// format. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.DateTime? CurrentRevision_Created { get; set; } #endregion #region Parameter ExecutionDetails_ExternalExecutionId /// /// /// The system-generated unique ID of this action used to identify this job worker in /// any external systems, such as CodeDeploy. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ExecutionDetails_ExternalExecutionId { get; set; } #endregion #region Parameter JobId /// /// /// The ID of the job that successfully completed. This is the same ID returned from PollForThirdPartyJobs. /// /// #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 JobId { get; set; } #endregion #region Parameter ExecutionDetails_PercentComplete /// /// /// The percentage of work completed on the action, represented on a scale of 0 to 100 /// percent. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? ExecutionDetails_PercentComplete { get; set; } #endregion #region Parameter CurrentRevision_Revision /// /// /// The revision ID of the current version of an artifact. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String CurrentRevision_Revision { get; set; } #endregion #region Parameter CurrentRevision_RevisionSummary /// /// /// The summary of the most recent revision of the artifact. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String CurrentRevision_RevisionSummary { get; set; } #endregion #region Parameter ExecutionDetails_Summary /// /// /// The summary of the current status of the actions. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ExecutionDetails_Summary { get; set; } #endregion #region Parameter ClientToken /// /// /// The clientToken portion of the clientId and clientToken pair used to verify that the /// calling entity is allowed access to the job and its details. /// /// #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 ClientToken { 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.CodePipeline.Model.PutThirdPartyJobSuccessResultResponse). /// 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 JobId parameter. /// The -PassThru parameter is deprecated, use -Select '^JobId' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^JobId' 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.JobId), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Write-CPThirdPartyJobSuccessResult (PutThirdPartyJobSuccessResult)")) { 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.JobId; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.ClientToken = this.ClientToken; #if MODULAR if (this.ClientToken == null && ParameterWasBound(nameof(this.ClientToken))) { WriteWarning("You are passing $null as a value for parameter ClientToken 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.ContinuationToken = this.ContinuationToken; context.CurrentRevision_ChangeIdentifier = this.CurrentRevision_ChangeIdentifier; context.CurrentRevision_Created = this.CurrentRevision_Created; context.CurrentRevision_Revision = this.CurrentRevision_Revision; context.CurrentRevision_RevisionSummary = this.CurrentRevision_RevisionSummary; context.ExecutionDetails_ExternalExecutionId = this.ExecutionDetails_ExternalExecutionId; context.ExecutionDetails_PercentComplete = this.ExecutionDetails_PercentComplete; context.ExecutionDetails_Summary = this.ExecutionDetails_Summary; context.JobId = this.JobId; #if MODULAR if (this.JobId == null && ParameterWasBound(nameof(this.JobId))) { WriteWarning("You are passing $null as a value for parameter JobId 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.CodePipeline.Model.PutThirdPartyJobSuccessResultRequest(); if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.ContinuationToken != null) { request.ContinuationToken = cmdletContext.ContinuationToken; } // populate CurrentRevision var requestCurrentRevisionIsNull = true; request.CurrentRevision = new Amazon.CodePipeline.Model.CurrentRevision(); System.String requestCurrentRevision_currentRevision_ChangeIdentifier = null; if (cmdletContext.CurrentRevision_ChangeIdentifier != null) { requestCurrentRevision_currentRevision_ChangeIdentifier = cmdletContext.CurrentRevision_ChangeIdentifier; } if (requestCurrentRevision_currentRevision_ChangeIdentifier != null) { request.CurrentRevision.ChangeIdentifier = requestCurrentRevision_currentRevision_ChangeIdentifier; requestCurrentRevisionIsNull = false; } System.DateTime? requestCurrentRevision_currentRevision_Created = null; if (cmdletContext.CurrentRevision_Created != null) { requestCurrentRevision_currentRevision_Created = cmdletContext.CurrentRevision_Created.Value; } if (requestCurrentRevision_currentRevision_Created != null) { request.CurrentRevision.Created = requestCurrentRevision_currentRevision_Created.Value; requestCurrentRevisionIsNull = false; } System.String requestCurrentRevision_currentRevision_Revision = null; if (cmdletContext.CurrentRevision_Revision != null) { requestCurrentRevision_currentRevision_Revision = cmdletContext.CurrentRevision_Revision; } if (requestCurrentRevision_currentRevision_Revision != null) { request.CurrentRevision.Revision = requestCurrentRevision_currentRevision_Revision; requestCurrentRevisionIsNull = false; } System.String requestCurrentRevision_currentRevision_RevisionSummary = null; if (cmdletContext.CurrentRevision_RevisionSummary != null) { requestCurrentRevision_currentRevision_RevisionSummary = cmdletContext.CurrentRevision_RevisionSummary; } if (requestCurrentRevision_currentRevision_RevisionSummary != null) { request.CurrentRevision.RevisionSummary = requestCurrentRevision_currentRevision_RevisionSummary; requestCurrentRevisionIsNull = false; } // determine if request.CurrentRevision should be set to null if (requestCurrentRevisionIsNull) { request.CurrentRevision = null; } // populate ExecutionDetails var requestExecutionDetailsIsNull = true; request.ExecutionDetails = new Amazon.CodePipeline.Model.ExecutionDetails(); System.String requestExecutionDetails_executionDetails_ExternalExecutionId = null; if (cmdletContext.ExecutionDetails_ExternalExecutionId != null) { requestExecutionDetails_executionDetails_ExternalExecutionId = cmdletContext.ExecutionDetails_ExternalExecutionId; } if (requestExecutionDetails_executionDetails_ExternalExecutionId != null) { request.ExecutionDetails.ExternalExecutionId = requestExecutionDetails_executionDetails_ExternalExecutionId; requestExecutionDetailsIsNull = false; } System.Int32? requestExecutionDetails_executionDetails_PercentComplete = null; if (cmdletContext.ExecutionDetails_PercentComplete != null) { requestExecutionDetails_executionDetails_PercentComplete = cmdletContext.ExecutionDetails_PercentComplete.Value; } if (requestExecutionDetails_executionDetails_PercentComplete != null) { request.ExecutionDetails.PercentComplete = requestExecutionDetails_executionDetails_PercentComplete.Value; requestExecutionDetailsIsNull = false; } System.String requestExecutionDetails_executionDetails_Summary = null; if (cmdletContext.ExecutionDetails_Summary != null) { requestExecutionDetails_executionDetails_Summary = cmdletContext.ExecutionDetails_Summary; } if (requestExecutionDetails_executionDetails_Summary != null) { request.ExecutionDetails.Summary = requestExecutionDetails_executionDetails_Summary; requestExecutionDetailsIsNull = false; } // determine if request.ExecutionDetails should be set to null if (requestExecutionDetailsIsNull) { request.ExecutionDetails = null; } if (cmdletContext.JobId != null) { request.JobId = cmdletContext.JobId; } 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.CodePipeline.Model.PutThirdPartyJobSuccessResultResponse CallAWSServiceOperation(IAmazonCodePipeline client, Amazon.CodePipeline.Model.PutThirdPartyJobSuccessResultRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS CodePipeline", "PutThirdPartyJobSuccessResult"); try { #if DESKTOP return client.PutThirdPartyJobSuccessResult(request); #elif CORECLR return client.PutThirdPartyJobSuccessResultAsync(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 ClientToken { get; set; } public System.String ContinuationToken { get; set; } public System.String CurrentRevision_ChangeIdentifier { get; set; } public System.DateTime? CurrentRevision_Created { get; set; } public System.String CurrentRevision_Revision { get; set; } public System.String CurrentRevision_RevisionSummary { get; set; } public System.String ExecutionDetails_ExternalExecutionId { get; set; } public System.Int32? ExecutionDetails_PercentComplete { get; set; } public System.String ExecutionDetails_Summary { get; set; } public System.String JobId { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => null; } } }