export type DeleteApiRepositoriesWorkspaceRepoSlugArgs = {redirect_to?: string | undefined}; export type DeleteApiRepositoriesWorkspaceRepoSlugOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete a repository * * DELETE /repositories/{workspace}/{repo_slug} * * Also accepts auth: basic, api_key */ export const deleteApiRepositoriesWorkspaceRepoSlug = async (args: DeleteApiRepositoriesWorkspaceRepoSlugArgs, options?: DeleteApiRepositoriesWorkspaceRepoSlugOptions) => { const {baseUrl = "https://api.bitbucket.org/2.0", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.redirect_to != null) query.append("redirect_to", String(args.redirect_to)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/repositories/${encodeURIComponent(String(args.workspace))}/${encodeURIComponent(String(args.repo_slug))}${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 };