export type ReindexPlaylistSchema = {sync_to_another_dc?: boolean | undefined}; export type CreateApiV1PlaylistsPlaylistIdReindexArgs = {'App-ID': string, 'Auth-Token': string, playlist_id: string, index_immediately?: boolean | undefined, body: ReindexPlaylistSchema}; export type CreateApiV1PlaylistsPlaylistIdReindexOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Reindex the playlist * * POST /v1/playlists/{playlist_id}/reindex/ */ export const createApiV1PlaylistsPlaylistIdReindex = async (args: CreateApiV1PlaylistsPlaylistIdReindexArgs, options: CreateApiV1PlaylistsPlaylistIdReindexOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) if (args.index_immediately != null) query.append("index_immediately", String(args.index_immediately)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/playlists/${encodeURIComponent(String(args.playlist_id))}/reindex/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };