2424import com .google .api .gax .rpc .NotFoundException ;
2525import com .google .bigtable .admin .v2 .DeleteAuthorizedViewRequest ;
2626import com .google .bigtable .admin .v2 .DeleteBackupRequest ;
27+ import com .google .bigtable .admin .v2 .DeleteSchemaBundleRequest ;
2728import com .google .bigtable .admin .v2 .DeleteTableRequest ;
2829import com .google .bigtable .admin .v2 .DropRowRangeRequest ;
29- import com .google .bigtable .admin .v2 .DeleteSchemaBundleRequest ;
3030import com .google .bigtable .admin .v2 .GetAuthorizedViewRequest ;
3131import com .google .bigtable .admin .v2 .GetBackupRequest ;
3232import com .google .bigtable .admin .v2 .GetSchemaBundleRequest ;
@@ -1808,8 +1808,7 @@ public ApiFuture<Void> deleteAuthorizedViewAsync(String tableId, String authoriz
18081808 /**
18091809 * Creates a new schema bundle with the specified configuration.
18101810 *
1811- * <p>
1812- * Sample code:
1811+ * <p>Sample code:
18131812 *
18141813 * <pre>{@code
18151814 * CreateSchemaBundleRequest request = CreateSchemaBundleRequest.of("my-table", "my-new-schema-bundle")
@@ -1832,8 +1831,7 @@ public SchemaBundle createSchemaBundle(CreateSchemaBundleRequest request) {
18321831 /**
18331832 * Asynchronously creates a new schema bundle with the specified configuration.
18341833 *
1835- * <p>
1836- * Sample code:
1834+ * <p>Sample code:
18371835 *
18381836 * <pre>{@code
18391837 * CreateSchemaBundleRequest request = CreateSchemaBundleRequest.of("my-table", "my-new-schema-bundle")
@@ -1868,8 +1866,7 @@ public ApiFuture<SchemaBundle> createSchemaBundleAsync(CreateSchemaBundleRequest
18681866 .futureCall (request .toProto (projectId , instanceId )),
18691867 new ApiFunction <com .google .bigtable .admin .v2 .SchemaBundle , SchemaBundle >() {
18701868 @ Override
1871- public SchemaBundle apply (
1872- com .google .bigtable .admin .v2 .SchemaBundle schemaBundleProto ) {
1869+ public SchemaBundle apply (com .google .bigtable .admin .v2 .SchemaBundle schemaBundleProto ) {
18731870 return SchemaBundle .fromProto (schemaBundleProto );
18741871 }
18751872 },
@@ -1879,8 +1876,7 @@ public SchemaBundle apply(
18791876 /**
18801877 * Updates an existing schema bundle with the specified configuration.
18811878 *
1882- * <p>
1883- * Sample code:
1879+ * <p>Sample code:
18841880 *
18851881 * <pre>{@code
18861882 * SchemaBundle existingSchemaBundle = client.getSchemaBundle("my-table", "my-schema-bundle");
@@ -1897,11 +1893,9 @@ public SchemaBundle updateSchemaBundle(UpdateSchemaBundleRequest request) {
18971893 }
18981894
18991895 /**
1900- * Asynchronously updates an existing schema bundle with the specified
1901- * configuration.
1896+ * Asynchronously updates an existing schema bundle with the specified configuration.
19021897 *
1903- * <p>
1904- * Sample code:
1898+ * <p>Sample code:
19051899 *
19061900 * <pre>{@code
19071901 * SchemaBundle existingSchemaBundle = client.getSchemaBundle("my-table", "my-schema-bundle");
@@ -1932,20 +1926,17 @@ public ApiFuture<SchemaBundle> updateSchemaBundleAsync(UpdateSchemaBundleRequest
19321926 .futureCall (request .toProto (projectId , instanceId )),
19331927 new ApiFunction <com .google .bigtable .admin .v2 .SchemaBundle , SchemaBundle >() {
19341928 @ Override
1935- public SchemaBundle apply (
1936- com .google .bigtable .admin .v2 .SchemaBundle schemaBundleProto ) {
1929+ public SchemaBundle apply (com .google .bigtable .admin .v2 .SchemaBundle schemaBundleProto ) {
19371930 return SchemaBundle .fromProto (schemaBundleProto );
19381931 }
19391932 },
19401933 MoreExecutors .directExecutor ());
19411934 }
19421935
19431936 /**
1944- * Gets an schema bundle with the specified schema bundle ID in the specified
1945- * table.
1937+ * Gets an schema bundle with the specified schema bundle ID in the specified table.
19461938 *
1947- * <p>
1948- * Sample code:
1939+ * <p>Sample code:
19491940 *
19501941 * <pre>{@code
19511942 * SchemaBundle schemaBundle = client.getSchemaBundle("my-table", "my-schema-bundle");
@@ -1957,12 +1948,10 @@ public SchemaBundle getSchemaBundle(String tableId, String schemaBundleId) {
19571948 }
19581949
19591950 /**
1960- * Asynchronously gets an schema bundle with the specified schema bundle ID in
1961- * the specified
1951+ * Asynchronously gets an schema bundle with the specified schema bundle ID in the specified
19621952 * table.
19631953 *
1964- * <p>
1965- * Sample code:
1954+ * <p>Sample code:
19661955 *
19671956 * <pre>{@code
19681957 * ApiFuture<SchemaBundle> future = client.getSchemaBundleAsync("my-table", "my-schema-bundle");
@@ -1982,16 +1971,16 @@ public SchemaBundle getSchemaBundle(String tableId, String schemaBundleId) {
19821971 * }</pre>
19831972 */
19841973 public ApiFuture <SchemaBundle > getSchemaBundleAsync (String tableId , String schemaBundleId ) {
1985- GetSchemaBundleRequest request = GetSchemaBundleRequest .newBuilder ()
1986- .setName (
1987- NameUtil .formatSchemaBundleName (projectId , instanceId , tableId , schemaBundleId ))
1988- .build ();
1974+ GetSchemaBundleRequest request =
1975+ GetSchemaBundleRequest .newBuilder ()
1976+ .setName (
1977+ NameUtil .formatSchemaBundleName (projectId , instanceId , tableId , schemaBundleId ))
1978+ .build ();
19891979 return ApiFutures .transform (
19901980 stub .getSchemaBundleCallable ().futureCall (request ),
19911981 new ApiFunction <com .google .bigtable .admin .v2 .SchemaBundle , SchemaBundle >() {
19921982 @ Override
1993- public SchemaBundle apply (
1994- com .google .bigtable .admin .v2 .SchemaBundle schemaBundleProto ) {
1983+ public SchemaBundle apply (com .google .bigtable .admin .v2 .SchemaBundle schemaBundleProto ) {
19951984 return SchemaBundle .fromProto (schemaBundleProto );
19961985 }
19971986 },
@@ -2001,8 +1990,7 @@ public SchemaBundle apply(
20011990 /**
20021991 * Lists all schema bundle IDs in the specified table.
20031992 *
2004- * <p>
2005- * Sample code:
1993+ * <p>Sample code:
20061994 *
20071995 * <pre>{@code
20081996 * List<String> schemaBundles = client.listSchemaBundles("my-table");
@@ -2015,8 +2003,7 @@ public List<String> listSchemaBundles(String tableId) {
20152003 /**
20162004 * Asynchronously lists all schema bundle IDs in the specified table.
20172005 *
2018- * <p>
2019- * Sample code:
2006+ * <p>Sample code:
20202007 *
20212008 * <pre>{@code
20222009 * ApiFuture<List<String>> future = client.listSchemaBundlesAsync("my-table");
@@ -2039,48 +2026,53 @@ public List<String> listSchemaBundles(String tableId) {
20392026 * }</pre>
20402027 */
20412028 public ApiFuture <List <String >> listSchemaBundlesAsync (String tableId ) {
2042- ListSchemaBundlesRequest request = ListSchemaBundlesRequest .newBuilder ()
2043- .setParent (NameUtil .formatTableName (projectId , instanceId , tableId ))
2044- .build ();
2029+ ListSchemaBundlesRequest request =
2030+ ListSchemaBundlesRequest .newBuilder ()
2031+ .setParent (NameUtil .formatTableName (projectId , instanceId , tableId ))
2032+ .build ();
20452033
20462034 // TODO(igorbernstein2): try to upstream pagination spooling or figure out a way
20472035 // to expose the
20482036 // paginated responses while maintaining the wrapper facade.
20492037
20502038 // Fetches the first page.
2051- ApiFuture <ListSchemaBundlesPage > firstPageFuture = ApiFutures .transform (
2052- stub .listSchemaBundlesPagedCallable ().futureCall (request ),
2053- new ApiFunction <ListSchemaBundlesPagedResponse , ListSchemaBundlesPage >() {
2054- @ Override
2055- public ListSchemaBundlesPage apply (ListSchemaBundlesPagedResponse response ) {
2056- return response .getPage ();
2057- }
2058- },
2059- MoreExecutors .directExecutor ());
2039+ ApiFuture <ListSchemaBundlesPage > firstPageFuture =
2040+ ApiFutures .transform (
2041+ stub .listSchemaBundlesPagedCallable ().futureCall (request ),
2042+ new ApiFunction <ListSchemaBundlesPagedResponse , ListSchemaBundlesPage >() {
2043+ @ Override
2044+ public ListSchemaBundlesPage apply (ListSchemaBundlesPagedResponse response ) {
2045+ return response .getPage ();
2046+ }
2047+ },
2048+ MoreExecutors .directExecutor ());
20602049
20612050 // Fetches the rest of the pages by chaining the futures.
2062- ApiFuture <List <com .google .bigtable .admin .v2 .SchemaBundle >> allProtos = ApiFutures .transformAsync (
2063- firstPageFuture ,
2064- new ApiAsyncFunction <ListSchemaBundlesPage , List <com .google .bigtable .admin .v2 .SchemaBundle >>() {
2065- List <com .google .bigtable .admin .v2 .SchemaBundle > responseAccumulator = Lists .newArrayList ();
2051+ ApiFuture <List <com .google .bigtable .admin .v2 .SchemaBundle >> allProtos =
2052+ ApiFutures .transformAsync (
2053+ firstPageFuture ,
2054+ new ApiAsyncFunction <
2055+ ListSchemaBundlesPage , List <com .google .bigtable .admin .v2 .SchemaBundle >>() {
2056+ List <com .google .bigtable .admin .v2 .SchemaBundle > responseAccumulator =
2057+ Lists .newArrayList ();
20662058
2067- @ Override
2068- public ApiFuture <List <com .google .bigtable .admin .v2 .SchemaBundle >> apply (
2069- ListSchemaBundlesPage page ) {
2070- // Add all entries from the page
2071- responseAccumulator .addAll (Lists .newArrayList (page .getValues ()));
2072-
2073- // If this is the last page, just return the accumulated responses.
2074- if (!page .hasNextPage ()) {
2075- return ApiFutures .immediateFuture (responseAccumulator );
2076- }
2059+ @ Override
2060+ public ApiFuture <List <com .google .bigtable .admin .v2 .SchemaBundle >> apply (
2061+ ListSchemaBundlesPage page ) {
2062+ // Add all entries from the page
2063+ responseAccumulator .addAll (Lists .newArrayList (page .getValues ()));
20772064
2078- // Otherwise fetch the next page.
2079- return ApiFutures .transformAsync (
2080- page .getNextPageAsync (), this , MoreExecutors .directExecutor ());
2081- }
2082- },
2083- MoreExecutors .directExecutor ());
2065+ // If this is the last page, just return the accumulated responses.
2066+ if (!page .hasNextPage ()) {
2067+ return ApiFutures .immediateFuture (responseAccumulator );
2068+ }
2069+
2070+ // Otherwise fetch the next page.
2071+ return ApiFutures .transformAsync (
2072+ page .getNextPageAsync (), this , MoreExecutors .directExecutor ());
2073+ }
2074+ },
2075+ MoreExecutors .directExecutor ());
20842076
20852077 // Wraps all of the accumulated protos.
20862078 return ApiFutures .transform (
@@ -2099,33 +2091,25 @@ public List<String> apply(List<com.google.bigtable.admin.v2.SchemaBundle> protos
20992091 }
21002092
21012093 /**
2102- * Deletes an schema bundle with the specified schema bundle ID in the specified
2103- * table. Note
2104- * that the deletion is prohibited if the schema bundle has deletion_protection
2105- * field set to
2106- * true.
2094+ * Deletes an schema bundle with the specified schema bundle ID in the specified table. Note that
2095+ * the deletion is prohibited if the schema bundle has deletion_protection field set to true.
21072096 *
2108- * <p>
2109- * Sample code:
2097+ * <p>Sample code:
21102098 *
21112099 * <pre>{@code
21122100 * client.deleteSchemaBundle("my-table", "my-schema-bundle");
21132101 * }</pre>
21142102 */
21152103 public void deleteSchemaBundle (String tableId , String schemaBundleId ) {
2116- ApiExceptions .callAndTranslateApiException (
2117- deleteSchemaBundleAsync (tableId , schemaBundleId ));
2104+ ApiExceptions .callAndTranslateApiException (deleteSchemaBundleAsync (tableId , schemaBundleId ));
21182105 }
21192106
21202107 /**
2121- * Asynchronously deletes an schema bundle with the specified schema bundle ID
2122- * in the
2123- * specified table. Note that the deletion is prohibited if the schema bundle
2124- * has
2125- * deletion_protection field set to true.
2108+ * Asynchronously deletes an schema bundle with the specified schema bundle ID in the specified
2109+ * table. Note that the deletion is prohibited if the schema bundle has deletion_protection field
2110+ * set to true.
21262111 *
2127- * <p>
2128- * Sample code:
2112+ * <p>Sample code:
21292113 *
21302114 * <pre>{@code
21312115 * ApiFuture<void> future = client.deleteSchemaBundleAsync("my-table", "my-schema-bundle");
@@ -2146,10 +2130,11 @@ public void deleteSchemaBundle(String tableId, String schemaBundleId) {
21462130 * }</pre>
21472131 */
21482132 public ApiFuture <Void > deleteSchemaBundleAsync (String tableId , String schemaBundleId ) {
2149- DeleteSchemaBundleRequest request = DeleteSchemaBundleRequest .newBuilder ()
2150- .setName (
2151- NameUtil .formatSchemaBundleName (projectId , instanceId , tableId , schemaBundleId ))
2152- .build ();
2133+ DeleteSchemaBundleRequest request =
2134+ DeleteSchemaBundleRequest .newBuilder ()
2135+ .setName (
2136+ NameUtil .formatSchemaBundleName (projectId , instanceId , tableId , schemaBundleId ))
2137+ .build ();
21532138
21542139 return transformToVoid (this .stub .deleteSchemaBundleCallable ().futureCall (request ));
21552140 }
0 commit comments