Example #1
0
def update_rollout_override(project_id, deployment_id, config_id,
                            realm_location, realm_id):
    """Update the rollout of a game server deployment to set the override 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.name = (
        f"projects/{project_id}/locations/global/gameServerDeployments/{deployment_id}"
    )
    realm_name = f"projects/{project_id}/locations/{realm_location}/realms/{realm_id}"
    config_override = game_server_deployments.GameServerConfigOverride(
        realms_selector=common.RealmSelector(realms=[realm_name]),
        config_version=config_id,
    )
    request.rollout.game_server_config_overrides = [config_override]
    request.update_mask = field_mask.FieldMask(
        paths=["game_server_config_overrides"])

    operation = client.update_game_server_deployment_rollout(request)
    print(f"Update deployment rollout operation: {operation.operation.name}")
    operation.result(timeout=120)
def list_deployments(project_id):
    """Lists the existing game server deployments."""

    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.
    response = client.list_game_server_deployments(
        parent=f"projects/{project_id}/locations/global")

    for deployment in response.game_server_deployments:
        print(f"Name: {deployment.name}")

    return response.game_server_deployments
Example #3
0
def delete_deployment(project_id, deployment_id):
    """Deletes a game server deployment."""

    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.DeleteGameServerDeploymentRequest(
        name=f"projects/{project_id}/locations/global/gameServerDeployments/{deployment_id}",
    )

    operation = client.delete_game_server_deployment(request)
    print(f"Delete deployment operation: {operation.operation.name}")
    operation.result(timeout=120)
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.name = f"projects/{project_id}/locations/global/gameServerDeployments/{deployment_id}"
    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: {operation.operation.name}")
    operation.result(timeout=120)
Example #5
0
def get_deployment(project_id, deployment_id):
    """Gets a game server deployment."""

    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.GetGameServerDeploymentRequest(
        name=
        f"projects/{project_id}/locations/global/gameServerDeployments/{deployment_id}",
    )

    response = client.get_game_server_deployment(request)
    print(f"Get deployment response:\n{response}")
    return response
Example #6
0
def update_deployment(project_id, deployment_id):
    """Updates a game server deployment."""

    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.UpdateGameServerDeploymentRequest(
        game_server_deployment=game_server_deployments.GameServerDeployment(
            name=
            f"projects/{project_id}/locations/global/gameServerDeployments/{deployment_id}",
            labels={
                "label-key-1": "label-value-1",
                "label-key-2": "label-value-2"
            },
        ),
        update_mask=field_mask.FieldMask(paths=["labels"]),
    )

    operation = client.update_game_server_deployment(request)
    print(f"Update deployment operation: {operation.operation.name}")
    operation.result(timeout=120)