Beispiel #1
0
 private Amazon.Lightsail.Model.CreateContainerServiceResponse CallAWSServiceOperation(IAmazonLightsail client, Amazon.Lightsail.Model.CreateContainerServiceRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Lightsail", "CreateContainerService");
     try
     {
         #if DESKTOP
         return(client.CreateContainerService(request));
         #elif CORECLR
         return(client.CreateContainerServiceAsync(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;
     }
 }
Beispiel #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Lightsail.Model.CreateContainerServiceRequest();


            // populate Deployment
            var requestDeploymentIsNull = true;

            request.Deployment = new Amazon.Lightsail.Model.ContainerServiceDeploymentRequest();
            Dictionary <System.String, Amazon.Lightsail.Model.Container> requestDeployment_deployment_Container = null;

            if (cmdletContext.Deployment_Container != null)
            {
                requestDeployment_deployment_Container = cmdletContext.Deployment_Container;
            }
            if (requestDeployment_deployment_Container != null)
            {
                request.Deployment.Containers = requestDeployment_deployment_Container;
                requestDeploymentIsNull       = false;
            }
            Amazon.Lightsail.Model.EndpointRequest requestDeployment_deployment_PublicEndpoint = null;

            // populate PublicEndpoint
            var requestDeployment_deployment_PublicEndpointIsNull = true;

            requestDeployment_deployment_PublicEndpoint = new Amazon.Lightsail.Model.EndpointRequest();
            System.String requestDeployment_deployment_PublicEndpoint_publicEndpoint_ContainerName = null;
            if (cmdletContext.PublicEndpoint_ContainerName != null)
            {
                requestDeployment_deployment_PublicEndpoint_publicEndpoint_ContainerName = cmdletContext.PublicEndpoint_ContainerName;
            }
            if (requestDeployment_deployment_PublicEndpoint_publicEndpoint_ContainerName != null)
            {
                requestDeployment_deployment_PublicEndpoint.ContainerName = requestDeployment_deployment_PublicEndpoint_publicEndpoint_ContainerName;
                requestDeployment_deployment_PublicEndpointIsNull         = false;
            }
            System.Int32?requestDeployment_deployment_PublicEndpoint_publicEndpoint_ContainerPort = null;
            if (cmdletContext.PublicEndpoint_ContainerPort != null)
            {
                requestDeployment_deployment_PublicEndpoint_publicEndpoint_ContainerPort = cmdletContext.PublicEndpoint_ContainerPort.Value;
            }
            if (requestDeployment_deployment_PublicEndpoint_publicEndpoint_ContainerPort != null)
            {
                requestDeployment_deployment_PublicEndpoint.ContainerPort = requestDeployment_deployment_PublicEndpoint_publicEndpoint_ContainerPort.Value;
                requestDeployment_deployment_PublicEndpointIsNull         = false;
            }
            Amazon.Lightsail.Model.ContainerServiceHealthCheckConfig requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck = null;

            // populate HealthCheck
            var requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheckIsNull = true;

            requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck = new Amazon.Lightsail.Model.ContainerServiceHealthCheckConfig();
            System.Int32?requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_HealthyThreshold = null;
            if (cmdletContext.HealthCheck_HealthyThreshold != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_HealthyThreshold = cmdletContext.HealthCheck_HealthyThreshold.Value;
            }
            if (requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_HealthyThreshold != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck.HealthyThreshold = requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_HealthyThreshold.Value;
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheckIsNull            = false;
            }
            System.Int32?requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_IntervalSecond = null;
            if (cmdletContext.HealthCheck_IntervalSecond != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_IntervalSecond = cmdletContext.HealthCheck_IntervalSecond.Value;
            }
            if (requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_IntervalSecond != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck.IntervalSeconds = requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_IntervalSecond.Value;
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheckIsNull           = false;
            }
            System.String requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_Path = null;
            if (cmdletContext.HealthCheck_Path != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_Path = cmdletContext.HealthCheck_Path;
            }
            if (requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_Path != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck.Path  = requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_Path;
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheckIsNull = false;
            }
            System.String requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_SuccessCode = null;
            if (cmdletContext.HealthCheck_SuccessCode != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_SuccessCode = cmdletContext.HealthCheck_SuccessCode;
            }
            if (requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_SuccessCode != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck.SuccessCodes = requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_SuccessCode;
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheckIsNull        = false;
            }
            System.Int32?requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_TimeoutSecond = null;
            if (cmdletContext.HealthCheck_TimeoutSecond != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_TimeoutSecond = cmdletContext.HealthCheck_TimeoutSecond.Value;
            }
            if (requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_TimeoutSecond != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck.TimeoutSeconds = requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_TimeoutSecond.Value;
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheckIsNull          = false;
            }
            System.Int32?requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_UnhealthyThreshold = null;
            if (cmdletContext.HealthCheck_UnhealthyThreshold != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_UnhealthyThreshold = cmdletContext.HealthCheck_UnhealthyThreshold.Value;
            }
            if (requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_UnhealthyThreshold != null)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck.UnhealthyThreshold = requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck_healthCheck_UnhealthyThreshold.Value;
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheckIsNull = false;
            }
            // determine if requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck should be set to null
            if (requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheckIsNull)
            {
                requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck = null;
            }
            if (requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck != null)
            {
                requestDeployment_deployment_PublicEndpoint.HealthCheck = requestDeployment_deployment_PublicEndpoint_deployment_PublicEndpoint_HealthCheck;
                requestDeployment_deployment_PublicEndpointIsNull       = false;
            }
            // determine if requestDeployment_deployment_PublicEndpoint should be set to null
            if (requestDeployment_deployment_PublicEndpointIsNull)
            {
                requestDeployment_deployment_PublicEndpoint = null;
            }
            if (requestDeployment_deployment_PublicEndpoint != null)
            {
                request.Deployment.PublicEndpoint = requestDeployment_deployment_PublicEndpoint;
                requestDeploymentIsNull           = false;
            }
            // determine if request.Deployment should be set to null
            if (requestDeploymentIsNull)
            {
                request.Deployment = null;
            }
            if (cmdletContext.Power != null)
            {
                request.Power = cmdletContext.Power;
            }
            if (cmdletContext.PublicDomainName != null)
            {
                request.PublicDomainNames = cmdletContext.PublicDomainName;
            }
            if (cmdletContext.Scale != null)
            {
                request.Scale = cmdletContext.Scale.Value;
            }
            if (cmdletContext.ServiceName != null)
            {
                request.ServiceName = cmdletContext.ServiceName;
            }
            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);
        }