UNPKG

moonlogs-ts

Version:

OpenAPI client for moonlogs

771 lines (740 loc) 17.4 kB
type ApiRequestOptions = { readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; readonly url: string; readonly path?: Record<string, any>; readonly cookies?: Record<string, any>; readonly headers?: Record<string, any>; readonly query?: Record<string, any>; readonly formData?: Record<string, any>; readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; readonly errors?: Record<number, string>; }; declare class CancelError extends Error { constructor(message: string); get isCancelled(): boolean; } interface OnCancel { readonly isResolved: boolean; readonly isRejected: boolean; readonly isCancelled: boolean; (cancelHandler: () => void): void; } declare class CancelablePromise<T> implements Promise<T> { #private; constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void); get [Symbol.toStringTag](): string; then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>; catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>; finally(onFinally?: (() => void) | null): Promise<T>; cancel(): void; get isCancelled(): boolean; } type Resolver<T> = (options: ApiRequestOptions) => Promise<T>; type Headers = Record<string, string>; type OpenAPIConfig = { BASE: string; VERSION: string; WITH_CREDENTIALS: boolean; CREDENTIALS: 'include' | 'omit' | 'same-origin'; TOKEN?: string | Resolver<string> | undefined; USERNAME?: string | Resolver<string> | undefined; PASSWORD?: string | Resolver<string> | undefined; HEADERS?: Headers | Resolver<Headers> | undefined; ENCODE_PATH?: ((path: string) => string) | undefined; }; declare const OpenAPI: OpenAPIConfig; declare abstract class BaseHttpRequest { readonly config: OpenAPIConfig; constructor(config: OpenAPIConfig); abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>; } type Condition = { attribute: string; operation: string; value: string; }; type ActionRequest = { name: string; pattern: string; method: string; conditions?: Array<Condition>; schema_name: string; schema_ids?: Array<number>; disabled?: boolean; }; type ActionResponse = { id: number; name: string; pattern: string; method: string; conditions: Array<Condition>; schema_name: string; schema_ids: Array<number>; disabled: boolean; }; type ApiTokenRequest = { name: string; }; type ApiTokenResponse = { id: number; token: string; name: string; is_revoked: boolean; }; type Credentials = { email: string; password: string; }; type IncidentResponse = { id: number; rule_name: string; rule_id: number; keys: any; count: number; /** * ISO8601 date-time */ ttl: string; }; type IncidentSearchRequest = { keys?: any; }; type Meta = { page: number; count: number; pages: number; }; declare enum Level { TRACE = "Trace", DEBUG = "Debug", INFO = "Info", WARN = "Warn", ERROR = "Error", FATAL = "Fatal" } type RecordRequest = { text: string; schema_name: string; /** * ISO8601 date-time */ created_at?: string; schema_id?: number; query: any; request?: any; response?: any; kind?: string; level?: Level; is_exposed?: boolean; old_value?: string; new_value?: string; changes?: any; }; type RecordResponse = { id: number; text: string; schema_name: string; schema_id: number; query: any; request: any; response: any; kind: string; /** * ISO8601 date-time */ created_at: string; group_hash: string; level: Level; is_exposed: boolean; old_value?: string; new_value?: string; changes?: any; }; type SchemaField = { title: string; name: string; }; type SchemaKind = { title: string; name: string; }; type SchemaRequest = { title: string; description: string; name: string; fields: Array<SchemaField>; kinds?: Array<SchemaKind>; tag_id?: number; tag_name?: string; retention_days?: number; }; type SchemaResponse = { id: number; title: string; description?: string; name: string; fields: Array<SchemaField>; kinds: Array<SchemaKind>; tag_id?: number; retention_days?: number; }; type Session = { token: string; }; type TagRequest = { name: string; view_order: number; }; type TagResponse = { id: number; name: string; view_order: number; }; declare enum Role { MEMBER = "Member", ADMIN = "Admin" } type UserRequest = { name: string; email: string; password: string; password_digest?: string; role: Role; tags?: Array<number>; token?: string; is_revoked?: boolean; }; type UserResponse = { id: number; name: string; email: string; password: string; password_digest?: string; role: Role; tags: Array<number>; token?: string; is_revoked: boolean; }; declare class DefaultService { readonly httpRequest: BaseHttpRequest; constructor(httpRequest: BaseHttpRequest); /** * @returns any * @throws ApiError */ getSchemas(): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<SchemaResponse>; meta: Meta; }>; /** * @returns any * @throws ApiError */ createSchema({ requestBody, }: { requestBody?: SchemaRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: SchemaResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ getSchemaById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: SchemaResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ updateSchemaById({ id, requestBody, }: { id: number; requestBody?: SchemaRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: SchemaResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ deleteSchemaById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: number; meta: Meta; }>; /** * @returns any * @throws ApiError */ createLog({ requestBody, }: { requestBody?: RecordRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: RecordResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ getLog({ page, limit, }: { page?: number; limit?: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<RecordResponse>; meta: Meta; }>; /** * @returns any * @throws ApiError */ getLogById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: RecordResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ getLogsBySchemaAndHash({ schemaName, hash, }: { schemaName: string; hash: string; }): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<RecordResponse>; meta: Meta; }>; /** * @returns any * @throws ApiError */ searchLogs({ page, limit, from, to, requestBody, }: { page?: number; limit?: number; /** * Time in format "YYYY-DD-MMTHH:SS" */ from?: string; /** * Time in format "YYYY-DD-MMTHH:SS" */ to?: string; requestBody?: RecordRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<RecordResponse>; meta: Meta; }>; /** * @returns any * @throws ApiError */ getUsers(): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<UserResponse>; meta: Meta; }>; /** * @returns any * @throws ApiError */ createUser({ requestBody, }: { requestBody?: UserRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: UserResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ getUserById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: UserResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ deleteUserById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; /** * Deleted User's ID */ data: number; meta: Meta; }>; /** * @returns any * @throws ApiError */ updateUserById({ id, requestBody, }: { id: number; requestBody?: UserRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: UserResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ getSession(): CancelablePromise<{ success: boolean; code: number; error: string; data: Session; meta: Meta; }>; /** * @returns any * @throws ApiError */ createSession({ requestBody, }: { requestBody?: Credentials; }): CancelablePromise<{ success: boolean; code: number; error: string; data: Session; meta: Meta; }>; /** * @returns UserResponse * @throws ApiError */ registerAdmin({ requestBody, }: { requestBody?: UserRequest; }): CancelablePromise<UserResponse>; /** * @returns any * @throws ApiError */ getTokens(): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<ApiTokenResponse>; meta: Meta; }>; /** * @returns any * @throws ApiError */ createToken({ requestBody, }: { requestBody?: ApiTokenRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: ApiTokenResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ getTokenById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: ApiTokenResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ updateTokenById({ id, requestBody, }: { id: number; requestBody?: ApiTokenRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: ApiTokenResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ deleteTokenById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: number; meta: Meta; }>; /** * @returns any * @throws ApiError */ getTags(): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<TagResponse>; meta: Meta; }>; /** * @returns any * @throws ApiError */ createTag({ requestBody, }: { requestBody?: TagRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: TagResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ getTagById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: TagResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ updateTagById({ id, requestBody, }: { id: number; requestBody?: TagRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: TagResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ deleteTagById({ id, }: { id: number; }): CancelablePromise<{ success: boolean; code: number; error: string; data: number; meta: Meta; }>; /** * @returns any * @throws ApiError */ createLogAsync({ requestBody, }: { requestBody?: RecordRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: string; meta: Meta; }>; /** * @returns any * @throws ApiError */ getLogRequestById({ id, }: { id: number; }): CancelablePromise<any>; /** * @returns any * @throws ApiError */ getLogResponseById({ id, }: { id: number; }): CancelablePromise<any>; /** * @returns any * @throws ApiError */ exposeRecordById({ id, }: { id: number; }): CancelablePromise<{ success: string; code: number; error: string; data: RecordResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ coverRecordById({ id, }: { id: number; }): CancelablePromise<{ success: string; code: number; error: string; data: RecordResponse; meta: RecordResponse; }>; /** * @returns any * @throws ApiError */ getActions(): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<ActionResponse>; meta: Meta; }>; /** * @returns any * @throws ApiError */ createAction({ requestBody, }: { requestBody?: ActionRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: ActionResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ getActionById(): CancelablePromise<{ success: boolean; code: number; error: string; data: ActionResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ deleteActionById(): CancelablePromise<{ success: boolean; code: number; error: string; /** * Deleted Actions's ID */ data: number; meta: Meta; }>; /** * @returns any * @throws ApiError */ updateActionById({ requestBody, }: { requestBody?: ActionRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: ActionResponse; meta: Meta; }>; /** * @returns any * @throws ApiError */ searchIncidents({ requestBody, }: { requestBody?: IncidentSearchRequest; }): CancelablePromise<{ success: boolean; code: number; error: string; data: Array<IncidentResponse>; meta: Meta; }>; } type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest; declare class MoonlogsClient { readonly default: DefaultService; readonly request: BaseHttpRequest; constructor(config?: Partial<OpenAPIConfig>, HttpRequest?: HttpRequestConstructor); } type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; readonly body: any; }; declare class ApiError extends Error { readonly url: string; readonly status: number; readonly statusText: string; readonly body: any; readonly request: ApiRequestOptions; constructor(request: ApiRequestOptions, response: ApiResult, message: string); } export { type ActionRequest, type ActionResponse, ApiError, type ApiTokenRequest, type ApiTokenResponse, BaseHttpRequest, CancelError, CancelablePromise, type Condition, type Credentials, DefaultService, type IncidentResponse, type IncidentSearchRequest, Level, type Meta, MoonlogsClient, OpenAPI, type OpenAPIConfig, type RecordRequest, type RecordResponse, Role, type SchemaField, type SchemaKind, type SchemaRequest, type SchemaResponse, type Session, type TagRequest, type TagResponse, type UserRequest, type UserResponse };