|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import * as Core from '../core'; |
| 4 | +import { APIResource } from '../resource'; |
| 5 | +import * as EventsAPI from './events'; |
| 6 | +import { Stream } from '../streaming'; |
| 7 | + |
| 8 | +export class Events extends APIResource { |
| 9 | + /** |
| 10 | + * Get download events. |
| 11 | + */ |
| 12 | + downloadEvent(): Core.APIPromise<Stream<DownloadStateEvent>> { |
| 13 | + return this._client.get(`/events/download`, { |
| 14 | + stream: true, |
| 15 | + }) as Core.APIPromise<Stream<DownloadStateEvent>>; |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +export enum DownloadStatus { |
| 20 | + Pending = 'pending', |
| 21 | + Downloading = 'downloading', |
| 22 | + Error = 'error', |
| 23 | + Downloaded = 'downloaded', |
| 24 | +} |
| 25 | + |
| 26 | +export enum DownloadType { |
| 27 | + Model = 'model', |
| 28 | + Miscelanous = 'miscelanous', |
| 29 | + Engine = 'engine', |
| 30 | +} |
| 31 | + |
| 32 | +export interface DownloadItem { |
| 33 | + /** |
| 34 | + * Filename of the download. |
| 35 | + */ |
| 36 | + id: string; |
| 37 | + |
| 38 | + time: { |
| 39 | + elapsed: number; |
| 40 | + remaining: number; |
| 41 | + }; |
| 42 | + |
| 43 | + size: { |
| 44 | + total: number; |
| 45 | + transferred: number; |
| 46 | + }; |
| 47 | + |
| 48 | + checksum?: string; |
| 49 | + |
| 50 | + status: DownloadStatus; |
| 51 | + |
| 52 | + error?: string; |
| 53 | + |
| 54 | + metadata?: Record<string, unknown>; |
| 55 | +} |
| 56 | + |
| 57 | +export interface DownloadState { |
| 58 | + /** |
| 59 | + * The id of a particular download. Being used to prevent duplication of downloads. |
| 60 | + */ |
| 61 | + id: string; |
| 62 | + |
| 63 | + /** |
| 64 | + * For displaying purposes. |
| 65 | + */ |
| 66 | + title: string; |
| 67 | + |
| 68 | + /** |
| 69 | + * The type of download. |
| 70 | + */ |
| 71 | + type: DownloadType; |
| 72 | + |
| 73 | + /** |
| 74 | + * The status of the download. |
| 75 | + */ |
| 76 | + status: DownloadStatus; |
| 77 | + |
| 78 | + /** |
| 79 | + * Explanation of the error if the download failed. |
| 80 | + */ |
| 81 | + error?: string; |
| 82 | + |
| 83 | + /** |
| 84 | + * The actual downloads. [DownloadState] is just a group to supporting for download multiple files. |
| 85 | + */ |
| 86 | + children: DownloadItem[]; |
| 87 | +} |
| 88 | + |
| 89 | +export type DownloadStateEvent = DownloadState[]; |
| 90 | + |
| 91 | +export namespace Events { |
| 92 | + export import DownloadStateEvent = EventsAPI.DownloadStateEvent; |
| 93 | + export import DownloadStatus = EventsAPI.DownloadStatus; |
| 94 | + export import DownloadType = EventsAPI.DownloadType; |
| 95 | + export import DownloadItem = EventsAPI.DownloadItem; |
| 96 | +} |
0 commit comments