export type CreateApiChannelsChannelNameArtifactsArgs = {channel_name: string, body: BodyInit}; export type CreateApiChannelsChannelNameArtifactsOptions = {baseUrl?: string | undefined, jwt?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload an artifact to the channel (implemented by repo-proxy, can't be called directly) * * POST /channels/{channel_name}/artifacts * * Also accepts auth: user_token */ export const createApiChannelsChannelNameArtifacts = async (args: CreateApiChannelsChannelNameArtifactsArgs, options?: CreateApiChannelsChannelNameArtifactsOptions) => { const {baseUrl = "https://api.anaconda.cloud/api", fetch: fetchFn = fetch, jwt} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (jwt !== undefined) headers.set('authorization', `Bearer ${jwt}`) const url = `${baseUrl.replace(/\/+$/, '')}/channels/${encodeURIComponent(String(args.channel_name))}/artifacts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };