Class CompanyServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
Company company = Company.newBuilder().build();
Company response = companyServiceClient.createCompany(parent, company);
}
Note: close() needs to be called on the CompanyServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
CreateCompany |
Creates a new company entity. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetCompany |
Retrieves specified company. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateCompany |
Updates specified company. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteCompany |
Deletes specified company. Prerequisite: The company has no jobs associated with it. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListCompanies |
Lists all companies associated with the project. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of CompanyServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
CompanyServiceSettings companyServiceSettings =
CompanyServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CompanyServiceClient companyServiceClient = CompanyServiceClient.create(companyServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
CompanyServiceSettings companyServiceSettings =
CompanyServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
CompanyServiceClient companyServiceClient = CompanyServiceClient.create(companyServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
CompanyServiceSettings companyServiceSettings =
CompanyServiceSettings.newHttpJsonBuilder().build();
CompanyServiceClient companyServiceClient = CompanyServiceClient.create(companyServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCompanyServiceClient(CompanyServiceSettings settings) Constructs an instance of CompanyServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidclose()static final CompanyServiceClientcreate()Constructs an instance of CompanyServiceClient with default settings.static final CompanyServiceClientcreate(CompanyServiceSettings settings) Constructs an instance of CompanyServiceClient, using the given settings.static final CompanyServiceClientcreate(CompanyServiceStub stub) Constructs an instance of CompanyServiceClient, using the given stub for making calls.final CompanycreateCompany(CreateCompanyRequest request) Creates a new company entity.final CompanycreateCompany(TenantName parent, Company company) Creates a new company entity.final CompanycreateCompany(String parent, Company company) Creates a new company entity.Creates a new company entity.final voiddeleteCompany(CompanyName name) Deletes specified company.final voiddeleteCompany(DeleteCompanyRequest request) Deletes specified company.final voiddeleteCompany(String name) Deletes specified company.final UnaryCallable<DeleteCompanyRequest,com.google.protobuf.Empty> Deletes specified company.final CompanygetCompany(CompanyName name) Retrieves specified company.final CompanygetCompany(GetCompanyRequest request) Retrieves specified company.final CompanygetCompany(String name) Retrieves specified company.Retrieves specified company.final CompanyServiceSettingsgetStub()booleanbooleanlistCompanies(ListCompaniesRequest request) Lists all companies associated with the project.listCompanies(TenantName parent) Lists all companies associated with the project.listCompanies(String parent) Lists all companies associated with the project.Lists all companies associated with the project.Lists all companies associated with the project.voidshutdown()voidfinal CompanyupdateCompany(Company company, com.google.protobuf.FieldMask updateMask) Updates specified company.final CompanyupdateCompany(UpdateCompanyRequest request) Updates specified company.Updates specified company.
-
Constructor Details
-
CompanyServiceClient
Constructs an instance of CompanyServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.- Throws:
IOException
-
CompanyServiceClient
-
-
Method Details
-
create
Constructs an instance of CompanyServiceClient with default settings.- Throws:
IOException
-
create
Constructs an instance of CompanyServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of CompanyServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(CompanyServiceSettings). -
getSettings
-
getStub
-
createCompany
Creates a new company entity.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { TenantName parent = TenantName.of("[PROJECT]", "[TENANT]"); Company company = Company.newBuilder().build(); Company response = companyServiceClient.createCompany(parent, company); }- Parameters:
parent- Required. Resource name of the tenant under which the company is created.The format is "projects/{project_id}/tenants/{tenant_id}", for example, "projects/foo/tenants/bar".
company- Required. The company to be created.- Throws:
ApiException- if the remote call fails
-
createCompany
Creates a new company entity.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { String parent = TenantName.of("[PROJECT]", "[TENANT]").toString(); Company company = Company.newBuilder().build(); Company response = companyServiceClient.createCompany(parent, company); }- Parameters:
parent- Required. Resource name of the tenant under which the company is created.The format is "projects/{project_id}/tenants/{tenant_id}", for example, "projects/foo/tenants/bar".
company- Required. The company to be created.- Throws:
ApiException- if the remote call fails
-
createCompany
Creates a new company entity.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { CreateCompanyRequest request = CreateCompanyRequest.newBuilder() .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) .setCompany(Company.newBuilder().build()) .build(); Company response = companyServiceClient.createCompany(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createCompanyCallable
Creates a new company entity.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { CreateCompanyRequest request = CreateCompanyRequest.newBuilder() .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) .setCompany(Company.newBuilder().build()) .build(); ApiFuture<Company> future = companyServiceClient.createCompanyCallable().futureCall(request); // Do something. Company response = future.get(); } -
getCompany
Retrieves specified company.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { CompanyName name = CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]"); Company response = companyServiceClient.getCompany(name); }- Parameters:
name- Required. The resource name of the company to be retrieved.The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for example, "projects/api-test-project/tenants/foo/companies/bar".
- Throws:
ApiException- if the remote call fails
-
getCompany
Retrieves specified company.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { String name = CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString(); Company response = companyServiceClient.getCompany(name); }- Parameters:
name- Required. The resource name of the company to be retrieved.The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for example, "projects/api-test-project/tenants/foo/companies/bar".
- Throws:
ApiException- if the remote call fails
-
getCompany
Retrieves specified company.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { GetCompanyRequest request = GetCompanyRequest.newBuilder() .setName(CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString()) .build(); Company response = companyServiceClient.getCompany(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getCompanyCallable
Retrieves specified company.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { GetCompanyRequest request = GetCompanyRequest.newBuilder() .setName(CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString()) .build(); ApiFuture<Company> future = companyServiceClient.getCompanyCallable().futureCall(request); // Do something. Company response = future.get(); } -
updateCompany
Updates specified company.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { Company company = Company.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Company response = companyServiceClient.updateCompany(company, updateMask); }- Parameters:
company- Required. The company resource to replace the current resource in the system.updateMask- Strongly recommended for the best service experience.If [update_mask][google.cloud.talent.v4.UpdateCompanyRequest.update_mask] is provided, only the specified fields in [company][google.cloud.talent.v4.UpdateCompanyRequest.company] are updated. Otherwise all the fields are updated.
A field mask to specify the company fields to be updated. Only top level fields of [Company][google.cloud.talent.v4.Company] are supported.
- Throws:
ApiException- if the remote call fails
-
updateCompany
Updates specified company.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { UpdateCompanyRequest request = UpdateCompanyRequest.newBuilder() .setCompany(Company.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Company response = companyServiceClient.updateCompany(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateCompanyCallable
Updates specified company.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { UpdateCompanyRequest request = UpdateCompanyRequest.newBuilder() .setCompany(Company.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Company> future = companyServiceClient.updateCompanyCallable().futureCall(request); // Do something. Company response = future.get(); } -
deleteCompany
Deletes specified company. Prerequisite: The company has no jobs associated with it.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { CompanyName name = CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]"); companyServiceClient.deleteCompany(name); }- Parameters:
name- Required. The resource name of the company to be deleted.The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for example, "projects/foo/tenants/bar/companies/baz".
- Throws:
ApiException- if the remote call fails
-
deleteCompany
Deletes specified company. Prerequisite: The company has no jobs associated with it.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { String name = CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString(); companyServiceClient.deleteCompany(name); }- Parameters:
name- Required. The resource name of the company to be deleted.The format is "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for example, "projects/foo/tenants/bar/companies/baz".
- Throws:
ApiException- if the remote call fails
-
deleteCompany
Deletes specified company. Prerequisite: The company has no jobs associated with it.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { DeleteCompanyRequest request = DeleteCompanyRequest.newBuilder() .setName(CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString()) .build(); companyServiceClient.deleteCompany(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteCompanyCallable
Deletes specified company. Prerequisite: The company has no jobs associated with it.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { DeleteCompanyRequest request = DeleteCompanyRequest.newBuilder() .setName(CompanyName.of("[PROJECT]", "[TENANT]", "[COMPANY]").toString()) .build(); ApiFuture<Empty> future = companyServiceClient.deleteCompanyCallable().futureCall(request); // Do something. future.get(); } -
listCompanies
Lists all companies associated with the project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { TenantName parent = TenantName.of("[PROJECT]", "[TENANT]"); for (Company element : companyServiceClient.listCompanies(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. Resource name of the tenant under which the company is created.The format is "projects/{project_id}/tenants/{tenant_id}", for example, "projects/foo/tenants/bar".
- Throws:
ApiException- if the remote call fails
-
listCompanies
Lists all companies associated with the project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { String parent = TenantName.of("[PROJECT]", "[TENANT]").toString(); for (Company element : companyServiceClient.listCompanies(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. Resource name of the tenant under which the company is created.The format is "projects/{project_id}/tenants/{tenant_id}", for example, "projects/foo/tenants/bar".
- Throws:
ApiException- if the remote call fails
-
listCompanies
public final CompanyServiceClient.ListCompaniesPagedResponse listCompanies(ListCompaniesRequest request) Lists all companies associated with the project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { ListCompaniesRequest request = ListCompaniesRequest.newBuilder() .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) .setPageToken("pageToken873572522") .setPageSize(883849137) .setRequireOpenJobs(true) .build(); for (Company element : companyServiceClient.listCompanies(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listCompaniesPagedCallable
public final UnaryCallable<ListCompaniesRequest,CompanyServiceClient.ListCompaniesPagedResponse> listCompaniesPagedCallable()Lists all companies associated with the project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { ListCompaniesRequest request = ListCompaniesRequest.newBuilder() .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) .setPageToken("pageToken873572522") .setPageSize(883849137) .setRequireOpenJobs(true) .build(); ApiFuture<Company> future = companyServiceClient.listCompaniesPagedCallable().futureCall(request); // Do something. for (Company element : future.get().iterateAll()) { // doThingsWith(element); } } -
listCompaniesCallable
Lists all companies associated with the project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { ListCompaniesRequest request = ListCompaniesRequest.newBuilder() .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString()) .setPageToken("pageToken873572522") .setPageSize(883849137) .setRequireOpenJobs(true) .build(); while (true) { ListCompaniesResponse response = companyServiceClient.listCompaniesCallable().call(request); for (Company element : response.getCompaniesList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-