/// <summary>Snippet for CreateGameServerConfigAsync</summary> public async Task CreateGameServerConfigResourceNamesAsync() { // Snippet: CreateGameServerConfigAsync(GameServerDeploymentName, GameServerConfig, CallSettings) // Additional: CreateGameServerConfigAsync(GameServerDeploymentName, GameServerConfig, CancellationToken) // Create client GameServerConfigsServiceClient gameServerConfigsServiceClient = await GameServerConfigsServiceClient.CreateAsync(); // Initialize request argument(s) GameServerDeploymentName parent = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"); GameServerConfig gameServerConfig = new GameServerConfig(); // Make the request Operation <GameServerConfig, OperationMetadata> response = await gameServerConfigsServiceClient.CreateGameServerConfigAsync(parent, gameServerConfig); // Poll until the returned long-running operation is complete Operation <GameServerConfig, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result GameServerConfig result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <GameServerConfig, OperationMetadata> retrievedResponse = await gameServerConfigsServiceClient.PollOnceCreateGameServerConfigAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result GameServerConfig retrievedResult = retrievedResponse.Result; } // End snippet }
public async Task <GameServerConfig> CreateConfigAsync( string projectId, string regionId, string deploymentId, string configId) { // Create the client. GameServerConfigsServiceClient client = await GameServerConfigsServiceClient.CreateAsync(); GameServerConfig config = new GameServerConfig { GameServerConfigName = GameServerConfigName.FromProjectLocationDeploymentConfig(projectId, regionId, deploymentId, configId), Description = "My Game Server Config", FleetConfigs = { new FleetConfig { Name = "fleet-spec-1", FleetSpec = JsonConvert.SerializeObject(new { replicas = 10, scheduling = "Packed", strategy = new { type = "RollingUpdate", rollingUpdate = new { maxSurge = "25%", maxUnavailable = "25%", } }, template = new { metadata = new { labels = new { gameName = "udp-server", } }, spec = new { ports = new [] { new { name = "default", portPolicy = "Dynamic", containerPort = 7654, protocol = "UDP", } }, health = new { initialDelaySeconds = 30, periodSeconds = 60, }, sdkServer = new { logLevel = "Info", grpcPort = 9357, httpPort = 9358, }, template = new { spec = new { containers = new []{ new { name = "dedicated", image = "gcr.io/agones-images/udp-server:0.21", imagePullPolicy = "Always", resources = new { requests = new { memory = "200Mi", cpu = "500m", }, limits = new { memory = "200Mi", cpu = "500m", } } } } } } } } }) } } }; CreateGameServerConfigRequest request = new CreateGameServerConfigRequest { ParentAsGameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment(projectId, regionId, deploymentId), ConfigId = configId, GameServerConfig = config }; // Make the request. Operation <GameServerConfig, OperationMetadata> response = await client.CreateGameServerConfigAsync(request); // Poll until the returned long-running operation is complete. Operation <GameServerConfig, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result. return(completedResponse.Result); }