Skip to content
This repository has been archived by the owner on Jun 12, 2019. It is now read-only.

Expose client via attr_reader #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hunzinker
Copy link

Thanks for the great gem!

I propose exposing the Google::APIClient object client via attr_reader for the following:

  • Add additional authorization scopes.
  • Add additional discovered apis.

Why?

The above enable a BigQuery user to easily download a temporary table from Google Cloud storage.

Example:

bq = BigQuery::Client.new(opts)

# Perform query
# Extract data to Google Storage bucket

client = bq.client
client.authorization.scope=["https://www.googleapis.com/auth/cloud-platform"]
client.authorization.fetch_access_token! 

storage = client.discovered_api('storage', 'v1')
res = client.execute(                                                                                                                                                             
  api_method: storage.objects.get,                                                                                                                                                
  parameters: {                                                                                                                                                                   
    bucket: "bucket",                                                                                                                                                  
    object: "file.csv.gz"                                                                                                                                                      
  }                                                                                                                                                                               
) 

If you find the above scenario valid for this project, one option is expanding the initial authorization scope to cloud-platform instead of bigquery? Another is rolling in a BigQuery::Client::Download module which seems out of scope for this gem? Thoughts?

I'm happy to provide additional PRs if needed.

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant