示例#1
0
 private Amazon.Proton.Model.CreateEnvironmentTemplateVersionResponse CallAWSServiceOperation(IAmazonProton client, Amazon.Proton.Model.CreateEnvironmentTemplateVersionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Proton", "CreateEnvironmentTemplateVersion");
     try
     {
         #if DESKTOP
         return(client.CreateEnvironmentTemplateVersion(request));
         #elif CORECLR
         return(client.CreateEnvironmentTemplateVersionAsync(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;
     }
 }
示例#2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Proton.Model.CreateEnvironmentTemplateVersionRequest();

            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.MajorVersion != null)
            {
                request.MajorVersion = cmdletContext.MajorVersion;
            }

            // populate Source
            var requestSourceIsNull = true;

            request.Source = new Amazon.Proton.Model.TemplateVersionSourceInput();
            Amazon.Proton.Model.S3ObjectSource requestSource_source_S3 = null;

            // populate S3
            var requestSource_source_S3IsNull = true;

            requestSource_source_S3 = new Amazon.Proton.Model.S3ObjectSource();
            System.String requestSource_source_S3_s3_Bucket = null;
            if (cmdletContext.S3_Bucket != null)
            {
                requestSource_source_S3_s3_Bucket = cmdletContext.S3_Bucket;
            }
            if (requestSource_source_S3_s3_Bucket != null)
            {
                requestSource_source_S3.Bucket = requestSource_source_S3_s3_Bucket;
                requestSource_source_S3IsNull  = false;
            }
            System.String requestSource_source_S3_s3_Key = null;
            if (cmdletContext.S3_Key != null)
            {
                requestSource_source_S3_s3_Key = cmdletContext.S3_Key;
            }
            if (requestSource_source_S3_s3_Key != null)
            {
                requestSource_source_S3.Key   = requestSource_source_S3_s3_Key;
                requestSource_source_S3IsNull = false;
            }
            // determine if requestSource_source_S3 should be set to null
            if (requestSource_source_S3IsNull)
            {
                requestSource_source_S3 = null;
            }
            if (requestSource_source_S3 != null)
            {
                request.Source.S3   = requestSource_source_S3;
                requestSourceIsNull = false;
            }
            // determine if request.Source should be set to null
            if (requestSourceIsNull)
            {
                request.Source = null;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.TemplateName != null)
            {
                request.TemplateName = cmdletContext.TemplateName;
            }

            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);
        }