-
-
Notifications
You must be signed in to change notification settings - Fork 297
/
Namespaces.ts
65 lines (59 loc) · 1.83 KB
/
Namespaces.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
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type {
GitlabAPIResponse,
PaginationRequestOptions,
PaginationTypes,
ShowExpanded,
Sudo,
} from '../infrastructure';
export interface CondensedNamespaceSchema extends Record<string, unknown> {
id: number;
name: string;
path: string;
kind: string;
full_path: string;
parent_id?: number;
avatar_url: string;
web_url: string;
}
export interface NamespaceSchema extends CondensedNamespaceSchema {
members_count_with_descendants: number;
billable_members_count: number;
plan: string;
trial_ends_on?: string;
trial: boolean;
}
export interface NamespaceExistsSchema extends Record<string, unknown> {
exists: boolean;
suggests: string[];
}
export class Namespaces<C extends boolean = false> extends BaseResource<C> {
all<E extends boolean = false, P extends PaginationTypes = 'offset'>(
options?: {
search?: string;
ownedOnly?: string;
topLevelOnly?: boolean;
} & PaginationRequestOptions<P> &
Sudo &
ShowExpanded<E>,
): Promise<GitlabAPIResponse<NamespaceSchema[], C, E, P>> {
return RequestHelper.get<NamespaceSchema[]>()(this, 'namespaces', options);
}
exists<E extends boolean = false>(
namespace: string,
options?: { parentId?: string } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<NamespaceExistsSchema, C, E, void>> {
return RequestHelper.get<NamespaceExistsSchema>()(
this,
endpoint`namespaces/${namespace}/exists`,
options,
);
}
show<E extends boolean = false>(
namespaceId: string | number,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<NamespaceSchema, C, E, void>> {
return RequestHelper.get<NamespaceSchema>()(this, endpoint`namespaces/${namespaceId}`, options);
}
}