クライアントを使用して会社を作成します。
このコードサンプルが含まれるドキュメント ページ
コンテキストで使用されているコードサンプルを表示するには、次のドキュメントをご覧ください。
コードサンプル
C#
public static object CreateCompany(string projectId, string tenantId, string displayName, string externalId)
{
CompanyServiceClient companyServiceClient = CompanyServiceClient.Create();
TenantName tenantName = TenantName.FromProjectTenant(projectId, tenantId);
Company company = new Company
{
DisplayName = displayName,
ExternalId = externalId
};
CreateCompanyRequest request = new CreateCompanyRequest
{
ParentAsTenantName = tenantName,
Company = company
};
Company response = companyServiceClient.CreateCompany(request);
Console.WriteLine("Created Company");
Console.WriteLine($"Name: {response.Name}");
Console.WriteLine($"Display Name: {response.DisplayName}");
Console.WriteLine($"External ID: {response.ExternalId}");
return 0;
}
Java
import com.google.cloud.talent.v4.Company;
import com.google.cloud.talent.v4.CompanyServiceClient;
import com.google.cloud.talent.v4.CreateCompanyRequest;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;
public class JobSearchCreateCompany {
public static void createCompany() throws IOException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "your-project-id";
String tenantId = "your-tenant-id";
String displayName = "your-company-display-name";
String externalId = "your-external-id";
createCompany(projectId, tenantId, displayName, externalId);
}
// Create a company.
public static void createCompany(
String projectId, String tenantId, String displayName, String externalId) throws IOException {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
TenantName parent = TenantName.of(projectId, tenantId);
Company company =
Company.newBuilder().setDisplayName(displayName).setExternalId(externalId).build();
CreateCompanyRequest request =
CreateCompanyRequest.newBuilder()
.setParent(parent.toString())
.setCompany(company)
.build();
Company response = companyServiceClient.createCompany(request);
System.out.println("Created Company");
System.out.format("Name: %s%n", response.getName());
System.out.format("Display Name: %s%n", response.getDisplayName());
System.out.format("External ID: %s%n", response.getExternalId());
}
}
}
次のステップ
他の Google Cloud プロダクト用のコードサンプルを検索してフィルタリングするには、Google Cloud のサンプル ブラウザをご覧ください。