From e324a29030b4906f2704a2bae4000f854bb8bdc9 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Mon, 27 Sep 2021 09:14:21 -0700 Subject: [PATCH] docs(samples): show cluster installation state details for get and list methods (#188) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 🦕 --- samples/snippets/get_cluster.py | 13 +++++++++---- samples/snippets/list_clusters.py | 15 +++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/samples/snippets/get_cluster.py b/samples/snippets/get_cluster.py index 1cc6c25e..6a3cbba4 100644 --- a/samples/snippets/get_cluster.py +++ b/samples/snippets/get_cluster.py @@ -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() diff --git a/samples/snippets/list_clusters.py b/samples/snippets/list_clusters.py index 5d31a526..6b8adf73 100644 --- a/samples/snippets/list_clusters.py +++ b/samples/snippets/list_clusters.py @@ -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] @@ -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()