export type GetApiInstallRepositoriesUserIdRepoAptAuthConfArgs = {user_id: string, repo: string, dist: string, name: string, os: string}; export type GetApiInstallRepositoriesUserIdRepoAptAuthConfOptions = {baseUrl?: string | undefined, masterToken?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * apt auth.conf * * GET /install/repositories/{user_id}/{repo}/apt_auth_conf */ export const getApiInstallRepositoriesUserIdRepoAptAuthConf = async (args: GetApiInstallRepositoriesUserIdRepoAptAuthConfArgs, options?: GetApiInstallRepositoriesUserIdRepoAptAuthConfOptions) => { const {baseUrl = "https://packagecloud.io", fetch: fetchFn = fetch, masterToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.dist != null) query.append("dist", String(args.dist)) if (args.name != null) query.append("name", String(args.name)) if (args.os != null) query.append("os", String(args.os)) if (masterToken !== undefined) headers.set('authorization', `Basic ${btoa(`${masterToken.username}:${masterToken.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/install/repositories/${encodeURIComponent(String(args.user_id))}/${encodeURIComponent(String(args.repo))}/apt_auth_conf${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };