Justin Dalrymple 7f1648802b Major Release v36.0.0 - Improved Typing, and API support (16.0) (#2258)
Adding extensive typing support
Unified browser and Node.JS implementations
Adding support of Gitlab API 16.0
2023-04-26 12:58:56 -04:00

57 lines
1.7 KiB
TypeScript

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 class Namespaces<C extends boolean = false> extends BaseResource<C> {
all<E extends boolean = false, P extends PaginationTypes = 'offset'>(
options?: { search?: string; ownedOnly?: string } & PaginationRequestOptions<P> &
Sudo &
ShowExpanded<E>,
): Promise<GitlabAPIResponse<NamespaceSchema[], C, E, P>> {
return RequestHelper.get<NamespaceSchema[]>()(this, 'namespaces', options);
}
exists<E extends boolean = false>(
namespaceId: string | number,
options?: { parentId?: string } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<NamespaceSchema, C, E, void>> {
return RequestHelper.get<NamespaceSchema>()(
this,
endpoint`namespaces/${namespaceId}/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);
}
}