Roll out default deployment

Roll out the default deployment for a Game Server.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


To learn how to install and use the client library for Game Servers, see Game Servers client libraries.

using Google.Cloud.Gaming.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public class UpdateRolloutDefaultConfigSample
    public async Task<GameServerDeployment> UpdateRolloutDefaultConfigAsync(
        string projectId, string deploymentId, string configId)
        // Create the client.
        GameServerDeploymentsServiceClient client = await GameServerDeploymentsServiceClient.CreateAsync();

        GameServerDeploymentRollout rollout = new GameServerDeploymentRollout
            Name = GameServerDeploymentName.FormatProjectLocationDeployment(projectId, "global", deploymentId),
            DefaultGameServerConfig = configId

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

        // 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;


To learn how to install and use the client library for Game Servers, see Game Servers client libraries.

import (

	gaming ""
	gamingpb ""

// updateRolloutDefaultConfig sets the default config for a game deployment.
func updateRolloutDefaultConfig(w io.Writer, projectID, deploymentID, configID string) error {
	// projectID := "my-project"
	// deploymentID := "mydeployment"
	// configID := "myconfig"
	ctx := context.Background()
	client, err := gaming.NewGameServerDeploymentsClient(ctx)
	if err != nil {
		return fmt.Errorf("NewGameServerDeploymentsClient: %v", err)
	defer client.Close()

	req := &gamingpb.UpdateGameServerDeploymentRolloutRequest{
		Rollout: &gamingpb.GameServerDeploymentRollout{
			Name: fmt.Sprintf("projects/%s/locations/global/gameServerDeployments/%s", projectID, deploymentID),

			DefaultGameServerConfig: configID,
		UpdateMask: &fieldmaskpb.FieldMask{
			Paths: []string{

	op, err := client.UpdateGameServerDeploymentRollout(ctx, req)
	if err != nil {
		return fmt.Errorf("UpdateGameServerDeploymentRollout: %v", err)
	resp, err := op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("Wait: %v", err)

	fmt.Fprintf(w, "Deployment rollout updated: %v", resp.Name)
	return nil


To learn how to install and use the client library for Game Servers, see Game Servers client libraries.

const {
} = require('@google-cloud/game-servers');

const client = new GameServerDeploymentsServiceClient();

async function rolloutDefaultGameServerDeployment() {
   * TODO(developer): Uncomment these variables before running the sample.
  // const projectId = 'Your Google Cloud Project ID';
  // const deploymentId = 'A unique ID for the Game Server Deployment';
  // const configId = 'A unique ID for the Game Server Config';
  const request = {
    rollout: {
      name: client.gameServerDeploymentPath(
      defaultGameServerConfig: configId,
    updateMask: {
      paths: ['default_game_server_config'],

  const [operation] = await client.updateGameServerDeploymentRollout(request);
  const [deployment] = await operation.promise();

  console.log(`Deployment updated: ${}`);



To learn how to install and use the client library for Game Servers, see Game Servers client libraries.

def update_rollout_default(project_id, deployment_id, config_id):
    """Update the rollout of a game server deployment to set the default config."""

    client = gaming.GameServerDeploymentsServiceClient()

    # Location is hard coded as global, as game server deployments can
    # only be created in global.  This is done for all operations on
    # game Server deployments, as well as for its child resource types.
    request = game_server_deployments.UpdateGameServerDeploymentRolloutRequest() = (
    request.rollout.default_game_server_config = config_id
    request.update_mask = field_mask.FieldMask(paths=["default_game_server_config"])

    operation = client.update_game_server_deployment_rollout(request)
    print(f"Update deployment rollout operation: {}")

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.