Tenant and Analytics Creation
Creating a Tenant
To create a new tenant for an individual or organization, use the add_tenant method.
| Parameter | Required | Description | Default Value |
|---|---|---|---|
| name | Yes | The name of the tenant to be added. | None |
| iconUri | No | The 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
- Create an Analytics Type
- Create an Analytics Category
- Create an Analytic
Function Details
1. Adding Analytics Type
This function creates a new analytics type under a tenant.
| Parameter | Required | Description | Default Value |
|---|---|---|---|
| name | Yes | Name of the analytics type | None |
| description | Yes | Description of the analytics type | None |
| tenant_id | Yes | ID of the tenant | None |
2. Adding Analytics Category
This function creates a category under a specific analytics type.
| Parameter | Required | Description | Default Value |
|---|---|---|---|
| name | Yes | Name of the analytics category | None |
| description | Yes | Description of the analytics category | None |
| tenant_id | Yes | ID of the tenant | None |
| analytics_type_id | Yes | ID of the analytics type | None |
3. Adding Analytics
This function creates an individual analytic under a given category and type.
| Parameter | Required | Description | Default Value |
|---|---|---|---|
| name | Yes | Name of the analytics | None |
| description | Yes | Description of the analytics | None |
| tenant_id | Yes | ID of the tenant | None |
| analytics_type_id | Yes | ID of the analytics type | None |
| analytics_category_id | Yes | ID of the analytics category | None |
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.