From e29c17a29a6ee84944f8d67d7b6f3c4292763c10 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Tue, 2 Feb 2021 08:49:18 +0100 Subject: [PATCH] Added a simplified runnergroup class ref #1 --- src/models/RunnerGroup.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/models/RunnerGroup.ts diff --git a/src/models/RunnerGroup.ts b/src/models/RunnerGroup.ts new file mode 100644 index 0000000..f50a179 --- /dev/null +++ b/src/models/RunnerGroup.ts @@ -0,0 +1,36 @@ +import { IsInt, IsNotEmpty, IsObject, IsOptional, IsString } from "class-validator"; + +/** + * Defines the runner group class - a simplified version of the backend's ResponseRunnerTeam/-Organization +*/ +export abstract class RunnerGroup { + /** + * The group's id. + */ + @IsInt() + @IsNotEmpty() + id: number;; + + /** + * The group's name. + */ + @IsString() + @IsNotEmpty() + name: string; + + /** + * The group's parent group. + * If it is set this implies that the object is a team. + */ + @IsObject() + @IsOptional() + parentGroup?: RunnerGroup + + /** + * Returns the groups full name in the format: org.name/team.name (or just org). + */ + public get fullName(): string { + if (!this.parentGroup) { return this.name; } + return `${this.name}/${this.parentGroup.fullName}`; + } +}