Last active
March 24, 2017 18:01
-
-
Save lukwam/1c738349ff48da61cdff90638589f01c to your computer and use it in GitHub Desktop.
function to run bigquery.projects().list()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_projects(self, credentials): | |
"""Return list of BigQuery projects.""" | |
bq = build('bigquery', 'v2', credentials=credentials) | |
projects = bq.projects() | |
request = projects.list(maxResults=10) | |
google_projects = [] | |
while request is not None: | |
projects_list = request.execute() | |
google_projects += projects_list.get('projects', []) | |
print '%s: %s' % (len(google_projects), datetime.datetime.now()) | |
request = projects.list_next(request, projects_list) | |
return google_projects |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment