mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Adding extensive typing support Unified browser and Node.JS implementations Adding support of Gitlab API 16.0
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { BaseResource } from '@gitbeaker/requester-utils';
|
|
import { RequestHelper, endpoint } from '../infrastructure';
|
|
import type {
|
|
GitlabAPIResponse,
|
|
PaginationRequestOptions,
|
|
PaginationTypes,
|
|
ShowExpanded,
|
|
Sudo,
|
|
} from '../infrastructure';
|
|
|
|
export type ProjectTemplateType =
|
|
| 'dockerfiles'
|
|
| 'gitignores'
|
|
| 'gitlab_ci_ymls'
|
|
| 'licenses'
|
|
| 'issues'
|
|
| 'merge_requests';
|
|
export interface ProjectTemplateSchema extends Record<string, unknown> {
|
|
name: string;
|
|
content: string;
|
|
}
|
|
|
|
export class ProjectTemplates<C extends boolean = false> extends BaseResource<C> {
|
|
all<E extends boolean = false, P extends PaginationTypes = 'offset'>(
|
|
projectId: string | number,
|
|
type: ProjectTemplateType,
|
|
options?: PaginationRequestOptions<P> & Sudo & ShowExpanded<E>,
|
|
): Promise<GitlabAPIResponse<ProjectTemplateSchema[], C, E, P>> {
|
|
return RequestHelper.get<ProjectTemplateSchema[]>()(
|
|
this,
|
|
endpoint`projects/${projectId}/templates/${type}`,
|
|
options,
|
|
);
|
|
}
|
|
|
|
show<E extends boolean = false>(
|
|
projectId: string | number,
|
|
type: ProjectTemplateType,
|
|
name: string,
|
|
options?: { project?: string; fullname?: string; sourceTemplateProjectId?: number } & Sudo &
|
|
ShowExpanded<E>,
|
|
): Promise<GitlabAPIResponse<ProjectTemplateSchema, C, E, void>> {
|
|
return RequestHelper.get<ProjectTemplateSchema>()(
|
|
this,
|
|
endpoint`projects/${projectId}/templates/${type}/${name}`,
|
|
options,
|
|
);
|
|
}
|
|
}
|