export type BundleId = string; export type RemoveFilesRequest = {path: string, bundleId?: BundleId | undefined}; export type CreateApiSessionsSessionIdDeviceRemoveFileArgs = {sessionId: string, body: RemoveFilesRequest}; export type CreateApiSessionsSessionIdDeviceRemoveFileOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Remove a file from the device * * POST /sessions/{sessionId}/device/removeFile */ export const createApiSessionsSessionIdDeviceRemoveFile = async (args: CreateApiSessionsSessionIdDeviceRemoveFileArgs, options?: CreateApiSessionsSessionIdDeviceRemoveFileOptions) => { const {baseUrl = "https://api.us-west-1.saucelabs.com/rdc/v2", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/sessions/${encodeURIComponent(String(args.sessionId))}/device/removeFile${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 };