[v4beta1] 클라이언트를 사용하여 테넌트 나열

클라이언트를 사용하여 테넌트를 나열합니다.

이 코드 샘플이 포함된 문서 페이지

컨텍스트에서 사용된 코드 샘플을 보려면 다음 문서를 참조하세요.

코드 샘플

Node.js


const talent = require('@google-cloud/talent').v4;

/** List Tenants */
function sampleListTenants(projectId) {
  const client = new talent.TenantServiceClient();
  // Iterate over all elements.
  // const projectId = 'Your Google Cloud Project ID';
  const formattedParent = client.projectPath(projectId);

  client
    .listTenants({parent: formattedParent})
    .then(responses => {
      const resources = responses[0];
      for (const resource of resources) {
        console.log(`Tenant Name: ${resource.name}`);
        console.log(`External ID: ${resource.externalId}`);
      }
    })
    .catch(err => {
      console.error(err);
    });
}

Python


from google.cloud import talent
import six

def list_tenants(project_id):
    """List Tenants"""

    client = talent.TenantServiceClient()

    # project_id = 'Your Google Cloud Project ID'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    parent = f"projects/{project_id}"

    # Iterate over all results
    for response_item in client.list_tenants(parent=parent):
        print(f"Tenant Name: {response_item.name}")
        print(f"External ID: {response_item.external_id}")

Ruby

require "google/cloud/talent"

# Instantiate a client
tenant_service = Google::Cloud::Talent.tenant_service

# project_id = "Your Google Cloud Project ID"
formatted_parent = tenant_service.project_path project: project_id

# Iterate over all results.
tenant_service.list_tenants(parent: formatted_parent).each do |element|
  puts "Tenant Name: #{element.name}"
  puts "External ID: #{element.external_id}"
end