0
votes

I'm making an open data website powered by BigQuery. How do I make a Bigquery dataset public using command line tool or Python?

Note I tried to make every dataset in my project public but got an unexplained error. In project permission settings via WebUI under "Add members" I put allAuthenticatedUsers and did the permission Data Viewer. The error was "Error Sorry, there’s a problem. If you entered information, check it and try again. Otherwise, the problem might clear up on its own, so check back later."

I wasn't able to find any command line examples for updating permissions. I also can't find a JSON string to pass to https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/update

1
Does it have to be via the CLI or Python (you can do it easily in the Web UI)? - Graham Polley
@GrahamPolley yes it needs to be pro-grammatical because I'm building a web interface to BigQuery. - WayEasy Corporation
Roger that. See answer. - Graham Polley

1 Answers

0
votes

To achieve this programatically, you need to use a dataset patch request and use the specialGroup item with the value allAuthenticatedUsers, like so:

{  
"datasetReference":{  
  "projectId":"<removed>",
  "datasetId":"<removed>"
},
"access":[  
  ... //other access roles
  {  
     "specialGroup":"allAuthenticatedUsers",
     "role":"READER"
  }
 ]
}

Note: You should use a read-modify-write cycle as described here & here:

Note about arrays: Patch requests that contain arrays replace the existing array with the one you provide. You cannot modify, add, or delete items in an array in a piecemeal fashion.