/******************************************************************************* * 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.Imagebuilder; using Amazon.Imagebuilder.Model; namespace Amazon.PowerShell.Cmdlets.EC2IB { /// /// Updates an image pipeline. Image pipelines enable you to automate the creation and /// distribution of images. /// /// /// UpdateImagePipeline does not support selective updates for the pipeline. You must /// specify all of the required properties in the update request, not just the properties /// that have changed. /// /// [Cmdlet("Update", "EC2IBImagePipeline", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("System.String")] [AWSCmdlet("Calls the EC2 Image Builder UpdateImagePipeline API operation.", Operation = new[] {"UpdateImagePipeline"}, SelectReturnType = typeof(Amazon.Imagebuilder.Model.UpdateImagePipelineResponse))] [AWSCmdletOutput("System.String or Amazon.Imagebuilder.Model.UpdateImagePipelineResponse", "This cmdlet returns a System.String object.", "The service call response (type Amazon.Imagebuilder.Model.UpdateImagePipelineResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class UpdateEC2IBImagePipelineCmdlet : AmazonImagebuilderClientCmdlet, IExecutor { #region Parameter ContainerRecipeArn /// /// /// The Amazon Resource Name (ARN) of the container pipeline to update. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ContainerRecipeArn { get; set; } #endregion #region Parameter EcrConfiguration_ContainerTag /// /// /// Tags for Image Builder to apply to the output container image that &INS; scans. /// Tags can help you identify and manage your scanned images. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ImageScanningConfiguration_EcrConfiguration_ContainerTags")] public System.String[] EcrConfiguration_ContainerTag { get; set; } #endregion #region Parameter Description /// /// /// The description of the image pipeline. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String Description { get; set; } #endregion #region Parameter DistributionConfigurationArn /// /// /// The Amazon Resource Name (ARN) of the distribution configuration that Image Builder /// uses to configure and distribute images that this image pipeline has updated. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String DistributionConfigurationArn { get; set; } #endregion #region Parameter EnhancedImageMetadataEnabled /// /// /// Collects additional information about the image being created, including the operating /// system (OS) version and package list. This information is used to enhance the overall /// experience of using EC2 Image Builder. Enabled by default. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? EnhancedImageMetadataEnabled { get; set; } #endregion #region Parameter ImagePipelineArn /// /// /// The Amazon Resource Name (ARN) of the image pipeline that you want to update. /// /// #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 ImagePipelineArn { get; set; } #endregion #region Parameter ImageRecipeArn /// /// /// The Amazon Resource Name (ARN) of the image recipe that will be used to configure /// images updated by this image pipeline. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ImageRecipeArn { get; set; } #endregion #region Parameter ImageScanningConfiguration_ImageScanningEnabled /// /// /// A setting that indicates whether Image Builder keeps a snapshot of the vulnerability /// scans that Amazon Inspector runs against the build instance when you create a new /// image. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? ImageScanningConfiguration_ImageScanningEnabled { get; set; } #endregion #region Parameter ImageTestsConfiguration_ImageTestsEnabled /// /// /// Determines if tests should run after building the image. Image Builder defaults to /// enable tests to run following the image build, before image distribution. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? ImageTestsConfiguration_ImageTestsEnabled { get; set; } #endregion #region Parameter InfrastructureConfigurationArn /// /// /// The Amazon Resource Name (ARN) of the infrastructure configuration that Image Builder /// uses to build images that this image pipeline has updated. /// /// #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 InfrastructureConfigurationArn { get; set; } #endregion #region Parameter Schedule_PipelineExecutionStartCondition /// /// /// The condition configures when the pipeline should trigger a new image build. When /// the pipelineExecutionStartCondition is set to EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE, /// and you use semantic version filters on the base image or components in your image /// recipe, EC2 Image Builder will build a new image only when there are new versions /// of the image or components in your recipe that match the semantic version filter. /// When it is set to EXPRESSION_MATCH_ONLY, it will build a new image every /// time the CRON expression matches the current time. For semantic version syntax, see /// CreateComponent /// in the EC2 Image Builder API Reference. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.Imagebuilder.PipelineExecutionStartCondition")] public Amazon.Imagebuilder.PipelineExecutionStartCondition Schedule_PipelineExecutionStartCondition { get; set; } #endregion #region Parameter EcrConfiguration_RepositoryName /// /// /// The name of the container repository that Amazon Inspector scans to identify findings /// for your container images. The name includes the path for the repository location. /// If you don’t provide this information, Image Builder creates a repository in your /// account named image-builder-image-scanning-repository for vulnerability /// scans of your output container images. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ImageScanningConfiguration_EcrConfiguration_RepositoryName")] public System.String EcrConfiguration_RepositoryName { get; set; } #endregion #region Parameter Schedule_ScheduleExpression /// /// /// The cron expression determines how often EC2 Image Builder evaluates your pipelineExecutionStartCondition.For information on how to format a cron expression in Image Builder, see Use /// cron expressions in EC2 Image Builder. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String Schedule_ScheduleExpression { get; set; } #endregion #region Parameter Status /// /// /// The status of the image pipeline. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.Imagebuilder.PipelineStatus")] public Amazon.Imagebuilder.PipelineStatus Status { get; set; } #endregion #region Parameter ImageTestsConfiguration_TimeoutMinute /// /// /// The maximum time in minutes that tests are permitted to run.The timeoutMinutes attribute is not currently active. This value is ignored. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ImageTestsConfiguration_TimeoutMinutes")] public System.Int32? ImageTestsConfiguration_TimeoutMinute { get; set; } #endregion #region Parameter Schedule_Timezone /// /// /// The timezone that applies to the scheduling expression. For example, "Etc/UTC", "America/Los_Angeles" /// in the IANA timezone format. /// If not specified this defaults to UTC. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String Schedule_Timezone { get; set; } #endregion #region Parameter ClientToken /// /// /// The idempotency token used to make this request idempotent. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ClientToken { get; set; } #endregion #region Parameter Select /// /// Use the -Select parameter to control the cmdlet output. The default value is 'ImagePipelineArn'. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.Imagebuilder.Model.UpdateImagePipelineResponse). /// Specifying the name of a property of type Amazon.Imagebuilder.Model.UpdateImagePipelineResponse 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; } = "ImagePipelineArn"; #endregion #region Parameter PassThru /// /// Changes the cmdlet behavior to return the value passed to the ImagePipelineArn parameter. /// The -PassThru parameter is deprecated, use -Select '^ImagePipelineArn' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^ImagePipelineArn' 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.ImagePipelineArn), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-EC2IBImagePipeline (UpdateImagePipeline)")) { 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.ImagePipelineArn; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.ClientToken = this.ClientToken; context.ContainerRecipeArn = this.ContainerRecipeArn; context.Description = this.Description; context.DistributionConfigurationArn = this.DistributionConfigurationArn; context.EnhancedImageMetadataEnabled = this.EnhancedImageMetadataEnabled; context.ImagePipelineArn = this.ImagePipelineArn; #if MODULAR if (this.ImagePipelineArn == null && ParameterWasBound(nameof(this.ImagePipelineArn))) { WriteWarning("You are passing $null as a value for parameter ImagePipelineArn 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.ImageRecipeArn = this.ImageRecipeArn; if (this.EcrConfiguration_ContainerTag != null) { context.EcrConfiguration_ContainerTag = new List(this.EcrConfiguration_ContainerTag); } context.EcrConfiguration_RepositoryName = this.EcrConfiguration_RepositoryName; context.ImageScanningConfiguration_ImageScanningEnabled = this.ImageScanningConfiguration_ImageScanningEnabled; context.ImageTestsConfiguration_ImageTestsEnabled = this.ImageTestsConfiguration_ImageTestsEnabled; context.ImageTestsConfiguration_TimeoutMinute = this.ImageTestsConfiguration_TimeoutMinute; context.InfrastructureConfigurationArn = this.InfrastructureConfigurationArn; #if MODULAR if (this.InfrastructureConfigurationArn == null && ParameterWasBound(nameof(this.InfrastructureConfigurationArn))) { WriteWarning("You are passing $null as a value for parameter InfrastructureConfigurationArn 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.Schedule_PipelineExecutionStartCondition = this.Schedule_PipelineExecutionStartCondition; context.Schedule_ScheduleExpression = this.Schedule_ScheduleExpression; context.Schedule_Timezone = this.Schedule_Timezone; context.Status = this.Status; // 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.Imagebuilder.Model.UpdateImagePipelineRequest(); if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.ContainerRecipeArn != null) { request.ContainerRecipeArn = cmdletContext.ContainerRecipeArn; } if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } if (cmdletContext.DistributionConfigurationArn != null) { request.DistributionConfigurationArn = cmdletContext.DistributionConfigurationArn; } if (cmdletContext.EnhancedImageMetadataEnabled != null) { request.EnhancedImageMetadataEnabled = cmdletContext.EnhancedImageMetadataEnabled.Value; } if (cmdletContext.ImagePipelineArn != null) { request.ImagePipelineArn = cmdletContext.ImagePipelineArn; } if (cmdletContext.ImageRecipeArn != null) { request.ImageRecipeArn = cmdletContext.ImageRecipeArn; } // populate ImageScanningConfiguration var requestImageScanningConfigurationIsNull = true; request.ImageScanningConfiguration = new Amazon.Imagebuilder.Model.ImageScanningConfiguration(); System.Boolean? requestImageScanningConfiguration_imageScanningConfiguration_ImageScanningEnabled = null; if (cmdletContext.ImageScanningConfiguration_ImageScanningEnabled != null) { requestImageScanningConfiguration_imageScanningConfiguration_ImageScanningEnabled = cmdletContext.ImageScanningConfiguration_ImageScanningEnabled.Value; } if (requestImageScanningConfiguration_imageScanningConfiguration_ImageScanningEnabled != null) { request.ImageScanningConfiguration.ImageScanningEnabled = requestImageScanningConfiguration_imageScanningConfiguration_ImageScanningEnabled.Value; requestImageScanningConfigurationIsNull = false; } Amazon.Imagebuilder.Model.EcrConfiguration requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration = null; // populate EcrConfiguration var requestImageScanningConfiguration_imageScanningConfiguration_EcrConfigurationIsNull = true; requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration = new Amazon.Imagebuilder.Model.EcrConfiguration(); List requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration_ecrConfiguration_ContainerTag = null; if (cmdletContext.EcrConfiguration_ContainerTag != null) { requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration_ecrConfiguration_ContainerTag = cmdletContext.EcrConfiguration_ContainerTag; } if (requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration_ecrConfiguration_ContainerTag != null) { requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration.ContainerTags = requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration_ecrConfiguration_ContainerTag; requestImageScanningConfiguration_imageScanningConfiguration_EcrConfigurationIsNull = false; } System.String requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration_ecrConfiguration_RepositoryName = null; if (cmdletContext.EcrConfiguration_RepositoryName != null) { requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration_ecrConfiguration_RepositoryName = cmdletContext.EcrConfiguration_RepositoryName; } if (requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration_ecrConfiguration_RepositoryName != null) { requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration.RepositoryName = requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration_ecrConfiguration_RepositoryName; requestImageScanningConfiguration_imageScanningConfiguration_EcrConfigurationIsNull = false; } // determine if requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration should be set to null if (requestImageScanningConfiguration_imageScanningConfiguration_EcrConfigurationIsNull) { requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration = null; } if (requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration != null) { request.ImageScanningConfiguration.EcrConfiguration = requestImageScanningConfiguration_imageScanningConfiguration_EcrConfiguration; requestImageScanningConfigurationIsNull = false; } // determine if request.ImageScanningConfiguration should be set to null if (requestImageScanningConfigurationIsNull) { request.ImageScanningConfiguration = null; } // populate ImageTestsConfiguration var requestImageTestsConfigurationIsNull = true; request.ImageTestsConfiguration = new Amazon.Imagebuilder.Model.ImageTestsConfiguration(); System.Boolean? requestImageTestsConfiguration_imageTestsConfiguration_ImageTestsEnabled = null; if (cmdletContext.ImageTestsConfiguration_ImageTestsEnabled != null) { requestImageTestsConfiguration_imageTestsConfiguration_ImageTestsEnabled = cmdletContext.ImageTestsConfiguration_ImageTestsEnabled.Value; } if (requestImageTestsConfiguration_imageTestsConfiguration_ImageTestsEnabled != null) { request.ImageTestsConfiguration.ImageTestsEnabled = requestImageTestsConfiguration_imageTestsConfiguration_ImageTestsEnabled.Value; requestImageTestsConfigurationIsNull = false; } System.Int32? requestImageTestsConfiguration_imageTestsConfiguration_TimeoutMinute = null; if (cmdletContext.ImageTestsConfiguration_TimeoutMinute != null) { requestImageTestsConfiguration_imageTestsConfiguration_TimeoutMinute = cmdletContext.ImageTestsConfiguration_TimeoutMinute.Value; } if (requestImageTestsConfiguration_imageTestsConfiguration_TimeoutMinute != null) { request.ImageTestsConfiguration.TimeoutMinutes = requestImageTestsConfiguration_imageTestsConfiguration_TimeoutMinute.Value; requestImageTestsConfigurationIsNull = false; } // determine if request.ImageTestsConfiguration should be set to null if (requestImageTestsConfigurationIsNull) { request.ImageTestsConfiguration = null; } if (cmdletContext.InfrastructureConfigurationArn != null) { request.InfrastructureConfigurationArn = cmdletContext.InfrastructureConfigurationArn; } // populate Schedule var requestScheduleIsNull = true; request.Schedule = new Amazon.Imagebuilder.Model.Schedule(); Amazon.Imagebuilder.PipelineExecutionStartCondition requestSchedule_schedule_PipelineExecutionStartCondition = null; if (cmdletContext.Schedule_PipelineExecutionStartCondition != null) { requestSchedule_schedule_PipelineExecutionStartCondition = cmdletContext.Schedule_PipelineExecutionStartCondition; } if (requestSchedule_schedule_PipelineExecutionStartCondition != null) { request.Schedule.PipelineExecutionStartCondition = requestSchedule_schedule_PipelineExecutionStartCondition; requestScheduleIsNull = false; } System.String requestSchedule_schedule_ScheduleExpression = null; if (cmdletContext.Schedule_ScheduleExpression != null) { requestSchedule_schedule_ScheduleExpression = cmdletContext.Schedule_ScheduleExpression; } if (requestSchedule_schedule_ScheduleExpression != null) { request.Schedule.ScheduleExpression = requestSchedule_schedule_ScheduleExpression; requestScheduleIsNull = false; } System.String requestSchedule_schedule_Timezone = null; if (cmdletContext.Schedule_Timezone != null) { requestSchedule_schedule_Timezone = cmdletContext.Schedule_Timezone; } if (requestSchedule_schedule_Timezone != null) { request.Schedule.Timezone = requestSchedule_schedule_Timezone; requestScheduleIsNull = false; } // determine if request.Schedule should be set to null if (requestScheduleIsNull) { request.Schedule = null; } if (cmdletContext.Status != null) { request.Status = cmdletContext.Status; } 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.Imagebuilder.Model.UpdateImagePipelineResponse CallAWSServiceOperation(IAmazonImagebuilder client, Amazon.Imagebuilder.Model.UpdateImagePipelineRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "EC2 Image Builder", "UpdateImagePipeline"); try { #if DESKTOP return client.UpdateImagePipeline(request); #elif CORECLR return client.UpdateImagePipelineAsync(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 ContainerRecipeArn { get; set; } public System.String Description { get; set; } public System.String DistributionConfigurationArn { get; set; } public System.Boolean? EnhancedImageMetadataEnabled { get; set; } public System.String ImagePipelineArn { get; set; } public System.String ImageRecipeArn { get; set; } public List EcrConfiguration_ContainerTag { get; set; } public System.String EcrConfiguration_RepositoryName { get; set; } public System.Boolean? ImageScanningConfiguration_ImageScanningEnabled { get; set; } public System.Boolean? ImageTestsConfiguration_ImageTestsEnabled { get; set; } public System.Int32? ImageTestsConfiguration_TimeoutMinute { get; set; } public System.String InfrastructureConfigurationArn { get; set; } public Amazon.Imagebuilder.PipelineExecutionStartCondition Schedule_PipelineExecutionStartCondition { get; set; } public System.String Schedule_ScheduleExpression { get; set; } public System.String Schedule_Timezone { get; set; } public Amazon.Imagebuilder.PipelineStatus Status { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response.ImagePipelineArn; } } }