-
-
Notifications
You must be signed in to change notification settings - Fork 297
/
License.ts
72 lines (66 loc) · 2.05 KB
/
License.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
64
65
66
67
68
69
70
71
72
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper } from '../infrastructure';
import type {
GitlabAPIResponse,
PaginationRequestOptions,
PaginationTypes,
ShowExpanded,
Sudo,
} from '../infrastructure';
export interface LicenseSchema extends Record<string, unknown> {
id: number;
plan: string;
created_at: string;
starts_at: string;
expires_at: string;
historical_max: number;
maximum_user_count: number;
expired: boolean;
overage: number;
user_limit: number;
active_users: number;
licensee: {
Name: string;
};
add_ons: {
GitLab_FileLocks: number;
GitLab_Auditor_User: number;
};
}
export class License<C extends boolean = false> extends BaseResource<C> {
add<E extends boolean = false>(
license: string,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<LicenseSchema, C, E, void>> {
return RequestHelper.post<LicenseSchema>()(this, 'license', {
searchParams: { license },
...options,
});
}
all<E extends boolean = false, P extends PaginationTypes = 'offset'>(
options?: Sudo & ShowExpanded<E> & PaginationRequestOptions<P>,
): Promise<GitlabAPIResponse<LicenseSchema[], C, E, P>> {
return RequestHelper.get<LicenseSchema[]>()(this, 'licenses', options);
}
show<E extends boolean = false>(
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<LicenseSchema, C, E, void>> {
return RequestHelper.get<LicenseSchema>()(this, 'license', options);
}
remove<E extends boolean = false>(
licenceId: number,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<LicenseSchema, C, E, void>> {
return RequestHelper.del<LicenseSchema>()(this, `license/${licenceId}`, options);
}
recalculateBillableUsers<E extends boolean = false>(
licenceId: number,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<{ success: boolean }, C, E, void>> {
return RequestHelper.put<{ success: boolean }>()(
this,
`license/${licenceId}/refresh_billable_users`,
options,
);
}
}