BigQuery
BigQuery copied to clipboard
Expose client via attr_reader
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!