mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
Covers #36760, #36758. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) ## Testing - [x] Added/updated automated tests - [x] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [ ] QA'd all new/changed functionality manually
111 lines
2.8 KiB
TypeScript
111 lines
2.8 KiB
TypeScript
import PropTypes from "prop-types";
|
|
|
|
export default PropTypes.shape({
|
|
created_at: PropTypes.string,
|
|
updated_at: PropTypes.string,
|
|
id: PropTypes.oneOfType([PropTypes.number]),
|
|
name: PropTypes.string,
|
|
query: PropTypes.string,
|
|
label_type: PropTypes.oneOf(["regular", "builtin"]),
|
|
label_membership_type: PropTypes.oneOf(["dynamic", "manual"]),
|
|
hosts_count: PropTypes.number,
|
|
display_text: PropTypes.string,
|
|
count: PropTypes.number, // seems to be a repeat of hosts_count issue #1618
|
|
host_ids: PropTypes.arrayOf(PropTypes.number),
|
|
});
|
|
|
|
export type LabelType = "regular" | "builtin";
|
|
export type LabelMembershipType = "dynamic" | "manual" | "host_vitals";
|
|
export const LabelMembershipTypeToDisplayCopy: Record<
|
|
LabelMembershipType,
|
|
string
|
|
> = {
|
|
dynamic: "Dynamic",
|
|
manual: "Manual",
|
|
host_vitals: "Host vitals",
|
|
};
|
|
|
|
export type LabelHostVitalsCriterion =
|
|
| "end_user_idp_group"
|
|
| "end_user_idp_department"; // for now, may expand to be configurable
|
|
|
|
export type LabelLeafCriterion = {
|
|
vital: LabelHostVitalsCriterion;
|
|
value: string; // from user input
|
|
};
|
|
|
|
type LabelAndCriterion = {
|
|
and: LabelHostVitalsCriteria[];
|
|
};
|
|
|
|
type LabelOrCriterion = {
|
|
or: LabelHostVitalsCriteria[];
|
|
};
|
|
|
|
export type LabelHostVitalsCriteria =
|
|
| LabelLeafCriterion
|
|
| LabelAndCriterion
|
|
| LabelOrCriterion;
|
|
|
|
export interface ILabelSummary {
|
|
id: number;
|
|
name: string;
|
|
description?: string;
|
|
label_type: LabelType;
|
|
}
|
|
|
|
export interface ILabelSoftwareTitle {
|
|
id: number;
|
|
name: string;
|
|
}
|
|
|
|
export interface ILabelQuery {
|
|
id: number;
|
|
name: string;
|
|
}
|
|
|
|
export interface ILabelPolicy {
|
|
id: number;
|
|
name: string;
|
|
}
|
|
|
|
export interface ILabel extends ILabelSummary {
|
|
created_at: string;
|
|
updated_at: string;
|
|
uuid?: string;
|
|
host_count?: number; // returned for built-in labels but not custom labels
|
|
display_text: string;
|
|
count: number; // seems to be a repeat of hosts_count issue #1618
|
|
type?: "custom" | "platform" | "status" | "all";
|
|
slug?: string; // e.g., "labels/13" | "online"
|
|
target_type?: string; // e.g., "labels"
|
|
author_id?: number;
|
|
team_id: number | null;
|
|
team_name?: string | null; // returned on individual label endpoints but not list endpoints
|
|
|
|
label_membership_type: LabelMembershipType;
|
|
|
|
// dynamic-specific
|
|
query: string; // does return '""' for other types
|
|
platform: string; // does return '""' for other types
|
|
|
|
// host_vitals-specific
|
|
criteria: LabelHostVitalsCriteria | null;
|
|
|
|
// manual-specific
|
|
host_ids: number[] | null;
|
|
}
|
|
|
|
// corresponding to fleet>server>fleet>labels.go>LabelSpec
|
|
export interface ILabelSpecResponse {
|
|
specs: {
|
|
id: number;
|
|
name: string;
|
|
description: string;
|
|
query: string;
|
|
platform?: string; // improve to only allow possible platforms from API
|
|
label_type?: LabelType;
|
|
label_membership_type: LabelMembershipType;
|
|
hosts?: string[];
|
|
};
|
|
}
|