/** * Copyright (c) 2020 TypeFox GmbH. All rights reserved. * Licensed under the GNU Affero General Public License (AGPL). * See License-AGPL.txt in the project root for license information. */ import { User, WorkspaceInfo, WorkspaceCreationResult, UserMessage, WorkspaceInstanceUser, WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, Branding, CreateWorkspaceMode, Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType, GitpodToken, AuthProviderEntry } from './protocol'; import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory'; import { Disposable } from 'vscode-jsonrpc'; import { HeadlessLogEvent } from './headless-workspace-log'; import { WorkspaceInstance, WorkspaceInstancePort } from './workspace-instance'; import { AdminServer } from './admin-protocol'; import { PermissionName } from './permission'; import { LicenseService } from './license-protocol'; export interface GitpodClient { onInstanceUpdate(instance: WorkspaceInstance): void; onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback; onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void; } export declare const GitpodServer: unique symbol; export interface GitpodServer extends JsonRpcServer, AdminServer, LicenseService { getLoggedInUser(): Promise; updateLoggedInUser(user: Partial): Promise; getAuthProviders(): Promise; getOwnAuthProviders(): Promise; updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise; deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise; getBranding(): Promise; getConfiguration(): Promise; getToken(query: GitpodServer.GetTokenSearchOptions): Promise; getPortAuthenticationToken(workspaceId: string): Promise; deleteAccount(): Promise; getClientRegion(): Promise; hasPermission(permission: PermissionName): Promise; getWorkspaces(options: GitpodServer.GetWorkspacesOptions): Promise; getWorkspaceOwner(workspaceId: string): Promise; getWorkspaceUsers(workspaceId: string): Promise; getFeaturedRepositories(): Promise; getWorkspace(id: string): Promise; isWorkspaceOwner(workspaceId: string): Promise; /** * Creates and starts a workspace for the given context URL. * @param options GitpodServer.CreateWorkspaceOptions * @return WorkspaceCreationResult */ createWorkspace(options: GitpodServer.CreateWorkspaceOptions): Promise; startWorkspace(id: string, options: { forceDefaultImage: boolean; }): Promise; stopWorkspace(id: string): Promise; deleteWorkspace(id: string): Promise; setWorkspaceDescription(id: string, desc: string): Promise; controlAdmission(id: string, level: "owner" | "everyone"): Promise; updateWorkspaceUserPin(id: string, action: "pin" | "unpin" | "toggle"): Promise; sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise; watchWorkspaceImageBuildLogs(workspaceId: string): Promise; watchHeadlessWorkspaceLogs(workspaceId: string): Promise; isPrebuildAvailable(pwsid: string): Promise; setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise; getWorkspaceTimeout(workspaceId: string): Promise; sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise; updateWorkspaceUserPin(id: string, action: "pin" | "unpin" | "toggle"): Promise; getOpenPorts(workspaceId: string): Promise; openPort(workspaceId: string, port: WorkspaceInstancePort): Promise; closePort(workspaceId: string, port: number): Promise; getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise; updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise; getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise; updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise; getEnvVars(): Promise; setEnvVar(variable: UserEnvVarValue): Promise; deleteEnvVar(variable: UserEnvVarValue): Promise; getGitpodTokens(): Promise; generateNewGitpodToken(options: { name?: string; type: GitpodTokenType; scopes?: []; }): Promise; deleteGitpodToken(tokenHash: string): Promise; sendFeedback(feedback: string): Promise; registerGithubApp(installationId: string): Promise; /** * Stores a new snapshot for the given workspace and bucketId * @return the snapshot id */ takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise; /** * Returns the list of snapshots that exist for a workspace. */ getSnapshots(workspaceID: string): Promise; /** * stores/updates layout information for the given workspace */ storeLayout(workspaceId: string, layoutData: string): Promise; /** * retrieves layout information for the given workspace */ getLayout(workspaceId: string): Promise; /** * @param params * @returns promise resolves to an URL to be used for the upload */ preparePluginUpload(params: PreparePluginUploadParams): Promise; resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise; installUserPlugins(params: InstallPluginsParams): Promise; uninstallUserPlugin(params: UninstallPluginParams): Promise; } export declare const WorkspaceTimeoutValues: readonly ["30m", "60m", "180m"]; export declare const createServiceMock: (methods: Partial>) => GitpodServiceImpl; export declare const createServerMock: (methods: Partial>) => JsonRpcProxy; declare type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues; export declare type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number]; export interface SetWorkspaceTimeoutResult { resetTimeoutOnWorkspaces: string[]; } export interface GetWorkspaceTimeoutResult { duration: WorkspaceTimeoutDuration; canChange: boolean; } export interface StartWorkspaceResult { instanceID: string; workspaceURL?: string; } export declare namespace GitpodServer { interface GetWorkspacesOptions { limit?: number; searchString?: string; pinnedOnly?: boolean; } interface GetAccountStatementOptions { date?: string; } interface CreateWorkspaceOptions { contextUrl: string; mode?: CreateWorkspaceMode; } interface TakeSnapshotOptions { workspaceId: string; layoutData?: string; } interface GetUserMessagesOptions { readonly releaseNotes?: boolean; readonly workspaceInstanceId: string; } interface UpdateUserMessagesOptions { readonly messageIds: string[]; } interface GetUserStorageResourceOptions { readonly uri: string; } interface UpdateUserStorageResourceOptions { readonly uri: string; readonly content: string; } interface GetTokenSearchOptions { readonly host: string; } interface SendHeartBeatOptions { readonly instanceId: string; readonly wasClosed?: boolean; readonly roundTripTime?: number; } interface UpdateOwnAuthProviderParams { readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry; } interface DeleteOwnAuthProviderParams { readonly id: string; } } export declare const GitpodServerPath = "/gitpod"; export declare const GitpodServerProxy: unique symbol; export declare type GitpodServerProxy = JsonRpcProxy; export declare class GitpodCompositeClient implements GitpodClient { protected clients: Partial[]; registerClient(client: Partial): Disposable; onInstanceUpdate(instance: WorkspaceInstance): void; onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void; onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void; } export declare const GitpodService: unique symbol; export declare type GitpodService = GitpodServiceImpl; export declare class GitpodServiceImpl { readonly server: JsonRpcProxy; protected compositeClient: GitpodCompositeClient; constructor(server: JsonRpcProxy); registerClient(client: Partial): Disposable; } export declare function createGitpodService(serverUrl: string): GitpodServiceImpl; export {}; //# sourceMappingURL=gitpod-service.d.ts.map