Search in sources :

Example 1 with BatchOperationMetadata

use of com.google.cloud.talent.v4beta1.BatchOperationMetadata in project java-talent by googleapis.

the class JobSearchBatchCreateJobs method sampleBatchCreateJobs.

/**
 * Batch Create Jobs
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleBatchCreateJobs(String projectId, String tenantId, String companyNameOne, String requisitionIdOne, String titleOne, String descriptionOne, String jobApplicationUrlOne, String addressOne, String languageCodeOne, String companyNameTwo, String requisitionIdTwo, String titleTwo, String descriptionTwo, String jobApplicationUrlTwo, String addressTwo, String languageCodeTwo) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        String formattedParent = TenantName.format(projectId, tenantId);
        List<String> uris = Arrays.asList(jobApplicationUrlOne);
        Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(uris).build();
        List<String> addresses = Arrays.asList(addressOne);
        Job jobsElement = Job.newBuilder().setCompany(companyNameOne).setRequisitionId(requisitionIdOne).setTitle(titleOne).setDescription(descriptionOne).setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode(languageCodeOne).build();
        List<String> uris2 = Arrays.asList(jobApplicationUrlTwo);
        Job.ApplicationInfo applicationInfo2 = Job.ApplicationInfo.newBuilder().addAllUris(uris2).build();
        List<String> addresses2 = Arrays.asList(addressTwo);
        Job jobsElement2 = Job.newBuilder().setCompany(companyNameTwo).setRequisitionId(requisitionIdTwo).setTitle(titleTwo).setDescription(descriptionTwo).setApplicationInfo(applicationInfo2).addAllAddresses(addresses2).setLanguageCode(languageCodeTwo).build();
        List<Job> jobs = Arrays.asList(jobsElement, jobsElement2);
        BatchCreateJobsRequest request = BatchCreateJobsRequest.newBuilder().setParent(formattedParent).addAllJobs(jobs).build();
        OperationFuture<JobOperationResult, BatchOperationMetadata> future = jobServiceClient.batchCreateJobsAsync(request);
        System.out.println("Waiting for operation to complete...");
        JobOperationResult response = future.get();
        System.out.printf("Batch response: %s\n", response);
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobOperationResult(com.google.cloud.talent.v4beta1.JobOperationResult) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) BatchCreateJobsRequest(com.google.cloud.talent.v4beta1.BatchCreateJobsRequest) BatchOperationMetadata(com.google.cloud.talent.v4beta1.BatchOperationMetadata) Job(com.google.cloud.talent.v4beta1.Job)

Example 2 with BatchOperationMetadata

use of com.google.cloud.talent.v4beta1.BatchOperationMetadata in project java-talent by googleapis.

the class JobSearchBatchUpdateJobs method sampleBatchUpdateJobs.

/**
 * Batch Update Jobs
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleBatchUpdateJobs(String projectId, String tenantId, String jobNameOne, String companyNameOne, String requisitionIdOne, String titleOne, String descriptionOne, String jobApplicationUrlOne, String addressOne, String languageCodeOne, String jobNameTwo, String companyNameTwo, String requisitionIdTwo, String titleTwo, String descriptionTwo, String jobApplicationUrlTwo, String addressTwo, String languageCodeTwo) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        String formattedParent = TenantName.format(projectId, tenantId);
        List<String> uris = Arrays.asList(jobApplicationUrlOne);
        Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(uris).build();
        List<String> addresses = Arrays.asList(addressOne);
        Job jobsElement = Job.newBuilder().setName(jobNameOne).setCompany(companyNameOne).setRequisitionId(requisitionIdOne).setTitle(titleOne).setDescription(descriptionOne).setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode(languageCodeOne).build();
        List<String> uris2 = Arrays.asList(jobApplicationUrlTwo);
        Job.ApplicationInfo applicationInfo2 = Job.ApplicationInfo.newBuilder().addAllUris(uris2).build();
        List<String> addresses2 = Arrays.asList(addressTwo);
        Job jobsElement2 = Job.newBuilder().setName(jobNameTwo).setCompany(companyNameTwo).setRequisitionId(requisitionIdTwo).setTitle(titleTwo).setDescription(descriptionTwo).setApplicationInfo(applicationInfo2).addAllAddresses(addresses2).setLanguageCode(languageCodeTwo).build();
        List<Job> jobs = Arrays.asList(jobsElement, jobsElement2);
        BatchUpdateJobsRequest request = BatchUpdateJobsRequest.newBuilder().setParent(formattedParent).addAllJobs(jobs).build();
        OperationFuture<JobOperationResult, BatchOperationMetadata> future = jobServiceClient.batchUpdateJobsAsync(request);
        System.out.println("Waiting for operation to complete...");
        JobOperationResult response = future.get();
        System.out.printf("Batch response: %s\n", response);
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobOperationResult(com.google.cloud.talent.v4beta1.JobOperationResult) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) BatchUpdateJobsRequest(com.google.cloud.talent.v4beta1.BatchUpdateJobsRequest) BatchOperationMetadata(com.google.cloud.talent.v4beta1.BatchOperationMetadata) Job(com.google.cloud.talent.v4beta1.Job)

Example 3 with BatchOperationMetadata

use of com.google.cloud.talent.v4beta1.BatchOperationMetadata in project java-vision by googleapis.

the class PurgeProductsInProductSet method purgeProductsInProductSet.

// Delete all products in a product set.
public static void purgeProductsInProductSet(String projectId, String location, String productSetId) throws Exception {
    try (ProductSearchClient client = ProductSearchClient.create()) {
        String parent = LocationName.format(projectId, location);
        ProductSetPurgeConfig productSetPurgeConfig = ProductSetPurgeConfig.newBuilder().setProductSetId(productSetId).build();
        PurgeProductsRequest request = PurgeProductsRequest.newBuilder().setParent(parent).setProductSetPurgeConfig(productSetPurgeConfig).setForce(true).build();
        OperationFuture<Empty, BatchOperationMetadata> response = client.purgeProductsAsync(request);
        response.getPollingFuture().get(180, TimeUnit.SECONDS);
        System.out.println("Products removed from product set.");
    }
}
Also used : Empty(com.google.protobuf.Empty) PurgeProductsRequest(com.google.cloud.vision.v1.PurgeProductsRequest) ProductSearchClient(com.google.cloud.vision.v1.ProductSearchClient) ProductSetPurgeConfig(com.google.cloud.vision.v1.ProductSetPurgeConfig) BatchOperationMetadata(com.google.cloud.vision.v1.BatchOperationMetadata)

Example 4 with BatchOperationMetadata

use of com.google.cloud.talent.v4beta1.BatchOperationMetadata in project java-vision by googleapis.

the class ImportProductSets method importProductSets.

// [START vision_product_search_import_product_images]
/**
 * Import images of different products in the product set.
 *
 * @param projectId - Id of the project.
 * @param computeRegion - Region name.
 * @param gcsUri - Google Cloud Storage URI.Target files must be in Product Search CSV format.
 * @throws Exception - on client errors.
 */
