Se usó la API de Cloud Translation para traducir esta página.
Switch to English

Crear empresa con el cliente (v4beta1)

Crea una empresa con el cliente.

Páginas de documentación que incluyen esta muestra de código

Para ver la muestra de código usada en contexto, consulta la siguiente documentación:

Muestra de código

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());
    }
  }
}

¿Qué sigue?

Para buscar y filtrar muestras de código de otros productos de Google Cloud, consulta el navegador de muestra de Google Cloud.