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

Commit

Permalink
Properly forwarding the "region" parameter provided as an input argum…
Browse files Browse the repository at this point in the history
  • Loading branch information
gioiab authored and Jon Wayne Parrott committed Jul 21, 2017
1 parent 668510b commit 86abc22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion samples/snippets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Create local credentials by running the following command and following the oaut

To run list_clusters.py:

python list_clusters.py --project_id=<YOUR-PROJECT-ID> --zone=us-central1-b
python list_clusters.py <YOUR-PROJECT-ID> --region=us-central1


To run create_cluster_and_submit_job, first create a GCS bucket, from the Cloud Console or with
Expand Down
17 changes: 8 additions & 9 deletions samples/snippets/list_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@

import googleapiclient.discovery

# Currently only the "global" region is supported
REGION = 'global'


# [START list_clusters]
def list_clusters(dataproc, project):
def list_clusters(dataproc, project, region):
result = dataproc.projects().regions().clusters().list(
projectId=project,
region=REGION).execute()
region=region).execute()
return result
# [END list_clusters]

Expand All @@ -39,9 +36,9 @@ def get_client():
# [END get_client]


def main(project_id, zone):
def main(project_id, region):
dataproc = get_client()
result = list_clusters(dataproc, project_id)
result = list_clusters(dataproc, project_id, region)
print(result)


Expand All @@ -52,8 +49,10 @@ def main(project_id, zone):
)
parser.add_argument(
'project_id', help='Project ID you want to access.'),
# Sets the region to "global" if it's not provided
# Note: sub-regions (e.g.: us-central1-a/b) are currently not supported
parser.add_argument(
'zone', help='Region to create clusters in')
'--region', default='global', help='Region to create clusters in')

args = parser.parse_args()
main(args.project_id, args.zone)
main(args.project_id, args.region)

0 comments on commit 86abc22

Please sign in to comment.