-
Notifications
You must be signed in to change notification settings - Fork 1
/
keys.ts
56 lines (42 loc) · 1.73 KB
/
keys.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
import {IKeys} from '../api/i-keys';
import {IKeyQuery} from '../query/i-key';
import {IKey} from '../model/i-key';
import {Base} from '../internal/base';
import {validate, checkString as s, checkNumber as n, checkPage} from '../internal/validators';
export class Keys extends Base implements IKeys {
@validate
list(@s projectId: string, @checkPage query?: IKeyQuery):
Promise<{project_id: string, keys: IKey[]}> {
return this.request.get({url: `/projects/${projectId}/keys`, query});
}
@validate
get(@s projectId: string, @n keyId: number):
Promise<{project_id: string, key: IKey}> {
return this.request.get({url: `/projects/${projectId}/keys/${keyId}`});
}
@validate
create(@s projectId: string, body: object):
Promise<{keys: IKey[]}> {
return this.request.post({body, url: `/projects/${projectId}/keys`});
}
@validate
update(@s projectId: string, @n keyId: number, body: object):
Promise<{project_id: string, key: IKey}> {
return this.request.put({body, url: `/projects/${projectId}/keys/${keyId}`});
}
@validate
updateMany(@s projectId: string, body: object):
Promise<{project_id: string, keys: IKey[]}> {
return this.request.put({body, url: `/projects/${projectId}/keys`});
}
@validate
deleteMany(@s projectId: string, body: object):
Promise<{project_id: string, keys_removed: boolean}> {
return this.request.delete({body, url: `/projects/${projectId}/keys`});
}
@validate
delete(@s projectId: string, @n keyId: number):
Promise<{project_id: string, key_removed: boolean}> {
return this.request.delete({url: `/projects/${projectId}/keys/${keyId}`});
}
}