18
18
19
19
import googleapiclient .discovery
20
20
21
- # Currently only the "global" region is supported
22
- REGION = 'global'
23
-
24
21
25
22
# [START list_clusters]
26
- def list_clusters (dataproc , project ):
23
+ def list_clusters (dataproc , project , region ):
27
24
result = dataproc .projects ().regions ().clusters ().list (
28
25
projectId = project ,
29
- region = REGION ).execute ()
26
+ region = region ).execute ()
30
27
return result
31
28
# [END list_clusters]
32
29
@@ -39,9 +36,9 @@ def get_client():
39
36
# [END get_client]
40
37
41
38
42
- def main (project_id , zone ):
39
+ def main (project_id , region ):
43
40
dataproc = get_client ()
44
- result = list_clusters (dataproc , project_id )
41
+ result = list_clusters (dataproc , project_id , region )
45
42
print (result )
46
43
47
44
@@ -52,8 +49,10 @@ def main(project_id, zone):
52
49
)
53
50
parser .add_argument (
54
51
'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
55
54
parser .add_argument (
56
- 'zone ' , help = 'Region to create clusters in' )
55
+ '--region' , default = 'global ' , help = 'Region to create clusters in' )
57
56
58
57
args = parser .parse_args ()
59
- main (args .project_id , args .zone )
58
+ main (args .project_id , args .region )
0 commit comments