1818
1919import googleapiclient .discovery
2020
21- # Currently only the "global" region is supported
22- REGION = 'global'
23-
2421
2522# [START list_clusters]
26- def list_clusters (dataproc , project ):
23+ def list_clusters (dataproc , project , region ):
2724 result = dataproc .projects ().regions ().clusters ().list (
2825 projectId = project ,
29- region = REGION ).execute ()
26+ region = region ).execute ()
3027 return result
3128# [END list_clusters]
3229
@@ -39,9 +36,9 @@ def get_client():
3936# [END get_client]
4037
4138
42- def main (project_id , zone ):
39+ def main (project_id , region ):
4340 dataproc = get_client ()
44- result = list_clusters (dataproc , project_id )
41+ result = list_clusters (dataproc , project_id , region )
4542 print (result )
4643
4744
@@ -52,8 +49,10 @@ def main(project_id, zone):
5249 )
5350 parser .add_argument (
5451 'project_id' , help = 'Project ID you want to access.' ),
52+ # Sets the region to "global" if it's not provided
53+ # Note: sub-regions (e.g.: us-central1-a/b) are currently not supported
5554 parser .add_argument (
56- 'zone ' , help = 'Region to create clusters in' )
55+ '--region' , default = 'global ' , help = 'Region to create clusters in' )
5756
5857 args = parser .parse_args ()
59- main (args .project_id , args .zone )
58+ main (args .project_id , args .region )
0 commit comments