var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import DockerHost from "./DockerHost";
import KubernetesCluster from "./KubernetesCluster";
import Label from "./Label";
import Project from "./Project";
import User from "./User";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import AccessControlColumn from "../../Types/Database/AccessControlColumn";
import ColumnLength from "../../Types/Database/ColumnLength";
import ColumnType from "../../Types/Database/ColumnType";
import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
import EnableDocumentation from "../../Types/Database/EnableDocumentation";
import SlugifyColumn from "../../Types/Database/SlugifyColumn";
import TableColumn from "../../Types/Database/TableColumn";
import TableColumnType from "../../Types/Database/TableColumnType";
import TableMetadata from "../../Types/Database/TableMetadata";
import TenantColumn from "../../Types/Database/TenantColumn";
import UniqueColumnBy from "../../Types/Database/UniqueColumnBy";
import IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, } from "typeorm";
let Host = class Host extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.name = undefined;
        this.slug = undefined;
        this.description = undefined;
        this.hostIdentifier = undefined;
        this.otelCollectorStatus = undefined;
        this.agentVersion = undefined;
        this.lastSeenAt = undefined;
        this.osType = undefined;
        this.osVersion = undefined;
        this.hostId = undefined;
        this.hostArch = undefined;
        this.hostType = undefined;
        this.hostIpAddresses = undefined;
        this.cpuCores = undefined;
        this.totalMemoryBytes = undefined;
        this.processCount = undefined;
        this.containerRuntime = undefined;
        this.dockerHost = undefined;
        this.dockerHostId = undefined;
        this.kubernetesCluster = undefined;
        this.kubernetesClusterId = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.labels = undefined;
        this.retainTelemetryDataForDays = undefined;
        this.telemetryRetentionConfig = undefined;
        /*
         * The columns below are auto-populated from OpenTelemetry resource
         * attributes at ingest time (see OtelIngestBaseService.autoDiscoverHost ->
         * HostService.updateLastSeen). They are system-managed — not user-editable.
         */
        this.deploymentEnvironment = undefined;
        this.runtimeName = undefined;
        this.runtimeVersion = undefined;
        this.cloudProvider = undefined;
        this.cloudPlatform = undefined;
        this.cloudRegion = undefined;
        this.cloudAccountId = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "projectId",
        type: TableColumnType.Entity,
        modelType: Project,
        title: "Project",
        description: "Relation to Project Resource in which this object belongs",
    }),
    ManyToOne(() => {
        return Project;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "projectId" }),
    __metadata("design:type", Project)
], Host.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Project ID",
        description: "ID of your OneUptime Project in which this object belongs",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Host.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Name",
        description: "Friendly name for this host",
        example: "production-host-1",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    UniqueColumnBy("projectId"),
    __metadata("design:type", String)
], Host.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        required: true,
        unique: true,
        type: TableColumnType.Slug,
        computed: true,
        title: "Slug",
        description: "Friendly globally unique name for your object",
    }),
    Column({
        nullable: false,
        type: ColumnType.Slug,
        length: ColumnLength.Slug,
    }),
    __metadata("design:type", String)
], Host.prototype, "slug", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        canReadOnRelationQuery: true,
        title: "Description",
        description: "Friendly description for this host",
        example: "Production host running in US East region",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], Host.prototype, "description", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditHost,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Host Identifier",
        description: "Unique identifier for this host, sourced from the host.name OTel resource attribute",
        example: "host-prod-1",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    UniqueColumnBy("projectId"),
    __metadata("design:type", String)
], Host.prototype, "hostIdentifier", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "OTel Collector Status",
        description: "Connection status of the OTel Collector reporting on this host (connected or disconnected)",
        example: "connected",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        default: "disconnected",
    }),
    __metadata("design:type", String)
], Host.prototype, "otelCollectorStatus", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Agent Version",
        description: "Version of the OneUptime agent reporting telemetry on this host, as self-reported via the oneuptime.agent.version resource attribute",
        example: "1.0.0",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "agentVersion", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Date,
        canReadOnRelationQuery: true,
        title: "Last Seen At",
        description: "When telemetry was last received from this host",
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], Host.prototype, "lastSeenAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "OS Type",
        description: "Operating system type of the host",
        example: "linux",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "osType", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        canReadOnRelationQuery: true,
        title: "OS Version",
        description: "Operating system version of the host",
        example: "Ubuntu 22.04",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], Host.prototype, "osVersion", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Host ID",
        description: "Stable host identifier reported by the OTel host.id resource attribute",
        example: "ec2-instance-id-or-machine-id",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "hostId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Host Architecture",
        description: "CPU architecture from the OTel host.arch resource attribute",
        example: "amd64",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "hostArch", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Host Type",
        description: "Cloud-instance class reported by the OTel host.type resource attribute",
        example: "t3.medium",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "hostType", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        canReadOnRelationQuery: true,
        title: "Host IP Addresses",
        description: "Comma-separated list of IP addresses reported by the OTel host.ip resource attribute. The first non-loopback IPv4 is used for display.",
        example: "192.168.1.42, 10.0.0.5",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], Host.prototype, "hostIpAddresses", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        canReadOnRelationQuery: true,
        title: "CPU Cores",
        description: "Logical CPU core count, sourced from system.cpu.logical.count metric",
    }),
    Column({
        type: ColumnType.Number,
        nullable: true,
    }),
    __metadata("design:type", Number)
], Host.prototype, "cpuCores", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.BigNumber,
        canReadOnRelationQuery: true,
        title: "Total Memory (Bytes)",
        description: "Total physical memory in bytes, sourced from system.memory.usage metric (sum of all states).",
    }),
    Column({
        type: ColumnType.BigNumber,
        nullable: true,
        transformer: {
            to: (value) => {
                if (value === undefined || value === null) {
                    return undefined;
                }
                return value.toString();
            },
            from: (value) => {
                if (value === undefined || value === null) {
                    return undefined;
                }
                return Number(value);
            },
        },
    }),
    __metadata("design:type", Number)
], Host.prototype, "totalMemoryBytes", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        canReadOnRelationQuery: true,
        title: "Process Count",
        description: "Most recent process count from system.processes.count metric",
    }),
    Column({
        type: ColumnType.Number,
        nullable: true,
    }),
    __metadata("design:type", Number)
], Host.prototype, "processCount", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Container Runtime",
        description: "Container runtime detected on this host, if any (e.g. docker, containerd)",
        example: "docker",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "containerRuntime", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "dockerHostId",
        type: TableColumnType.Entity,
        modelType: DockerHost,
        title: "Docker Host",
        description: "Optional link to the DockerHost record for this same host when it is also running the Docker runtime",
    }),
    ManyToOne(() => {
        return DockerHost;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "dockerHostId" }),
    __metadata("design:type", DockerHost)
], Host.prototype, "dockerHost", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Docker Host ID",
        description: "Optional FK to the DockerHost record for this same host when it is also running the Docker runtime",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Host.prototype, "dockerHostId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "kubernetesClusterId",
        type: TableColumnType.Entity,
        modelType: KubernetesCluster,
        title: "Kubernetes Cluster",
        description: "Optional link to the KubernetesCluster this host belongs to (typically a node) when k8s.cluster.name is reported",
    }),
    ManyToOne(() => {
        return KubernetesCluster;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "kubernetesClusterId" }),
    __metadata("design:type", KubernetesCluster)
], Host.prototype, "kubernetesCluster", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Kubernetes Cluster ID",
        description: "Optional FK to the KubernetesCluster this host belongs to when k8s.cluster.name is reported",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Host.prototype, "kubernetesClusterId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "createdByUserId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "Created by User",
        description: "Relation to User who created this object (if this object was created by a User)",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByUserId" }),
    __metadata("design:type", User)
], Host.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Created by User ID",
        description: "User ID who created this object (if this object was created by a User)",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Host.prototype, "createdByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "deletedByUserId",
        type: TableColumnType.Entity,
        title: "Deleted by User",
        modelType: User,
        description: "Relation to User who deleted this object (if this object was deleted by a User)",
    }),
    ManyToOne(() => {
        return User;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "deletedByUserId" }),
    __metadata("design:type", User)
], Host.prototype, "deletedByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Deleted by User ID",
        description: "User ID who deleted this object (if this object was deleted by a User)",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Host.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Labels",
        description: "Relation to Labels Array where this object is categorized in.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "HostLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "hostId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Host.prototype, "labels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        type: TableColumnType.Number,
        title: "Retain Telemetry Data For Days",
        description: "Number of days to retain telemetry data for this host. Leave blank to use the project-wide default.",
    }),
    Column({
        type: ColumnType.Number,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Number)
], Host.prototype, "retainTelemetryDataForDays", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditHost,
        ],
    }),
    TableColumn({
        type: TableColumnType.JSON,
        required: false,
        title: "Telemetry Data Retention Overrides",
        description: "Per-pillar retention overrides for this host (logs by severity, traces by status, metrics, profiles). Unset fields fall back to the host default, then the project's retention settings.",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], Host.prototype, "telemetryRetentionConfig", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Deployment Environment",
        description: "Last-seen value of the deployment.environment.name (or deployment.environment) OpenTelemetry resource attribute, e.g. production, staging.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "deploymentEnvironment", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Runtime Name",
        description: "Last-seen value of the process.runtime.name OpenTelemetry resource attribute.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "runtimeName", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Runtime Version",
        description: "Last-seen value of the process.runtime.version OpenTelemetry resource attribute.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "runtimeVersion", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Cloud Provider",
        description: "Last-seen value of the cloud.provider OpenTelemetry resource attribute, e.g. aws, gcp, azure.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "cloudProvider", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Cloud Platform",
        description: "Last-seen value of the cloud.platform OpenTelemetry resource attribute, e.g. aws_ec2, gcp_compute_engine.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "cloudPlatform", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Cloud Region",
        description: "Last-seen value of the cloud.region OpenTelemetry resource attribute, e.g. us-east-1.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "cloudRegion", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Cloud Account ID",
        description: "Last-seen value of the cloud.account.id OpenTelemetry resource attribute.",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Host.prototype, "cloudAccountId", void 0);
Host = __decorate([
    AccessControlColumn("labels"),
    EnableDocumentation(),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.CreateHost,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadHost,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.DeleteHost,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.EditHost,
        ],
    }),
    CrudApiEndpoint(new Route("/host")),
    SlugifyColumn("name", "slug"),
    TableMetadata({
        tableName: "Host",
        singularName: "Host",
        pluralName: "Hosts",
        icon: IconProp.Server,
        tableDescription: "Hosts that are being monitored in this project. Each host is auto-discovered when an OTel Collector reports the host.name resource attribute, or can be manually registered.",
    }),
    Entity({
        name: "Host",
    })
], Host);
export default Host;
//# sourceMappingURL=Host.js.map