export type SubscriptionUpdate = {events?: (Array<'pipeline-complete' | 'pipeline-complete-with-results' | 'pipeline-complete-no-results' | 'pipeline-create' | 'pipeline-interval-processing' | 'pipeline-interval-ordering' | 'pipeline-interval-failure' | 'pipeline-interval-tasking-order-committed' | 'pipeline-interval-tasking-order-cancelled'>) | undefined, secret?: string | undefined, callback_uri?: string | undefined, status?: ('active' | 'inactive') | undefined, callback_headers?: Record | undefined}; export type CreateApiSubscriptionsIdArgs = {id: string, body: SubscriptionUpdate}; export type CreateApiSubscriptionsIdOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update subscription * * POST /subscriptions/{id} */ export const createApiSubscriptionsId = async (args: CreateApiSubscriptionsIdArgs, options?: CreateApiSubscriptionsIdOptions) => { const {baseUrl = "https://api.skywatch.co/earthcache", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKey !== undefined) headers.set("x-api-key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/subscriptions/${encodeURIComponent(String(args.id))}${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 };