Search in sources :

Example 26 with Image

use of com.google.cloud.vision.v1p4beta1.Image in project aem-core-wcm-components by adobe.

the class ImageIT method setupBeforeEach.

@BeforeEach
public void setupBeforeEach() throws ClientException {
    imageTests = new ImageTests();
    imageTests.setup(adminClient, contextPath, label, Commons.RT_IMAGE_V1, rootPage, defaultPageTemplate, clientlibs, new Image());
}
Also used : ImageTests(com.adobe.cq.wcm.core.components.it.seljup.tests.image.ImageTests) Image(com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v1.Image) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 27 with Image

use of com.google.cloud.vision.v1p4beta1.Image in project aem-core-wcm-components by adobe.

the class ImageIT method setupBeforeEach.

@BeforeEach
public void setupBeforeEach() throws ClientException {
    clientlibs = Commons.CLIENTLIBS_IMAGE_V3;
    imageTests = new ImageTests();
    imageTests.setup(adminClient, contextPath, label, Commons.RT_IMAGE_V3, rootPage, defaultPageTemplate, clientlibs, new Image());
}
Also used : ImageTests(com.adobe.cq.wcm.core.components.it.seljup.tests.image.ImageTests) Image(com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v2.Image) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 28 with Image

use of com.google.cloud.vision.v1p4beta1.Image in project java-docs-samples by GoogleCloudPlatform.

the class CreateInstancesAdvanced method createWithSubnetwork.

// [END compute_instances_create_from_image_plus_snapshot_disk]
// [START compute_instances_create_from_image]
/**
 * Create a new VM instance with Debian 10 operating system in specified network and subnetwork.
 *
 * @param project project ID or project number of the Cloud project you want to use.
 * @param zone name of the zone to create the instance in. For example: "us-west3-b"
 * @param instanceName name of the new virtual machine (VM) instance.
 * @param networkLink name of the network you want the new instance to use. For example:
 * "global/networks/default" represents the network named "default", which is created
 * automatically for each project.
 * @param subnetworkLink name of the subnetwork you want the new instance to use. This value uses
 * the following format: "regions/{region}/subnetworks/{subnetwork_name}"
 * @return Instance object.
 */
public static Instance createWithSubnetwork(String project, String zone, String instanceName, String networkLink, String subnetworkLink) throws IOException, InterruptedException, ExecutionException, TimeoutException {
    try (ImagesClient imagesClient = ImagesClient.create()) {
        // List of public operating system (OS) images: https://cloud.google.com/compute/docs/images/os-details
        Image image = imagesClient.getFromFamily("debian-cloud", "debian-10");
        String diskType = String.format("zones/%s/diskTypes/pd-standard", zone);
        Vector<AttachedDisk> disks = new Vector<>();
        disks.add(diskFromImage(diskType, 10, true, image.getSelfLink()));
        return createWithDisks(project, zone, instanceName, disks, "n1-standard-1", networkLink, subnetworkLink);
    }
}
Also used : AttachedDisk(com.google.cloud.compute.v1.AttachedDisk) ImagesClient(com.google.cloud.compute.v1.ImagesClient) Image(com.google.cloud.compute.v1.Image) Vector(java.util.Vector)

Example 29 with Image

use of com.google.cloud.vision.v1p4beta1.Image in project java-docs-samples by GoogleCloudPlatform.

the class ListImages method listImages.

// [START compute_images_list]
// Prints a list of all non-deprecated image names available in given project.
public static void listImages(String project) throws IOException {
    // safely clean up any remaining background resources.
    try (ImagesClient imagesClient = ImagesClient.create()) {
        // Listing only non-deprecated images to reduce the size of the reply.
        ListImagesRequest imagesRequest = ListImagesRequest.newBuilder().setProject(project).setMaxResults(100).setFilter("deprecated.state != DEPRECATED").build();
        // Although the `setMaxResults` parameter is specified in the request, the iterable returned
        // by the `list()` method hides the pagination mechanic. The library makes multiple
        // requests to the API for you, so you can simply iterate over all the images.
        int imageCount = 0;
        for (Image image : imagesClient.list(imagesRequest).iterateAll()) {
            imageCount++;
            System.out.println(image.getName());
        }
        System.out.printf("Image count in %s is: %s", project, imageCount);
    }
}
Also used : ImagesClient(com.google.cloud.compute.v1.ImagesClient) ListImagesRequest(com.google.cloud.compute.v1.ListImagesRequest) Image(com.google.cloud.compute.v1.Image)

Example 30 with Image

use of com.google.cloud.vision.v1p4beta1.Image in project java-docs-samples by GoogleCloudPlatform.

the class ListImages method listImagesByPage.

// [END compute_images_list]
// [START compute_images_list_page]
// Prints a list of all non-deprecated image names available in a given project,
// divided into pages as returned by the Compute Engine API.
public static void listImagesByPage(String project, int pageSize) throws IOException {
    // safely clean up any remaining background resources.
    try (ImagesClient imagesClient = ImagesClient.create()) {
        // Listing only non-deprecated images to reduce the size of the reply.
        ListImagesRequest imagesRequest = ListImagesRequest.newBuilder().setProject(project).setMaxResults(pageSize).setFilter("deprecated.state != DEPRECATED").build();
        // Use the `iteratePages` attribute of returned iterable to have more granular control of
        // iteration over paginated results from the API. Each time you want to access the
        // next page, the library retrieves that page from the API.
        int pageNumber = 1;
        for (ListPage page : imagesClient.list(imagesRequest).iteratePages()) {
            System.out.println("Page Number: " + pageNumber++);
            for (Image image : page.getValues()) {
                System.out.println(image.getName());
            }
        }
    }
}
Also used : ListPage(com.google.cloud.compute.v1.ImagesClient.ListPage) ImagesClient(com.google.cloud.compute.v1.ImagesClient) ListImagesRequest(com.google.cloud.compute.v1.ListImagesRequest) Image(com.google.cloud.compute.v1.Image)

Aggregations

AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)75 Image (com.google.cloud.vision.v1.Image)75 Feature (com.google.cloud.vision.v1.Feature)73 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)72 ArrayList (java.util.ArrayList)71 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)69 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)66 ByteString (com.google.protobuf.ByteString)53 ImageSource (com.google.cloud.vision.v1.ImageSource)41 FileInputStream (java.io.FileInputStream)33 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)28 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)26 IOException (java.io.IOException)20 ImageContext (com.google.cloud.vision.v1.ImageContext)14 SafeSearchAnnotation (com.google.cloud.vision.v1.SafeSearchAnnotation)11 WebDetection (com.google.cloud.vision.v1.WebDetection)11 LocationInfo (com.google.cloud.vision.v1.LocationInfo)10 Arrays (java.util.Arrays)10 Image (com.google.cloud.compute.v1.Image)9 ImagesClient (com.google.cloud.compute.v1.ImagesClient)9