export type DeleteApiProjectsOwnerNameArtifactsArgs = {owner: string, name: string, path?: Array | undefined, page?: number | undefined, 'per-page'?: number | undefined}; export type DeleteApiProjectsOwnerNameArtifactsOptions = {baseUrl: string, JWTAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete one or many artifacts by key/prefix * * DELETE /projects/{owner}/{name}/artifacts * * Also accepts auth: APIKeyAuth */ export const deleteApiProjectsOwnerNameArtifacts = async (args: DeleteApiProjectsOwnerNameArtifactsArgs, options: DeleteApiProjectsOwnerNameArtifactsOptions) => { const {baseUrl, fetch: fetchFn = fetch, JWTAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() for (const item of args.path ?? []) query.append("path", String(item)) if (args.page != null) query.append("page", String(args.page)) if (args['per-page'] != null) query.append("per-page", String(args['per-page'])) if (JWTAuth !== undefined) headers.set('authorization', `Bearer ${JWTAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/projects/${encodeURIComponent(String(args.owner))}/${encodeURIComponent(String(args.name))}/artifacts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };