-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(samples): fix checkstyle errors (#682)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [X] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-bigquery/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [X] Ensure the tests and linter pass - [X] Code coverage does not decrease (if any source code was changed) - [X] Appropriate docs were updated (if necessary) Fixes #681
- Loading branch information
Praful Makani
authored
Aug 19, 2020
1 parent
5acb756
commit fe5abc0
Showing
49 changed files
with
347 additions
and
365 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,9 +57,8 @@ public static void authorizedViewTutorial( | |
// [START bigquery_authorized_view_tutorial] | ||
// [START bigquery_avt_create_source_dataset] | ||
// Create a source dataset to store your table. | ||
Dataset sourceDataset = bigquery.create(DatasetInfo.of(sourceDatasetId)); | ||
final Dataset sourceDataset = bigquery.create(DatasetInfo.of(sourceDatasetId)); | ||
// [END bigquery_avt_create_source_dataset] | ||
|
||
// [START bigquery_avt_create_source_table] | ||
// Populate a source table | ||
String tableQuery = | ||
|
@@ -72,32 +71,27 @@ public static void authorizedViewTutorial( | |
.build(); | ||
bigquery.query(queryConfig); | ||
// [END bigquery_avt_create_source_table] | ||
|
||
// [START bigquery_avt_create_shared_dataset] | ||
// Create a separate dataset to store your view | ||
Dataset sharedDataset = bigquery.create(DatasetInfo.of(sharedDatasetId)); | ||
// [END bigquery_avt_create_shared_dataset] | ||
|
||
// [START bigquery_avt_create_view] | ||
// Create the view in the new dataset | ||
String viewQuery = | ||
String.format( | ||
"SELECT commit, author.name as author, committer.name as committer, repo_name FROM %s.%s.%s", | ||
"SELECT commit, author.name as author, " | ||
+ "committer.name as committer, repo_name FROM %s.%s.%s", | ||
projectId, sourceDatasetId, sourceTableId); | ||
|
||
ViewDefinition viewDefinition = ViewDefinition.of(viewQuery); | ||
|
||
Table view = | ||
bigquery.create(TableInfo.of(TableId.of(sharedDatasetId, sharedViewId), viewDefinition)); | ||
// [END bigquery_avt_create_view] | ||
|
||
// [START bigquery_avt_shared_dataset_access] | ||
// Assign access controls to the dataset containing the view | ||
List<Acl> viewAcl = new ArrayList<>(sharedDataset.getAcl()); | ||
viewAcl.add(Acl.of(new Acl.Group("[email protected]"), Acl.Role.READER)); | ||
sharedDataset.toBuilder().setAcl(viewAcl).build().update(); | ||
// [END bigquery_avt_shared_dataset_access] | ||
|
||
// [START bigquery_avt_source_dataset_access] | ||
// Authorize the view to access the source dataset | ||
List<Acl> srcAcl = new ArrayList<>(sourceDataset.getAcl()); | ||
|
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,21 +47,17 @@ public static void grantViewAccess(String srcDatasetId, String viewDatasetId, St | |
Dataset srcDataset = bigquery.getDataset(DatasetId.of(srcDatasetId)); | ||
Dataset viewDataset = bigquery.getDataset(DatasetId.of(viewDatasetId)); | ||
Table view = viewDataset.get(viewId); | ||
|
||
// First, we'll add a group to the ACL for the dataset containing the view. This will allow | ||
// users within that group to query the view, but they must have direct access to any tables | ||
// referenced by the view. | ||
List<Acl> viewAcl = new ArrayList<>(); | ||
viewAcl.addAll(viewDataset.getAcl()); | ||
List<Acl> viewAcl = new ArrayList<>(viewDataset.getAcl()); | ||
viewAcl.add(Acl.of(new Acl.Group("[email protected]"), Acl.Role.READER)); | ||
viewDataset.toBuilder().setAcl(viewAcl).build().update(); | ||
|
||
// Now, we'll authorize a specific view against a source dataset, delegating access | ||
// enforcement. Once this has been completed, members of the group previously added to the | ||
// view dataset's ACL no longer require access to the source dataset to successfully query the | ||
// view | ||
List<Acl> srcAcl = new ArrayList<>(); | ||
srcAcl.addAll(srcDataset.getAcl()); | ||
List<Acl> srcAcl = new ArrayList<>(srcDataset.getAcl()); | ||
srcAcl.add(Acl.of(new Acl.View(view.getTableId()))); | ||
srcDataset.toBuilder().setAcl(srcAcl).build().update(); | ||
System.out.println("Grant view access successfully"); | ||
|
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
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
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
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
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
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
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
Oops, something went wrong.