Create Tenant: Example

The following example creates the tenant asynchronously and bypasses the tenant cache. Also, an email confirmation is not sent to the administrator so that the tenant is activated as soon as it is in the Active state.

Also see the Create a Tenant operation in the API Reference. For information about authenticating API calls, see Authenticate with Deep Security Manager.

Python

# Define the administrator account
admin = api.Administrator()
admin.username = "TenantAdmin"
admin.password = "Pas$w0rd"
admin.email_address = "example@email.com"
admin.receive_notifications = "false"
admin.role_id = 1

# Create a tenant
tenant = api.Tenant(administrator=admin)

# Set the visible modules
modules = api.Tenant.modules_visible = ["anti-malware", "firewall", "intrusion-prevention"]
tenant.modules_visible = modules

# Set the account name
tenant.name = account_name

# Set the locale and description
tenant.locale = "en-US"
tenant.description = "Test tenant."

# Create the tenant on Deep Security Manager
tenants_api = api.TenantsApi(api.ApiClient(configuration))
return tenants_api.create_tenant(tenant, api_version, confirmation_required=False, asynchronous=True)

JavaScript

// Tenant object
const tenant = new api.Tenant();

// Set the visible modules
tenant.modulesVisible = [
  api.Tenant.ModulesVisibleEnum["anti-malware"],
  api.Tenant.ModulesVisibleEnum.firewall,
  api.Tenant.ModulesVisibleEnum["intrusion-prevention"]
];

// Set the account name
tenant.name = accountName;

// Define the administrator account
const admin = new api.Administrator();
admin.username = "MasterAdmin";
admin.password = "P@55word";
admin.emailAddress = "example@email.com";
tenant.administrator = admin;

// Set the locale and description
tenant.locale = api.Tenant.LocaleEnum["en-US"];
tenant.description = "Test tenant.";

// Creates the tenant
const createTenant = () => {
  const tenantsApi = new api.TenantsApi();
  return tenantsApi.createTenant(tenant, apiVersion, {
    confirmationRequired: "false",
    asynchronous: "true"
  });
};

createTenant()
  .then(newTenant => {
    resolve(newTenant.ID);
  })
  .catch(error => {
    reject(error);
  });

Java

// Create and configure a Tenant object
Tenant tenant = new Tenant();

// Set module visibility
List<ModulesVisibleEnum> modules = new ArrayList<>();
modules.add(ModulesVisibleEnum.ANTI_MALWARE);
modules.add(ModulesVisibleEnum.FIREWALL);
modules.add(ModulesVisibleEnum.INTRUSION_PREVENTION);

// Administrator account
Administrator admin = new Administrator();
admin.setUsername("MasterAdmin");
admin.setPassword("P@55word");
admin.setEmailAddress("bad@email.com");

tenant.setName(accountName);
tenant.setLocale(Tenant.LocaleEnum.EN_US);
tenant.setDescription("Test tenant.");
tenant.setAdministrator(admin);
tenant.setModulesVisible(modules);

// Add the tenant to the manager
TenantsApi tenantsApi = new TenantsApi();
Boolean confirmationRequired = Boolean.FALSE;
Boolean bypassTenantCache = Boolean.TRUE;
Boolean asynchronous = Boolean.TRUE;

return tenantsApi.createTenant(tenant, bypassTenantCache, confirmationRequired, asynchronous, apiVersion);