/// <summary>Snippet for CreateGameServerConfig</summary>
        public void CreateGameServerConfigRequestObject()
        {
            // Snippet: CreateGameServerConfig(CreateGameServerConfigRequest, CallSettings)
            // Create client
            GameServerConfigsServiceClient gameServerConfigsServiceClient = GameServerConfigsServiceClient.Create();
            // Initialize request argument(s)
            CreateGameServerConfigRequest request = new CreateGameServerConfigRequest
            {
                ParentAsGameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
                ConfigId         = "",
                GameServerConfig = new GameServerConfig(),
            };
            // Make the request
            Operation <GameServerConfig, OperationMetadata> response = gameServerConfigsServiceClient.CreateGameServerConfig(request);

            // Poll until the returned long-running operation is complete
            Operation <GameServerConfig, OperationMetadata> completedResponse = response.PollUntilCompleted();
            // 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 = gameServerConfigsServiceClient.PollOnceCreateGameServerConfig(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
        }
        /// <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 stt::Task GetGameServerDeploymentRequestObjectAsync()
        {
            moq::Mock <GameServerDeploymentsService.GameServerDeploymentsServiceClient> mockGrpcClient = new moq::Mock <GameServerDeploymentsService.GameServerDeploymentsServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetGameServerDeploymentRequest request = new GetGameServerDeploymentRequest
            {
                GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
            };
            GameServerDeployment expectedResponse = new GameServerDeployment
            {
                GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Etag        = "etage8ad7218",
                Description = "description2cf9da67",
            };

            mockGrpcClient.Setup(x => x.GetGameServerDeploymentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GameServerDeployment>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            GameServerDeploymentsServiceClient client = new GameServerDeploymentsServiceClientImpl(mockGrpcClient.Object, null);
            GameServerDeployment responseCallSettings = await client.GetGameServerDeploymentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            GameServerDeployment responseCancellationToken = await client.GetGameServerDeploymentAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void GetGameServerDeploymentRolloutResourceNames()
        {
            moq::Mock <GameServerDeploymentsService.GameServerDeploymentsServiceClient> mockGrpcClient = new moq::Mock <GameServerDeploymentsService.GameServerDeploymentsServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetGameServerDeploymentRolloutRequest request = new GetGameServerDeploymentRolloutRequest
            {
                GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
            };
            GameServerDeploymentRollout expectedResponse = new GameServerDeploymentRollout
            {
                GameServerDeploymentRolloutName = GameServerDeploymentRolloutName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                DefaultGameServerConfig   = "default_game_server_config2214de2f",
                GameServerConfigOverrides =
                {
                    new GameServerConfigOverride(),
                },
                Etag = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetGameServerDeploymentRollout(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GameServerDeploymentsServiceClient client   = new GameServerDeploymentsServiceClientImpl(mockGrpcClient.Object, null);
            GameServerDeploymentRollout        response = client.GetGameServerDeploymentRollout(request.GameServerDeploymentName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetGameServerDeploymentRolloutResourceNamesAsync()
        {
            moq::Mock <GameServerDeploymentsService.GameServerDeploymentsServiceClient> mockGrpcClient = new moq::Mock <GameServerDeploymentsService.GameServerDeploymentsServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetGameServerDeploymentRolloutRequest request = new GetGameServerDeploymentRolloutRequest
            {
                GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
            };
            GameServerDeploymentRollout expectedResponse = new GameServerDeploymentRollout
            {
                GameServerDeploymentRolloutName = GameServerDeploymentRolloutName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                DefaultGameServerConfig   = "default_game_server_config2214de2f",
                GameServerConfigOverrides =
                {
                    new GameServerConfigOverride(),
                },
                Etag = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetGameServerDeploymentRolloutAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GameServerDeploymentRollout>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            GameServerDeploymentsServiceClient client = new GameServerDeploymentsServiceClientImpl(mockGrpcClient.Object, null);
            GameServerDeploymentRollout        responseCallSettings = await client.GetGameServerDeploymentRolloutAsync(request.GameServerDeploymentName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            GameServerDeploymentRollout responseCancellationToken = await client.GetGameServerDeploymentRolloutAsync(request.GameServerDeploymentName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #6
0
    public async Task <GameServerDeployment> UpdateRolloutRemoveOverrideConfigAsync(
        string projectId, string deploymentId)
    {
        // Create the client.
        GameServerDeploymentsServiceClient client = await GameServerDeploymentsServiceClient.CreateAsync();

        GameServerDeploymentRollout rollout = new GameServerDeploymentRollout
        {
            Name = GameServerDeploymentName.FormatProjectLocationDeployment(projectId, "global", deploymentId)
        };

        UpdateGameServerDeploymentRolloutRequest request = new UpdateGameServerDeploymentRolloutRequest
        {
            Rollout    = rollout,
            UpdateMask = new FieldMask {
                Paths = { "game_server_config_overrides" }
            }
        };

        // Make the request.
        Operation <GameServerDeployment, OperationMetadata> response = await client.UpdateGameServerDeploymentRolloutAsync(request);

        Operation <GameServerDeployment, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

        // Retrieve the operation result.
        return(completedResponse.Result);
    }
        public void GetGameServerDeploymentRequestObject()
        {
            moq::Mock <GameServerDeploymentsService.GameServerDeploymentsServiceClient> mockGrpcClient = new moq::Mock <GameServerDeploymentsService.GameServerDeploymentsServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetGameServerDeploymentRequest request = new GetGameServerDeploymentRequest
            {
                GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
            };
            GameServerDeployment expectedResponse = new GameServerDeployment
            {
                GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Etag        = "etage8ad7218",
                Description = "description2cf9da67",
            };

            mockGrpcClient.Setup(x => x.GetGameServerDeployment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GameServerDeploymentsServiceClient client = new GameServerDeploymentsServiceClientImpl(mockGrpcClient.Object, null);
            GameServerDeployment response             = client.GetGameServerDeployment(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
    public async Task <GameServerDeployment> UpdateDeploymentAsync(
        string projectId, string deploymentId)
    {
        // Create the client.
        GameServerDeploymentsServiceClient client = await GameServerDeploymentsServiceClient.CreateAsync();

        GameServerDeployment deployment = new GameServerDeployment
        {
            GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment(projectId, "global", deploymentId)
        };

        deployment.Labels.Add("label-key-1", "label-value-1");
        deployment.Labels.Add("label-key-2", "label-value-2");

        UpdateGameServerDeploymentRequest request = new UpdateGameServerDeploymentRequest
        {
            GameServerDeployment = deployment,
            UpdateMask           = new FieldMask {
                Paths = { "labels" }
            }
        };

        // Make the request.
        Operation <GameServerDeployment, OperationMetadata> response = await client.UpdateGameServerDeploymentAsync(request);

        Operation <GameServerDeployment, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

        // Retrieve the operation result. This result will NOT contain the updated labels.
        // If you want to get the updated resource, use a GET request on the resource.
        return(completedResponse.Result);
    }
Example #9
0
    public async Task <GameServerDeployment> CreateDeploymentAsync(
        string projectId, string deploymentId)
    {
        // Create the client.
        GameServerDeploymentsServiceClient client = await GameServerDeploymentsServiceClient.CreateAsync();

        GameServerDeployment deployment = new GameServerDeployment()
        {
            GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment(projectId, "global", deploymentId)
        };
        CreateGameServerDeploymentRequest request = new CreateGameServerDeploymentRequest
        {
            DeploymentId         = deploymentId,
            ParentAsLocationName = LocationName.FromProjectLocation(projectId, "global"),
            GameServerDeployment = deployment
        };

        // Make the request.
        Operation <GameServerDeployment, OperationMetadata> response = await client.CreateGameServerDeploymentAsync(request);

        // Poll until the returned long-running operation is complete.
        Operation <GameServerDeployment, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

        // Retrieve the operation result.
        return(completedResponse.Result);
    }
        /// <summary>Snippet for ListGameServerConfigs</summary>
        public async Task ListGameServerConfigsRequestObjectAsync()
        {
            // Snippet: ListGameServerConfigsAsync(ListGameServerConfigsRequest, CallSettings)
            // Create client
            GameServerConfigsServiceClient gameServerConfigsServiceClient = await GameServerConfigsServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListGameServerConfigsRequest request = new ListGameServerConfigsRequest
            {
                ParentAsGameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]"),
                Filter  = "",
                OrderBy = "",
            };
            // Make the request
            PagedAsyncEnumerable <ListGameServerConfigsResponse, GameServerConfig> response = gameServerConfigsServiceClient.ListGameServerConfigsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((GameServerConfig item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListGameServerConfigsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (GameServerConfig item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <GameServerConfig> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (GameServerConfig item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Example #11
0
    public GameServerDeploymentRollout GetRollout(
        string projectId, string deploymentId)
    {
        // Create the client.
        GameServerDeploymentsServiceClient client = GameServerDeploymentsServiceClient.Create();

        GetGameServerDeploymentRolloutRequest request = new GetGameServerDeploymentRolloutRequest
        {
            GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment(projectId, "global", deploymentId)
        };

        // Make the request.
        GameServerDeploymentRollout response = client.GetGameServerDeploymentRollout(request);

        return(response);
    }
Example #12
0
    public void DeleteDeployment(
        string projectId, string deploymentId)
    {
        // Create the client.
        GameServerDeploymentsServiceClient client = GameServerDeploymentsServiceClient.Create();

        DeleteGameServerDeploymentRequest request = new DeleteGameServerDeploymentRequest
        {
            GameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment(projectId, "global", deploymentId)
        };

        // Make the request.
        Operation <Empty, OperationMetadata> response = client.DeleteGameServerDeployment(request);

        // Poll until the returned long-running operation is complete.
        response.PollUntilCompleted();
    }
    public IList <GameServerConfig> ListConfigs(
        string projectId, string regionId, string deploymentId)
    {
        // Create the client.
        GameServerConfigsServiceClient client = GameServerConfigsServiceClient.Create();

        ListGameServerConfigsRequest request = new ListGameServerConfigsRequest
        {
            ParentAsGameServerDeploymentName = GameServerDeploymentName.FromProjectLocationDeployment(projectId, regionId, deploymentId)
        };

        // Make the request.
        PagedEnumerable <ListGameServerConfigsResponse, GameServerConfig> response = client.ListGameServerConfigs(request);

        // The returned sequence will lazily perform RPCs as it's being iterated over.
        return(response.ToList());
    }
        /// <summary>Snippet for ListGameServerConfigs</summary>
        public void ListGameServerConfigsResourceNames()
        {
            // Snippet: ListGameServerConfigs(GameServerDeploymentName, string, int?, CallSettings)
            // Create client
            GameServerConfigsServiceClient gameServerConfigsServiceClient = GameServerConfigsServiceClient.Create();
            // Initialize request argument(s)
            GameServerDeploymentName parent = GameServerDeploymentName.FromProjectLocationDeployment("[PROJECT]", "[LOCATION]", "[DEPLOYMENT]");
            // Make the request
            PagedEnumerable <ListGameServerConfigsResponse, GameServerConfig> response = gameServerConfigsServiceClient.ListGameServerConfigs(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (GameServerConfig item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListGameServerConfigsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (GameServerConfig item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <GameServerConfig> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (GameServerConfig item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
    public async Task <GameServerDeployment> UpdateRolloutOverrideConfigAsync(
        string projectId, string deploymentId, string configId, string realmRegionId, string realmId)
    {
        // Create the client.
        GameServerDeploymentsServiceClient client = await GameServerDeploymentsServiceClient.CreateAsync();

        GameServerConfigOverride configOverride = new GameServerConfigOverride
        {
            ConfigVersion  = configId,
            RealmsSelector = new RealmSelector()
        };

        configOverride.RealmsSelector.Realms.Add(RealmName.FormatProjectLocationRealm(projectId, realmRegionId, realmId));

        GameServerDeploymentRollout rollout = new GameServerDeploymentRollout
        {
            Name = GameServerDeploymentName.FormatProjectLocationDeployment(projectId, "global", deploymentId)
        };

        rollout.GameServerConfigOverrides.Add(configOverride);

        UpdateGameServerDeploymentRolloutRequest request = new UpdateGameServerDeploymentRolloutRequest
        {
            Rollout    = rollout,
            UpdateMask = new FieldMask {
                Paths = { "game_server_config_overrides" }
            }
        };

        // Make the request.
        Operation <GameServerDeployment, OperationMetadata> response = await client.UpdateGameServerDeploymentRolloutAsync(request);

        Operation <GameServerDeployment, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

        // Retrieve the operation result.
        return(completedResponse.Result);
    }
    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);
    }