Exemplo n.º 1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Imagebuilder.Model.CreateImageRecipeRequest();

            if (cmdletContext.BlockDeviceMapping != null)
            {
                request.BlockDeviceMappings = cmdletContext.BlockDeviceMapping;
            }
            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }
            if (cmdletContext.Component != null)
            {
                request.Components = cmdletContext.Component;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }
            if (cmdletContext.ParentImage != null)
            {
                request.ParentImage = cmdletContext.ParentImage;
            }
            if (cmdletContext.SemanticVersion != null)
            {
                request.SemanticVersion = cmdletContext.SemanticVersion;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }

            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);
        }
Exemplo n.º 2
0
 private Amazon.Imagebuilder.Model.CreateImageRecipeResponse CallAWSServiceOperation(IAmazonImagebuilder client, Amazon.Imagebuilder.Model.CreateImageRecipeRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "EC2 Image Builder", "CreateImageRecipe");
     try
     {
         #if DESKTOP
         return(client.CreateImageRecipe(request));
         #elif CORECLR
         return(client.CreateImageRecipeAsync(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;
     }
 }
Exemplo n.º 3
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Imagebuilder.Model.CreateImageRecipeRequest();


            // populate AdditionalInstanceConfiguration
            var requestAdditionalInstanceConfigurationIsNull = true;

            request.AdditionalInstanceConfiguration = new Amazon.Imagebuilder.Model.AdditionalInstanceConfiguration();
            System.String requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_UserDataOverride = null;
            if (cmdletContext.AdditionalInstanceConfiguration_UserDataOverride != null)
            {
                requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_UserDataOverride = cmdletContext.AdditionalInstanceConfiguration_UserDataOverride;
            }
            if (requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_UserDataOverride != null)
            {
                request.AdditionalInstanceConfiguration.UserDataOverride = requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_UserDataOverride;
                requestAdditionalInstanceConfigurationIsNull             = false;
            }
            Amazon.Imagebuilder.Model.SystemsManagerAgent requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent = null;

            // populate SystemsManagerAgent
            var requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgentIsNull = true;

            requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent = new Amazon.Imagebuilder.Model.SystemsManagerAgent();
            System.Boolean?requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent_systemsManagerAgent_UninstallAfterBuild = null;
            if (cmdletContext.SystemsManagerAgent_UninstallAfterBuild != null)
            {
                requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent_systemsManagerAgent_UninstallAfterBuild = cmdletContext.SystemsManagerAgent_UninstallAfterBuild.Value;
            }
            if (requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent_systemsManagerAgent_UninstallAfterBuild != null)
            {
                requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent.UninstallAfterBuild = requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent_systemsManagerAgent_UninstallAfterBuild.Value;
                requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgentIsNull = false;
            }
            // determine if requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent should be set to null
            if (requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgentIsNull)
            {
                requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent = null;
            }
            if (requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent != null)
            {
                request.AdditionalInstanceConfiguration.SystemsManagerAgent = requestAdditionalInstanceConfiguration_additionalInstanceConfiguration_SystemsManagerAgent;
                requestAdditionalInstanceConfigurationIsNull = false;
            }
            // determine if request.AdditionalInstanceConfiguration should be set to null
            if (requestAdditionalInstanceConfigurationIsNull)
            {
                request.AdditionalInstanceConfiguration = null;
            }
            if (cmdletContext.BlockDeviceMapping != null)
            {
                request.BlockDeviceMappings = cmdletContext.BlockDeviceMapping;
            }
            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }
            if (cmdletContext.Component != null)
            {
                request.Components = cmdletContext.Component;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }
            if (cmdletContext.ParentImage != null)
            {
                request.ParentImage = cmdletContext.ParentImage;
            }
            if (cmdletContext.SemanticVersion != null)
            {
                request.SemanticVersion = cmdletContext.SemanticVersion;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.WorkingDirectory != null)
            {
                request.WorkingDirectory = cmdletContext.WorkingDirectory;
            }

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