public static void importProductSets(String projectId, String computeRegion, String gcsUri) throws Exception {
    try (ProductSearchClient client = ProductSearchClient.create()) {
        // A resource that represents Google Cloud Platform location.
        String formattedParent = ProductSearchClient.formatLocationName(projectId, computeRegion);
        Builder gcsSource = ImportProductSetsGcsSource.newBuilder().setCsvFileUri(gcsUri);
        // Set the input configuration along with Google Cloud Storage URI
        ImportProductSetsInputConfig inputConfig = ImportProductSetsInputConfig.newBuilder().setGcsSource(gcsSource).build();
        // Import the product sets from the input URI.
        OperationFuture<ImportProductSetsResponse, BatchOperationMetadata> response = client.importProductSetsAsync(formattedParent, inputConfig);
        System.out.println(String.format("Processing operation name: %s", response.getName()));
        ImportProductSetsResponse results = response.get();
        System.out.println("Processing done.");
        System.out.println("Results of the processing:");
        for (int i = 0; i < results.getStatusesCount(); i++) {
            System.out.println(String.format("Status of processing line %s of the csv: %s", i, results.getStatuses(i)));
            // Check the status of reference image.
            if (results.getStatuses(i).getCode() == 0) {
                ReferenceImage referenceImage = results.getReferenceImages(i);
                System.out.println(referenceImage);
            } else {
                System.out.println("No reference image.");
            }
        }
    }
}
Also used : ImportProductSetsResponse(com.google.cloud.vision.v1.ImportProductSetsResponse) ProductSearchClient(com.google.cloud.vision.v1.ProductSearchClient) Builder(com.google.cloud.vision.v1.ImportProductSetsGcsSource.Builder) BatchOperationMetadata(com.google.cloud.vision.v1.BatchOperationMetadata) ReferenceImage(com.google.cloud.vision.v1.ReferenceImage) ImportProductSetsInputConfig(com.google.cloud.vision.v1.ImportProductSetsInputConfig)

Aggregations

BatchOperationMetadata (com.google.cloud.talent.v4beta1.BatchOperationMetadata)2 Job (com.google.cloud.talent.v4beta1.Job)2 JobOperationResult (com.google.cloud.talent.v4beta1.JobOperationResult)2 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)2 BatchOperationMetadata (com.google.cloud.vision.v1.BatchOperationMetadata)2 ProductSearchClient (com.google.cloud.vision.v1.ProductSearchClient)2 BatchCreateJobsRequest (com.google.cloud.talent.v4beta1.BatchCreateJobsRequest)1 BatchUpdateJobsRequest (com.google.cloud.talent.v4beta1.BatchUpdateJobsRequest)1 Builder (com.google.cloud.vision.v1.ImportProductSetsGcsSource.Builder)1 ImportProductSetsInputConfig (com.google.cloud.vision.v1.ImportProductSetsInputConfig)1 ImportProductSetsResponse (com.google.cloud.vision.v1.ImportProductSetsResponse)1 ProductSetPurgeConfig (com.google.cloud.vision.v1.ProductSetPurgeConfig)1 PurgeProductsRequest (com.google.cloud.vision.v1.PurgeProductsRequest)1 ReferenceImage (com.google.cloud.vision.v1.ReferenceImage)1 Empty (com.google.protobuf.Empty)1