122 lines
3.6 KiB
TypeScript
Raw Normal View History

///
2021-01-11 13:42:16 +02:00
/// Copyright © 2016-2021 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { ContactBased } from '@shared/models/contact-based.model';
import { TenantId } from './id/tenant-id';
2020-08-26 15:00:11 +03:00
import { TenantProfileId } from '@shared/models/id/tenant-profile-id';
import { BaseData } from '@shared/models/base-data';
import {Validators} from "@angular/forms";
2020-08-26 15:00:11 +03:00
2020-10-22 15:33:34 +03:00
export enum TenantProfileType {
DEFAULT = 'DEFAULT'
}
export interface DefaultTenantProfileConfiguration {
maxDevices: number;
maxAssets: number;
maxCustomers: number;
maxUsers: number;
maxDashboards: number;
maxRuleChains: number;
maxResourcesInBytes: number;
maxOtaPackagesInBytes: number;
2020-10-22 15:33:34 +03:00
transportTenantMsgRateLimit?: string;
transportTenantTelemetryMsgRateLimit?: string;
transportTenantTelemetryDataPointsRateLimit?: string;
transportDeviceMsgRateLimit?: string;
transportDeviceTelemetryMsgRateLimit?: string;
transportDeviceTelemetryDataPointsRateLimit?: string;
maxTransportMessages: number;
maxTransportDataPoints: number;
maxREExecutions: number;
maxJSExecutions: number;
maxDPStorageDays: number;
maxRuleNodeExecutionsPerMessage: number;
maxEmails: number;
maxSms: number;
maxCreatedAlarms: number;
defaultStorageTtlDays: number;
2021-06-11 14:34:43 +03:00
alarmsTtlDays: number;
rpcTtlDays: number;
2020-10-22 15:33:34 +03:00
}
export type TenantProfileConfigurations = DefaultTenantProfileConfiguration;
export interface TenantProfileConfiguration extends TenantProfileConfigurations {
type: TenantProfileType;
}
export function createTenantProfileConfiguration(type: TenantProfileType): TenantProfileConfiguration {
let configuration: TenantProfileConfiguration = null;
if (type) {
switch (type) {
case TenantProfileType.DEFAULT:
const defaultConfiguration: DefaultTenantProfileConfiguration = {
maxDevices: 0,
maxAssets: 0,
maxCustomers: 0,
maxUsers: 0,
maxDashboards: 0,
maxRuleChains: 0,
maxResourcesInBytes: 0,
maxOtaPackagesInBytes: 0,
2020-10-22 15:33:34 +03:00
maxTransportMessages: 0,
maxTransportDataPoints: 0,
maxREExecutions: 0,
maxJSExecutions: 0,
maxDPStorageDays: 0,
maxRuleNodeExecutionsPerMessage: 0,
maxEmails: 0,
maxSms: 0,
maxCreatedAlarms: 0,
2021-06-11 14:34:43 +03:00
defaultStorageTtlDays: 0,
alarmsTtlDays: 0,
rpcTtlDays: 0
2020-10-22 15:33:34 +03:00
};
configuration = {...defaultConfiguration, type: TenantProfileType.DEFAULT};
break;
}
}
return configuration;
}
2020-08-26 15:00:11 +03:00
export interface TenantProfileData {
2020-10-22 15:33:34 +03:00
configuration: TenantProfileConfiguration;
2020-08-26 15:00:11 +03:00
}
export interface TenantProfile extends BaseData<TenantProfileId> {
name: string;
2020-09-01 18:41:42 +03:00
description?: string;
default?: boolean;
isolatedTbCore?: boolean;
isolatedTbRuleEngine?: boolean;
profileData?: TenantProfileData;
2020-08-26 15:00:11 +03:00
}
export interface Tenant extends ContactBased<TenantId> {
title: string;
region: string;
2020-08-26 15:00:11 +03:00
tenantProfileId: TenantProfileId;
additionalInfo?: any;
}
2020-08-26 15:00:11 +03:00
export interface TenantInfo extends Tenant {
tenantProfileName: string;
}