Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
iyannsch committed Aug 27, 2024
2 parents a1d8cf8 + 39be9e4 commit 71d2a4a
Show file tree
Hide file tree
Showing 15 changed files with 20,923 additions and 7,817 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion documentation/OpenAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Install the `openapi-generator-cli`:

```bash
npm install @openapitools/openapi-generator-cli -g
openapi-generator-cli version-manager set 6.6.0
openapi-generator-cli version-manager set 7.8.0
```

Use the `openapi-generator-cli` from the root of this repository:
Expand Down
24 changes: 14 additions & 10 deletions java/common/maven-conf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@

<properties>
<failsafe.useModulePath>false</failsafe.useModulePath>
<guice.version>5.0.1</guice.version>
<kubernetes-client.version>6.10.0</kubernetes-client.version>
<log4j.version>2.17.1</log4j.version>
<slf4j.version>1.7.32</slf4j.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
<maven-compiler-plugin.version>3.9.0</maven-compiler-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.8.1</quarkus.platform.version>
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
<webhooks.framework.core.version>1.1.2</webhooks.framework.core.version>
<guice.version>7.0.0</guice.version>
<log4j.version>2.23.1</log4j.version>
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<surefire-plugin.version>3.4.0</surefire-plugin.version>
<google.artifactregistry-maven-wagon-version>2.2.2</google.artifactregistry-maven-wagon-version>
<junit-jupiter.version>5.11.0</junit-jupiter.version>
<org.json.version>20240303</org.json.version>
<picocli.version>4.7.6</picocli.version>
<webhooks.framework.core.version>1.1.4</webhooks.framework.core.version>
<slf4j.version>1.7.36</slf4j.version>
<kubernetes-client.version>6.12.1</kubernetes-client.version>
<quarkus.platform.version>3.11.3</quarkus.platform.version>
</properties>

