Mencantumkan tenant menggunakan klien (v4beta1)

Mencantumkan tenant menggunakan klien.

Jelajahi lebih lanjut

Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:

Contoh kode

Node.js

Untuk mempelajari cara menginstal dan menggunakan library klien untuk CTS, lihat library klien CTS. Untuk informasi selengkapnya, lihat dokumentasi referensi API CTS Node.js.

Untuk mengautentikasi ke CTS, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


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

Untuk mempelajari cara menginstal dan menggunakan library klien untuk CTS, lihat library klien CTS. Untuk informasi selengkapnya, lihat dokumentasi referensi API CTS Python.

Untuk mengautentikasi ke CTS, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


from google.cloud import talent

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

    client = talent.TenantServiceClient()

    # project_id = 'Your Google Cloud Project ID'

    if isinstance(project_id, bytes):
        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}")

Langkah selanjutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat browser contoh Google Cloud.