Search in sources :

Example 11 with LibraryServiceClient

use of com.google.cloud.example.library.v1.LibraryServiceClient in project gapic-generator-java by googleapis.

the class AsyncListBooksPaged method asyncListBooksPaged.

public static void asyncListBooksPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        ListBooksRequest request = ListBooksRequest.newBuilder().setParent(ShelfName.of("[SHELF_ID]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();
        while (true) {
            ListBooksResponse response = libraryServiceClient.listBooksCallable().call(request);
            for (Book element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) ListBooksResponse(com.google.example.library.v1.ListBooksResponse) Book(com.google.example.library.v1.Book) ListBooksRequest(com.google.example.library.v1.ListBooksRequest)

Example 12 with LibraryServiceClient

use of com.google.cloud.example.library.v1.LibraryServiceClient in project gapic-generator-java by googleapis.

the class AsyncListShelvesPaged method asyncListShelvesPaged.

public static void asyncListShelvesPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        ListShelvesRequest request = ListShelvesRequest.newBuilder().setPageSize(883849137).setPageToken("pageToken873572522").build();
        while (true) {
            ListShelvesResponse response = libraryServiceClient.listShelvesCallable().call(request);
            for (Shelf element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) Shelf(com.google.example.library.v1.Shelf) ListShelvesResponse(com.google.example.library.v1.ListShelvesResponse) ListShelvesRequest(com.google.example.library.v1.ListShelvesRequest)

Example 13 with LibraryServiceClient

use of com.google.cloud.example.library.v1.LibraryServiceClient in project gapic-generator-java by googleapis.

the class AsyncGetBook method asyncGetBook.

public static void asyncGetBook() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        GetBookRequest request = GetBookRequest.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).build();
        ApiFuture<Book> future = libraryServiceClient.getBookCallable().futureCall(request);
        // Do something.
        Book response = future.get();
    }
}
Also used : GetBookRequest(com.google.example.library.v1.GetBookRequest) LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) Book(com.google.example.library.v1.Book)

Example 14 with LibraryServiceClient

use of com.google.cloud.example.library.v1.LibraryServiceClient in project gapic-generator-java by googleapis.

the class AsyncGetShelf method asyncGetShelf.

public static void asyncGetShelf() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        GetShelfRequest request = GetShelfRequest.newBuilder().setName(ShelfName.of("[SHELF_ID]").toString()).build();
        ApiFuture<Shelf> future = libraryServiceClient.getShelfCallable().futureCall(request);
        // Do something.
        Shelf response = future.get();
    }
}
Also used : LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) GetShelfRequest(com.google.example.library.v1.GetShelfRequest) Shelf(com.google.example.library.v1.Shelf)

Example 15 with LibraryServiceClient

use of com.google.cloud.example.library.v1.LibraryServiceClient in project gapic-generator-java by googleapis.

the class SyncCreateSetCredentialsProvider method syncCreateSetCredentialsProvider.

public static void syncCreateSetCredentialsProvider() throws Exception {
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    LibraryServiceSettings libraryServiceSettings = LibraryServiceSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)).build();
    LibraryServiceClient libraryServiceClient = LibraryServiceClient.create(libraryServiceSettings);
}
Also used : LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) LibraryServiceSettings(com.google.cloud.example.library.v1.LibraryServiceSettings)

Aggregations

LibraryServiceClient (com.google.cloud.example.library.v1.LibraryServiceClient)43 Book (com.google.example.library.v1.Book)19 Shelf (com.google.example.library.v1.Shelf)14 ShelfName (com.google.example.library.v1.ShelfName)8 BookName (com.google.example.library.v1.BookName)4 LibraryServiceSettings (com.google.cloud.example.library.v1.LibraryServiceSettings)2 CreateBookRequest (com.google.example.library.v1.CreateBookRequest)2 DeleteBookRequest (com.google.example.library.v1.DeleteBookRequest)2 DeleteShelfRequest (com.google.example.library.v1.DeleteShelfRequest)2 GetBookRequest (com.google.example.library.v1.GetBookRequest)2 GetShelfRequest (com.google.example.library.v1.GetShelfRequest)2 ListBooksRequest (com.google.example.library.v1.ListBooksRequest)2 ListShelvesRequest (com.google.example.library.v1.ListShelvesRequest)2 MergeShelvesRequest (com.google.example.library.v1.MergeShelvesRequest)2 MoveBookRequest (com.google.example.library.v1.MoveBookRequest)2 UpdateBookRequest (com.google.example.library.v1.UpdateBookRequest)2 Empty (com.google.protobuf.Empty)2 CreateShelfRequest (com.google.example.library.v1.CreateShelfRequest)1 ListBooksResponse (com.google.example.library.v1.ListBooksResponse)1 ListShelvesResponse (com.google.example.library.v1.ListShelvesResponse)1