Example #1
0
 private Amazon.GameLift.Model.CreateGameServerGroupResponse CallAWSServiceOperation(IAmazonGameLift client, Amazon.GameLift.Model.CreateGameServerGroupRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon GameLift Service", "CreateGameServerGroup");
     try
     {
         #if DESKTOP
         return(client.CreateGameServerGroup(request));
         #elif CORECLR
         return(client.CreateGameServerGroupAsync(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;
     }
 }
Example #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.GameLift.Model.CreateGameServerGroupRequest();


            // populate AutoScalingPolicy
            var requestAutoScalingPolicyIsNull = true;

            request.AutoScalingPolicy = new Amazon.GameLift.Model.GameServerGroupAutoScalingPolicy();
            System.Int32?requestAutoScalingPolicy_autoScalingPolicy_EstimatedInstanceWarmup = null;
            if (cmdletContext.AutoScalingPolicy_EstimatedInstanceWarmup != null)
            {
                requestAutoScalingPolicy_autoScalingPolicy_EstimatedInstanceWarmup = cmdletContext.AutoScalingPolicy_EstimatedInstanceWarmup.Value;
            }
            if (requestAutoScalingPolicy_autoScalingPolicy_EstimatedInstanceWarmup != null)
            {
                request.AutoScalingPolicy.EstimatedInstanceWarmup = requestAutoScalingPolicy_autoScalingPolicy_EstimatedInstanceWarmup.Value;
                requestAutoScalingPolicyIsNull = false;
            }
            Amazon.GameLift.Model.TargetTrackingConfiguration requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration = null;

            // populate TargetTrackingConfiguration
            var requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfigurationIsNull = true;

            requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration = new Amazon.GameLift.Model.TargetTrackingConfiguration();
            System.Double?requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration_targetTrackingConfiguration_TargetValue = null;
            if (cmdletContext.TargetTrackingConfiguration_TargetValue != null)
            {
                requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration_targetTrackingConfiguration_TargetValue = cmdletContext.TargetTrackingConfiguration_TargetValue.Value;
            }
            if (requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration_targetTrackingConfiguration_TargetValue != null)
            {
                requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration.TargetValue = requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration_targetTrackingConfiguration_TargetValue.Value;
                requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfigurationIsNull       = false;
            }
            // determine if requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration should be set to null
            if (requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfigurationIsNull)
            {
                requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration = null;
            }
            if (requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration != null)
            {
                request.AutoScalingPolicy.TargetTrackingConfiguration = requestAutoScalingPolicy_autoScalingPolicy_TargetTrackingConfiguration;
                requestAutoScalingPolicyIsNull = false;
            }
            // determine if request.AutoScalingPolicy should be set to null
            if (requestAutoScalingPolicyIsNull)
            {
                request.AutoScalingPolicy = null;
            }
            if (cmdletContext.BalancingStrategy != null)
            {
                request.BalancingStrategy = cmdletContext.BalancingStrategy;
            }
            if (cmdletContext.GameServerGroupName != null)
            {
                request.GameServerGroupName = cmdletContext.GameServerGroupName;
            }
            if (cmdletContext.GameServerProtectionPolicy != null)
            {
                request.GameServerProtectionPolicy = cmdletContext.GameServerProtectionPolicy;
            }
            if (cmdletContext.InstanceDefinition != null)
            {
                request.InstanceDefinitions = cmdletContext.InstanceDefinition;
            }

            // populate LaunchTemplate
            var requestLaunchTemplateIsNull = true;

            request.LaunchTemplate = new Amazon.GameLift.Model.LaunchTemplateSpecification();
            System.String requestLaunchTemplate_launchTemplate_LaunchTemplateId = null;
            if (cmdletContext.LaunchTemplate_LaunchTemplateId != null)
            {
                requestLaunchTemplate_launchTemplate_LaunchTemplateId = cmdletContext.LaunchTemplate_LaunchTemplateId;
            }
            if (requestLaunchTemplate_launchTemplate_LaunchTemplateId != null)
            {
                request.LaunchTemplate.LaunchTemplateId = requestLaunchTemplate_launchTemplate_LaunchTemplateId;
                requestLaunchTemplateIsNull             = false;
            }
            System.String requestLaunchTemplate_launchTemplate_LaunchTemplateName = null;
            if (cmdletContext.LaunchTemplate_LaunchTemplateName != null)
            {
                requestLaunchTemplate_launchTemplate_LaunchTemplateName = cmdletContext.LaunchTemplate_LaunchTemplateName;
            }
            if (requestLaunchTemplate_launchTemplate_LaunchTemplateName != null)
            {
                request.LaunchTemplate.LaunchTemplateName = requestLaunchTemplate_launchTemplate_LaunchTemplateName;
                requestLaunchTemplateIsNull = false;
            }
            System.String requestLaunchTemplate_launchTemplate_Version = null;
            if (cmdletContext.LaunchTemplate_Version != null)
            {
                requestLaunchTemplate_launchTemplate_Version = cmdletContext.LaunchTemplate_Version;
            }
            if (requestLaunchTemplate_launchTemplate_Version != null)
            {
                request.LaunchTemplate.Version = requestLaunchTemplate_launchTemplate_Version;
                requestLaunchTemplateIsNull    = false;
            }
            // determine if request.LaunchTemplate should be set to null
            if (requestLaunchTemplateIsNull)
            {
                request.LaunchTemplate = null;
            }
            if (cmdletContext.MaxSize != null)
            {
                request.MaxSize = cmdletContext.MaxSize.Value;
            }
            if (cmdletContext.MinSize != null)
            {
                request.MinSize = cmdletContext.MinSize.Value;
            }
            if (cmdletContext.RoleArn != null)
            {
                request.RoleArn = cmdletContext.RoleArn;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.VpcSubnet != null)
            {
                request.VpcSubnets = cmdletContext.VpcSubnet;
            }

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