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

Commit

Permalink
docs(samples): show cluster installation state details for get and li…
Browse files Browse the repository at this point in the history
…st methods (#188)

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [X] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-game-servers/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [X] Ensure the tests and linter pass
- [X] Code coverage does not decrease (if any source code was changed)
- [X] Appropriate docs were updated (if necessary)

Fixes b:179738605 🦕
  • Loading branch information
irataxy committed Sep 27, 2021
1 parent 3a701f7 commit e324a29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
13 changes: 9 additions & 4 deletions samples/snippets/get_cluster.py
Expand Up @@ -34,20 +34,25 @@ def get_cluster(project_id, location, realm_id, cluster_id):

request = game_server_clusters.GetGameServerClusterRequest(
name=f"projects/{project_id}/locations/{location}/realms/{realm_id}/gameServerClusters/{cluster_id}",
view=game_server_clusters.GameServerClusterView.FULL,
)

response = client.get_game_server_cluster(request)
print(f"Get cluster response:\n{response}")
return response


# [END cloud_game_servers_cluster_get]


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--project-id', help='Your cloud project ID.', required=True)
parser.add_argument('--location', help='Your realm location.', required=True)
parser.add_argument('--realm-id', help='Your realm ID.', required=True)
parser.add_argument('--cluster-id', help='Your game server cluster ID.', required=True)
parser.add_argument("--project-id", help="Your cloud project ID.", required=True)
parser.add_argument("--location", help="Your realm location.", required=True)
parser.add_argument("--realm-id", help="Your realm ID.", required=True)
parser.add_argument(
"--cluster-id", help="Your game server cluster ID.", required=True
)

args = parser.parse_args()

Expand Down
15 changes: 11 additions & 4 deletions samples/snippets/list_clusters.py
Expand Up @@ -23,6 +23,7 @@
import argparse

from google.cloud import gaming
from google.cloud.gaming_v1.types import game_server_clusters


# [START cloud_game_servers_cluster_list]
Expand All @@ -32,21 +33,27 @@ def list_clusters(project_id, location, realm_id):
client = gaming.GameServerClustersServiceClient()

response = client.list_game_server_clusters(
parent=f"projects/{project_id}/locations/{location}/realms/{realm_id}"
request=game_server_clusters.ListGameServerClustersRequest(
parent=f"projects/{project_id}/locations/{location}/realms/{realm_id}",
view=game_server_clusters.GameServerClusterView.FULL,
)
)

for cluster in response.game_server_clusters:
print(f"Name: {cluster.name}")
print(f"State:\n{cluster.cluster_state}")

return response.game_server_clusters


# [END cloud_game_servers_cluster_list]


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--project-id', help='Your cloud project ID.', required=True)
parser.add_argument('--location', help='Your realm location.', required=True)
parser.add_argument('--realm-id', help='Your realm ID.', required=True)
parser.add_argument("--project-id", help="Your cloud project ID.", required=True)
parser.add_argument("--location", help="Your realm location.", required=True)
parser.add_argument("--realm-id", help="Your realm ID.", required=True)

args = parser.parse_args()

Expand Down

0 comments on commit e324a29

Please sign in to comment.