<profiles>
Expand Down Expand Up @@ -73,7 +77,7 @@
<plugin>
<groupId>com.google.cloud.artifactregistry</groupId>
<artifactId>artifactregistry-maven-wagon</artifactId>
<version>2.2.0</version>
<version>${google.artifactregistry-maven-wagon-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
Expand Down
3 changes: 1 addition & 2 deletions java/common/org.eclipse.theia.cloud.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.3</version>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
<relativePath>../../common/maven-conf/</relativePath>
</parent>

<properties>
<picocli.version>4.6.3</picocli.version>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.theia.cloud</groupId>
Expand All @@ -33,7 +29,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
<version>${org.json.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
Expand Down
6 changes: 1 addition & 5 deletions java/operator/org.eclipse.theia.cloud.operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
<relativePath>../../common/maven-conf/</relativePath>
</parent>

<properties>
<picocli.version>4.6.3</picocli.version>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.theia.cloud</groupId>
Expand All @@ -28,7 +24,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
<version>${org.json.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
Expand Down
2 changes: 1 addition & 1 deletion node/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"dependencies": {
"@types/uuid": "^8.3.4",
"axios": "^0.27.2",
"axios": "^1.6.1",
"uuid": "^8.3.2"
}
}
188 changes: 153 additions & 35 deletions node/common/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
/* eslint-disable indent */
import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
import { v4 as uuidv4 } from 'uuid';

import {
LaunchRequest as ClientLaunchRequest,
PingRequest as ClientPingRequest, RootResourceApi, SessionActivityRequest as ClientSessionActivityRequest, SessionListRequest as ClientSessionListRequest,
SessionPerformance, SessionPerformanceRequest as ClientSessionPerformanceRequest,
SessionResourceApi, SessionSpec, SessionStartRequest as ClientSessionStartRequest, SessionStopRequest as ClientSessionStopRequest,
UserWorkspace, WorkspaceCreationRequest as ClientWorkspaceCreationRequest,
WorkspaceDeletionRequest as ClientWorkspaceDeletionRequest, WorkspaceListRequest as ClientWorkspaceListRequest,
WorkspaceResourceApi } from './client/api';
PingRequest as ClientPingRequest,
RootResourceApi,
SessionActivityRequest as ClientSessionActivityRequest,
SessionListRequest as ClientSessionListRequest,
SessionPerformance,
SessionPerformanceRequest as ClientSessionPerformanceRequest,
SessionResourceApi,
SessionSpec,
SessionStartRequest as ClientSessionStartRequest,
SessionStopRequest as ClientSessionStopRequest,
UserWorkspace,
WorkspaceCreationRequest as ClientWorkspaceCreationRequest,
WorkspaceDeletionRequest as ClientWorkspaceDeletionRequest,
WorkspaceListRequest as ClientWorkspaceListRequest,
WorkspaceResourceApi
} from './client/api';
import { Configuration } from './client/configuration';

export const DEFAULT_CALL_TIMEOUT = 30000;
Expand Down Expand Up @@ -44,17 +55,37 @@ export type LaunchRequest = ClientLaunchRequest & ServiceRequest;
export namespace LaunchRequest {
export const KIND = 'launchRequest';

export function ephemeral(serviceUrl: string, appId: string, appDefinition: string, timeout?: number, user: string = createUser()): LaunchRequest {
export function ephemeral(
serviceUrl: string,
appId: string,
appDefinition: string,
timeout?: number,
user: string = createUser()
): LaunchRequest {
return { serviceUrl, appId, appDefinition, user, ephemeral: true, timeout };
}

export function createWorkspace(serviceUrl: string, appId: string, appDefinition: string, timeout?: number, user: string = createUser(),
workspaceName?: string, label?: string): LaunchRequest {
export function createWorkspace(
serviceUrl: string,
appId: string,
appDefinition: string,
timeout?: number,
user: string = createUser(),
workspaceName?: string,
label?: string
): LaunchRequest {
return { serviceUrl, appId, appDefinition, user, label, workspaceName, ephemeral: false, timeout };
}

// eslint-disable-next-line max-len
export function existingWorkspace(serviceUrl: string, appId: string, workspaceName: string, timeout?: number, appDefinition?: string, user: string = createUser()): LaunchRequest {
export function existingWorkspace(
serviceUrl: string,
appId: string,
workspaceName: string,
timeout?: number,
appDefinition?: string,
user: string = createUser()
): LaunchRequest {
return { serviceUrl, appId, workspaceName, appDefinition, user, timeout };
}
}
Expand Down Expand Up @@ -114,13 +145,19 @@ export namespace TheiaCloud {

export async function ping(request: PingRequest, options: RequestOptions = {}): Promise<boolean> {
const { accessToken, retries, timeout } = options;
return call(() => rootApi(request.serviceUrl, accessToken).serviceAppIdGet(request.appId, createConfig(timeout)), retries);
return call(
() => rootApi(request.serviceUrl, accessToken).serviceAppIdGet(request.appId, createConfig(timeout)),
retries
);
}

export async function launch(request: LaunchRequest, options: RequestOptions = {}): Promise<string> {
const { accessToken, retries, timeout } = options;
const launchRequest = { kind: LaunchRequest.KIND, ...request };
return call(() => rootApi(request.serviceUrl, accessToken).servicePost(launchRequest, createConfig(timeout)), retries);
return call(
() => rootApi(request.serviceUrl, accessToken).servicePost(launchRequest, createConfig(timeout)),
retries
);
}

export async function launchAndRedirect(request: LaunchRequest, options: RequestOptions = {}): Promise<string> {
Expand All @@ -131,54 +168,122 @@ export namespace TheiaCloud {
}

export namespace Session {
export async function listSessions(request: SessionListRequest, options: RequestOptions = {}): Promise<SessionSpec[]> {
export async function listSessions(
request: SessionListRequest,
options: RequestOptions = {}
): Promise<SessionSpec[]> {
const { accessToken, retries, timeout } = options;
return call(() => sessionApi(request.serviceUrl, accessToken).serviceSessionAppIdUserGet(request.appId, request.user, createConfig(timeout)), retries);
return call(
() =>
sessionApi(request.serviceUrl, accessToken).serviceSessionAppIdUserGet(
request.appId,
request.user,
createConfig(timeout)
),
retries
);
}

export async function startSession(request: SessionStartRequest, options: RequestOptions = {}): Promise<string> {
const { accessToken, retries, timeout } = options;
const sessionStartRequest = { kind: SessionStartRequest.KIND, ...request };
return call(() => sessionApi(request.serviceUrl, accessToken).serviceSessionPost(sessionStartRequest, createConfig(timeout)), retries);
return call(
() =>
sessionApi(request.serviceUrl, accessToken).serviceSessionPost(sessionStartRequest, createConfig(timeout)),
retries
);
}

export async function stopSession(request: SessionStopRequest, options: RequestOptions = {}): Promise<boolean> {
const { accessToken, retries, timeout } = options;
const sessionStopRequest = { kind: SessionStopRequest.KIND, ...request };
return call(() => sessionApi(request.serviceUrl, accessToken).serviceSessionDelete(sessionStopRequest, createConfig(timeout)), retries);
return call(
() =>
sessionApi(request.serviceUrl, accessToken).serviceSessionDelete(sessionStopRequest, createConfig(timeout)),
retries
);
}

export async function reportSessionActivity(request: SessionActivityRequest, options: RequestOptions = {}): Promise<boolean> {
export async function reportSessionActivity(
request: SessionActivityRequest,
options: RequestOptions = {}
): Promise<boolean> {
const { accessToken, retries, timeout } = options;
const sessionActivityRequest = { kind: SessionActivityRequest.KIND, ...request };
return call(() => sessionApi(request.serviceUrl, accessToken).serviceSessionPatch(sessionActivityRequest, createConfig(timeout)), retries);
return call(
() =>
sessionApi(request.serviceUrl, accessToken).serviceSessionPatch(
sessionActivityRequest,
createConfig(timeout)
),
retries
);
}

export async function getSessionPerformance(request: SessionPerformanceRequest, options: RequestOptions = {}): Promise<SessionPerformance> {
export async function getSessionPerformance(
request: SessionPerformanceRequest,
options: RequestOptions = {}
): Promise<SessionPerformance> {
const { accessToken, retries, timeout } = options;
return call(
() => sessionApi(request.serviceUrl, accessToken).serviceSessionPerformanceAppIdSessionNameGet(request.appId, request.sessionName, createConfig(timeout)),
() =>
sessionApi(request.serviceUrl, accessToken).serviceSessionPerformanceAppIdSessionNameGet(
request.appId,
request.sessionName,
createConfig(timeout)
),
retries
);
}
}

export namespace Workspace {
export async function listWorkspaces(request: WorkspaceListRequest, options: RequestOptions = {}): Promise<UserWorkspace[]> {
export async function listWorkspaces(
request: WorkspaceListRequest,
options: RequestOptions = {}
): Promise<UserWorkspace[]> {
const { accessToken, retries, timeout } = options;
return call(() => workspaceApi(request.serviceUrl, accessToken).serviceWorkspaceAppIdUserGet(request.appId, request.user, createConfig(timeout)), retries);
return call(
() =>
workspaceApi(request.serviceUrl, accessToken).serviceWorkspaceAppIdUserGet(
request.appId,
request.user,
createConfig(timeout)
),
retries
);
}

export async function createWorkspace(request: WorkspaceCreationRequest, options: RequestOptions = {}): Promise<UserWorkspace> {
export async function createWorkspace(
request: WorkspaceCreationRequest,
options: RequestOptions = {}
): Promise<UserWorkspace> {
const { accessToken, retries, timeout } = options;
const workspaceCreationRequest = { kind: WorkspaceCreationRequest.KIND, ...request };
return call(() => workspaceApi(request.serviceUrl, accessToken).serviceWorkspacePost(workspaceCreationRequest, createConfig(timeout)), retries);
return call(
() =>
workspaceApi(request.serviceUrl, accessToken).serviceWorkspacePost(
workspaceCreationRequest,
createConfig(timeout)
),
retries
);
}

export async function deleteWorkspace(request: WorkspaceDeletionRequest, options: RequestOptions = {}): Promise<boolean> {
export async function deleteWorkspace(
request: WorkspaceDeletionRequest,
options: RequestOptions = {}
): Promise<boolean> {
const { accessToken, retries, timeout } = options;
const workspaceDeletionRequest = { kind: WorkspaceDeletionRequest.KIND, ...request };
return call(() => workspaceApi(request.serviceUrl, accessToken).serviceWorkspaceDelete(workspaceDeletionRequest, createConfig(timeout)), retries);
return call(
() =>
workspaceApi(request.serviceUrl, accessToken).serviceWorkspaceDelete(
workspaceDeletionRequest,
createConfig(timeout)
),
retries
);
}
}
}
Expand Down Expand Up @@ -218,7 +323,13 @@ export namespace TheiaCloudErrorResponse {
export class TheiaCloudError extends Error {
static INTERNAL_ERROR = 500;

constructor(message: string, public status: number, public originalError: Error, public serverError?: TheiaCloudErrorResponse, public request?: ServiceRequest) {
constructor(
message: string,
public status: number,
public originalError: Error,
public serverError?: TheiaCloudErrorResponse,
public request?: ServiceRequest
) {
super(message);
}

Expand All @@ -228,14 +339,21 @@ export class TheiaCloudError extends Error {
const errorResponse = TheiaCloudErrorResponse.is(responseData) ? responseData : undefined;
const message = errorResponse ? errorResponse.reason : error.message;

const requestData = typeof error.config.data === 'string' ? JSON.parse(error.config.data) : error.config.data;
const serviceRequest = ServiceRequest.is(requestData) ? requestData : undefined;

const status = error.status ? parseInt(error.status, 10)
: error.response ? error.response.status
: errorResponse ? errorResponse.code
: TheiaCloudError.INTERNAL_ERROR;
return new TheiaCloudError(message, status, error, errorResponse, serviceRequest);
const status = error.status
? error.status
: error.response
? error.response.status
: errorResponse
? errorResponse.code
: TheiaCloudError.INTERNAL_ERROR;

if (error.config === undefined) {
return new TheiaCloudError(message, status, error, errorResponse);
} else {
const requestData = typeof error.config.data === 'string' ? JSON.parse(error.config.data) : error.config.data;
const serviceRequest = ServiceRequest.is(requestData) ? requestData : undefined;
return new TheiaCloudError(message, status, error, errorResponse, serviceRequest);
}
}
return new TheiaCloudError(error.message, TheiaCloudError.INTERNAL_ERROR, error);
}
Expand Down
Loading

0 comments on commit 71d2a4a

Please sign in to comment.