Added a simplified runnergroup class

ref #1
This commit is contained in:
Nicolai Ort 2021-02-02 08:49:18 +01:00
parent 63f9523766
commit e29c17a29a

36
src/models/RunnerGroup.ts Normal file
View File

@ -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}`;
}
}