Delete tenant (v4beta1)

Delete tenant.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


 * Please include the following imports to run this sample.
 * import;
 * import;
 * import;

public static void sampleDeleteTenant() {
  // TODO(developer): Replace these variables before running the sample.
  String projectId = "Your Google Cloud Project ID";
  String tenantId = "Your Tenant ID)";
  sampleDeleteTenant(projectId, tenantId);

/** Delete Tenant */
public static void sampleDeleteTenant(String projectId, String tenantId) {
  try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
    TenantName name = TenantName.of(projectId, tenantId);
    DeleteTenantRequest request =
    System.out.println("Deleted Tenant.");
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);


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

/** Delete Tenant */
function sampleDeleteTenant(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.deleteTenant({name: formattedName}).catch(err => {
  console.log('Deleted Tenant.');


from import talent
import six

def delete_tenant(project_id, tenant_id):
    """Delete Tenant"""

    client = talent.TenantServiceClient()

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

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

    print("Deleted Tenant.")

What's next

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