Search in sources :

Example 26 with Tenant

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

the class JobSearchCreateJob method sampleCreateJob.

/**
 * Create Job
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleCreateJob(String projectId, String tenantId, String companyName, String requisitionId, String title, String description, String jobApplicationUrl, String addressOne, String addressTwo, String languageCode) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        List<String> uris = Arrays.asList(jobApplicationUrl);
        Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(uris).build();
        List<String> addresses = Arrays.asList(addressOne, addressTwo);
        Job job = Job.newBuilder().setCompany(companyName).setRequisitionId(requisitionId).setTitle(title).setDescription(description).setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode(languageCode).build();
        CreateJobRequest request = CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();
        Job response = jobServiceClient.createJob(request);
        System.out.printf("Created job: %s\n", response.getName());
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest)

Example 27 with Tenant

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

the class JobSearchCreateTenant method sampleCreateTenant.

/**
 * Create Tenant for scoping resources, e.g. companies and jobs
 */
public static void sampleCreateTenant(String projectId, String externalId) {
    try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        Tenant tenant = Tenant.newBuilder().setExternalId(externalId).build();
        CreateTenantRequest request = CreateTenantRequest.newBuilder().setParent(parent.toString()).setTenant(tenant).build();
        Tenant response = tenantServiceClient.createTenant(request);
        System.out.println("Created Tenant");
        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 : CreateTenantRequest(com.google.cloud.talent.v4beta1.CreateTenantRequest) TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) Tenant(com.google.cloud.talent.v4beta1.Tenant) ProjectName(com.google.cloud.talent.v4beta1.ProjectName)

Example 28 with Tenant

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

the class CompanyServiceClientTest method listCompaniesTest2.

@Test
public void listCompaniesTest2() throws Exception {
    Company responsesElement = Company.newBuilder().build();
    ListCompaniesResponse expectedResponse = ListCompaniesResponse.newBuilder().setNextPageToken("").addAllCompanies(Arrays.asList(responsesElement)).build();
    mockCompanyService.addResponse(expectedResponse);
    TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
    ListCompaniesPagedResponse pagedListResponse = client.listCompanies(parent);
    List<Company> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getCompaniesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCompanyService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListCompaniesRequest actualRequest = ((ListCompaniesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListCompaniesPagedResponse(com.google.cloud.talent.v4beta1.CompanyServiceClient.ListCompaniesPagedResponse) Test(org.junit.Test)

Example 29 with Tenant

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

the class ApplicationServiceClientTest method listApplicationsTest.

@Test
public void listApplicationsTest() throws Exception {
    Application responsesElement = Application.newBuilder().build();
    ListApplicationsResponse expectedResponse = ListApplicationsResponse.newBuilder().setNextPageToken("").addAllApplications(Arrays.asList(responsesElement)).build();
    mockApplicationService.addResponse(expectedResponse);
    ProfileName parent = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]");
    ListApplicationsPagedResponse pagedListResponse = client.listApplications(parent);
    List<Application> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getApplicationsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockApplicationService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListApplicationsRequest actualRequest = ((ListApplicationsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListApplicationsPagedResponse(com.google.cloud.talent.v4beta1.ApplicationServiceClient.ListApplicationsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 30 with Tenant

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

the class TenantServiceClientTest method listTenantsTest.

@Test
public void listTenantsTest() throws Exception {
    Tenant responsesElement = Tenant.newBuilder().build();
    ListTenantsResponse expectedResponse = ListTenantsResponse.newBuilder().setNextPageToken("").addAllTenants(Arrays.asList(responsesElement)).build();
    mockTenantService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListTenantsPagedResponse pagedListResponse = client.listTenants(parent);
    List<Tenant> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTenantsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockTenantService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTenantsRequest actualRequest = ((ListTenantsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListTenantsPagedResponse(com.google.cloud.talent.v4beta1.TenantServiceClient.ListTenantsPagedResponse) Test(org.junit.Test)

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