Get tenant (v4beta1)

Get tenant.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Node.js

To learn how to install and use the client library for CTS, see CTS client libraries. For more information, see the CTS Node.js API reference documentation.

To authenticate to CTS, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


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

/** Get Tenant by name */
function sampleGetTenant(projectId, tenantId) {
  const client = new talent.TenantServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID';
  const formattedName = client.tenantPath(projectId, tenantId);
  client
    .getTenant({name: formattedName})
    .then(responses => {
      const response = responses[0];
      console.log(`Name: ${response.name}`);
      console.log(`External ID: ${response.externalId}`);
    })
    .catch(err => {
      console.error(err);
    });
}

Python

To learn how to install and use the client library for CTS, see CTS client libraries. For more information, see the CTS Python API reference documentation.

To authenticate to CTS, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


from google.cloud import talent


def get_tenant(project_id, tenant_id):
    """Get Tenant by name"""

    client = talent.TenantServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    name = client.tenant_path(project_id, tenant_id)

    response = client.get_tenant(name=name)
    print(f"Name: {response.name}")
    print(f"External ID: {response.external_id}")

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.