Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Latest commit

 

History

History
755 lines (429 loc) · 23.2 KB

README.rst

File metadata and controls

755 lines (429 loc) · 23.2 KB

Google Cloud Game Servers Python Samples

image

This directory contains samples for Google Cloud Game Servers. The Google Cloud Game Servers is a managed service that enables game developers to deploy and manage their dedicated game servers across multiple Agones clusters around the world through a single interface.

Setup

Authentication

This sample requires you to have authentication setup. Refer to the Authentication Getting Started Guide for instructions on setting up credentials for applications.

Install Dependencies

  1. Clone python-docs-samples and change directory to the sample directory you want to use.

    $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
  2. Install pip and virtualenv if you do not already have them. You may want to refer to the Python Development Environment Setup Guide for Google Cloud Platform for instructions.

  3. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

    $ virtualenv env
    $ source env/bin/activate
  4. Install the dependencies needed to run the samples.

    $ pip install -r requirements.txt

Samples

Create game server deployment

image

To run this sample:

$ python create_deployment.py

usage: create_deployment.py [-h] --project-id PROJECT_ID --deployment-id
                            DEPLOYMENT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.

Delete game server deployment

image

To run this sample:

$ python delete_deployment.py

usage: delete_deployment.py [-h] --project-id PROJECT_ID --deployment-id
                            DEPLOYMENT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.

Get game server deployment

image

To run this sample:

$ python get_deployment.py

usage: get_deployment.py [-h] --project-id PROJECT_ID --deployment-id
                         DEPLOYMENT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.

Update game server deployment

image

To run this sample:

$ python update_deployment.py

usage: update_deployment.py [-h] --project-id PROJECT_ID --deployment-id
                            DEPLOYMENT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.

Get rollout

image

To run this sample:

$ python get_rollout.py

usage: get_rollout.py [-h] --project-id PROJECT_ID --deployment-id
                      DEPLOYMENT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.

List game server deployments

image

To run this sample:

$ python list_deployments.py

usage: list_deployments.py [-h] --project-id PROJECT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.

Update rollout to set default config

image

To run this sample:

$ python update_rollout_default.py

usage: update_rollout_default.py [-h] --project-id PROJECT_ID --deployment-id
                                 DEPLOYMENT_ID --config-id CONFIG_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.
  --config-id CONFIG_ID
                        Your game server config ID.

Update rollout to set override config

image

To run this sample:

$ python update_rollout_override.py

usage: update_rollout_override.py [-h] --project-id PROJECT_ID --deployment-id
                                  DEPLOYMENT_ID --config-id CONFIG_ID
                                  --realm-location REALM_LOCATION --realm-id
                                  REALM_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.
  --config-id CONFIG_ID
                        Your game server config ID.
  --realm-location REALM_LOCATION
                        Your game server config ID.
  --realm-id REALM_ID   Your game server config ID.

Update rollout to remove default config

image

To run this sample:

$ python update_rollout_remove_default.py

usage: update_rollout_remove_default.py [-h] --project-id PROJECT_ID
                                        --deployment-id DEPLOYMENT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.

Update rollout to remove override config

image

To run this sample:

$ python update_rollout_remove_override.py

usage: update_rollout_remove_override.py [-h] --project-id PROJECT_ID
                                         --deployment-id DEPLOYMENT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.

Create game server config

image

To run this sample:

$ python create_config.py

usage: create_config.py [-h] --project-id PROJECT_ID --deployment-id
                        DEPLOYMENT_ID --config-id CONFIG_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.
  --config-id CONFIG_ID
                        Your game server config ID.

Delete game server config

image

To run this sample:

$ python delete_config.py

usage: delete_config.py [-h] --project-id PROJECT_ID --deployment-id
                        DEPLOYMENT_ID --config-id CONFIG_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.
  --config-id CONFIG_ID
                        Your game server config ID.

Get game server config

image

To run this sample:

$ python get_config.py

usage: get_config.py [-h] --project-id PROJECT_ID --deployment-id
                     DEPLOYMENT_ID --config-id CONFIG_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.
  --config-id CONFIG_ID
                        Your game server config ID.

List game server configs

image

To run this sample:

$ python list_configs.py

usage: list_configs.py [-h] --project-id PROJECT_ID --deployment-id
                       DEPLOYMENT_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --deployment-id DEPLOYMENT_ID
                        Your game server deployment ID.

Create realm

image

To run this sample:

$ python create_realm.py

usage: create_realm.py [-h] --project-id PROJECT_ID --location LOCATION
                       --realm-id REALM_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.

Delete realm

image

To run this sample:

$ python delete_realm.py

usage: delete_realm.py [-h] --project-id PROJECT_ID --location LOCATION
                       --realm-id REALM_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.

Get realm

image

To run this sample:

$ python get_realm.py

usage: get_realm.py [-h] --project-id PROJECT_ID --location LOCATION
                    --realm-id REALM_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.

Update realm

image

To run this sample:

$ python update_realm.py

usage: update_realm.py [-h] --project-id PROJECT_ID --location LOCATION
                       --realm-id REALM_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.

List realms

image

To run this sample:

$ python list_realms.py

usage: list_realms.py [-h] --project-id PROJECT_ID --location LOCATION

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.

Create game server cluster

image

To run this sample:

$ python create_cluster.py

usage: create_cluster.py [-h] --project-id PROJECT_ID --location LOCATION
                         --realm-id REALM_ID --cluster-id CLUSTER_ID
                         --gke-cluster-name GKE_CLUSTER_NAME

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.
  --cluster-id CLUSTER_ID
                        Your game server cluster ID.
  --gke-cluster-name GKE_CLUSTER_NAME
                        The name of the GKE cluster which is managed by the
                        game server cluster being created.

Delete game server cluster

image

To run this sample:

$ python delete_cluster.py

usage: delete_cluster.py [-h] --project-id PROJECT_ID --location LOCATION
                         --realm-id REALM_ID --cluster-id CLUSTER_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.
  --cluster-id CLUSTER_ID
                        Your game server cluster ID.

Get game server cluster

image

To run this sample:

$ python get_cluster.py

usage: get_cluster.py [-h] --project-id PROJECT_ID --location LOCATION
                      --realm-id REALM_ID --cluster-id CLUSTER_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.
  --cluster-id CLUSTER_ID
                        Your game server cluster ID.

Update game server cluster

image

To run this sample:

$ python update_cluster.py

usage: update_cluster.py [-h] --project-id PROJECT_ID --location LOCATION
                         --realm-id REALM_ID --cluster-id CLUSTER_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.
  --cluster-id CLUSTER_ID
                        Your game server cluster ID.

List game server cluster

image

To run this sample:

$ python list_clusters.py

usage: list_clusters.py [-h] --project-id PROJECT_ID --location LOCATION
                        --realm-id REALM_ID

optional arguments:
  -h, --help            show this help message and exit
  --project-id PROJECT_ID
                        Your cloud project ID.
  --location LOCATION   Your realm location.
  --realm-id REALM_ID   Your realm ID.

The client library

This sample uses the Google Cloud Client Library for Python. You can read the documentation for more details on API usage and use GitHub to browse the source and report issues.