Search in sources :

Example 56 with Book

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

the class SyncCreateBookStringBook method syncCreateBookStringBook.

public static void syncCreateBookStringBook() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        String parent = ShelfName.of("[SHELF_ID]").toString();
        Book book = Book.newBuilder().build();
        Book response = libraryServiceClient.createBook(parent, book);
    }
}
Also used : LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) Book(com.google.example.library.v1.Book)

Example 57 with Book

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

the class SyncUpdateBookBookFieldmask method syncUpdateBookBookFieldmask.

public static void syncUpdateBookBookFieldmask() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        Book book = Book.newBuilder().build();
        FieldMask updateMask = FieldMask.newBuilder().build();
        Book response = libraryServiceClient.updateBook(book, updateMask);
    }
}
Also used : LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) Book(com.google.example.library.v1.Book) FieldMask(com.google.protobuf.FieldMask)

Example 58 with Book

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

the class LibraryServiceClient method deleteBook.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a book. Returns NOT_FOUND if the book does not exist.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * // This snippet has been automatically generated for illustrative purposes only.
 * // It may require modifications to work in your environment.
 * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
 *   BookName name = BookName.of("[SHELF]", "[BOOK]");
 *   libraryServiceClient.deleteBook(name);
 * }
 * }</pre>
 *
 * @param name The name of the book to delete.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteBook(BookName name) {
    DeleteBookRequest request = DeleteBookRequest.newBuilder().setName(name == null ? null : name.toString()).build();
    deleteBook(request);
}
Also used : DeleteBookRequest(com.google.example.library.v1.DeleteBookRequest)

Example 59 with Book

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

the class LibraryServiceClient method deleteBook.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a book. Returns NOT_FOUND if the book does not exist.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * // This snippet has been automatically generated for illustrative purposes only.
 * // It may require modifications to work in your environment.
 * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
 *   String name = BookName.of("[SHELF]", "[BOOK]").toString();
 *   libraryServiceClient.deleteBook(name);
 * }
 * }</pre>
 *
 * @param name The name of the book to delete.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteBook(String name) {
    DeleteBookRequest request = DeleteBookRequest.newBuilder().setName(name).build();
    deleteBook(request);
}
Also used : DeleteBookRequest(com.google.example.library.v1.DeleteBookRequest)

Example 60 with Book

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

the class LibraryServiceClientTest method getBookExceptionTest.

@Test
public void getBookExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockLibraryService.addException(exception);
    try {
        BookName name = BookName.of("[SHELF]", "[BOOK]");
        client.getBook(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) BookName(com.google.example.library.v1.BookName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

Book (com.google.example.library.v1.Book)33 Test (org.junit.Test)25 LibraryServiceClient (com.google.cloud.example.library.v1.LibraryServiceClient)22 Book (student_arturs_melnikovs.lesson_10.level_02.Book)16 BookName (com.google.example.library.v1.BookName)12 AbstractMessage (com.google.protobuf.AbstractMessage)12 ShelfName (com.google.example.library.v1.ShelfName)9 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 MoveBookRequest (com.google.example.library.v1.MoveBookRequest)6 DeleteBookRequest (com.google.example.library.v1.DeleteBookRequest)5 Scanner (java.util.Scanner)5 CreateBookRequest (com.google.example.library.v1.CreateBookRequest)4 GetBookRequest (com.google.example.library.v1.GetBookRequest)4 Page (org.apache.wicket.Page)4 Book (org.apache.wicket.core.util.tester.apps_1.Book)4 WebPage (org.apache.wicket.markup.html.WebPage)4 AccessDeniedPage (org.apache.wicket.markup.html.pages.AccessDeniedPage)4 DummyPage (org.apache.wicket.resource.DummyPage)4 Book (org.apache.wicket.util.tester.apps_1.Book)4