Search in sources :

Example 21 with Tenant

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

the class JobSearchDeleteTenant method sampleDeleteTenant.

/**
 * Delete Tenant
 */
public static void sampleDeleteTenant(String projectId, String tenantId) {
    try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
        TenantName name = TenantName.of(projectId, tenantId);
        DeleteTenantRequest request = DeleteTenantRequest.newBuilder().setName(name.toString()).build();
        tenantServiceClient.deleteTenant(request);
        System.out.println("Deleted Tenant.");
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) TenantName(com.google.cloud.talent.v4beta1.TenantName) DeleteTenantRequest(com.google.cloud.talent.v4beta1.DeleteTenantRequest)

Example 22 with Tenant

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

the class JobSearchGetTenant method sampleGetTenant.

/**
 * Get Tenant by name
 */
public static void sampleGetTenant(String projectId, String tenantId) {
    try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
        TenantName name = TenantName.of(projectId, tenantId);
        GetTenantRequest request = GetTenantRequest.newBuilder().setName(name.toString()).build();
        Tenant response = tenantServiceClient.getTenant(request);
        System.out.printf("Name: %s\n", response.getName());
        System.out.printf("External ID: %s\n", response.getExternalId());
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) Tenant(com.google.cloud.talent.v4beta1.Tenant) TenantName(com.google.cloud.talent.v4beta1.TenantName) GetTenantRequest(com.google.cloud.talent.v4beta1.GetTenantRequest)

Example 23 with Tenant

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

the class JobSearchListCompanies method sampleListCompanies.

/**
 * List Companies
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleListCompanies(String projectId, String tenantId) {
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent.toString()).build();
        for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
            System.out.printf("Company Name: %s\n", responseItem.getName());
            System.out.printf("Display Name: %s\n", responseItem.getDisplayName());
            System.out.printf("External ID: %s\n", responseItem.getExternalId());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : ListCompaniesRequest(com.google.cloud.talent.v4beta1.ListCompaniesRequest) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Example 24 with Tenant

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

the class JobSearchListTenants method sampleListTenants.

/**
 * List Tenants
 */
public static void sampleListTenants(String projectId) {
    try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        ListTenantsRequest request = ListTenantsRequest.newBuilder().setParent(parent.toString()).build();
        for (Tenant responseItem : tenantServiceClient.listTenants(request).iterateAll()) {
            System.out.printf("Tenant Name: %s\n", responseItem.getName());
            System.out.printf("External ID: %s\n", responseItem.getExternalId());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) Tenant(com.google.cloud.talent.v4beta1.Tenant) ProjectName(com.google.cloud.talent.v4beta1.ProjectName) ListTenantsRequest(com.google.cloud.talent.v4beta1.ListTenantsRequest)

Example 25 with Tenant

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

the class JobSearchCreateClientEvent method sampleCreateClientEvent.

/**
 * Creates a client event
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 * @param requestId A unique ID generated in the API responses. Value should be set to the
 *     request_id from an API response.
 * @param eventId A unique identifier, generated by the client application
 */
public static void sampleCreateClientEvent(String projectId, String tenantId, String requestId, String eventId) {
    try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        // The timestamp of the event as seconds of UTC time since Unix epoch
        // For more information on how to create google.protobuf.Timestamps
        // See:
        // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
        long seconds = 0L;
        Timestamp createTime = Timestamp.newBuilder().setSeconds(seconds).build();
        // The type of event attributed to the behavior of the end user
        JobEvent.JobEventType type = JobEvent.JobEventType.VIEW;
        // List of job names associated with this event
        String jobsElement = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
        String jobsElement2 = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
        List<String> jobs = Arrays.asList(jobsElement, jobsElement2);
        JobEvent jobEvent = JobEvent.newBuilder().setType(type).addAllJobs(jobs).build();
        ClientEvent clientEvent = ClientEvent.newBuilder().setRequestId(requestId).setEventId(eventId).setCreateTime(createTime).setJobEvent(jobEvent).build();
        CreateClientEventRequest request = CreateClientEventRequest.newBuilder().setParent(parent.toString()).setClientEvent(clientEvent).build();
        ClientEvent response = eventServiceClient.createClientEvent(request);
        System.out.println("Created client event");
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobEvent(com.google.cloud.talent.v4beta1.JobEvent) CreateClientEventRequest(com.google.cloud.talent.v4beta1.CreateClientEventRequest) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Timestamp(com.google.protobuf.Timestamp) EventServiceClient(com.google.cloud.talent.v4beta1.EventServiceClient) ClientEvent(com.google.cloud.talent.v4beta1.ClientEvent)

Aggregations

Test (org.junit.Test)12 Tenant (com.google.cloud.talent.v4beta1.Tenant)10 AbstractMessage (com.google.protobuf.AbstractMessage)9 TenantServiceClient (com.google.cloud.talent.v4beta1.TenantServiceClient)8 Job (com.google.cloud.talent.v4beta1.Job)5 TenantName (com.google.cloud.talent.v4beta1.TenantName)5 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)5 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)4 ProjectName (com.google.cloud.talent.v4beta1.ProjectName)4 Tenant (com.google.cloud.talent.v4.Tenant)3 TenantServiceClient (com.google.cloud.talent.v4.TenantServiceClient)3 Company (com.google.cloud.talent.v4beta1.Company)3 CreateTenantRequest (com.google.cloud.talent.v4beta1.CreateTenantRequest)3 DeleteTenantRequest (com.google.cloud.talent.v4beta1.DeleteTenantRequest)3 GetTenantRequest (com.google.cloud.talent.v4beta1.GetTenantRequest)3 ListTenantsRequest (com.google.cloud.talent.v4beta1.ListTenantsRequest)3 ProjectName (com.google.cloud.talent.v4.ProjectName)2 BatchOperationMetadata (com.google.cloud.talent.v4beta1.BatchOperationMetadata)2 ClientEvent (com.google.cloud.talent.v4beta1.ClientEvent)2 CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)2