public async Task <GameServerCluster> UpdateClusterAsync( string projectId, string regionId, string realmId, string clusterId) { // Create the client. GameServerClustersServiceClient client = await GameServerClustersServiceClient.CreateAsync(); GameServerCluster cluster = new GameServerCluster() { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster(projectId, regionId, realmId, clusterId) }; cluster.Labels.Add("label-key-1", "label-value-1"); cluster.Labels.Add("label-key-2", "label-value-2"); UpdateGameServerClusterRequest request = new UpdateGameServerClusterRequest { GameServerCluster = cluster, UpdateMask = new FieldMask { Paths = { "labels" } } }; // Make the request. Operation <GameServerCluster, OperationMetadata> response = await client.UpdateGameServerClusterAsync(request); Operation <GameServerCluster, 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); }
public async Task <GameServerCluster> CreateClusterAsync( string projectId, string regionId, string realmId, string clusterId, string gkeName) { // Create the client. GameServerClustersServiceClient client = await GameServerClustersServiceClient.CreateAsync(); GameServerCluster cluster = new GameServerCluster() { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster(projectId, regionId, realmId, clusterId), ConnectionInfo = new GameServerClusterConnectionInfo { GkeClusterReference = new GkeClusterReference { Cluster = gkeName }, Namespace = "default" } }; CreateGameServerClusterRequest request = new CreateGameServerClusterRequest { ParentAsRealmName = RealmName.FromProjectLocationRealm(projectId, regionId, realmId), GameServerClusterId = clusterId, GameServerCluster = cluster }; // Make the request. Operation <GameServerCluster, OperationMetadata> response = await client.CreateGameServerClusterAsync(request); // Poll until the returned long-running operation is complete. Operation <GameServerCluster, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result. return(completedResponse.Result); }