@ SuppressWarnings ( "WeakerAccess" ) public ApiFuture < List < Instance > > listInstancesAsync ( ) { com . google . bigtable . admin . v2 . ListInstancesRequest request = com . google . bigtable . admin . v2 . ListInstancesRequest . newBuilder ( ) . setParent ( NameUtil . formatProjectName ( projectId ) ) . build ( ) ; ApiFuture < com . google . bigtable . admin . v2 . ListInstancesResponse > responseFuture = stub . listInstancesCallable ( ) . futureCall ( request ) ; return ApiFutures . transform ( responseFuture , new ApiFunction < com . google . bigtable . admin . v2 . ListInstancesResponse , List < Instance > > ( ) { @ Override public List < Instance > apply ( com . google . bigtable . admin . v2 . ListInstancesResponse proto ) { // NOTE: pagination is intentionally ignored. The server does not implement it and never // will. Verify . verify ( proto . getNextPageToken ( ) . isEmpty ( ) , "Server returned an unexpected paginated response" ) ; ImmutableList . Builder < Instance > instances = ImmutableList . builder ( ) ; for ( com . google . bigtable . admin . v2 . Instance protoInstance : proto . getInstancesList ( ) ) { instances . add ( Instance . fromProto ( protoInstance ) ) ; } ImmutableList . Builder < String > failedZones = ImmutableList . builder ( ) ; for ( String locationStr : proto . getFailedLocationsList ( ) ) { failedZones . add ( NameUtil . extractZoneIdFromLocationName ( locationStr ) ) ; } if ( ! failedZones . build ( ) . isEmpty ( ) ) { throw new PartialListInstancesException ( failedZones . build ( ) , instances . build ( ) ) ; } return instances . build ( ) ; } } , MoreExecutors . directExecutor ( ) ) ; }
Asynchronously lists all of the instances in the current project .