Skip to main content

Tenant and Analytics Creation

Creating a Tenant

To create a new tenant for an individual or organization, use the add_tenant method.

ParameterRequiredDescriptionDefault Value
nameYesThe name of the tenant to be added.None
iconUriNoThe URL for the tenant's icon/logo image."https://example.com/acme\_logo.png"

Example:

tenant_add = sdk.add_tenant(name="MK Security", iconUri="https://example.com/acme\_logo.png")

print(tenant_add)

Creating New Analytics for Tenants

This guide outlines how to create and associate analytics with a tenant using the following functions:

  • add_analytics_type
  • add_analytics_category
  • add_analytics

Step-by-Step Process

  1. Create an Analytics Type
  2. Create an Analytics Category
  3. Create an Analytic

Function Details

1. Adding Analytics Type

This function creates a new analytics type under a tenant.

ParameterRequiredDescriptionDefault Value
nameYesName of the analytics typeNone
descriptionYesDescription of the analytics typeNone
tenant_idYesID of the tenantNone

2. Adding Analytics Category

This function creates a category under a specific analytics type.

ParameterRequiredDescriptionDefault Value
nameYesName of the analytics categoryNone
descriptionYesDescription of the analytics categoryNone
tenant_idYesID of the tenantNone
analytics_type_idYesID of the analytics typeNone

3. Adding Analytics

This function creates an individual analytic under a given category and type.

ParameterRequiredDescriptionDefault Value
nameYesName of the analyticsNone
descriptionYesDescription of the analyticsNone
tenant_idYesID of the tenantNone
analytics_type_idYesID of the analytics typeNone
analytics_category_idYesID of the analytics categoryNone

Example

# Step 1: Create analytics type

analytics_type = sdk.add_analytics_type(

name="Zoo analytics",

description="Zoo analytics",

tenant_id=1

)

print(analytics_type)

# Step 2: Create analytics category

analytics_category = sdk.add_analytics_category(

name="Birds",

description="Birds",

tenant_id=1,

analytics_type_id=analytics_type["id"]

)

print(analytics_category)

# Step 3: Create analytic

new_analytic = sdk.add_analytics(

name="Birds Detection",

description="Analytics to detect birds",

tenant_id=1,

analytics_type_id=analytics_type["id"],

analytics_category_id=analytics_category["id"]

)

print(new_analytic)

Note: Use the IDs returned by previous function calls or existing values to create Analytics.

Fetching All Tenants

This method retrieves a list of all tenants in the system.

This method does not require any parameters.

Example

tenants = sdk.get_all_tenants()

for tenant in tenants:

print(tenant)

Notes

  • Ensure that the SDK is initialized properly with a valid User token before invoking these methods.
  • All returned data is typically formatted as a dictionary or list.