private Amazon.Imagebuilder.Model.CreateInfrastructureConfigurationResponse CallAWSServiceOperation(IAmazonImagebuilder client, Amazon.Imagebuilder.Model.CreateInfrastructureConfigurationRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "EC2 Image Builder", "CreateInfrastructureConfiguration"); try { #if DESKTOP return(client.CreateInfrastructureConfiguration(request)); #elif CORECLR return(client.CreateInfrastructureConfigurationAsync(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.CreateInfrastructureConfigurationRequest(); if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } 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.Name != null) { request.Name = cmdletContext.Name; } 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.Tag != null) { request.Tags = cmdletContext.Tag; } 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); }