Esta página foi traduzida pela API Cloud Translation.
Switch to English

Acessar locatário (v4beta1)

Obter locatário.

Páginas de documentação que incluem esta amostra de código

Para visualizar o exemplo de código usado em contexto, consulte a seguinte documentação:

Amostra de código

C#

public static object GetTenant(string projectId, string tenantId)
{
    TenantServiceClient tenantServiceClient = TenantServiceClient.Create();
    TenantName name = TenantName.FromProjectTenant(projectId, tenantId);
    GetTenantRequest request = new GetTenantRequest
    {
        TenantName = name
    };
    Tenant response = tenantServiceClient.GetTenant(request);
    Console.WriteLine($"Name: {response.Name}");
    Console.WriteLine($"External ID: {response.ExternalId}");
    return 0;
}

Java


import com.google.cloud.talent.v4.GetTenantRequest;
import com.google.cloud.talent.v4.Tenant;
import com.google.cloud.talent.v4.TenantName;
import com.google.cloud.talent.v4.TenantServiceClient;
import java.io.IOException;

public class JobSearchGetTenant {

  public static void getTenant() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    getTenant(projectId, tenantId);
  }

  // Get Tenant by name.
  public static void getTenant(String projectId, String tenantId) 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 (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.format("Name: %s%n", response.getName());
      System.out.format("External ID: %s%n", response.getExternalId());
    }
  }
}