/
Log.ts
63 lines (53 loc) · 1.61 KB
/
Log.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the
MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
Copyright Buildbot Team Members
*/
import BaseClass from "./BaseClass";
import IDataDescriptor from "./DataDescriptor";
import {IDataAccessor} from "../DataAccessor";
import {RequestQuery} from "../DataQuery";
export class Log extends BaseClass {
logid!: number;
complete!: boolean;
name!: string;
num_lines!: number;
slug!: string;
stepid!: number;
type!: string;
constructor(accessor: IDataAccessor, endpoint: string, object: any) {
super(accessor, endpoint, String(object.logid));
this.update(object);
}
update(object: any) {
this.logid = object.logid;
this.complete = object.complete;
this.name = object.name;
this.num_lines = object.num_lines;
this.slug = object.slug;
this.stepid = object.stepid;
this.type = object.type;
}
toObject() {
return {
logid: this.logid,
complete: this.complete,
name: this.name,
num_lines: this.num_lines,
slug: this.slug,
stepid: this.stepid,
type: this.type,
};
}
static getAll(accessor: IDataAccessor, query: RequestQuery = {}) {
return accessor.get<Log>("logs", query, logDescriptor);
}
}
export class LogDescriptor implements IDataDescriptor<Log> {
restArrayField = "logs";
fieldId: string = "logid";
parse(accessor: IDataAccessor, endpoint: string, object: any) {
return new Log(accessor, endpoint, object);
}
}
export const logDescriptor = new LogDescriptor();