2121import com .google .api .gax .rpc .NotFoundException ;
2222import com .google .api .gax .rpc .PermissionDeniedException ;
2323import com .google .api .gax .rpc .ServerStream ;
24+ import com .google .bigtable .admin .v2 .AuthorizedView ;
25+ import com .google .bigtable .admin .v2 .AuthorizedViewName ;
26+ import com .google .bigtable .admin .v2 .ColumnFamily ;
27+ import com .google .bigtable .admin .v2 .CreateAuthorizedViewRequest ;
28+ import com .google .bigtable .admin .v2 .CreateTableRequest ;
29+ import com .google .bigtable .admin .v2 .GetTableRequest ;
30+ import com .google .bigtable .admin .v2 .ListAuthorizedViewsRequest ;
31+ import com .google .bigtable .admin .v2 .Table ;
32+ import com .google .bigtable .admin .v2 .UpdateAuthorizedViewRequest ;
2433import com .google .cloud .bigtable .admin .v2 .BaseBigtableTableAdminSettings ;
2534import com .google .cloud .bigtable .admin .v2 .BigtableTableAdminClientV2 ;
2635import com .google .cloud .bigtable .data .v2 .BigtableDataClient ;
@@ -90,9 +99,9 @@ public AuthorizedViewExample(
9099 private boolean exists (String tableId ) {
91100 try {
92101 adminClient .getTable (
93- com . google . bigtable . admin . v2 . GetTableRequest .newBuilder ()
102+ GetTableRequest .newBuilder ()
94103 .setName ("projects/" + projectId + "/instances/" + instanceId + "/tables/" + tableId )
95- .setView (com . google . bigtable . admin . v2 . Table .View .NAME_ONLY )
104+ .setView (Table .View .NAME_ONLY )
96105 .build ());
97106 return true ;
98107 } catch (com .google .api .gax .rpc .NotFoundException e ) {
@@ -123,18 +132,16 @@ public void createTable() {
123132 // Checks if table exists, creates table if it does not exist.
124133 if (!exists (tableId )) {
125134 System .out .println ("Table does not exist, creating table: " + tableId );
126- com . google . bigtable . admin . v2 . CreateTableRequest request =
127- com . google . bigtable . admin . v2 . CreateTableRequest .newBuilder ()
135+ CreateTableRequest request =
136+ CreateTableRequest .newBuilder ()
128137 .setParent ("projects/" + projectId + "/instances/" + instanceId )
129138 .setTableId (tableId )
130139 .setTable (
131- com .google .bigtable .admin .v2 .Table .newBuilder ()
132- .putColumnFamilies (
133- COLUMN_FAMILY ,
134- com .google .bigtable .admin .v2 .ColumnFamily .getDefaultInstance ())
140+ Table .newBuilder ()
141+ .putColumnFamilies (COLUMN_FAMILY , ColumnFamily .getDefaultInstance ())
135142 .build ())
136143 .build ();
137- com . google . bigtable . admin . v2 . Table table = adminClient .createTable (request );
144+ Table table = adminClient .createTable (request );
138145 System .out .printf ("Table: %s created successfully%n" , table .getName ());
139146 }
140147 }
@@ -170,29 +177,26 @@ public void createAuthorizedView() {
170177 System .out .printf ("%nCreating authorized view %s in table %s%n" , authorizedViewId , tableId );
171178 // [START bigtable_create_authorized_view]
172179 try {
173- com . google . bigtable . admin . v2 . AuthorizedView .SubsetView subsetView =
174- com . google . bigtable . admin . v2 . AuthorizedView .SubsetView .newBuilder ()
180+ AuthorizedView .SubsetView subsetView =
181+ AuthorizedView .SubsetView .newBuilder ()
175182 .addRowPrefixes (com .google .protobuf .ByteString .EMPTY )
176183 .putFamilySubsets (
177184 COLUMN_FAMILY ,
178- com . google . bigtable . admin . v2 . AuthorizedView .FamilySubsets .newBuilder ()
185+ AuthorizedView .FamilySubsets .newBuilder ()
179186 .addQualifierPrefixes (
180187 com .google .protobuf .ByteString .copyFromUtf8 (COLUMN_QUALIFIER_NAME ))
181188 .build ())
182189 .build ();
183- com .google .bigtable .admin .v2 .AuthorizedView authorizedViewObj =
184- com .google .bigtable .admin .v2 .AuthorizedView .newBuilder ()
185- .setSubsetView (subsetView )
186- .build ();
187- com .google .bigtable .admin .v2 .CreateAuthorizedViewRequest request =
188- com .google .bigtable .admin .v2 .CreateAuthorizedViewRequest .newBuilder ()
190+ AuthorizedView authorizedViewObj =
191+ AuthorizedView .newBuilder ().setSubsetView (subsetView ).build ();
192+ CreateAuthorizedViewRequest request =
193+ CreateAuthorizedViewRequest .newBuilder ()
189194 .setParent (
190195 "projects/" + projectId + "/instances/" + instanceId + "/tables/" + tableId )
191196 .setAuthorizedViewId (authorizedViewId )
192197 .setAuthorizedView (authorizedViewObj )
193198 .build ();
194- com .google .bigtable .admin .v2 .AuthorizedView authorizedView =
195- adminClient .createAuthorizedViewAsync (request ).get ();
199+ AuthorizedView authorizedView = adminClient .createAuthorizedViewAsync (request ).get ();
196200 System .out .printf ("AuthorizedView: %s created successfully%n" , authorizedView .getName ());
197201 } catch (Exception e ) {
198202 System .err .println ("Failed to create an authorized view: " + e .getMessage ());
@@ -207,17 +211,17 @@ public void updateAuthorizedView() {
207211 // [START bigtable_update_authorized_view]
208212 try {
209213 // Update to an authorized view permitting everything.
210- com . google . bigtable . admin . v2 . AuthorizedView .SubsetView subsetView =
211- com . google . bigtable . admin . v2 . AuthorizedView .SubsetView .newBuilder ()
214+ AuthorizedView .SubsetView subsetView =
215+ AuthorizedView .SubsetView .newBuilder ()
212216 .addRowPrefixes (com .google .protobuf .ByteString .EMPTY )
213217 .putFamilySubsets (
214218 COLUMN_FAMILY ,
215- com . google . bigtable . admin . v2 . AuthorizedView .FamilySubsets .newBuilder ()
219+ AuthorizedView .FamilySubsets .newBuilder ()
216220 .addQualifierPrefixes (com .google .protobuf .ByteString .EMPTY )
217221 .build ())
218222 .build ();
219- com . google . bigtable . admin . v2 . AuthorizedView authorizedViewObj =
220- com . google . bigtable . admin . v2 . AuthorizedView .newBuilder ()
223+ AuthorizedView authorizedViewObj =
224+ AuthorizedView .newBuilder ()
221225 .setSubsetView (subsetView )
222226 .setName (
223227 "projects/"
@@ -229,14 +233,13 @@ public void updateAuthorizedView() {
229233 + "/authorizedViews/"
230234 + authorizedViewId )
231235 .build ();
232- com . google . bigtable . admin . v2 . UpdateAuthorizedViewRequest request =
233- com . google . bigtable . admin . v2 . UpdateAuthorizedViewRequest .newBuilder ()
236+ UpdateAuthorizedViewRequest request =
237+ UpdateAuthorizedViewRequest .newBuilder ()
234238 .setAuthorizedView (authorizedViewObj )
235239 .setUpdateMask (
236240 com .google .protobuf .FieldMask .newBuilder ().addPaths ("subset_view" ).build ())
237241 .build ();
238- com .google .bigtable .admin .v2 .AuthorizedView authorizedView =
239- adminClient .updateAuthorizedViewAsync (request ).get ();
242+ AuthorizedView authorizedView = adminClient .updateAuthorizedViewAsync (request ).get ();
240243 System .out .printf ("AuthorizedView: %s updated successfully%n" , authorizedView .getName ());
241244 } catch (Exception e ) {
242245 System .err .println ("Failed to modify authorized view: " + e .getMessage ());
@@ -245,10 +248,10 @@ public void updateAuthorizedView() {
245248 }
246249
247250 /** Demonstrates how to get an authorized view's metadata. */
248- public com . google . bigtable . admin . v2 . AuthorizedView getAuthorizedView () {
251+ public AuthorizedView getAuthorizedView () {
249252 System .out .printf ("%nGetting authorized view %s in table %s%n" , authorizedViewId , tableId );
250253 // [START bigtable_get_authorized_view]
251- com . google . bigtable . admin . v2 . AuthorizedView authorizedView = null ;
254+ AuthorizedView authorizedView = null ;
252255 try {
253256 authorizedView =
254257 adminClient .getAuthorizedView (
@@ -260,13 +263,12 @@ public com.google.bigtable.admin.v2.AuthorizedView getAuthorizedView() {
260263 + tableId
261264 + "/authorizedViews/"
262265 + authorizedViewId );
263- com .google .bigtable .admin .v2 .AuthorizedView .SubsetView subsetView =
264- authorizedView .getSubsetView ();
266+ AuthorizedView .SubsetView subsetView = authorizedView .getSubsetView ();
265267
266268 for (ByteString rowPrefix : subsetView .getRowPrefixesList ()) {
267269 System .out .printf ("Row Prefix: %s%n" , rowPrefix .toStringUtf8 ());
268270 }
269- for (Map .Entry <String , com . google . bigtable . admin . v2 . AuthorizedView .FamilySubsets > entry :
271+ for (Map .Entry <String , AuthorizedView .FamilySubsets > entry :
270272 subsetView .getFamilySubsetsMap ().entrySet ()) {
271273 for (ByteString qualifierPrefix : entry .getValue ().getQualifierPrefixesList ()) {
272274 System .out .printf (
@@ -292,16 +294,13 @@ public List<String> listAllAuthorizedViews() {
292294 // [START bigtable_list_authorized_views]
293295 List <String > authorizedViewIds = new ArrayList <>();
294296 try {
295- com . google . bigtable . admin . v2 . ListAuthorizedViewsRequest request =
296- com . google . bigtable . admin . v2 . ListAuthorizedViewsRequest .newBuilder ()
297+ ListAuthorizedViewsRequest request =
298+ ListAuthorizedViewsRequest .newBuilder ()
297299 .setParent (
298300 "projects/" + projectId + "/instances/" + instanceId + "/tables/" + tableId )
299301 .build ();
300- for (com .google .bigtable .admin .v2 .AuthorizedView view :
301- adminClient .listAuthorizedViews (request ).iterateAll ()) {
302- String id =
303- com .google .bigtable .admin .v2 .AuthorizedViewName .parse (view .getName ())
304- .getAuthorizedView ();
302+ for (AuthorizedView view : adminClient .listAuthorizedViews (request ).iterateAll ()) {
303+ String id = AuthorizedViewName .parse (view .getName ()).getAuthorizedView ();
305304 System .out .println (id );
306305 authorizedViewIds .add (id );
307306 }
0 commit comments