-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpublic_ips.ts
54 lines (50 loc) · 1.4 KB
/
public_ips.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
import { assertBoolean, assertId, assertNatural, assertString } from "../utils";
import { AbstractBuilder, BuilderMapper, BuilderMethods, BuilderValidator } from "./abstract_builder";
import { SortBy, SortOrder } from "./nodes";
export interface PublicIpQuery {
page: number;
size: number;
retCount: boolean;
randomize: boolean;
sortBy: SortBy;
sortOrder: SortOrder;
farmIds: number;
ip: string;
gateway: string;
free: boolean;
}
const PUBLICIPS_MAPPER: BuilderMapper<PublicIpQuery> = {
page: "page",
size: "size",
retCount: "ret_count",
randomize: "randomize",
sortBy: "sort_by",
sortOrder: "sort_order",
farmIds: "farm_ids",
ip: "ip",
gateway: "gateway",
free: "free",
};
const PUBLICIPS_VALIDATOR: BuilderValidator<PublicIpQuery> = {
page: assertNatural,
size: assertNatural,
retCount: assertBoolean,
randomize: assertBoolean,
sortBy: assertString,
sortOrder: assertString,
farmIds: assertId,
ip: assertString,
gateway: assertString,
free: assertBoolean,
};
export class PublicIpBuilder extends AbstractBuilder<PublicIpQuery> {
constructor(public uri: string, queries: Partial<PublicIpQuery> = {}) {
super({
mapper: PUBLICIPS_MAPPER,
validator: PUBLICIPS_VALIDATOR,
queries,
});
}
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface PublicIpBuilder extends BuilderMethods<PublicIpQuery, PublicIpBuilder> {}