private Amazon.Imagebuilder.Model.UpdateInfrastructureConfigurationResponse CallAWSServiceOperation(IAmazonImagebuilder client, Amazon.Imagebuilder.Model.UpdateInfrastructureConfigurationRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "EC2 Image Builder", "UpdateInfrastructureConfiguration"); try { #if DESKTOP return(client.UpdateInfrastructureConfiguration(request)); #elif CORECLR return(client.UpdateInfrastructureConfigurationAsync(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; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.Imagebuilder.Model.UpdateInfrastructureConfigurationRequest(); if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } if (cmdletContext.InfrastructureConfigurationArn != null) { request.InfrastructureConfigurationArn = cmdletContext.InfrastructureConfigurationArn; } // populate InstanceMetadataOptions var requestInstanceMetadataOptionsIsNull = true; request.InstanceMetadataOptions = new Amazon.Imagebuilder.Model.InstanceMetadataOptions(); System.Int32?requestInstanceMetadataOptions_instanceMetadataOptions_HttpPutResponseHopLimit = null; if (cmdletContext.InstanceMetadataOptions_HttpPutResponseHopLimit != null) { requestInstanceMetadataOptions_instanceMetadataOptions_HttpPutResponseHopLimit = cmdletContext.InstanceMetadataOptions_HttpPutResponseHopLimit.Value; } if (requestInstanceMetadataOptions_instanceMetadataOptions_HttpPutResponseHopLimit != null) { request.InstanceMetadataOptions.HttpPutResponseHopLimit = requestInstanceMetadataOptions_instanceMetadataOptions_HttpPutResponseHopLimit.Value; requestInstanceMetadataOptionsIsNull = false; } System.String requestInstanceMetadataOptions_instanceMetadataOptions_HttpToken = null; if (cmdletContext.InstanceMetadataOptions_HttpToken != null) { requestInstanceMetadataOptions_instanceMetadataOptions_HttpToken = cmdletContext.InstanceMetadataOptions_HttpToken; } if (requestInstanceMetadataOptions_instanceMetadataOptions_HttpToken != null) { request.InstanceMetadataOptions.HttpTokens = requestInstanceMetadataOptions_instanceMetadataOptions_HttpToken; requestInstanceMetadataOptionsIsNull = false; } // determine if request.InstanceMetadataOptions should be set to null if (requestInstanceMetadataOptionsIsNull) { request.InstanceMetadataOptions = null; } if (cmdletContext.InstanceProfileName != null) { request.InstanceProfileName = cmdletContext.InstanceProfileName; } if (cmdletContext.InstanceType != null) { request.InstanceTypes = cmdletContext.InstanceType; } if (cmdletContext.KeyPair != null) { request.KeyPair = cmdletContext.KeyPair; } // populate Logging var requestLoggingIsNull = true; request.Logging = new Amazon.Imagebuilder.Model.Logging(); Amazon.Imagebuilder.Model.S3Logs requestLogging_logging_S3Logs = null; // populate S3Logs var requestLogging_logging_S3LogsIsNull = true; requestLogging_logging_S3Logs = new Amazon.Imagebuilder.Model.S3Logs(); System.String requestLogging_logging_S3Logs_s3Logs_S3BucketName = null; if (cmdletContext.S3Logs_S3BucketName != null) { requestLogging_logging_S3Logs_s3Logs_S3BucketName = cmdletContext.S3Logs_S3BucketName; } if (requestLogging_logging_S3Logs_s3Logs_S3BucketName != null) { requestLogging_logging_S3Logs.S3BucketName = requestLogging_logging_S3Logs_s3Logs_S3BucketName; requestLogging_logging_S3LogsIsNull = false; } System.String requestLogging_logging_S3Logs_s3Logs_S3KeyPrefix = null; if (cmdletContext.S3Logs_S3KeyPrefix != null) { requestLogging_logging_S3Logs_s3Logs_S3KeyPrefix = cmdletContext.S3Logs_S3KeyPrefix; } if (requestLogging_logging_S3Logs_s3Logs_S3KeyPrefix != null) { requestLogging_logging_S3Logs.S3KeyPrefix = requestLogging_logging_S3Logs_s3Logs_S3KeyPrefix; requestLogging_logging_S3LogsIsNull = false; } // determine if requestLogging_logging_S3Logs should be set to null if (requestLogging_logging_S3LogsIsNull) { requestLogging_logging_S3Logs = null; } if (requestLogging_logging_S3Logs != null) { request.Logging.S3Logs = requestLogging_logging_S3Logs; requestLoggingIsNull = false; } // determine if request.Logging should be set to null if (requestLoggingIsNull) { request.Logging = null; } if (cmdletContext.ResourceTag != null) { request.ResourceTags = cmdletContext.ResourceTag; } if (cmdletContext.SecurityGroupId != null) { request.SecurityGroupIds = cmdletContext.SecurityGroupId; } if (cmdletContext.SnsTopicArn != null) { request.SnsTopicArn = cmdletContext.SnsTopicArn; } if (cmdletContext.SubnetId != null) { request.SubnetId = cmdletContext.SubnetId; } if (cmdletContext.TerminateInstanceOnFailure != null) { request.TerminateInstanceOnFailure = cmdletContext.TerminateInstanceOnFailure.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); }