From 137e085038083402d140afeb68bbac113d94099a Mon Sep 17 00:00:00 2001 From: Jeongseok Kang Date: Fri, 16 Dec 2022 10:04:00 +0900 Subject: [PATCH 1/5] feat: Add support for typescript declaration (.d.ts) --- dist/backend.ai-client-node.d.ts | 1342 ++++++++++++++++++++++++++++++ package-lock.json | 4 +- package.json | 6 +- 3 files changed, 1348 insertions(+), 4 deletions(-) create mode 100644 dist/backend.ai-client-node.d.ts diff --git a/dist/backend.ai-client-node.d.ts b/dist/backend.ai-client-node.d.ts new file mode 100644 index 0000000..319acd5 --- /dev/null +++ b/dist/backend.ai-client-node.d.ts @@ -0,0 +1,1342 @@ +export namespace backend { + export { Client }; + export { ClientConfig }; +} +export class Client { + /** + * The client API wrapper. + * + * @param {ClientConfig} config - the API client-side configuration + * @param {string} agentSignature - an extra string that will be appended to User-Agent headers when making API requests + */ + constructor(config: ClientConfig, agentSignature: string); + ready: boolean; + code: any; + sessionId: any; + kernelType: any; + clientVersion: string; + agentSignature: string; + _config: ClientConfig; + _managerVersion: any; + _apiVersion: any; + _apiVersionMajor: any; + is_admin: boolean; + is_superadmin: boolean; + kernelPrefix: string; + resourcePreset: ResourcePreset; + vfolder: VFolder; + agent: Agent; + keypair: Keypair; + image: ContainerImage; + utils: utils; + computeSession: ComputeSession; + sessionTemplate: SessionTemplate; + resourcePolicy: ResourcePolicy; + user: User; + group: Group; + domain: Domain; + resources: Resources; + storageproxy: StorageProxy; + maintenance: Maintenance; + scalingGroup: ScalingGroup; + registry: Registry; + setting: Setting; + userConfig: UserConfig; + service: Service; + enterprise: Enterprise; + cloud: Cloud; + eduApp: EduApp; + _features: {}; + abortController: AbortController; + abortSignal: AbortSignal; + requestTimeout: number; + /** + * Return the server-side manager version. + */ + get managerVersion(): any; + /** + * Return the server-side manager version. + */ + get apiVersion(): any; + /** + * Promise wrapper for asynchronous request to Backend.AI manager. + * + * @param {Request} rqst - Request object to send + * @param {Boolean} rawFile - True if it is raw request + * @param {AbortController.signal} signal - Request signal to abort fetch + * @param {number} timeout - Custom timeout (sec.) If no timeout is given, default timeout is used. + * @param {number} retry - an integer to retry this request + * @param {Object} opts - Options + */ + _wrapWithPromise(rqst: Request, rawFile?: boolean, signal?: any, timeout?: number, retry?: number, opts?: any): any; + /** + * Return the server-side API version. + * + * @param {AbortController.signal} signal - Request signal to abort fetch + * + */ + getServerVersion(signal?: any): any; + /** + * Force API major version + */ + set APIMajorVersion(arg: any); + /** + * Get API major version + */ + get APIMajorVersion(): any; + /** + * Get the server-side manager version. + * + * @param {AbortController.signal} signal - Request signal to abort fetch + */ + get_manager_version(signal?: any): Promise; + /** + * Check compatibility of current manager + */ + supports(feature: any): any; + _updateFieldCompatibilityByAPIVersion(fields: any): any; + _updateSupportList(): void; + /** + * Return if manager is compatible with given version. + */ + isManagerVersionCompatibleWith(version: any): boolean; + /** + * Return if api is compatible with given version. + */ + isAPIVersionCompatibleWith(version: any): boolean; + /** + * Check if webserver is authenticated. This requires additional webserver package. + * + */ + check_login(): Promise; + /** + * Login into webserver with given ID/Password. This requires additional webserver package. + * + */ + login(): Promise; + /** + * Logout from webserver. This requires additional webserver package. + * + */ + logout(): any; + /** + * Login into webserver with auth cookie token. This requires additional webserver package. + * + */ + token_login(): Promise; + /** + * Leave from manager user. This requires additional webserver package. + * + */ + signout(userid: any, password: any): Promise; + /** + * Update user's full_name. + */ + update_full_name(email: any, fullName: any): Promise; + /** + * Update user's password. + * + */ + update_password(oldPassword: any, newPassword: any, newPassword2: any): Promise; + /** + * Return the resource slots. + */ + get_resource_slots(): Promise; + /** + * Create a compute session if the session for the given sessionId does not exists. + * It returns the information for the existing session otherwise, without error. + * + * @param {string} kernelType - the kernel type (usually language runtimes) + * @param {string} sessionId - user-defined session ID + * @param {object} resources - Per-session resource + * @param {number} timeout - Timeout of request. Default : default fetch value. (5sec.) + */ + createIfNotExists(kernelType: string, sessionId: string, resources?: object, timeout?: number): Promise; + /** + * Create a session with a session template. + * + * @param {string} sessionId - the sessionId given when created + */ + createSessionFromTemplate(templateId: any, image?: any, sessionName?: any, resources?: {}, timeout?: number): Promise; + /** + * Obtain the session information by given sessionId. + * + * @param {string} sessionId - the sessionId given when created + */ + get_info(sessionId: string, ownerKey?: any): Promise; + /** + * Obtain the session container logs by given sessionId. + * + * @param {string} sessionId - the sessionId given when created + * @param {string | null} ownerKey - owner key to access + * @param {number} timeout - timeout to wait log query. Set to 0 to use default value. + */ + get_logs(sessionId: string, ownerKey?: string | null, timeout?: number): Promise; + /** + * Obtain the batch session (task) logs by given sessionId. + * + * @param {string} sessionId - the sessionId given when created + */ + getTaskLogs(sessionId: string): any; + /** + * Terminate and destroy the kernel session. + * + * @param {string} sessionId - the sessionId given when created + * @param {string|null} ownerKey - owner key when terminating other users' session + * @param {boolean} forced - force destroy session. Requires admin privilege. + */ + destroy(sessionId: string, ownerKey?: string | null, forced?: boolean): Promise; + /** + * Restart the kernel session keeping its work directory and volume mounts. + * + * @param {string} sessionId - the sessionId given when created + */ + restart(sessionId: string, ownerKey?: any): Promise; + /** + * Execute a code snippet or schedule batch-mode executions. + * + * @param {string} sessionId - the sessionId given when created + * @param {string} runId - a random ID to distinguish each continuation until finish (the length must be between 8 to 64 bytes inclusively) + * @param {string} mode - either "query", "batch", "input", or "continue" + * @param {string} opts - an optional object specifying additional configs such as batch-mode build/exec commands + */ + execute(sessionId: string, runId: string, mode: string, code: any, opts: string, timeout?: number): Promise; + createKernel(kernelType: any, sessionId?: any, resources?: {}, timeout?: number): Promise; + destroyKernel(sessionId: any, ownerKey?: any): Promise; + refreshKernel(sessionId: any, ownerKey?: any): Promise; + runCode(code: any, sessionId: any, runId: any, mode: any): Promise; + shutdown_service(sessionId: any, service_name: any): Promise; + upload(sessionId: any, path: any, fs: any): Promise; + download(sessionId: any, files: any): Promise; + download_single(sessionId: any, file: any): Promise; + mangleUserAgentSignature(): string; + /** + * Send GraphQL requests + * + * @param {string} q - query string for GraphQL + * @param {string} v - variable string for GraphQL + * @param {number} timeout - Timeout to force terminate request + * @param {number} retry - The number of retry when request is failed + */ + query(q: string, v: string, signal?: any, timeout?: number, retry?: number): Promise; + /** + * Generate a RequestInfo object that can be passed to fetch() API, + * which includes a properly signed header with the configured auth information. + * + * @param {string} method - the HTTP method + * @param {string} queryString - the URI path and GET parameters + * @param {any} body - an object that will be encoded as JSON in the request body + */ + newSignedRequest(method: string, queryString: string, body: any): { + method: string; + headers: Headers; + cache: string; + body: any; + uri: string; + }; + /** + * Same to newRequest() method but it does not sign the request. + * Use this for unauthorized public APIs. + * + * @param {string} method - the HTTP method + * @param {string} queryString - the URI path and GET parameters + * @param {any} body - an object that will be encoded as JSON in the request body + */ + newUnsignedRequest(method: string, queryString: string, body: any): { + method: any; + headers: Headers; + mode: string; + cache: string; + uri: string; + }; + newPublicRequest(method: any, queryString: any, body: any, urlPrefix: any): { + method: any; + headers: Headers; + mode: string; + cache: string; + uri: string; + }; + getAuthenticationString(method: any, queryString: any, dateValue: any, bodyValue: any, content_type?: string): string; + getCurrentDate(now: any): string; + sign(key: any, key_encoding: any, msg: any, digest_type: any): string; + getSignKey(secret_key: any, now: any): string; + generateSessionId(length?: number, nosuffix?: boolean): string; + slugify(text: any): any; + /** + * fetch existing pubic key of SSH Keypair from container + * only ssh_public_key will be received. + */ + fetchSSHKeypair(): Promise; + /** + * refresh SSH Keypair from container + * gets randomly generated keypair (both ssh_public_key and ssh_private_key) will be received. + */ + refreshSSHKeypair(): Promise; +} +export namespace Client { + const ERR_SERVER: number; + const ERR_RESPONSE: number; + const ERR_REQUEST: number; + const ERR_ABORT: number; + const ERR_TIMEOUT: number; + const ERR_UNKNOWN: number; +} +export class ClientConfig { + /** + * Create a ClientConfig object from environment variables. + */ + static createFromEnv(): ClientConfig; + /** + * The client Configuration object. + * + * @param {string} accessKey - access key to connect Backend.AI manager + * @param {string} secretKey - secret key to connect Backend.AI manager + * @param {string} endpoint - endpoint of Backend.AI manager + * @param {string} connectionMode - connection mode. 'API', 'SESSION' is supported. `SESSION` mode requires webserver. + */ + constructor(accessKey: string, secretKey: string, endpoint: string, connectionMode?: string); + _apiVersionMajor: string; + _apiVersion: string; + _hashType: string; + _endpoint: string; + _endpointHost: string; + _accessKey: string; + _secretKey: string; + _userId: string; + _password: string; + _proxyURL: any; + _proxyToken: any; + _connectionMode: string; + get accessKey(): string; + get secretKey(): string; + get userId(): string; + get password(): string; + get endpoint(): string; + get proxyURL(): any; + get proxyToken(): any; + get endpointHost(): string; + get apiVersion(): string; + get apiVersionMajor(): string; + get hashType(): string; + get connectionMode(): string; +} +declare class ResourcePreset { + /** + * Resource Preset API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + urlPrefix: string; + /** + * Return the GraphQL Promise object containing resource preset list. + */ + list(param?: any): Promise; + /** + * Return the GraphQL Promise object containing resource preset checking result. + */ + check(param?: any): Promise; + /** + * add resource preset with given name and fields. + * + * @param {string} name - resource preset name. + * @param {json} input - resource preset specification and data. Required fields are: + * { + * 'resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. + * }; + */ + add(name: string, input: any): Promise; + /** + * mutate specified resource preset with given name with new values. + * + * @param {string} name - resource preset name to mutate. + * @param {json} input - resource preset specification and data. Required fields are: + * { + * 'resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. + * }; + */ + mutate(name: string, input: any): Promise; + /** + * delete specified resource preset with given name. + * + * @param {string} name - resource preset name to delete. + */ + delete(name?: string): Promise; +} +declare class VFolder { + /** + * The Virtual Folder API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + * @param {string} name - Virtual folder name. + */ + constructor(client: Client, name?: string); + client: Client; + name: string; + urlPrefix: string; + /** + * Get allowed types of folders + * + */ + list_allowed_types(): Promise; + /** + * Create a Virtual folder on specific host. + * + * @param {string} name - Virtual folder name. + * @param {string} host - Host name to create virtual folder in it. + * @param {string} group - Virtual folder group name. + * @param {string} usageMode - Virtual folder's purpose of use. Can be "general" (normal folders), "data" (data storage), and "model" (pre-trained model storage). + * @param {string} permission - Virtual folder's innate permission. + * @param {boolean} cloneable - Whether Virtual folder is cloneable or not. + */ + create(name: string, host?: string, group?: string, usageMode?: string, permission?: string, cloneable?: boolean): Promise; + /** + * Clone selected Virtual folder + * + * @param {json} input - parameters for cloning Vfolder + * @param {boolean} input.cloneable - whether new cloned Vfolder is cloneable or not + * @param {string} input.permission - permission for new cloned Vfolder. permission should one of the following: 'ro', 'rw', 'wd' + * @param {string} input.target_host - target_host for new cloned Vfolder + * @param {string} input.target_name - name for new cloned Vfolder + * @param {string} input.usage_mode - Cloned virtual folder's purpose of use. Can be "general" (normal folders), "data" (data storage), and "model" (pre-trained model storage). + * @param name - source Vfolder name + */ + clone(input: any, name?: any): Promise; + /** + * + * @param {json} input - parameters for updating folder options of Vfolder + * @param {boolean} input.cloneable - whether Vfolder is cloneable or not + * @param {string} input.permission - permission for Vfolder. permission should one of the following: 'ro', 'rw', 'wd' + * @param name - source Vfolder name + */ + update_folder(input: any, name?: any): Promise; + /** + * List Virtual folders that requested accessKey has permission to. + */ + list(groupId?: any): Promise; + /** + * List Virtual folder hosts that requested accessKey has permission to. + */ + list_hosts(): Promise; + /** + * Information about specific virtual folder. + */ + info(name?: any): Promise; + /** + * Rename a Virtual folder. + * + * @param {string} new_name - New virtual folder name. + */ + rename(new_name?: string): Promise; + /** + * Delete a Virtual folder. + * + * @param {string} name - Virtual folder name. If no name is given, use name on this VFolder object. + */ + delete(name?: string): Promise; + /** + * Leave an invited Virtual folder. + * + * @param {string} name - Virtual folder name. If no name is given, use name on this VFolder object. + */ + leave_invited(name?: string): Promise; + /** + * Upload files to specific Virtual folder. + * + * @param {string} path - Path to upload. + * @param {string} fs - File content to upload. + * @param {string} name - Virtual folder name. + */ + upload(path: string, fs: string, name?: string): Promise; + /** + * Upload file from formData to specific Virtual folder. + * + * @param {string} fss - formData with file specification. formData should contain {src, content, {filePath:filePath}}. + * @param {string} name - Virtual folder name. + */ + uploadFormData(fss: string, name?: string): Promise; + /** + * Create a upload session for a file to Virtual folder. + * + * @param {string} path - Path to upload. + * @param {string} fs - File object to upload. + * @param {string} name - Virtual folder name. + */ + create_upload_session(path: string, fs: string, name?: string): Promise; + /** + * Create directory in specific Virtual folder. + * + * @param {string} path - Directory path to create. + * @param {string} name - Virtual folder name. + * @param {string} parents - create parent folders when not exists (>=APIv6). + * @param {string} exist_ok - Do not raise error when the folder already exists (>=APIv6). + */ + mkdir(path: string, name?: string, parents?: string, exist_ok?: string): Promise; + /** + * Rename a file inside a virtual folder. + * + * @param {string} target_path - path to the target file or directory (with old name). + * @param {string} new_name - new name of the target. + * @param {string} name - Virtual folder name that target file exists. + * @param {string} is_dir - True when the object is directory, false when it is file + */ + rename_file(target_path: string, new_name: string, name?: string, is_dir?: string): Promise; + /** + * Delete multiple files in a Virtual folder. + * + * @param {string} files - Files to delete. + * @param {boolean} recursive - delete files recursively. + * @param {string} name - Virtual folder name that files are in. + */ + delete_files(files: string, recursive?: boolean, name?: string): Promise; + /** + * Download file from a Virtual folder. + * + * @param {string} file - File to download. Should contain full path. + * @param {string} name - Virtual folder name that files are in. + * @param {boolean} archive - Download target directory as an archive. + * @param {boolean} noCache - If true, do not store the file response in any cache. New in API v6. + */ + download(file: string, name?: string, archive?: boolean, noCache?: boolean): Promise; + /** + * Request a download and get the token for direct download. + * + * @param {string} file - File to download. Should contain full path. + * @param {string} name - Virtual folder name that files are in. + * @param {boolean} archive - Download target directory as an archive. + */ + request_download_token(file: string, name?: string, archive?: boolean): Promise; + /** + * Download file in a Virtual folder with token. + * + * @param {string} token - Temporary token to download specific file. + */ + download_with_token(token?: string): Promise; + /** + * Get download URL in a Virtual folder with token. + * + * @param {string} token - Temporary token to download specific file. + */ + get_download_url_with_token(token?: string): string; + /** + * List files in specific virtual folder / path. + * + * @param {string} path - Directory path to list. + * @param {string} name - Virtual folder name to look up with. + */ + list_files(path: string, name?: string): Promise; + /** + * Invite someone to specific virtual folder with permission. + * + * @param {string} perm - Permission to give to. `rw` or `ro`. + * @param {array} emails - User E-mail to invite. + * @param {string} name - Virtual folder name to invite. + */ + invite(perm: string, emails: any[], name?: string): Promise; + /** + * Show invitations to current API key. + */ + invitations(): Promise; + /** + * Accept specific invitation. + * + * @param {string} inv_id - Invitation ID. + */ + accept_invitation(inv_id: string): Promise; + /** + * Delete specific invitation. + * + * @param {string} inv_id - Invitation ID to delete. + */ + delete_invitation(inv_id: string): Promise; + /** + * List invitees(users who accepted an invitation) + * + * @param {string} vfolder_id - vfolder id. If no id is given, all users who accepted the client's invitation will be returned + */ + list_invitees(vfolder_id?: string): Promise; + /** + * Modify an invitee's permission to a shared vfolder + * + * @param {json} input - parameters for permission modification + * @param {string} input.perm - invitee's new permission. permission should one of the following: 'ro', 'rw', 'wd' + * @param {string} input.user - invitee's uuid + * @param {string} input.vfolder - id of the vfolder that has been shared to the invitee + */ + modify_invitee_permission(input: any): Promise; + /** + * Share specific users a group-type virtual folder with overriding permission. + * + * @param {string} perm - Permission to give to. `rw` or `ro`. + * @param {array} emails - User E-mail(s) to share. + * @param {string} name - A group virtual folder name to share. + */ + share(permission: any, emails: any[], name?: string): Promise; + /** + * Unshare a group-type virtual folder from given users. + * + * @param {array} emails - User E-mail(s) to unshare. + * @param {string} name - A group virtual folder name to unshare. + */ + unshare(emails: any[], name?: string): Promise; + /** + * Get the size quota of a vfolder. + * Only available for some specific file system such as XFS. + * + * @param {string} host - Host name of a virtual folder. + * @param {string} vfolder_id - id of the vfolder. + */ + get_quota(host: string, vfolder_id: string): Promise; + /** + * Set the size quota of a vfolder. + * Only available for some specific file system such as XFS. + * + * @param {string} host - Host name of a virtual folder. + * @param {string} vfolder_id - id of the vfolder. + * @param {number} quota - quota size of the vfolder. + */ + set_quota(host: string, vfolder_id: string, quota: number): Promise; +} +declare class Agent { + /** + * Agent API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * List computation agents. + * + * @param {string} status - Status to query. Should be one of 'ALIVE', 'PREPARING', 'TERMINATING' and 'TERMINATED'. + * @param {array} fields - Fields to query. Queryable fields are: 'id', 'status', 'region', 'first_contact', 'cpu_cur_pct', 'mem_cur_bytes', 'available_slots', 'occupied_slots'. + * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) + */ + list(status?: string, fields?: any[], timeout?: number): Promise; +} +declare class Keypair { + /** + * Keypair API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client, name?: any); + client: Client; + name: any; + /** + * Information of specific Keypair. + * + * @param {string} accessKey - Access key to query information. If client is not authorized as admin, this will be ignored and current API key infomation will be returned. + * @param {array} fields - Fields to query. Queryable fields are: 'access_key', 'secret_key', 'is_active', 'is_admin', 'user_id', 'created_at', 'last_used', + 'concurrency_limit', 'concurrency_used', 'rate_limit', 'num_queries', 'resource_policy'. + */ + info(accessKey: string, fields?: any[]): Promise; + /** + * List all Keypairs of given user ID. + * + * @param {string} userId - User ID to query API keys. If user ID is not given and client is authorized as admin, this will return every keypairs of the manager. + * @param {array} fields - Fields to query. Queryable fields are: "access_key", 'is_active', 'is_admin', 'user_id', 'created_at', 'last_used', + 'concurrency_used', 'rate_limit', 'num_queries', 'resource_policy'. + */ + list(userId?: string, fields?: any[], isActive?: boolean): Promise; + /** + * Add Keypair with given information. + * + * @param {string} userId - User ID for new Keypair. + * @param {boolean} isActive - is_active state. Default is True. + * @param {boolean} isAdmin - is_admin state. Default is False. + * @param {string} resourcePolicy - resource policy name to assign. Default is `default`. + * @param {integer} rateLimit - API rate limit for 900 seconds. Prevents from DDoS attack. + */ + add(userId?: string, isActive?: boolean, isAdmin?: boolean, resourcePolicy?: string, rateLimit?: any): Promise; + /** + * mutate Keypair for given accessKey. + * + * @param {string} accessKey - access key to mutate. + * @param {json} input - new information for mutation. JSON format should follow: + * { + * 'is_active': is_active, + * 'is_admin': is_admin, + * 'resource_policy': resource_policy, + * 'rate_limit': rate_limit + * } + */ + mutate(accessKey: string, input: any): Promise; + /** + * Delete Keypair with given accessKey + * + * @param {string} accessKey - access key to delete. + */ + delete(accessKey: string): Promise; +} +declare class ContainerImage { + /** + * The Container image API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * list container images registered on the manager. + * + * @param {array} fields - fields to query. Default fields are: ["name", "tag", "registry", "digest", "installed", "resource_limits { key min max }"] + * @param {boolean} installed_only - filter images to installed / not installed. true to query installed images only. + * @param {boolean} system_images - filter images to get system images such as web UI, SFTP server. true to query system images only. + */ + list(fields?: any[], installed_only?: boolean, system_images?: boolean): Promise; + /** + * Modify resource of given image. + * + * @param {string} registry - Registry name + * @param {string} image - image name. + * @param {string} tag - image tag. + * @param {object} input - value list to set. + */ + modifyResource(registry: string, image: string, tag: string, input: object): Promise; + /** + * Modify label of given image. + * + * @param {string} registry - Registry name + * @param {string} image - image name. + * @param {string} tag - image tag. + * @param {string} key - key to change. + * @param {string} value - value for the key. + */ + modifyLabel(registry: string, image: string, tag: string, key: string, value: string): Promise; + /** + * install specific container images from registry + * + * @param {string} name - name to install. it should contain full path with tags. e.g. lablup/python:3.6-ubuntu18.04 + * @param {object} resource - resource to use for installation. + * @param {string} registry - registry of image. default is 'index.docker.io', which is public Backend.AI docker registry. + */ + install(name: string, resource?: object, registry?: string): Promise; + /** + * uninstall specific container images from registry (TO BE IMPLEMENTED) + * + * @param {string} name - name to install. it should contain full path with tags. e.g. lablup/python:3.6-ubuntu18.04 + * @param {string} registry - registry of image. default is 'index.docker.io', which is public Backend.AI docker registry. + */ + uninstall(name: string, registry?: string): Promise; + /** + * Get image label information. + * + * @param {string} registry - Registry name + * @param {string} image - image name. + * @param {string} tag - tag to get. + */ + get(registry: string, image: string, tag: string): Promise; +} +declare class utils { + constructor(client: any); + client: any; + changeBinaryUnit(value: any, targetUnit?: string, defaultUnit?: string): any; + elapsedTime(start: any, end: any): string; + _padding_zeros(n: any, width: any): any; + /** + * Limit the boundary of value + * + * @param {number} value - input value to be clamped + * @param {number} min - minimum value of the input value + * @param {number} max - maximum value of the input vallue + */ + clamp(value: number, min: number, max: number): number; + gqlToObject(array: any, key: any): {}; + gqlToList(array: any, key: any): any[]; +} +declare class ComputeSession { + /** + * The Computate session API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * Get the number of compute sessions with specific conditions. + * + * @param {string or array} status - status to query. Default is 'RUNNING'. + * Available statuses are: `PREPARING`, `BUILDING`, `PENDING`, `SCHEDULED`, `RUNNING`, `RESTARTING`, `RESIZING`, `SUSPENDED`, `TERMINATING`, `TERMINATED`, `ERROR`. + * @param {string} accessKey - access key that is used to start compute sessions. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + * @param {string} group - project group id to query. Default returns sessions from all groups. + */ + total_count(status?: string, accessKey?: string, limit?: number, offset?: number, group?: string): Promise; + /** + * list compute sessions with specific conditions. + * + * @param {array} fields - fields to query. Default fields are: ["id", "name", "image", "created_at", "terminated_at", "status", "status_info", "occupied_slots", "cpu_used", "io_read_bytes", "io_write_bytes"]. + * @param {string or array} status - status to query. Default is 'RUNNING'. + * Available statuses are: `PREPARING`, `BUILDING`, `PENDING`, `SCHEDULED`, `RUNNING`, `RESTARTING`, `RESIZING`, `SUSPENDED`, `TERMINATING`, `TERMINATED`, `ERROR`. + * @param {string} accessKey - access key that is used to start compute sessions. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + * @param {string} group - project group id to query. Default returns sessions from all groups. + * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) + */ + list(fields?: any[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; + /** + * list all status of compute sessions. + * + * @param {array} fields - fields to query. Default fields are: ["session_name", "lang", "created_at", "terminated_at", "status", "status_info", "occupied_slots", "cpu_used", "io_read_bytes", "io_write_bytes"]. + * @param {String} status - status to query. The default is string with all status combined. + * @param {string} accessKey - access key that is used to start compute sessions. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + * @param {string} group - project group id to query. Default returns sessions from all groups. + * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) + */ + listAll(fields?: any[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; + /** + * get compute session with specific condition. + * + * @param {array} fields - fields to query. Default fields are: ["session_name", "lang", "created_at", "terminated_at", "status", "status_info", "occupied_slots", "cpu_used", "io_read_bytes", "io_write_bytes"]. + * @param {string} sessionUuid - session ID to query specific compute session. + */ + get(fields?: any[], sessionUuid?: string): Promise; + startService(session: any, app: any, port?: any, envs?: any, args?: any): Promise; +} +declare class SessionTemplate { + /** + * The Computate session template API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + urlPrefix: string; + /** + * list session templates with specific conditions. + * + * @param {array} fields - fields to query. Default fields are: ["id", "name", "image", "created_at", "terminated_at", "status", "status_info", "occupied_slots", "cpu_used", "io_read_bytes", "io_write_bytes"]. + * @param {string or array} status - status to query. Default is 'RUNNING'. + * Available statuses are: `PREPARING`, `BUILDING`,`PENDING`, `SCHEDULED`, `RUNNING`, `RESTARTING`, `RESIZING`, `SUSPENDED`, `TERMINATING`, `TERMINATED`, `ERROR`. + * @param {string} accessKey - access key that is used to start compute sessions. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + * @param {string} group - project group id to query. Default returns sessions from all groups. + * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) + */ + list(listall?: boolean, groupId?: any): Promise; +} +declare class ResourcePolicy { + /** + * The Resource Policy API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * get resource policy with given name and fields. + * + * @param {string} name - resource policy name. + * @param {array} fields - fields to query. + */ + get(name?: string, fields?: any[]): Promise; + /** + * add resource policy with given name and fields. + * + * @param {string} name - resource policy name. + * @param {json} input - resource policy specification and data. Required fields are: + * { + * 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. + * 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. + * 'max_concurrent_sessions': concurrency_limit, + * 'max_containers_per_session': containers_per_session_limit, + * 'idle_timeout': idle_timeout, + * 'max_vfolder_count': vfolder_count_limit, + * 'max_vfolder_size': vfolder_capacity_limit, + * 'allowed_vfolder_hosts': vfolder_hosts + * }; + */ + add(name: string, input: any): Promise; + /** + * mutate specified resource policy with given name with new values. + * + * @param {string} name - resource policy name to mutate. (READ-ONLY) + * @param {json} input - resource policy specification and data. Required fields are: + * { + * {string} 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. + * {JSONString} 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. + * {int} 'max_concurrent_sessions': concurrency_limit, + * {int} 'max_containers_per_session': containers_per_session_limit, + * {bigint} 'idle_timeout': idle_timeout, + * {int} 'max_vfolder_count': vfolder_count_limit, + * {bigint} 'max_vfolder_size': vfolder_capacity_limit, + * {[string]} 'allowed_vfolder_hosts': vfolder_hosts + * }; + */ + mutate(name: string, input: any): Promise; + /** + * delete specified resource policy that exists in policy list. + * + * @param {string} name - resource policy name to delete. (READ-ONLY) + */ + delete(name?: string): Promise; +} +declare class User { + /** + * The user API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * List all registred users. + * + * TODO: we need new paginated list API after implementation of server-side dynamic filtering. + * + * @param {boolean} is_active - List whether active users or inactive users. + * @param {json} input - User specification to query. Fields are: + * { + * 'username': String, // User name for given user id. + * 'password': String, // Password for user id. + * 'need_password_change': Boolean, // Let user change password at the next login. + * 'full_name': String, // Full name of given user id. + * 'description': String, // Description for user. + * 'is_active': Boolean, // Flag if user is active or not. + * 'domain_name': String, // Domain for user. + * 'role': String, // Role for user. + * 'groups': {id name} // Group Ids for user. Shoule be list of UUID strings. + * }; + */ + list(is_active?: boolean, fields?: string[]): Promise; + /** + * Get user information. + * + * @param {string} email - E-mail address as user id. + * @param {json} input - User specification to query. Fields are: + * { + * 'email': String, // E-mail for given E-mail (same as user) + * 'username': String, // User name for given user id. + * 'password': String, // Password for user id. + * 'need_password_change': Boolean, // Let user change password at the next login. + * 'full_name': String, // Full name of given user id. + * 'description': String, // Description for user. + * 'is_active': Boolean, // Flag if user is active or not. + * 'domain_name': String, // Domain for user. + * 'role': String, // Role for user. + * 'groups': List(UUID) // Group Ids for user. Shoule be list of UUID strings. + * }; + */ + get(email: string, fields?: string[]): Promise; + /** + * add new user with given information. + * + * @param {string} email - E-mail address as user id. + * @param {json} input - User specification to change. Required fields are: + * { + * 'username': String, // User name for given user id. + * 'password': String, // Password for user id. + * 'need_password_change': Boolean, // Let user change password at the next login. + * 'full_name': String, // Full name of given user id. + * 'description': String, // Description for user. + * 'is_active': Boolean, // Flag if user is active or not. + * 'domain_name': String, // Domain for user. + * 'role': String, // Role for user. + * 'group_ids': List(UUID) // Group Ids for user. Shoule be list of UUID strings. + * }; + */ + create(email: string, input: any): Promise; + /** + * modify user information with given user id with new values. + * + * @param {string} email - E-mail address as user id. + * @param {json} input - User specification to change. Required fields are: + * { + * 'username': String, // User name for given user id. + * 'password': String, // Password for user id. + * 'need_password_change': Boolean, // Let user change password at the next login. + * 'full_name': String, // Full name of given user id. + * 'description': String, // Description for user. + * 'is_active': Boolean, // Flag if user is active or not. + * 'domain_name': String, // Domain for user. + * 'role': String, // Role for user. + * 'group_ids': List(UUID) // Group Ids for user. Shoule be list of UUID strings. + * }; + */ + update(email: string, input: any): Promise; + /** + * delete user information with given user id + * + * @param {string} email - E-mail address as user id to delete. + */ + delete(email: string): Promise; +} +declare class Group { + /** + * The group API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * List registred groups. + * @param {boolean} is_active - List whether active users or inactive users. + * @param {string} domain_name - domain name of group + * { + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'domain_name': String, // Domain for group. + * }; + */ + list(is_active?: boolean, domain_name?: string, fields?: string[]): Promise; +} +declare class Domain { + /** + * The domain API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * Get domain information. + * @param {string} domain_name - domain name of group + * @param {array} fields - fields to query. Default fields are: ['name', 'description', 'is_active', 'created_at', 'modified_at', 'total_resource_slots', 'allowed_vfolder_hosts', + 'allowed_docker_registries', 'integration_id', 'scaling_groups'] + * { + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'total_resource_slots': JSOONString, // Total resource slots + * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts + * 'allowed_docker_registries': [String], // Allowed docker registry lists + * 'integration_id': [String], // Integration ids + * 'scaling_groups': [String], // Scaling groups + * }; + */ + get(domain_name?: string, fields?: any[]): Promise; + list(fields?: string[]): Promise; + /** + * Modify domain information. + * @param {string} domain_name - domain name of group + + + * @param {json} input - Domain specification to change. Required fields are: + * { + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'total_resource_slots': JSOONString, // Total resource slots + * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts + * 'allowed_docker_registries': [String], // Allowed docker registry lists + * 'integration_id': [String], // Integration ids + * 'scaling_groups': [String], // Scaling groups + * }; + */ + update(domain_name: string, input: any): Promise; +} +declare class Resources { + constructor(client: any); + client: any; + resources: {}; + _init_resource_values(): void; + agents: any; + /** + * Total resource information of Backend.AI cluster. + * + * @param {string} status - Resource node status to get information. + */ + totalResourceInformation(status?: string): Promise; + /** + * user statistics about usage. + * + */ + user_stats(): Promise; +} +declare class StorageProxy { + /** + * Agent API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * List storage proxies and its volumes. + * + * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + */ + list(fields?: any[], limit?: number, offset?: number): Promise; + /** + * Detail of specific storage proxy / volume. + * + * @param {string} host - Virtual folder host. + * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. + */ + detail(host?: string, fields?: any[]): Promise; +} +declare class Maintenance { + /** + * The Maintenance API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + urlPrefix: string; + /** + * Attach to the background task to listen to events + * @param {string} task_id - background task id. + */ + attach_background_task(task_id: string): EventSource; + /** + * Rescan image from repository + * @param {string} registry - registry. default is '' + */ + rescan_images(registry?: string): Promise; + recalculate_usage(): Promise; +} +declare class ScalingGroup { + /** + * The Scaling Group API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + list_available(): Promise; + list(group?: string): Promise; + /** + * Get the version of WSProxy for a specific scaling group. + * (NEW) manager version 21.09. + * + * @param {string} group - Scaling group name + */ + getWsproxyVersion(group: string): Promise; + /** + * Create a scaling group + * + * @param {string} name - Scaling group name + * @param {string} description - Scaling group description + * @param {string} wsproxyAddress - wsproxy url (NEW in manager 21.09) + */ + create(name: string, description?: string, wsproxyAddress?: string): Promise; + /** + * Associate a scaling group with a domain + * + * @param {string} domain - domain name + * @param {string} scaling_group - scaling group name + */ + associate_domain(domain: string, scaling_group: string): Promise; + /** + * Modify a scaling group + * + * @param {string} name - scaling group name + * @param {json} input - object containing desired modifications + * { + * 'description': String // description of scaling group + * 'is_active': Boolean // active status of scaling group + * 'driver': String + * 'driver_opts': JSONString + * 'scheduler': String + * 'scheduler_opts': JSONString + * 'wsproxy_addr': String // NEW in manager 21.09 + * } + */ + update(name: string, input: any): Promise; + /** + * Delete a scaling group + * + * @param {string} name - name of scaling group to be deleted + */ + delete(name: string): Promise; +} +declare class Registry { + constructor(client: any); + client: any; + list(): Promise; + set(key: any, value: any): Promise; + delete(key: any): Promise; +} +declare class Setting { + /** + * Setting API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + config: any; + /** + * List settings + * + * @param {string} prefix - prefix to get. This command will return every settings starting with the prefix. + */ + list(prefix?: string): Promise; + /** + * Get settings + * + * @param {string} prefix - prefix to get. This command will return every settings starting with the prefix. + */ + get(key: any): Promise; + /** + * Set a setting + * + * @param {string} key - key to add. + * @param {object} value - value to add. + */ + set(key: string, value: object): Promise; + /** + * Delete a setting + * + * @param {string} key - key to delete + * @param {boolean} prefix - prefix to delete. if prefix is true, this command will delete every settings starting with the key. + */ + delete(key: string, prefix?: boolean): Promise; +} +declare class UserConfig { + /** + * Setting API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + config: any; + /** + * Get content of bootstrap script of a keypair. + */ + get_bootstrap_script(): Promise; + /** + * Update bootstrap script of a keypair. + * + * @param {string} data - text content of bootstrap script. + */ + update_bootstrap_script(script: any): Promise; + /** + * Create content of script dotfile (.bashrc or .zshrc) + * @param {string} data - text content of script dotfile + * @param {string} path - path of script dotfile. (cwd: home directory) + */ + create(data: string, path: string): Promise; + /** + * Get content of script dotfile + */ + get(): Promise; + /** + * Update script dotfile of a keypair. + * + * @param {string} data - text content of script dotfile. + * @param {string} path - path of script dotfile. (cwd: home directory) + */ + update(data: string, path: string): Promise; + /** + * Delete script dotfile of a keypair. + * + * @param {string} path - path of script dotfile. + */ + delete(path: string): Promise; +} +declare class Service { + /** + * Service-specific API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + config: any; + /** + * Get announcements + * + */ + get_announcement(): Promise; + /** + * Update announcement + * + * @param {boolean} enabled - Enable / disable announcement. Default is True. + * @param {string} message - Announcement content. Usually in Markdown syntax. + */ + update_announcement(enabled: boolean, message: string): Promise; +} +declare class Enterprise { + /** + * Setting API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + config: any; + /** + * Get the current enterprise license. + */ + getLicense(): Promise; + certificate: any; +} +declare class Cloud { + /** + * Setting API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + config: any; + /** + * Check if cloud endpoint is available. + */ + ping(): Promise; + /** + * Verify signup email by JWT token. + * + * @param {string} token - JWT token which is delivered to user's email. + */ + verify_email(token: string): Promise; + /** + * Send verification email. + * + * @param {string} email - user's email. + */ + send_verification_email(email: string): Promise; + /** + * Send password change email to assist users who forgot their password. + * + * @param {string} email - user's email. + */ + send_password_change_email(email: string): Promise; + /** + * Verify JWT token for changing password. + * + * @param {string} email - user's email (for verification). + * @param {string} password - new password. + * @param {string} token - JWT token which is delivered to user's email. + */ + change_password(email: string, password: string, token: string): Promise; +} +declare class EduApp { + /** + * Setting API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + config: any; + /** + * Check if EduApp endpoint is available. + */ + ping(): Promise; + /** + * Get mount folders for auto-mount. + */ + get_mount_folders(): Promise; +} +export { Client as BackendAIClient, ClientConfig as BackendAIClientConfig }; diff --git a/package-lock.json b/package-lock.json index ec44862..55032b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "backend.ai-client", - "version": "21.3.1", + "version": "21.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "backend.ai-client", - "version": "21.3.1", + "version": "21.9.0", "license": "MIT", "dependencies": { "@types/node": "^16.7.5", diff --git a/package.json b/package.json index d9f8c37..55bb0ff 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "backend.ai-client.js", "scripts": { "test": "", - "build-doc": "./node_modules/jsdoc/jsdoc.js -c ./jsdoc.json" + "build-doc": "./node_modules/jsdoc/jsdoc.js -c ./jsdoc.json", + "declare": "npx -p typescript tsc backend.ai-client-node.js --declaration --allowJs --emitDeclarationOnly --outDir dist" }, "repository": { "type": "git", @@ -37,5 +38,6 @@ "node-fetch": "^2.6.1", "tinyify": "^3.0.0", "typescript": "^4.4.2" - } + }, + "types": "./dist/backend.ai-client-node.d.ts" } From 5cc5fe8053bc0aa817837fde653b41fbfdd043de Mon Sep 17 00:00:00 2001 From: Jeongseok Kang Date: Sun, 18 Dec 2022 17:18:31 +0900 Subject: [PATCH 2/5] fix: Use `lib` rather than `dist` for declarations --- {dist => lib}/backend.ai-client-node.d.ts | 0 package.json | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename {dist => lib}/backend.ai-client-node.d.ts (100%) diff --git a/dist/backend.ai-client-node.d.ts b/lib/backend.ai-client-node.d.ts similarity index 100% rename from dist/backend.ai-client-node.d.ts rename to lib/backend.ai-client-node.d.ts diff --git a/package.json b/package.json index 55bb0ff..b9811f4 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "", "build-doc": "./node_modules/jsdoc/jsdoc.js -c ./jsdoc.json", - "declare": "npx -p typescript tsc backend.ai-client-node.js --declaration --allowJs --emitDeclarationOnly --outDir dist" + "declare": "npx -p typescript tsc backend.ai-client-node.js --declaration --allowJs --emitDeclarationOnly --outDir lib" }, "repository": { "type": "git", @@ -39,5 +39,5 @@ "tinyify": "^3.0.0", "typescript": "^4.4.2" }, - "types": "./dist/backend.ai-client-node.d.ts" + "types": "./lib/backend.ai-client-node.d.ts" } From 7ebc99f8eda8923b33a40cfac123e4c55227b4f4 Mon Sep 17 00:00:00 2001 From: rapsealk Date: Tue, 20 Dec 2022 00:15:03 +0900 Subject: [PATCH 3/5] fix: Update valid main entry from package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9811f4..3a5f3ee 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "backend.ai-client", "version": "21.9.0", "description": "Backend.AI Client for javascript", - "main": "backend.ai-client.js", + "main": "backend.ai-client-node.js", "scripts": { "test": "", "build-doc": "./node_modules/jsdoc/jsdoc.js -c ./jsdoc.json", From 1a366fcf7edae805b0f1a0f3b17a233107b0dc46 Mon Sep 17 00:00:00 2001 From: Jeongseok Kang Date: Tue, 24 Jan 2023 20:52:38 +0900 Subject: [PATCH 4/5] feat: Update typescript declaration target to `es2017` --- lib/backend.ai-client-node.d.ts | 776 ++++++++++++++++---------------- package.json | 2 +- 2 files changed, 390 insertions(+), 388 deletions(-) diff --git a/lib/backend.ai-client-node.d.ts b/lib/backend.ai-client-node.d.ts index 319acd5..2d6ccfd 100644 --- a/lib/backend.ai-client-node.d.ts +++ b/lib/backend.ai-client-node.d.ts @@ -1,28 +1,60 @@ -export namespace backend { - export { Client }; - export { ClientConfig }; +declare const crypto_node: any; +declare const querystring: any; +interface Window { + backendaiclient: any; } -export class Client { +declare class ClientConfig { + _apiVersionMajor: string; + _apiVersion: string; + _hashType: string; + _endpoint: string; + _endpointHost: string; + _accessKey: string; + _secretKey: string; + _userId: string; + _password: string; + _proxyURL: any; + _proxyToken: any; + _connectionMode: string; /** - * The client API wrapper. + * The client Configuration object. * - * @param {ClientConfig} config - the API client-side configuration - * @param {string} agentSignature - an extra string that will be appended to User-Agent headers when making API requests + * @param {string} accessKey - access key to connect Backend.AI manager + * @param {string} secretKey - secret key to connect Backend.AI manager + * @param {string} endpoint - endpoint of Backend.AI manager + * @param {string} connectionMode - connection mode. 'API', 'SESSION' is supported. `SESSION` mode requires webserver. */ - constructor(config: ClientConfig, agentSignature: string); - ready: boolean; + constructor(accessKey: any, secretKey: any, endpoint: any, connectionMode?: string); + get accessKey(): string; + get secretKey(): string; + get userId(): string; + get password(): string; + get endpoint(): string; + get proxyURL(): any; + get proxyToken(): any; + get endpointHost(): string; + get apiVersion(): string; + get apiVersionMajor(): string; + get hashType(): string; + get connectionMode(): string; + /** + * Create a ClientConfig object from environment variables. + */ + static createFromEnv(): ClientConfig; +} +declare class Client { code: any; - sessionId: any; + sessionId: string | null; kernelType: any; clientVersion: string; - agentSignature: string; - _config: ClientConfig; + agentSignature: any; + _config: any; _managerVersion: any; _apiVersion: any; _apiVersionMajor: any; is_admin: boolean; is_superadmin: boolean; - kernelPrefix: string; + kernelPrefix: any; resourcePreset: ResourcePreset; vfolder: VFolder; agent: Agent; @@ -42,14 +74,28 @@ export class Client { registry: Registry; setting: Setting; userConfig: UserConfig; - service: Service; - enterprise: Enterprise; cloud: Cloud; eduApp: EduApp; - _features: {}; - abortController: AbortController; - abortSignal: AbortSignal; + service: Service; + enterprise: Enterprise; + _features: any; + ready: boolean; + abortController: any; + abortSignal: any; requestTimeout: number; + static ERR_REQUEST: any; + static ERR_RESPONSE: any; + static ERR_ABORT: any; + static ERR_TIMEOUT: any; + static ERR_SERVER: any; + static ERR_UNKNOWN: any; + /** + * The client API wrapper. + * + * @param {ClientConfig} config - the API client-side configuration + * @param {string} agentSignature - an extra string that will be appended to User-Agent headers when making API requests + */ + constructor(config: any, agentSignature: any); /** * Return the server-side manager version. */ @@ -68,7 +114,7 @@ export class Client { * @param {number} retry - an integer to retry this request * @param {Object} opts - Options */ - _wrapWithPromise(rqst: Request, rawFile?: boolean, signal?: any, timeout?: number, retry?: number, opts?: any): any; + _wrapWithPromise(rqst: any, rawFile?: boolean, signal?: any, timeout?: number, retry?: number, opts?: {}): any; /** * Return the server-side API version. * @@ -76,14 +122,14 @@ export class Client { * */ getServerVersion(signal?: any): any; - /** - * Force API major version - */ - set APIMajorVersion(arg: any); /** * Get API major version */ get APIMajorVersion(): any; + /** + * Force API major version + */ + set APIMajorVersion(value: any); /** * Get the server-side manager version. * @@ -151,19 +197,19 @@ export class Client { * @param {object} resources - Per-session resource * @param {number} timeout - Timeout of request. Default : default fetch value. (5sec.) */ - createIfNotExists(kernelType: string, sessionId: string, resources?: object, timeout?: number): Promise; + createIfNotExists(kernelType: any, sessionId: any, resources?: {}, timeout?: number): Promise; /** * Create a session with a session template. * * @param {string} sessionId - the sessionId given when created */ - createSessionFromTemplate(templateId: any, image?: any, sessionName?: any, resources?: {}, timeout?: number): Promise; + createSessionFromTemplate(templateId: any, image?: any, sessionName?: undefined | string | null, resources?: {}, timeout?: number): Promise; /** * Obtain the session information by given sessionId. * * @param {string} sessionId - the sessionId given when created */ - get_info(sessionId: string, ownerKey?: any): Promise; + get_info(sessionId: any, ownerKey?: any): Promise; /** * Obtain the session container logs by given sessionId. * @@ -171,13 +217,13 @@ export class Client { * @param {string | null} ownerKey - owner key to access * @param {number} timeout - timeout to wait log query. Set to 0 to use default value. */ - get_logs(sessionId: string, ownerKey?: string | null, timeout?: number): Promise; + get_logs(sessionId: any, ownerKey?: any, timeout?: number): Promise; /** * Obtain the batch session (task) logs by given sessionId. * * @param {string} sessionId - the sessionId given when created */ - getTaskLogs(sessionId: string): any; + getTaskLogs(sessionId: any): any; /** * Terminate and destroy the kernel session. * @@ -185,13 +231,13 @@ export class Client { * @param {string|null} ownerKey - owner key when terminating other users' session * @param {boolean} forced - force destroy session. Requires admin privilege. */ - destroy(sessionId: string, ownerKey?: string | null, forced?: boolean): Promise; + destroy(sessionId: any, ownerKey?: any, forced?: boolean): Promise; /** * Restart the kernel session keeping its work directory and volume mounts. * * @param {string} sessionId - the sessionId given when created */ - restart(sessionId: string, ownerKey?: any): Promise; + restart(sessionId: any, ownerKey?: any): Promise; /** * Execute a code snippet or schedule batch-mode executions. * @@ -200,7 +246,7 @@ export class Client { * @param {string} mode - either "query", "batch", "input", or "continue" * @param {string} opts - an optional object specifying additional configs such as batch-mode build/exec commands */ - execute(sessionId: string, runId: string, mode: string, code: any, opts: string, timeout?: number): Promise; + execute(sessionId: any, runId: any, mode: any, code: any, opts: any, timeout?: number): Promise; createKernel(kernelType: any, sessionId?: any, resources?: {}, timeout?: number): Promise; destroyKernel(sessionId: any, ownerKey?: any): Promise; refreshKernel(sessionId: any, ownerKey?: any): Promise; @@ -218,7 +264,7 @@ export class Client { * @param {number} timeout - Timeout to force terminate request * @param {number} retry - The number of retry when request is failed */ - query(q: string, v: string, signal?: any, timeout?: number, retry?: number): Promise; + query(q: any, v: any, signal?: any, timeout?: number, retry?: number): Promise; /** * Generate a RequestInfo object that can be passed to fetch() API, * which includes a properly signed header with the configured auth information. @@ -227,12 +273,12 @@ export class Client { * @param {string} queryString - the URI path and GET parameters * @param {any} body - an object that will be encoded as JSON in the request body */ - newSignedRequest(method: string, queryString: string, body: any): { + newSignedRequest(method: string, queryString: any, body: any): { method: string; - headers: Headers; + headers: any; cache: string; body: any; - uri: string; + uri: any; }; /** * Same to newRequest() method but it does not sign the request. @@ -242,7 +288,7 @@ export class Client { * @param {string} queryString - the URI path and GET parameters * @param {any} body - an object that will be encoded as JSON in the request body */ - newUnsignedRequest(method: string, queryString: string, body: any): { + newUnsignedRequest(method: any, queryString: any, body: any): { method: any; headers: Headers; mode: string; @@ -258,8 +304,8 @@ export class Client { }; getAuthenticationString(method: any, queryString: any, dateValue: any, bodyValue: any, content_type?: string): string; getCurrentDate(now: any): string; - sign(key: any, key_encoding: any, msg: any, digest_type: any): string; - getSignKey(secret_key: any, now: any): string; + sign(key: any, key_encoding: any, msg: any, digest_type: any): any; + getSignKey(secret_key: any, now: any): any; generateSessionId(length?: number, nosuffix?: boolean): string; slugify(text: any): any; /** @@ -273,62 +319,15 @@ export class Client { */ refreshSSHKeypair(): Promise; } -export namespace Client { - const ERR_SERVER: number; - const ERR_RESPONSE: number; - const ERR_REQUEST: number; - const ERR_ABORT: number; - const ERR_TIMEOUT: number; - const ERR_UNKNOWN: number; -} -export class ClientConfig { - /** - * Create a ClientConfig object from environment variables. - */ - static createFromEnv(): ClientConfig; - /** - * The client Configuration object. - * - * @param {string} accessKey - access key to connect Backend.AI manager - * @param {string} secretKey - secret key to connect Backend.AI manager - * @param {string} endpoint - endpoint of Backend.AI manager - * @param {string} connectionMode - connection mode. 'API', 'SESSION' is supported. `SESSION` mode requires webserver. - */ - constructor(accessKey: string, secretKey: string, endpoint: string, connectionMode?: string); - _apiVersionMajor: string; - _apiVersion: string; - _hashType: string; - _endpoint: string; - _endpointHost: string; - _accessKey: string; - _secretKey: string; - _userId: string; - _password: string; - _proxyURL: any; - _proxyToken: any; - _connectionMode: string; - get accessKey(): string; - get secretKey(): string; - get userId(): string; - get password(): string; - get endpoint(): string; - get proxyURL(): any; - get proxyToken(): any; - get endpointHost(): string; - get apiVersion(): string; - get apiVersionMajor(): string; - get hashType(): string; - get connectionMode(): string; -} declare class ResourcePreset { + client: any; + urlPrefix: any; /** * Resource Preset API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client); - client: Client; - urlPrefix: string; + constructor(client: any); /** * Return the GraphQL Promise object containing resource preset list. */ @@ -346,7 +345,7 @@ declare class ResourcePreset { * 'resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. * }; */ - add(name: string, input: any): Promise; + add(name: any, input: any): Promise; /** * mutate specified resource preset with given name with new values. * @@ -356,25 +355,25 @@ declare class ResourcePreset { * 'resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. * }; */ - mutate(name: string, input: any): Promise; + mutate(name: any, input: any): Promise; /** * delete specified resource preset with given name. * * @param {string} name - resource preset name to delete. */ - delete(name?: string): Promise; + delete(name?: any): Promise; } declare class VFolder { + client: any; + name: any; + urlPrefix: any; /** * The Virtual Folder API wrapper. * * @param {Client} client - the Client API wrapper object to bind * @param {string} name - Virtual folder name. */ - constructor(client: Client, name?: string); - client: Client; - name: string; - urlPrefix: string; + constructor(client: any, name?: any); /** * Get allowed types of folders * @@ -390,7 +389,7 @@ declare class VFolder { * @param {string} permission - Virtual folder's innate permission. * @param {boolean} cloneable - Whether Virtual folder is cloneable or not. */ - create(name: string, host?: string, group?: string, usageMode?: string, permission?: string, cloneable?: boolean): Promise; + create(name: any, host?: string, group?: string, usageMode?: string, permission?: string, cloneable?: boolean): Promise; /** * Clone selected Virtual folder * @@ -428,19 +427,19 @@ declare class VFolder { * * @param {string} new_name - New virtual folder name. */ - rename(new_name?: string): Promise; + rename(new_name?: any): Promise; /** * Delete a Virtual folder. * * @param {string} name - Virtual folder name. If no name is given, use name on this VFolder object. */ - delete(name?: string): Promise; + delete(name?: any): Promise; /** * Leave an invited Virtual folder. * * @param {string} name - Virtual folder name. If no name is given, use name on this VFolder object. */ - leave_invited(name?: string): Promise; + leave_invited(name?: any): Promise; /** * Upload files to specific Virtual folder. * @@ -448,14 +447,14 @@ declare class VFolder { * @param {string} fs - File content to upload. * @param {string} name - Virtual folder name. */ - upload(path: string, fs: string, name?: string): Promise; + upload(path: any, fs: any, name?: any): Promise; /** * Upload file from formData to specific Virtual folder. * * @param {string} fss - formData with file specification. formData should contain {src, content, {filePath:filePath}}. * @param {string} name - Virtual folder name. */ - uploadFormData(fss: string, name?: string): Promise; + uploadFormData(fss: any, name?: any): Promise; /** * Create a upload session for a file to Virtual folder. * @@ -463,7 +462,7 @@ declare class VFolder { * @param {string} fs - File object to upload. * @param {string} name - Virtual folder name. */ - create_upload_session(path: string, fs: string, name?: string): Promise; + create_upload_session(path: any, fs: any, name?: any): Promise; /** * Create directory in specific Virtual folder. * @@ -472,7 +471,7 @@ declare class VFolder { * @param {string} parents - create parent folders when not exists (>=APIv6). * @param {string} exist_ok - Do not raise error when the folder already exists (>=APIv6). */ - mkdir(path: string, name?: string, parents?: string, exist_ok?: string): Promise; + mkdir(path: any, name?: any, parents?: any, exist_ok?: any): Promise; /** * Rename a file inside a virtual folder. * @@ -481,7 +480,7 @@ declare class VFolder { * @param {string} name - Virtual folder name that target file exists. * @param {string} is_dir - True when the object is directory, false when it is file */ - rename_file(target_path: string, new_name: string, name?: string, is_dir?: string): Promise; + rename_file(target_path: any, new_name: any, name?: any, is_dir?: boolean): Promise; /** * Delete multiple files in a Virtual folder. * @@ -489,7 +488,7 @@ declare class VFolder { * @param {boolean} recursive - delete files recursively. * @param {string} name - Virtual folder name that files are in. */ - delete_files(files: string, recursive?: boolean, name?: string): Promise; + delete_files(files: any, recursive?: boolean, name?: any): Promise; /** * Download file from a Virtual folder. * @@ -498,7 +497,7 @@ declare class VFolder { * @param {boolean} archive - Download target directory as an archive. * @param {boolean} noCache - If true, do not store the file response in any cache. New in API v6. */ - download(file: string, name?: string, archive?: boolean, noCache?: boolean): Promise; + download(file: any, name?: boolean, archive?: boolean, noCache?: boolean): Promise; /** * Request a download and get the token for direct download. * @@ -506,7 +505,7 @@ declare class VFolder { * @param {string} name - Virtual folder name that files are in. * @param {boolean} archive - Download target directory as an archive. */ - request_download_token(file: string, name?: string, archive?: boolean): Promise; + request_download_token(file: any, name?: boolean, archive?: boolean): Promise; /** * Download file in a Virtual folder with token. * @@ -525,7 +524,7 @@ declare class VFolder { * @param {string} path - Directory path to list. * @param {string} name - Virtual folder name to look up with. */ - list_files(path: string, name?: string): Promise; + list_files(path: any, name?: any): Promise; /** * Invite someone to specific virtual folder with permission. * @@ -533,7 +532,7 @@ declare class VFolder { * @param {array} emails - User E-mail to invite. * @param {string} name - Virtual folder name to invite. */ - invite(perm: string, emails: any[], name?: string): Promise; + invite(perm: any, emails: any, name?: any): Promise; /** * Show invitations to current API key. */ @@ -543,19 +542,19 @@ declare class VFolder { * * @param {string} inv_id - Invitation ID. */ - accept_invitation(inv_id: string): Promise; + accept_invitation(inv_id: any): Promise; /** * Delete specific invitation. * * @param {string} inv_id - Invitation ID to delete. */ - delete_invitation(inv_id: string): Promise; + delete_invitation(inv_id: any): Promise; /** * List invitees(users who accepted an invitation) * * @param {string} vfolder_id - vfolder id. If no id is given, all users who accepted the client's invitation will be returned */ - list_invitees(vfolder_id?: string): Promise; + list_invitees(vfolder_id?: any): Promise; /** * Modify an invitee's permission to a shared vfolder * @@ -572,14 +571,14 @@ declare class VFolder { * @param {array} emails - User E-mail(s) to share. * @param {string} name - A group virtual folder name to share. */ - share(permission: any, emails: any[], name?: string): Promise; + share(permission: any, emails: any, name?: any): Promise; /** * Unshare a group-type virtual folder from given users. * * @param {array} emails - User E-mail(s) to unshare. * @param {string} name - A group virtual folder name to unshare. */ - unshare(emails: any[], name?: string): Promise; + unshare(emails: any, name?: any): Promise; /** * Get the size quota of a vfolder. * Only available for some specific file system such as XFS. @@ -587,7 +586,7 @@ declare class VFolder { * @param {string} host - Host name of a virtual folder. * @param {string} vfolder_id - id of the vfolder. */ - get_quota(host: string, vfolder_id: string): Promise; + get_quota(host: any, vfolder_id: any): Promise; /** * Set the size quota of a vfolder. * Only available for some specific file system such as XFS. @@ -596,16 +595,16 @@ declare class VFolder { * @param {string} vfolder_id - id of the vfolder. * @param {number} quota - quota size of the vfolder. */ - set_quota(host: string, vfolder_id: string, quota: number): Promise; + set_quota(host: any, vfolder_id: any, quota: any): Promise; } declare class Agent { + client: any; /** * Agent API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client); - client: Client; + constructor(client: any); /** * List computation agents. * @@ -613,17 +612,41 @@ declare class Agent { * @param {array} fields - Fields to query. Queryable fields are: 'id', 'status', 'region', 'first_contact', 'cpu_cur_pct', 'mem_cur_bytes', 'available_slots', 'occupied_slots'. * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) */ - list(status?: string, fields?: any[], timeout?: number): Promise; + list(status?: string, fields?: string[], timeout?: number): Promise; +} +declare class StorageProxy { + client: any; + /** + * Agent API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: any); + /** + * List storage proxies and its volumes. + * + * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + */ + list(fields?: string[], limit?: number, offset?: number): Promise; + /** + * Detail of specific storage proxy / volume. + * + * @param {string} host - Virtual folder host. + * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. + */ + detail(host?: string, fields?: string[]): Promise; } declare class Keypair { + client: any; + name: any; /** * Keypair API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client, name?: any); - client: Client; - name: any; + constructor(client: any, name?: any); /** * Information of specific Keypair. * @@ -631,7 +654,7 @@ declare class Keypair { * @param {array} fields - Fields to query. Queryable fields are: 'access_key', 'secret_key', 'is_active', 'is_admin', 'user_id', 'created_at', 'last_used', 'concurrency_limit', 'concurrency_used', 'rate_limit', 'num_queries', 'resource_policy'. */ - info(accessKey: string, fields?: any[]): Promise; + info(accessKey: any, fields?: string[]): Promise; /** * List all Keypairs of given user ID. * @@ -639,7 +662,7 @@ declare class Keypair { * @param {array} fields - Fields to query. Queryable fields are: "access_key", 'is_active', 'is_admin', 'user_id', 'created_at', 'last_used', 'concurrency_used', 'rate_limit', 'num_queries', 'resource_policy'. */ - list(userId?: string, fields?: any[], isActive?: boolean): Promise; + list(userId?: any, fields?: string[], isActive?: boolean): Promise; /** * Add Keypair with given information. * @@ -649,7 +672,7 @@ declare class Keypair { * @param {string} resourcePolicy - resource policy name to assign. Default is `default`. * @param {integer} rateLimit - API rate limit for 900 seconds. Prevents from DDoS attack. */ - add(userId?: string, isActive?: boolean, isAdmin?: boolean, resourcePolicy?: string, rateLimit?: any): Promise; + add(userId?: any, isActive?: boolean, isAdmin?: boolean, resourcePolicy?: string, rateLimit?: number): Promise; /** * mutate Keypair for given accessKey. * @@ -662,22 +685,78 @@ declare class Keypair { * 'rate_limit': rate_limit * } */ - mutate(accessKey: string, input: any): Promise; + mutate(accessKey: any, input: any): Promise; /** * Delete Keypair with given accessKey * * @param {string} accessKey - access key to delete. */ - delete(accessKey: string): Promise; + delete(accessKey: any): Promise; +} +declare class ResourcePolicy { + client: any; + /** + * The Resource Policy API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: any); + /** + * get resource policy with given name and fields. + * + * @param {string} name - resource policy name. + * @param {array} fields - fields to query. + */ + get(name?: any, fields?: string[]): Promise; + /** + * add resource policy with given name and fields. + * + * @param {string} name - resource policy name. + * @param {json} input - resource policy specification and data. Required fields are: + * { + * 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. + * 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. + * 'max_concurrent_sessions': concurrency_limit, + * 'max_containers_per_session': containers_per_session_limit, + * 'idle_timeout': idle_timeout, + * 'max_vfolder_count': vfolder_count_limit, + * 'max_vfolder_size': vfolder_capacity_limit, + * 'allowed_vfolder_hosts': vfolder_hosts + * }; + */ + add(name: any, input: any): Promise; + /** + * mutate specified resource policy with given name with new values. + * + * @param {string} name - resource policy name to mutate. (READ-ONLY) + * @param {json} input - resource policy specification and data. Required fields are: + * { + * {string} 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. + * {JSONString} 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. + * {int} 'max_concurrent_sessions': concurrency_limit, + * {int} 'max_containers_per_session': containers_per_session_limit, + * {bigint} 'idle_timeout': idle_timeout, + * {int} 'max_vfolder_count': vfolder_count_limit, + * {bigint} 'max_vfolder_size': vfolder_capacity_limit, + * {[string]} 'allowed_vfolder_hosts': vfolder_hosts + * }; + */ + mutate(name: any, input: any): Promise; + /** + * delete specified resource policy that exists in policy list. + * + * @param {string} name - resource policy name to delete. (READ-ONLY) + */ + delete(name?: any): Promise; } declare class ContainerImage { + client: any; /** * The Container image API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client); - client: Client; + constructor(client: any); /** * list container images registered on the manager. * @@ -685,7 +764,7 @@ declare class ContainerImage { * @param {boolean} installed_only - filter images to installed / not installed. true to query installed images only. * @param {boolean} system_images - filter images to get system images such as web UI, SFTP server. true to query system images only. */ - list(fields?: any[], installed_only?: boolean, system_images?: boolean): Promise; + list(fields?: string[], installed_only?: boolean, system_images?: boolean): Promise; /** * Modify resource of given image. * @@ -694,7 +773,7 @@ declare class ContainerImage { * @param {string} tag - image tag. * @param {object} input - value list to set. */ - modifyResource(registry: string, image: string, tag: string, input: object): Promise; + modifyResource(registry: any, image: any, tag: any, input: any): Promise; /** * Modify label of given image. * @@ -704,7 +783,7 @@ declare class ContainerImage { * @param {string} key - key to change. * @param {string} value - value for the key. */ - modifyLabel(registry: string, image: string, tag: string, key: string, value: string): Promise; + modifyLabel(registry: any, image: any, tag: any, key: any, value: any): Promise; /** * install specific container images from registry * @@ -712,14 +791,14 @@ declare class ContainerImage { * @param {object} resource - resource to use for installation. * @param {string} registry - registry of image. default is 'index.docker.io', which is public Backend.AI docker registry. */ - install(name: string, resource?: object, registry?: string): Promise; + install(name: any, resource?: object, registry?: string): Promise; /** * uninstall specific container images from registry (TO BE IMPLEMENTED) * * @param {string} name - name to install. it should contain full path with tags. e.g. lablup/python:3.6-ubuntu18.04 * @param {string} registry - registry of image. default is 'index.docker.io', which is public Backend.AI docker registry. */ - uninstall(name: string, registry?: string): Promise; + uninstall(name: any, registry?: string): Promise; /** * Get image label information. * @@ -727,33 +806,16 @@ declare class ContainerImage { * @param {string} image - image name. * @param {string} tag - tag to get. */ - get(registry: string, image: string, tag: string): Promise; -} -declare class utils { - constructor(client: any); - client: any; - changeBinaryUnit(value: any, targetUnit?: string, defaultUnit?: string): any; - elapsedTime(start: any, end: any): string; - _padding_zeros(n: any, width: any): any; - /** - * Limit the boundary of value - * - * @param {number} value - input value to be clamped - * @param {number} min - minimum value of the input value - * @param {number} max - maximum value of the input vallue - */ - clamp(value: number, min: number, max: number): number; - gqlToObject(array: any, key: any): {}; - gqlToList(array: any, key: any): any[]; + get(registry: any, image: any, tag: any): Promise; } declare class ComputeSession { + client: any; /** * The Computate session API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client); - client: Client; + constructor(client: any); /** * Get the number of compute sessions with specific conditions. * @@ -777,7 +839,7 @@ declare class ComputeSession { * @param {string} group - project group id to query. Default returns sessions from all groups. * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) */ - list(fields?: any[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; + list(fields?: string[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; /** * list all status of compute sessions. * @@ -789,25 +851,25 @@ declare class ComputeSession { * @param {string} group - project group id to query. Default returns sessions from all groups. * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) */ - listAll(fields?: any[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; + listAll(fields?: string[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; /** * get compute session with specific condition. * * @param {array} fields - fields to query. Default fields are: ["session_name", "lang", "created_at", "terminated_at", "status", "status_info", "occupied_slots", "cpu_used", "io_read_bytes", "io_write_bytes"]. * @param {string} sessionUuid - session ID to query specific compute session. */ - get(fields?: any[], sessionUuid?: string): Promise; - startService(session: any, app: any, port?: any, envs?: any, args?: any): Promise; + get(fields?: string[], sessionUuid?: string): Promise; + startService(session: string, app: string, port?: number | null, envs?: Record | null, args?: Record | null): Promise; } declare class SessionTemplate { + client: any; + urlPrefix: string; /** * The Computate session template API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client); - client: Client; - urlPrefix: string; + constructor(client: any); /** * list session templates with specific conditions. * @@ -822,70 +884,125 @@ declare class SessionTemplate { */ list(listall?: boolean, groupId?: any): Promise; } -declare class ResourcePolicy { +declare class Resources { + client: any; + resources: any; + agents: any; + constructor(client: any); + _init_resource_values(): void; /** - * The Resource Policy API wrapper. + * Total resource information of Backend.AI cluster. * - * @param {Client} client - the Client API wrapper object to bind + * @param {string} status - Resource node status to get information. */ - constructor(client: Client); - client: Client; + totalResourceInformation(status?: string): Promise; /** - * get resource policy with given name and fields. + * user statistics about usage. * - * @param {string} name - resource policy name. - * @param {array} fields - fields to query. */ - get(name?: string, fields?: any[]): Promise; + user_stats(): Promise; +} +declare class Group { + client: any; /** - * add resource policy with given name and fields. + * The group API wrapper. * - * @param {string} name - resource policy name. - * @param {json} input - resource policy specification and data. Required fields are: - * { - * 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. - * 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. - * 'max_concurrent_sessions': concurrency_limit, - * 'max_containers_per_session': containers_per_session_limit, - * 'idle_timeout': idle_timeout, - * 'max_vfolder_count': vfolder_count_limit, - * 'max_vfolder_size': vfolder_capacity_limit, - * 'allowed_vfolder_hosts': vfolder_hosts - * }; + * @param {Client} client - the Client API wrapper object to bind */ - add(name: string, input: any): Promise; + constructor(client: any); /** - * mutate specified resource policy with given name with new values. - * - * @param {string} name - resource policy name to mutate. (READ-ONLY) - * @param {json} input - resource policy specification and data. Required fields are: + * List registred groups. + * @param {boolean} is_active - List whether active users or inactive users. + * @param {string} domain_name - domain name of group * { - * {string} 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. - * {JSONString} 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. - * {int} 'max_concurrent_sessions': concurrency_limit, - * {int} 'max_containers_per_session': containers_per_session_limit, - * {bigint} 'idle_timeout': idle_timeout, - * {int} 'max_vfolder_count': vfolder_count_limit, - * {bigint} 'max_vfolder_size': vfolder_capacity_limit, - * {[string]} 'allowed_vfolder_hosts': vfolder_hosts + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'domain_name': String, // Domain for group. * }; */ - mutate(name: string, input: any): Promise; + list(is_active?: boolean, domain_name?: boolean, fields?: string[]): Promise; +} +declare class Domain { + client: any; /** - * delete specified resource policy that exists in policy list. + * The domain API wrapper. * - * @param {string} name - resource policy name to delete. (READ-ONLY) + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: any); + /** + * Get domain information. + * @param {string} domain_name - domain name of group + * @param {array} fields - fields to query. Default fields are: ['name', 'description', 'is_active', 'created_at', 'modified_at', 'total_resource_slots', 'allowed_vfolder_hosts', + 'allowed_docker_registries', 'integration_id', 'scaling_groups'] + * { + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'total_resource_slots': JSOONString, // Total resource slots + * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts + * 'allowed_docker_registries': [String], // Allowed docker registry lists + * 'integration_id': [String], // Integration ids + * 'scaling_groups': [String], // Scaling groups + * }; + */ + get(domain_name?: boolean, fields?: string[]): Promise; + list(fields?: string[]): Promise; + /** + * Modify domain information. + * @param {string} domain_name - domain name of group + + + * @param {json} input - Domain specification to change. Required fields are: + * { + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'total_resource_slots': JSOONString, // Total resource slots + * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts + * 'allowed_docker_registries': [String], // Allowed docker registry lists + * 'integration_id': [String], // Integration ids + * 'scaling_groups': [String], // Scaling groups + * }; + */ + update(domain_name: boolean, input: any): Promise; +} +declare class Maintenance { + client: any; + urlPrefix: any; + /** + * The Maintenance API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: any); + /** + * Attach to the background task to listen to events + * @param {string} task_id - background task id. + */ + attach_background_task(task_id: string): EventSource; + /** + * Rescan image from repository + * @param {string} registry - registry. default is '' */ - delete(name?: string): Promise; + rescan_images(registry?: string): Promise; + recalculate_usage(): Promise; } declare class User { + client: any; /** * The user API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client); - client: Client; + constructor(client: any); /** * List all registred users. * @@ -924,7 +1041,7 @@ declare class User { * 'groups': List(UUID) // Group Ids for user. Shoule be list of UUID strings. * }; */ - get(email: string, fields?: string[]): Promise; + get(email: any, fields?: string[]): Promise; /** * add new user with given information. * @@ -942,7 +1059,7 @@ declare class User { * 'group_ids': List(UUID) // Group Ids for user. Shoule be list of UUID strings. * }; */ - create(email: string, input: any): Promise; + create(email: any, input: any): Promise; /** * modify user information with given user id with new values. * @@ -960,157 +1077,22 @@ declare class User { * 'group_ids': List(UUID) // Group Ids for user. Shoule be list of UUID strings. * }; */ - update(email: string, input: any): Promise; + update(email: any, input: any): Promise; /** * delete user information with given user id * * @param {string} email - E-mail address as user id to delete. */ - delete(email: string): Promise; -} -declare class Group { - /** - * The group API wrapper. - * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: Client); - client: Client; - /** - * List registred groups. - * @param {boolean} is_active - List whether active users or inactive users. - * @param {string} domain_name - domain name of group - * { - * 'name': String, // Group name. - * 'description': String, // Description for group. - * 'is_active': Boolean, // Whether the group is active or not. - * 'created_at': String, // Created date of group. - * 'modified_at': String, // Modified date of group. - * 'domain_name': String, // Domain for group. - * }; - */ - list(is_active?: boolean, domain_name?: string, fields?: string[]): Promise; -} -declare class Domain { - /** - * The domain API wrapper. - * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: Client); - client: Client; - /** - * Get domain information. - * @param {string} domain_name - domain name of group - * @param {array} fields - fields to query. Default fields are: ['name', 'description', 'is_active', 'created_at', 'modified_at', 'total_resource_slots', 'allowed_vfolder_hosts', - 'allowed_docker_registries', 'integration_id', 'scaling_groups'] - * { - * 'name': String, // Group name. - * 'description': String, // Description for group. - * 'is_active': Boolean, // Whether the group is active or not. - * 'created_at': String, // Created date of group. - * 'modified_at': String, // Modified date of group. - * 'total_resource_slots': JSOONString, // Total resource slots - * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts - * 'allowed_docker_registries': [String], // Allowed docker registry lists - * 'integration_id': [String], // Integration ids - * 'scaling_groups': [String], // Scaling groups - * }; - */ - get(domain_name?: string, fields?: any[]): Promise; - list(fields?: string[]): Promise; - /** - * Modify domain information. - * @param {string} domain_name - domain name of group - - - * @param {json} input - Domain specification to change. Required fields are: - * { - * 'name': String, // Group name. - * 'description': String, // Description for group. - * 'is_active': Boolean, // Whether the group is active or not. - * 'created_at': String, // Created date of group. - * 'modified_at': String, // Modified date of group. - * 'total_resource_slots': JSOONString, // Total resource slots - * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts - * 'allowed_docker_registries': [String], // Allowed docker registry lists - * 'integration_id': [String], // Integration ids - * 'scaling_groups': [String], // Scaling groups - * }; - */ - update(domain_name: string, input: any): Promise; -} -declare class Resources { - constructor(client: any); - client: any; - resources: {}; - _init_resource_values(): void; - agents: any; - /** - * Total resource information of Backend.AI cluster. - * - * @param {string} status - Resource node status to get information. - */ - totalResourceInformation(status?: string): Promise; - /** - * user statistics about usage. - * - */ - user_stats(): Promise; -} -declare class StorageProxy { - /** - * Agent API wrapper. - * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: Client); - client: Client; - /** - * List storage proxies and its volumes. - * - * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. - * @param {number} limit - limit number of query items. - * @param {number} offset - offset for item query. Useful for pagination. - */ - list(fields?: any[], limit?: number, offset?: number): Promise; - /** - * Detail of specific storage proxy / volume. - * - * @param {string} host - Virtual folder host. - * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. - */ - detail(host?: string, fields?: any[]): Promise; -} -declare class Maintenance { - /** - * The Maintenance API wrapper. - * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: Client); - client: Client; - urlPrefix: string; - /** - * Attach to the background task to listen to events - * @param {string} task_id - background task id. - */ - attach_background_task(task_id: string): EventSource; - /** - * Rescan image from repository - * @param {string} registry - registry. default is '' - */ - rescan_images(registry?: string): Promise; - recalculate_usage(): Promise; + delete(email: any): Promise; } declare class ScalingGroup { + client: any; /** * The Scaling Group API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client); - client: Client; + constructor(client: any); list_available(): Promise; list(group?: string): Promise; /** @@ -1119,7 +1101,7 @@ declare class ScalingGroup { * * @param {string} group - Scaling group name */ - getWsproxyVersion(group: string): Promise; + getWsproxyVersion(group: any): Promise; /** * Create a scaling group * @@ -1127,14 +1109,14 @@ declare class ScalingGroup { * @param {string} description - Scaling group description * @param {string} wsproxyAddress - wsproxy url (NEW in manager 21.09) */ - create(name: string, description?: string, wsproxyAddress?: string): Promise; + create(name: any, description?: string, wsproxyAddress?: any): Promise; /** * Associate a scaling group with a domain * * @param {string} domain - domain name * @param {string} scaling_group - scaling group name */ - associate_domain(domain: string, scaling_group: string): Promise; + associate_domain(domain: any, scaling_group: any): Promise; /** * Modify a scaling group * @@ -1150,30 +1132,30 @@ declare class ScalingGroup { * 'wsproxy_addr': String // NEW in manager 21.09 * } */ - update(name: string, input: any): Promise; + update(name: any, input: any): Promise; /** * Delete a scaling group * * @param {string} name - name of scaling group to be deleted */ - delete(name: string): Promise; + delete(name: any): Promise; } declare class Registry { - constructor(client: any); client: any; + constructor(client: any); list(): Promise; set(key: any, value: any): Promise; delete(key: any): Promise; } declare class Setting { + client: any; + config: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: Client); - client: Client; - config: any; + constructor(client: any); /** * List settings * @@ -1192,24 +1174,46 @@ declare class Setting { * @param {string} key - key to add. * @param {object} value - value to add. */ - set(key: string, value: object): Promise; + set(key: any, value: any): Promise; /** * Delete a setting * * @param {string} key - key to delete * @param {boolean} prefix - prefix to delete. if prefix is true, this command will delete every settings starting with the key. */ - delete(key: string, prefix?: boolean): Promise; + delete(key: any, prefix?: boolean): Promise; +} +declare class Service { + client: any; + config: any; + /** + * Service-specific API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: any); + /** + * Get announcements + * + */ + get_announcement(): Promise; + /** + * Update announcement + * + * @param {boolean} enabled - Enable / disable announcement. Default is True. + * @param {string} message - Announcement content. Usually in Markdown syntax. + */ + update_announcement(enabled: boolean, message: any): Promise; } declare class UserConfig { + client: any; + config: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ constructor(client: Client); - client: Client; - config: any; /** * Get content of bootstrap script of a keypair. */ @@ -1219,7 +1223,7 @@ declare class UserConfig { * * @param {string} data - text content of bootstrap script. */ - update_bootstrap_script(script: any): Promise; + update_bootstrap_script(script: string): Promise; /** * Create content of script dotfile (.bashrc or .zshrc) * @param {string} data - text content of script dotfile @@ -1244,52 +1248,30 @@ declare class UserConfig { */ delete(path: string): Promise; } -declare class Service { - /** - * Service-specific API wrapper. - * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: Client); - client: Client; - config: any; - /** - * Get announcements - * - */ - get_announcement(): Promise; - /** - * Update announcement - * - * @param {boolean} enabled - Enable / disable announcement. Default is True. - * @param {string} message - Announcement content. Usually in Markdown syntax. - */ - update_announcement(enabled: boolean, message: string): Promise; -} declare class Enterprise { + client: any; + config: any; + certificate: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ constructor(client: Client); - client: Client; - config: any; /** * Get the current enterprise license. */ getLicense(): Promise; - certificate: any; } declare class Cloud { + client: any; + config: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ constructor(client: Client); - client: Client; - config: any; /** * Check if cloud endpoint is available. */ @@ -1322,14 +1304,14 @@ declare class Cloud { change_password(email: string, password: string, token: string): Promise; } declare class EduApp { + client: any; + config: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ constructor(client: Client); - client: Client; - config: any; /** * Check if EduApp endpoint is available. */ @@ -1339,4 +1321,24 @@ declare class EduApp { */ get_mount_folders(): Promise; } -export { Client as BackendAIClient, ClientConfig as BackendAIClientConfig }; +declare class utils { + client: any; + constructor(client: any); + changeBinaryUnit(value: any, targetUnit?: string, defaultUnit?: string): any; + elapsedTime(start: any, end: any): string; + _padding_zeros(n: any, width: any): any; + /** + * Limit the boundary of value + * + * @param {number} value - input value to be clamped + * @param {number} min - minimum value of the input value + * @param {number} max - maximum value of the input vallue + */ + clamp(value: number, min: number, max: number): number; + gqlToObject(array: any, key: any): {}; + gqlToList(array: any, key: any): any[]; +} +declare const backend: { + Client: typeof Client; + ClientConfig: typeof ClientConfig; +}; diff --git a/package.json b/package.json index 3a5f3ee..53d7f8c 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "", "build-doc": "./node_modules/jsdoc/jsdoc.js -c ./jsdoc.json", - "declare": "npx -p typescript tsc backend.ai-client-node.js --declaration --allowJs --emitDeclarationOnly --outDir lib" + "declare": "npx -p typescript tsc backend.ai-client-node.ts --target es2017 --declaration --emitDeclarationOnly --outDir lib" }, "repository": { "type": "git", From d4f0577d0560b8e48dbe56929e2f0fc4325045d2 Mon Sep 17 00:00:00 2001 From: Jeongseok Kang Date: Tue, 24 Jan 2023 21:29:17 +0900 Subject: [PATCH 5/5] fix: Generate type declaration from js --- lib/backend.ai-client-node.d.ts | 770 ++++++++++++++++---------------- package.json | 3 +- 2 files changed, 386 insertions(+), 387 deletions(-) diff --git a/lib/backend.ai-client-node.d.ts b/lib/backend.ai-client-node.d.ts index 2d6ccfd..319acd5 100644 --- a/lib/backend.ai-client-node.d.ts +++ b/lib/backend.ai-client-node.d.ts @@ -1,60 +1,28 @@ -declare const crypto_node: any; -declare const querystring: any; -interface Window { - backendaiclient: any; +export namespace backend { + export { Client }; + export { ClientConfig }; } -declare class ClientConfig { - _apiVersionMajor: string; - _apiVersion: string; - _hashType: string; - _endpoint: string; - _endpointHost: string; - _accessKey: string; - _secretKey: string; - _userId: string; - _password: string; - _proxyURL: any; - _proxyToken: any; - _connectionMode: string; +export class Client { /** - * The client Configuration object. + * The client API wrapper. * - * @param {string} accessKey - access key to connect Backend.AI manager - * @param {string} secretKey - secret key to connect Backend.AI manager - * @param {string} endpoint - endpoint of Backend.AI manager - * @param {string} connectionMode - connection mode. 'API', 'SESSION' is supported. `SESSION` mode requires webserver. - */ - constructor(accessKey: any, secretKey: any, endpoint: any, connectionMode?: string); - get accessKey(): string; - get secretKey(): string; - get userId(): string; - get password(): string; - get endpoint(): string; - get proxyURL(): any; - get proxyToken(): any; - get endpointHost(): string; - get apiVersion(): string; - get apiVersionMajor(): string; - get hashType(): string; - get connectionMode(): string; - /** - * Create a ClientConfig object from environment variables. + * @param {ClientConfig} config - the API client-side configuration + * @param {string} agentSignature - an extra string that will be appended to User-Agent headers when making API requests */ - static createFromEnv(): ClientConfig; -} -declare class Client { + constructor(config: ClientConfig, agentSignature: string); + ready: boolean; code: any; - sessionId: string | null; + sessionId: any; kernelType: any; clientVersion: string; - agentSignature: any; - _config: any; + agentSignature: string; + _config: ClientConfig; _managerVersion: any; _apiVersion: any; _apiVersionMajor: any; is_admin: boolean; is_superadmin: boolean; - kernelPrefix: any; + kernelPrefix: string; resourcePreset: ResourcePreset; vfolder: VFolder; agent: Agent; @@ -74,28 +42,14 @@ declare class Client { registry: Registry; setting: Setting; userConfig: UserConfig; - cloud: Cloud; - eduApp: EduApp; service: Service; enterprise: Enterprise; - _features: any; - ready: boolean; - abortController: any; - abortSignal: any; + cloud: Cloud; + eduApp: EduApp; + _features: {}; + abortController: AbortController; + abortSignal: AbortSignal; requestTimeout: number; - static ERR_REQUEST: any; - static ERR_RESPONSE: any; - static ERR_ABORT: any; - static ERR_TIMEOUT: any; - static ERR_SERVER: any; - static ERR_UNKNOWN: any; - /** - * The client API wrapper. - * - * @param {ClientConfig} config - the API client-side configuration - * @param {string} agentSignature - an extra string that will be appended to User-Agent headers when making API requests - */ - constructor(config: any, agentSignature: any); /** * Return the server-side manager version. */ @@ -114,7 +68,7 @@ declare class Client { * @param {number} retry - an integer to retry this request * @param {Object} opts - Options */ - _wrapWithPromise(rqst: any, rawFile?: boolean, signal?: any, timeout?: number, retry?: number, opts?: {}): any; + _wrapWithPromise(rqst: Request, rawFile?: boolean, signal?: any, timeout?: number, retry?: number, opts?: any): any; /** * Return the server-side API version. * @@ -123,13 +77,13 @@ declare class Client { */ getServerVersion(signal?: any): any; /** - * Get API major version + * Force API major version */ - get APIMajorVersion(): any; + set APIMajorVersion(arg: any); /** - * Force API major version + * Get API major version */ - set APIMajorVersion(value: any); + get APIMajorVersion(): any; /** * Get the server-side manager version. * @@ -197,19 +151,19 @@ declare class Client { * @param {object} resources - Per-session resource * @param {number} timeout - Timeout of request. Default : default fetch value. (5sec.) */ - createIfNotExists(kernelType: any, sessionId: any, resources?: {}, timeout?: number): Promise; + createIfNotExists(kernelType: string, sessionId: string, resources?: object, timeout?: number): Promise; /** * Create a session with a session template. * * @param {string} sessionId - the sessionId given when created */ - createSessionFromTemplate(templateId: any, image?: any, sessionName?: undefined | string | null, resources?: {}, timeout?: number): Promise; + createSessionFromTemplate(templateId: any, image?: any, sessionName?: any, resources?: {}, timeout?: number): Promise; /** * Obtain the session information by given sessionId. * * @param {string} sessionId - the sessionId given when created */ - get_info(sessionId: any, ownerKey?: any): Promise; + get_info(sessionId: string, ownerKey?: any): Promise; /** * Obtain the session container logs by given sessionId. * @@ -217,13 +171,13 @@ declare class Client { * @param {string | null} ownerKey - owner key to access * @param {number} timeout - timeout to wait log query. Set to 0 to use default value. */ - get_logs(sessionId: any, ownerKey?: any, timeout?: number): Promise; + get_logs(sessionId: string, ownerKey?: string | null, timeout?: number): Promise; /** * Obtain the batch session (task) logs by given sessionId. * * @param {string} sessionId - the sessionId given when created */ - getTaskLogs(sessionId: any): any; + getTaskLogs(sessionId: string): any; /** * Terminate and destroy the kernel session. * @@ -231,13 +185,13 @@ declare class Client { * @param {string|null} ownerKey - owner key when terminating other users' session * @param {boolean} forced - force destroy session. Requires admin privilege. */ - destroy(sessionId: any, ownerKey?: any, forced?: boolean): Promise; + destroy(sessionId: string, ownerKey?: string | null, forced?: boolean): Promise; /** * Restart the kernel session keeping its work directory and volume mounts. * * @param {string} sessionId - the sessionId given when created */ - restart(sessionId: any, ownerKey?: any): Promise; + restart(sessionId: string, ownerKey?: any): Promise; /** * Execute a code snippet or schedule batch-mode executions. * @@ -246,7 +200,7 @@ declare class Client { * @param {string} mode - either "query", "batch", "input", or "continue" * @param {string} opts - an optional object specifying additional configs such as batch-mode build/exec commands */ - execute(sessionId: any, runId: any, mode: any, code: any, opts: any, timeout?: number): Promise; + execute(sessionId: string, runId: string, mode: string, code: any, opts: string, timeout?: number): Promise; createKernel(kernelType: any, sessionId?: any, resources?: {}, timeout?: number): Promise; destroyKernel(sessionId: any, ownerKey?: any): Promise; refreshKernel(sessionId: any, ownerKey?: any): Promise; @@ -264,7 +218,7 @@ declare class Client { * @param {number} timeout - Timeout to force terminate request * @param {number} retry - The number of retry when request is failed */ - query(q: any, v: any, signal?: any, timeout?: number, retry?: number): Promise; + query(q: string, v: string, signal?: any, timeout?: number, retry?: number): Promise; /** * Generate a RequestInfo object that can be passed to fetch() API, * which includes a properly signed header with the configured auth information. @@ -273,12 +227,12 @@ declare class Client { * @param {string} queryString - the URI path and GET parameters * @param {any} body - an object that will be encoded as JSON in the request body */ - newSignedRequest(method: string, queryString: any, body: any): { + newSignedRequest(method: string, queryString: string, body: any): { method: string; - headers: any; + headers: Headers; cache: string; body: any; - uri: any; + uri: string; }; /** * Same to newRequest() method but it does not sign the request. @@ -288,7 +242,7 @@ declare class Client { * @param {string} queryString - the URI path and GET parameters * @param {any} body - an object that will be encoded as JSON in the request body */ - newUnsignedRequest(method: any, queryString: any, body: any): { + newUnsignedRequest(method: string, queryString: string, body: any): { method: any; headers: Headers; mode: string; @@ -304,8 +258,8 @@ declare class Client { }; getAuthenticationString(method: any, queryString: any, dateValue: any, bodyValue: any, content_type?: string): string; getCurrentDate(now: any): string; - sign(key: any, key_encoding: any, msg: any, digest_type: any): any; - getSignKey(secret_key: any, now: any): any; + sign(key: any, key_encoding: any, msg: any, digest_type: any): string; + getSignKey(secret_key: any, now: any): string; generateSessionId(length?: number, nosuffix?: boolean): string; slugify(text: any): any; /** @@ -319,15 +273,62 @@ declare class Client { */ refreshSSHKeypair(): Promise; } +export namespace Client { + const ERR_SERVER: number; + const ERR_RESPONSE: number; + const ERR_REQUEST: number; + const ERR_ABORT: number; + const ERR_TIMEOUT: number; + const ERR_UNKNOWN: number; +} +export class ClientConfig { + /** + * Create a ClientConfig object from environment variables. + */ + static createFromEnv(): ClientConfig; + /** + * The client Configuration object. + * + * @param {string} accessKey - access key to connect Backend.AI manager + * @param {string} secretKey - secret key to connect Backend.AI manager + * @param {string} endpoint - endpoint of Backend.AI manager + * @param {string} connectionMode - connection mode. 'API', 'SESSION' is supported. `SESSION` mode requires webserver. + */ + constructor(accessKey: string, secretKey: string, endpoint: string, connectionMode?: string); + _apiVersionMajor: string; + _apiVersion: string; + _hashType: string; + _endpoint: string; + _endpointHost: string; + _accessKey: string; + _secretKey: string; + _userId: string; + _password: string; + _proxyURL: any; + _proxyToken: any; + _connectionMode: string; + get accessKey(): string; + get secretKey(): string; + get userId(): string; + get password(): string; + get endpoint(): string; + get proxyURL(): any; + get proxyToken(): any; + get endpointHost(): string; + get apiVersion(): string; + get apiVersionMajor(): string; + get hashType(): string; + get connectionMode(): string; +} declare class ResourcePreset { - client: any; - urlPrefix: any; /** * Resource Preset API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any); + constructor(client: Client); + client: Client; + urlPrefix: string; /** * Return the GraphQL Promise object containing resource preset list. */ @@ -345,7 +346,7 @@ declare class ResourcePreset { * 'resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. * }; */ - add(name: any, input: any): Promise; + add(name: string, input: any): Promise; /** * mutate specified resource preset with given name with new values. * @@ -355,25 +356,25 @@ declare class ResourcePreset { * 'resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. * }; */ - mutate(name: any, input: any): Promise; + mutate(name: string, input: any): Promise; /** * delete specified resource preset with given name. * * @param {string} name - resource preset name to delete. */ - delete(name?: any): Promise; + delete(name?: string): Promise; } declare class VFolder { - client: any; - name: any; - urlPrefix: any; /** * The Virtual Folder API wrapper. * * @param {Client} client - the Client API wrapper object to bind * @param {string} name - Virtual folder name. */ - constructor(client: any, name?: any); + constructor(client: Client, name?: string); + client: Client; + name: string; + urlPrefix: string; /** * Get allowed types of folders * @@ -389,7 +390,7 @@ declare class VFolder { * @param {string} permission - Virtual folder's innate permission. * @param {boolean} cloneable - Whether Virtual folder is cloneable or not. */ - create(name: any, host?: string, group?: string, usageMode?: string, permission?: string, cloneable?: boolean): Promise; + create(name: string, host?: string, group?: string, usageMode?: string, permission?: string, cloneable?: boolean): Promise; /** * Clone selected Virtual folder * @@ -427,19 +428,19 @@ declare class VFolder { * * @param {string} new_name - New virtual folder name. */ - rename(new_name?: any): Promise; + rename(new_name?: string): Promise; /** * Delete a Virtual folder. * * @param {string} name - Virtual folder name. If no name is given, use name on this VFolder object. */ - delete(name?: any): Promise; + delete(name?: string): Promise; /** * Leave an invited Virtual folder. * * @param {string} name - Virtual folder name. If no name is given, use name on this VFolder object. */ - leave_invited(name?: any): Promise; + leave_invited(name?: string): Promise; /** * Upload files to specific Virtual folder. * @@ -447,14 +448,14 @@ declare class VFolder { * @param {string} fs - File content to upload. * @param {string} name - Virtual folder name. */ - upload(path: any, fs: any, name?: any): Promise; + upload(path: string, fs: string, name?: string): Promise; /** * Upload file from formData to specific Virtual folder. * * @param {string} fss - formData with file specification. formData should contain {src, content, {filePath:filePath}}. * @param {string} name - Virtual folder name. */ - uploadFormData(fss: any, name?: any): Promise; + uploadFormData(fss: string, name?: string): Promise; /** * Create a upload session for a file to Virtual folder. * @@ -462,7 +463,7 @@ declare class VFolder { * @param {string} fs - File object to upload. * @param {string} name - Virtual folder name. */ - create_upload_session(path: any, fs: any, name?: any): Promise; + create_upload_session(path: string, fs: string, name?: string): Promise; /** * Create directory in specific Virtual folder. * @@ -471,7 +472,7 @@ declare class VFolder { * @param {string} parents - create parent folders when not exists (>=APIv6). * @param {string} exist_ok - Do not raise error when the folder already exists (>=APIv6). */ - mkdir(path: any, name?: any, parents?: any, exist_ok?: any): Promise; + mkdir(path: string, name?: string, parents?: string, exist_ok?: string): Promise; /** * Rename a file inside a virtual folder. * @@ -480,7 +481,7 @@ declare class VFolder { * @param {string} name - Virtual folder name that target file exists. * @param {string} is_dir - True when the object is directory, false when it is file */ - rename_file(target_path: any, new_name: any, name?: any, is_dir?: boolean): Promise; + rename_file(target_path: string, new_name: string, name?: string, is_dir?: string): Promise; /** * Delete multiple files in a Virtual folder. * @@ -488,7 +489,7 @@ declare class VFolder { * @param {boolean} recursive - delete files recursively. * @param {string} name - Virtual folder name that files are in. */ - delete_files(files: any, recursive?: boolean, name?: any): Promise; + delete_files(files: string, recursive?: boolean, name?: string): Promise; /** * Download file from a Virtual folder. * @@ -497,7 +498,7 @@ declare class VFolder { * @param {boolean} archive - Download target directory as an archive. * @param {boolean} noCache - If true, do not store the file response in any cache. New in API v6. */ - download(file: any, name?: boolean, archive?: boolean, noCache?: boolean): Promise; + download(file: string, name?: string, archive?: boolean, noCache?: boolean): Promise; /** * Request a download and get the token for direct download. * @@ -505,7 +506,7 @@ declare class VFolder { * @param {string} name - Virtual folder name that files are in. * @param {boolean} archive - Download target directory as an archive. */ - request_download_token(file: any, name?: boolean, archive?: boolean): Promise; + request_download_token(file: string, name?: string, archive?: boolean): Promise; /** * Download file in a Virtual folder with token. * @@ -524,7 +525,7 @@ declare class VFolder { * @param {string} path - Directory path to list. * @param {string} name - Virtual folder name to look up with. */ - list_files(path: any, name?: any): Promise; + list_files(path: string, name?: string): Promise; /** * Invite someone to specific virtual folder with permission. * @@ -532,7 +533,7 @@ declare class VFolder { * @param {array} emails - User E-mail to invite. * @param {string} name - Virtual folder name to invite. */ - invite(perm: any, emails: any, name?: any): Promise; + invite(perm: string, emails: any[], name?: string): Promise; /** * Show invitations to current API key. */ @@ -542,19 +543,19 @@ declare class VFolder { * * @param {string} inv_id - Invitation ID. */ - accept_invitation(inv_id: any): Promise; + accept_invitation(inv_id: string): Promise; /** * Delete specific invitation. * * @param {string} inv_id - Invitation ID to delete. */ - delete_invitation(inv_id: any): Promise; + delete_invitation(inv_id: string): Promise; /** * List invitees(users who accepted an invitation) * * @param {string} vfolder_id - vfolder id. If no id is given, all users who accepted the client's invitation will be returned */ - list_invitees(vfolder_id?: any): Promise; + list_invitees(vfolder_id?: string): Promise; /** * Modify an invitee's permission to a shared vfolder * @@ -571,14 +572,14 @@ declare class VFolder { * @param {array} emails - User E-mail(s) to share. * @param {string} name - A group virtual folder name to share. */ - share(permission: any, emails: any, name?: any): Promise; + share(permission: any, emails: any[], name?: string): Promise; /** * Unshare a group-type virtual folder from given users. * * @param {array} emails - User E-mail(s) to unshare. * @param {string} name - A group virtual folder name to unshare. */ - unshare(emails: any, name?: any): Promise; + unshare(emails: any[], name?: string): Promise; /** * Get the size quota of a vfolder. * Only available for some specific file system such as XFS. @@ -586,7 +587,7 @@ declare class VFolder { * @param {string} host - Host name of a virtual folder. * @param {string} vfolder_id - id of the vfolder. */ - get_quota(host: any, vfolder_id: any): Promise; + get_quota(host: string, vfolder_id: string): Promise; /** * Set the size quota of a vfolder. * Only available for some specific file system such as XFS. @@ -595,16 +596,16 @@ declare class VFolder { * @param {string} vfolder_id - id of the vfolder. * @param {number} quota - quota size of the vfolder. */ - set_quota(host: any, vfolder_id: any, quota: any): Promise; + set_quota(host: string, vfolder_id: string, quota: number): Promise; } declare class Agent { - client: any; /** * Agent API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any); + constructor(client: Client); + client: Client; /** * List computation agents. * @@ -612,41 +613,17 @@ declare class Agent { * @param {array} fields - Fields to query. Queryable fields are: 'id', 'status', 'region', 'first_contact', 'cpu_cur_pct', 'mem_cur_bytes', 'available_slots', 'occupied_slots'. * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) */ - list(status?: string, fields?: string[], timeout?: number): Promise; -} -declare class StorageProxy { - client: any; - /** - * Agent API wrapper. - * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: any); - /** - * List storage proxies and its volumes. - * - * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. - * @param {number} limit - limit number of query items. - * @param {number} offset - offset for item query. Useful for pagination. - */ - list(fields?: string[], limit?: number, offset?: number): Promise; - /** - * Detail of specific storage proxy / volume. - * - * @param {string} host - Virtual folder host. - * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. - */ - detail(host?: string, fields?: string[]): Promise; + list(status?: string, fields?: any[], timeout?: number): Promise; } declare class Keypair { - client: any; - name: any; /** * Keypair API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any, name?: any); + constructor(client: Client, name?: any); + client: Client; + name: any; /** * Information of specific Keypair. * @@ -654,7 +631,7 @@ declare class Keypair { * @param {array} fields - Fields to query. Queryable fields are: 'access_key', 'secret_key', 'is_active', 'is_admin', 'user_id', 'created_at', 'last_used', 'concurrency_limit', 'concurrency_used', 'rate_limit', 'num_queries', 'resource_policy'. */ - info(accessKey: any, fields?: string[]): Promise; + info(accessKey: string, fields?: any[]): Promise; /** * List all Keypairs of given user ID. * @@ -662,7 +639,7 @@ declare class Keypair { * @param {array} fields - Fields to query. Queryable fields are: "access_key", 'is_active', 'is_admin', 'user_id', 'created_at', 'last_used', 'concurrency_used', 'rate_limit', 'num_queries', 'resource_policy'. */ - list(userId?: any, fields?: string[], isActive?: boolean): Promise; + list(userId?: string, fields?: any[], isActive?: boolean): Promise; /** * Add Keypair with given information. * @@ -672,7 +649,7 @@ declare class Keypair { * @param {string} resourcePolicy - resource policy name to assign. Default is `default`. * @param {integer} rateLimit - API rate limit for 900 seconds. Prevents from DDoS attack. */ - add(userId?: any, isActive?: boolean, isAdmin?: boolean, resourcePolicy?: string, rateLimit?: number): Promise; + add(userId?: string, isActive?: boolean, isAdmin?: boolean, resourcePolicy?: string, rateLimit?: any): Promise; /** * mutate Keypair for given accessKey. * @@ -685,78 +662,22 @@ declare class Keypair { * 'rate_limit': rate_limit * } */ - mutate(accessKey: any, input: any): Promise; + mutate(accessKey: string, input: any): Promise; /** * Delete Keypair with given accessKey * * @param {string} accessKey - access key to delete. */ - delete(accessKey: any): Promise; -} -declare class ResourcePolicy { - client: any; - /** - * The Resource Policy API wrapper. - * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: any); - /** - * get resource policy with given name and fields. - * - * @param {string} name - resource policy name. - * @param {array} fields - fields to query. - */ - get(name?: any, fields?: string[]): Promise; - /** - * add resource policy with given name and fields. - * - * @param {string} name - resource policy name. - * @param {json} input - resource policy specification and data. Required fields are: - * { - * 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. - * 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. - * 'max_concurrent_sessions': concurrency_limit, - * 'max_containers_per_session': containers_per_session_limit, - * 'idle_timeout': idle_timeout, - * 'max_vfolder_count': vfolder_count_limit, - * 'max_vfolder_size': vfolder_capacity_limit, - * 'allowed_vfolder_hosts': vfolder_hosts - * }; - */ - add(name: any, input: any): Promise; - /** - * mutate specified resource policy with given name with new values. - * - * @param {string} name - resource policy name to mutate. (READ-ONLY) - * @param {json} input - resource policy specification and data. Required fields are: - * { - * {string} 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. - * {JSONString} 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. - * {int} 'max_concurrent_sessions': concurrency_limit, - * {int} 'max_containers_per_session': containers_per_session_limit, - * {bigint} 'idle_timeout': idle_timeout, - * {int} 'max_vfolder_count': vfolder_count_limit, - * {bigint} 'max_vfolder_size': vfolder_capacity_limit, - * {[string]} 'allowed_vfolder_hosts': vfolder_hosts - * }; - */ - mutate(name: any, input: any): Promise; - /** - * delete specified resource policy that exists in policy list. - * - * @param {string} name - resource policy name to delete. (READ-ONLY) - */ - delete(name?: any): Promise; + delete(accessKey: string): Promise; } declare class ContainerImage { - client: any; /** * The Container image API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any); + constructor(client: Client); + client: Client; /** * list container images registered on the manager. * @@ -764,7 +685,7 @@ declare class ContainerImage { * @param {boolean} installed_only - filter images to installed / not installed. true to query installed images only. * @param {boolean} system_images - filter images to get system images such as web UI, SFTP server. true to query system images only. */ - list(fields?: string[], installed_only?: boolean, system_images?: boolean): Promise; + list(fields?: any[], installed_only?: boolean, system_images?: boolean): Promise; /** * Modify resource of given image. * @@ -773,7 +694,7 @@ declare class ContainerImage { * @param {string} tag - image tag. * @param {object} input - value list to set. */ - modifyResource(registry: any, image: any, tag: any, input: any): Promise; + modifyResource(registry: string, image: string, tag: string, input: object): Promise; /** * Modify label of given image. * @@ -783,7 +704,7 @@ declare class ContainerImage { * @param {string} key - key to change. * @param {string} value - value for the key. */ - modifyLabel(registry: any, image: any, tag: any, key: any, value: any): Promise; + modifyLabel(registry: string, image: string, tag: string, key: string, value: string): Promise; /** * install specific container images from registry * @@ -791,14 +712,14 @@ declare class ContainerImage { * @param {object} resource - resource to use for installation. * @param {string} registry - registry of image. default is 'index.docker.io', which is public Backend.AI docker registry. */ - install(name: any, resource?: object, registry?: string): Promise; + install(name: string, resource?: object, registry?: string): Promise; /** * uninstall specific container images from registry (TO BE IMPLEMENTED) * * @param {string} name - name to install. it should contain full path with tags. e.g. lablup/python:3.6-ubuntu18.04 * @param {string} registry - registry of image. default is 'index.docker.io', which is public Backend.AI docker registry. */ - uninstall(name: any, registry?: string): Promise; + uninstall(name: string, registry?: string): Promise; /** * Get image label information. * @@ -806,16 +727,33 @@ declare class ContainerImage { * @param {string} image - image name. * @param {string} tag - tag to get. */ - get(registry: any, image: any, tag: any): Promise; + get(registry: string, image: string, tag: string): Promise; } -declare class ComputeSession { +declare class utils { + constructor(client: any); client: any; + changeBinaryUnit(value: any, targetUnit?: string, defaultUnit?: string): any; + elapsedTime(start: any, end: any): string; + _padding_zeros(n: any, width: any): any; + /** + * Limit the boundary of value + * + * @param {number} value - input value to be clamped + * @param {number} min - minimum value of the input value + * @param {number} max - maximum value of the input vallue + */ + clamp(value: number, min: number, max: number): number; + gqlToObject(array: any, key: any): {}; + gqlToList(array: any, key: any): any[]; +} +declare class ComputeSession { /** * The Computate session API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any); + constructor(client: Client); + client: Client; /** * Get the number of compute sessions with specific conditions. * @@ -839,7 +777,7 @@ declare class ComputeSession { * @param {string} group - project group id to query. Default returns sessions from all groups. * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) */ - list(fields?: string[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; + list(fields?: any[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; /** * list all status of compute sessions. * @@ -851,25 +789,25 @@ declare class ComputeSession { * @param {string} group - project group id to query. Default returns sessions from all groups. * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) */ - listAll(fields?: string[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; + listAll(fields?: any[], status?: string, accessKey?: string, limit?: number, offset?: number, group?: string, timeout?: number): Promise; /** * get compute session with specific condition. * * @param {array} fields - fields to query. Default fields are: ["session_name", "lang", "created_at", "terminated_at", "status", "status_info", "occupied_slots", "cpu_used", "io_read_bytes", "io_write_bytes"]. * @param {string} sessionUuid - session ID to query specific compute session. */ - get(fields?: string[], sessionUuid?: string): Promise; - startService(session: string, app: string, port?: number | null, envs?: Record | null, args?: Record | null): Promise; + get(fields?: any[], sessionUuid?: string): Promise; + startService(session: any, app: any, port?: any, envs?: any, args?: any): Promise; } declare class SessionTemplate { - client: any; - urlPrefix: string; /** * The Computate session template API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any); + constructor(client: Client); + client: Client; + urlPrefix: string; /** * list session templates with specific conditions. * @@ -884,125 +822,70 @@ declare class SessionTemplate { */ list(listall?: boolean, groupId?: any): Promise; } -declare class Resources { - client: any; - resources: any; - agents: any; - constructor(client: any); - _init_resource_values(): void; +declare class ResourcePolicy { /** - * Total resource information of Backend.AI cluster. + * The Resource Policy API wrapper. * - * @param {string} status - Resource node status to get information. + * @param {Client} client - the Client API wrapper object to bind */ - totalResourceInformation(status?: string): Promise; + constructor(client: Client); + client: Client; /** - * user statistics about usage. + * get resource policy with given name and fields. * + * @param {string} name - resource policy name. + * @param {array} fields - fields to query. */ - user_stats(): Promise; -} -declare class Group { - client: any; + get(name?: string, fields?: any[]): Promise; /** - * The group API wrapper. + * add resource policy with given name and fields. * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: any); - /** - * List registred groups. - * @param {boolean} is_active - List whether active users or inactive users. - * @param {string} domain_name - domain name of group + * @param {string} name - resource policy name. + * @param {json} input - resource policy specification and data. Required fields are: * { - * 'name': String, // Group name. - * 'description': String, // Description for group. - * 'is_active': Boolean, // Whether the group is active or not. - * 'created_at': String, // Created date of group. - * 'modified_at': String, // Modified date of group. - * 'domain_name': String, // Domain for group. + * 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. + * 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. + * 'max_concurrent_sessions': concurrency_limit, + * 'max_containers_per_session': containers_per_session_limit, + * 'idle_timeout': idle_timeout, + * 'max_vfolder_count': vfolder_count_limit, + * 'max_vfolder_size': vfolder_capacity_limit, + * 'allowed_vfolder_hosts': vfolder_hosts * }; */ - list(is_active?: boolean, domain_name?: boolean, fields?: string[]): Promise; -} -declare class Domain { - client: any; + add(name: string, input: any): Promise; /** - * The domain API wrapper. + * mutate specified resource policy with given name with new values. * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: any); - /** - * Get domain information. - * @param {string} domain_name - domain name of group - * @param {array} fields - fields to query. Default fields are: ['name', 'description', 'is_active', 'created_at', 'modified_at', 'total_resource_slots', 'allowed_vfolder_hosts', - 'allowed_docker_registries', 'integration_id', 'scaling_groups'] - * { - * 'name': String, // Group name. - * 'description': String, // Description for group. - * 'is_active': Boolean, // Whether the group is active or not. - * 'created_at': String, // Created date of group. - * 'modified_at': String, // Modified date of group. - * 'total_resource_slots': JSOONString, // Total resource slots - * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts - * 'allowed_docker_registries': [String], // Allowed docker registry lists - * 'integration_id': [String], // Integration ids - * 'scaling_groups': [String], // Scaling groups - * }; - */ - get(domain_name?: boolean, fields?: string[]): Promise; - list(fields?: string[]): Promise; - /** - * Modify domain information. - * @param {string} domain_name - domain name of group - - - * @param {json} input - Domain specification to change. Required fields are: + * @param {string} name - resource policy name to mutate. (READ-ONLY) + * @param {json} input - resource policy specification and data. Required fields are: * { - * 'name': String, // Group name. - * 'description': String, // Description for group. - * 'is_active': Boolean, // Whether the group is active or not. - * 'created_at': String, // Created date of group. - * 'modified_at': String, // Modified date of group. - * 'total_resource_slots': JSOONString, // Total resource slots - * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts - * 'allowed_docker_registries': [String], // Allowed docker registry lists - * 'integration_id': [String], // Integration ids - * 'scaling_groups': [String], // Scaling groups + * {string} 'default_for_unspecified': 'UNLIMITED', // default resource policy when resource slot is not given. 'UNLIMITED' or 'LIMITED'. + * {JSONString} 'total_resource_slots': JSON.stringify(total_resource_slots), // Resource slot value. should be Stringified JSON. + * {int} 'max_concurrent_sessions': concurrency_limit, + * {int} 'max_containers_per_session': containers_per_session_limit, + * {bigint} 'idle_timeout': idle_timeout, + * {int} 'max_vfolder_count': vfolder_count_limit, + * {bigint} 'max_vfolder_size': vfolder_capacity_limit, + * {[string]} 'allowed_vfolder_hosts': vfolder_hosts * }; */ - update(domain_name: boolean, input: any): Promise; -} -declare class Maintenance { - client: any; - urlPrefix: any; + mutate(name: string, input: any): Promise; /** - * The Maintenance API wrapper. + * delete specified resource policy that exists in policy list. * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: any); - /** - * Attach to the background task to listen to events - * @param {string} task_id - background task id. - */ - attach_background_task(task_id: string): EventSource; - /** - * Rescan image from repository - * @param {string} registry - registry. default is '' + * @param {string} name - resource policy name to delete. (READ-ONLY) */ - rescan_images(registry?: string): Promise; - recalculate_usage(): Promise; + delete(name?: string): Promise; } declare class User { - client: any; /** * The user API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any); + constructor(client: Client); + client: Client; /** * List all registred users. * @@ -1041,7 +924,7 @@ declare class User { * 'groups': List(UUID) // Group Ids for user. Shoule be list of UUID strings. * }; */ - get(email: any, fields?: string[]): Promise; + get(email: string, fields?: string[]): Promise; /** * add new user with given information. * @@ -1059,7 +942,7 @@ declare class User { * 'group_ids': List(UUID) // Group Ids for user. Shoule be list of UUID strings. * }; */ - create(email: any, input: any): Promise; + create(email: string, input: any): Promise; /** * modify user information with given user id with new values. * @@ -1077,22 +960,157 @@ declare class User { * 'group_ids': List(UUID) // Group Ids for user. Shoule be list of UUID strings. * }; */ - update(email: any, input: any): Promise; + update(email: string, input: any): Promise; /** * delete user information with given user id * * @param {string} email - E-mail address as user id to delete. */ - delete(email: any): Promise; + delete(email: string): Promise; } -declare class ScalingGroup { +declare class Group { + /** + * The group API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * List registred groups. + * @param {boolean} is_active - List whether active users or inactive users. + * @param {string} domain_name - domain name of group + * { + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'domain_name': String, // Domain for group. + * }; + */ + list(is_active?: boolean, domain_name?: string, fields?: string[]): Promise; +} +declare class Domain { + /** + * The domain API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * Get domain information. + * @param {string} domain_name - domain name of group + * @param {array} fields - fields to query. Default fields are: ['name', 'description', 'is_active', 'created_at', 'modified_at', 'total_resource_slots', 'allowed_vfolder_hosts', + 'allowed_docker_registries', 'integration_id', 'scaling_groups'] + * { + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'total_resource_slots': JSOONString, // Total resource slots + * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts + * 'allowed_docker_registries': [String], // Allowed docker registry lists + * 'integration_id': [String], // Integration ids + * 'scaling_groups': [String], // Scaling groups + * }; + */ + get(domain_name?: string, fields?: any[]): Promise; + list(fields?: string[]): Promise; + /** + * Modify domain information. + * @param {string} domain_name - domain name of group + + + * @param {json} input - Domain specification to change. Required fields are: + * { + * 'name': String, // Group name. + * 'description': String, // Description for group. + * 'is_active': Boolean, // Whether the group is active or not. + * 'created_at': String, // Created date of group. + * 'modified_at': String, // Modified date of group. + * 'total_resource_slots': JSOONString, // Total resource slots + * 'allowed_vfolder_hosts': [String], // Allowed virtual folder hosts + * 'allowed_docker_registries': [String], // Allowed docker registry lists + * 'integration_id': [String], // Integration ids + * 'scaling_groups': [String], // Scaling groups + * }; + */ + update(domain_name: string, input: any): Promise; +} +declare class Resources { + constructor(client: any); client: any; + resources: {}; + _init_resource_values(): void; + agents: any; + /** + * Total resource information of Backend.AI cluster. + * + * @param {string} status - Resource node status to get information. + */ + totalResourceInformation(status?: string): Promise; + /** + * user statistics about usage. + * + */ + user_stats(): Promise; +} +declare class StorageProxy { + /** + * Agent API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + /** + * List storage proxies and its volumes. + * + * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + */ + list(fields?: any[], limit?: number, offset?: number): Promise; + /** + * Detail of specific storage proxy / volume. + * + * @param {string} host - Virtual folder host. + * @param {array} fields - Fields to query. Queryable fields are: 'id', 'backend', 'capabilities'. + */ + detail(host?: string, fields?: any[]): Promise; +} +declare class Maintenance { + /** + * The Maintenance API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; + urlPrefix: string; + /** + * Attach to the background task to listen to events + * @param {string} task_id - background task id. + */ + attach_background_task(task_id: string): EventSource; + /** + * Rescan image from repository + * @param {string} registry - registry. default is '' + */ + rescan_images(registry?: string): Promise; + recalculate_usage(): Promise; +} +declare class ScalingGroup { /** * The Scaling Group API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any); + constructor(client: Client); + client: Client; list_available(): Promise; list(group?: string): Promise; /** @@ -1101,7 +1119,7 @@ declare class ScalingGroup { * * @param {string} group - Scaling group name */ - getWsproxyVersion(group: any): Promise; + getWsproxyVersion(group: string): Promise; /** * Create a scaling group * @@ -1109,14 +1127,14 @@ declare class ScalingGroup { * @param {string} description - Scaling group description * @param {string} wsproxyAddress - wsproxy url (NEW in manager 21.09) */ - create(name: any, description?: string, wsproxyAddress?: any): Promise; + create(name: string, description?: string, wsproxyAddress?: string): Promise; /** * Associate a scaling group with a domain * * @param {string} domain - domain name * @param {string} scaling_group - scaling group name */ - associate_domain(domain: any, scaling_group: any): Promise; + associate_domain(domain: string, scaling_group: string): Promise; /** * Modify a scaling group * @@ -1132,30 +1150,30 @@ declare class ScalingGroup { * 'wsproxy_addr': String // NEW in manager 21.09 * } */ - update(name: any, input: any): Promise; + update(name: string, input: any): Promise; /** * Delete a scaling group * * @param {string} name - name of scaling group to be deleted */ - delete(name: any): Promise; + delete(name: string): Promise; } declare class Registry { - client: any; constructor(client: any); + client: any; list(): Promise; set(key: any, value: any): Promise; delete(key: any): Promise; } declare class Setting { - client: any; - config: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ - constructor(client: any); + constructor(client: Client); + client: Client; + config: any; /** * List settings * @@ -1174,46 +1192,24 @@ declare class Setting { * @param {string} key - key to add. * @param {object} value - value to add. */ - set(key: any, value: any): Promise; + set(key: string, value: object): Promise; /** * Delete a setting * * @param {string} key - key to delete * @param {boolean} prefix - prefix to delete. if prefix is true, this command will delete every settings starting with the key. */ - delete(key: any, prefix?: boolean): Promise; -} -declare class Service { - client: any; - config: any; - /** - * Service-specific API wrapper. - * - * @param {Client} client - the Client API wrapper object to bind - */ - constructor(client: any); - /** - * Get announcements - * - */ - get_announcement(): Promise; - /** - * Update announcement - * - * @param {boolean} enabled - Enable / disable announcement. Default is True. - * @param {string} message - Announcement content. Usually in Markdown syntax. - */ - update_announcement(enabled: boolean, message: any): Promise; + delete(key: string, prefix?: boolean): Promise; } declare class UserConfig { - client: any; - config: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ constructor(client: Client); + client: Client; + config: any; /** * Get content of bootstrap script of a keypair. */ @@ -1223,7 +1219,7 @@ declare class UserConfig { * * @param {string} data - text content of bootstrap script. */ - update_bootstrap_script(script: string): Promise; + update_bootstrap_script(script: any): Promise; /** * Create content of script dotfile (.bashrc or .zshrc) * @param {string} data - text content of script dotfile @@ -1248,30 +1244,52 @@ declare class UserConfig { */ delete(path: string): Promise; } -declare class Enterprise { - client: any; +declare class Service { + /** + * Service-specific API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client: Client); + client: Client; config: any; - certificate: any; + /** + * Get announcements + * + */ + get_announcement(): Promise; + /** + * Update announcement + * + * @param {boolean} enabled - Enable / disable announcement. Default is True. + * @param {string} message - Announcement content. Usually in Markdown syntax. + */ + update_announcement(enabled: boolean, message: string): Promise; +} +declare class Enterprise { /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ constructor(client: Client); + client: Client; + config: any; /** * Get the current enterprise license. */ getLicense(): Promise; + certificate: any; } declare class Cloud { - client: any; - config: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ constructor(client: Client); + client: Client; + config: any; /** * Check if cloud endpoint is available. */ @@ -1304,14 +1322,14 @@ declare class Cloud { change_password(email: string, password: string, token: string): Promise; } declare class EduApp { - client: any; - config: any; /** * Setting API wrapper. * * @param {Client} client - the Client API wrapper object to bind */ constructor(client: Client); + client: Client; + config: any; /** * Check if EduApp endpoint is available. */ @@ -1321,24 +1339,4 @@ declare class EduApp { */ get_mount_folders(): Promise; } -declare class utils { - client: any; - constructor(client: any); - changeBinaryUnit(value: any, targetUnit?: string, defaultUnit?: string): any; - elapsedTime(start: any, end: any): string; - _padding_zeros(n: any, width: any): any; - /** - * Limit the boundary of value - * - * @param {number} value - input value to be clamped - * @param {number} min - minimum value of the input value - * @param {number} max - maximum value of the input vallue - */ - clamp(value: number, min: number, max: number): number; - gqlToObject(array: any, key: any): {}; - gqlToList(array: any, key: any): any[]; -} -declare const backend: { - Client: typeof Client; - ClientConfig: typeof ClientConfig; -}; +export { Client as BackendAIClient, ClientConfig as BackendAIClientConfig }; diff --git a/package.json b/package.json index 53d7f8c..1eb6066 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "test": "", "build-doc": "./node_modules/jsdoc/jsdoc.js -c ./jsdoc.json", - "declare": "npx -p typescript tsc backend.ai-client-node.ts --target es2017 --declaration --emitDeclarationOnly --outDir lib" + "build": "npx -p typescript tsc backend.ai-client-node.ts --target es2017", + "declare": "npx -p typescript tsc backend.ai-client-node.js --allowJs --target es2017 --declaration --emitDeclarationOnly --outDir lib" }, "repository": { "type": "git",