import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { BaseRequestOptions, GitlabAPIResponse, MappedOmit, OneOf, PaginationRequestOptions, PaginationTypes, ShowExpanded, Sudo, } from '../infrastructure'; export interface RegistryRepositoryTagSchema extends Record { name: string; path: string; location: string; revision: string; short_revision: string; digest: string; created_at: string; total_size: number; } export type CondensedRegistryRepositoryTagSchema = Pick< RegistryRepositoryTagSchema, 'name' | 'path' | 'location' >; export interface RegistryRepositorySchema extends Record { id: number; name: string; path: string; project_id: number; location: string; created_at: string; cleanup_policy_started_at: string; tags_count?: number; tags?: Pick[]; } export type CondensedRegistryRepositorySchema = MappedOmit< RegistryRepositorySchema, 'tags' | 'tags_count' >; export class ContainerRegistry extends BaseResource { allRepositories( { groupId, projectId, ...options }: OneOf<{ projectId: string | number; groupId: string | number }> & { tags?: boolean; tagsCount?: boolean; } & PaginationRequestOptions

& BaseRequestOptions = {} as any, ): Promise> { let url: string; if (groupId) url = endpoint`groups/${groupId}/registry/repositories`; else if (projectId) url = endpoint`projects/${projectId}/registry/repositories`; else throw new Error( 'Missing required argument. Please supply a groupId or a projectId in the options parameter.', ); return RequestHelper.get()(this, url, options); } allTags( projectId: string | number, repositoryId: number, options?: PaginationRequestOptions

& Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/registry/repositories/${repositoryId}/tags`, options, ); } editRegistryVisibility( projectId: string | number, options?: { containerRegistryAccessLevel: 'enabled' | 'private' | 'disabled' } & Sudo & ShowExpanded, ) { return RequestHelper.get()( this, endpoint`projects/${projectId}`, options, ); } removeRepository( projectId: string | number, repositoryId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()( this, endpoint`projects/${projectId}/registry/repositories/${repositoryId}`, options, ); } removeTag( projectId: string | number, repositoryId: number, tagName: string, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()( this, endpoint`projects/${projectId}/registry/repositories/${repositoryId}/tags/${tagName}`, options, ); } removeTags( projectId: string | number, repositoryId: number, nameRegexDelete: string, options?: Sudo & { nameRegex?: string; nameRegexKeep?: string; keepN?: string; olderThan?: string; } & ShowExpanded, ): Promise> { return RequestHelper.del()( this, endpoint`projects/${projectId}/registry/repositories/${repositoryId}/tags`, { nameRegexDelete, ...options, }, ); } showRepository( repositoryId: number, options?: { tags?: boolean; tagsCount?: boolean; size?: boolean } & Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`registry/repositories/${repositoryId}`, options, ); } showTag( projectId: string | number, repositoryId: number, tagName: string, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/registry/repositories/${repositoryId}/tags/${tagName}`, options, ); } }