From b78952a3b862dcca426a5bcaf5ecf38160ea64d4 Mon Sep 17 00:00:00 2001 From: Johannes Faltermeier Date: Wed, 17 May 2023 14:10:33 +0200 Subject: [PATCH] Add new API to Service #69 * make auth info optional (for public repos) * regenerate open api schema * regenerate typescript API --- doc/docs/openapi.json | 60 +++++- .../common/k8s/resource/SessionSpec.java | 21 +- .../cloud/common/util/TheiaCloudError.java | 2 + .../handler/impl/GitInitOperationHandler.java | 200 ++++++++++-------- .../eclipse/theia/cloud/service/GitInit.java | 40 ++++ .../eclipse/theia/cloud/service/K8sUtil.java | 43 +++- .../theia/cloud/service/LaunchRequest.java | 7 +- .../theia/cloud/service/RootResource.java | 16 +- .../service/session/SessionResource.java | 17 +- .../service/session/SessionStartRequest.java | 6 +- .../service/session/SessionResourceTests.java | 4 +- node/common/src/client/api.ts | 138 ++++++++++-- node/common/src/client/base.ts | 18 +- node/common/src/client/common.ts | 4 +- node/common/src/client/configuration.ts | 11 +- node/common/src/client/index.ts | 2 +- node/package-lock.json | 51 +++-- 17 files changed, 475 insertions(+), 165 deletions(-) create mode 100644 java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/GitInit.java diff --git a/doc/docs/openapi.json b/doc/docs/openapi.json index da4f4057..09088c09 100644 --- a/doc/docs/openapi.json +++ b/doc/docs/openapi.json @@ -2,7 +2,7 @@ "openapi" : "3.0.3", "info" : { "title" : "Theia.cloud API", - "version" : "0.8.0" + "version" : "0.8.1" }, "paths" : { "/service" : { @@ -144,6 +144,7 @@ "description" : "Not Allowed" } }, + "deprecated" : true, "security" : [ { "SecurityScheme" : [ ] } ] @@ -422,6 +423,40 @@ } } }, + "GitInit" : { + "description" : "Holds information used to initialize a Workspace with a clone of a Git repository.", + "required" : [ "repository", "checkout" ], + "type" : "object", + "properties" : { + "repository" : { + "description" : "The Git repository URL.", + "type" : "string" + }, + "checkout" : { + "description" : "The branch, commit-id, or tag name to checkout.", + "type" : "string", + "example" : "main, bd402d6, tags/1.0.0" + }, + "authInformation" : { + "description" : "Key for the required auth information, if the repository is not public.", + "type" : "string" + } + } + }, + "InitOperation" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" + }, + "arguments" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } + }, "LaunchRequest" : { "description" : "A request to launch a new session.", "required" : [ "appId", "user" ], @@ -462,6 +497,13 @@ }, { "description" : "Environment variables" } ] + }, + "gitInit" : { + "allOf" : [ { + "$ref" : "#/components/schemas/GitInit" + }, { + "description" : "Git Init information" + } ] } } }, @@ -589,6 +631,12 @@ "items" : { "type" : "string" } + }, + "initOperations" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InitOperation" + } } } }, @@ -624,6 +672,13 @@ }, { "description" : "Environment variables" } ] + }, + "gitInit" : { + "allOf" : [ { + "$ref" : "#/components/schemas/GitInit" + }, { + "description" : "Git Init information" + } ] } } }, @@ -737,6 +792,9 @@ "description" : "Authentication", "flows" : { "implicit" : { + "authorizationUrl" : "http://localhost:34159/realms/quarkus/protocol/openid-connect/auth", + "tokenUrl" : "http://localhost:34159/realms/quarkus/protocol/openid-connect/token/introspect", + "refreshUrl" : "http://localhost:34159/realms/quarkus/protocol/openid-connect/token" } } } diff --git a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/SessionSpec.java b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/SessionSpec.java index 0ccac9f6..3d1fe464 100644 --- a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/SessionSpec.java +++ b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/k8s/resource/SessionSpec.java @@ -71,21 +71,27 @@ public SessionSpec(String name, String appDefinition, String user) { this(name, appDefinition, user, null); } - public SessionSpec(String name, String appDefinition, String user, String workspace) { - this(name, appDefinition, user, workspace, Map.of(), List.of(), List.of()); + public SessionSpec(String name, String appDefinition, String user, Map envVars, + List envVarsFromConfigMaps, List envVarsFromSecrets) { + this(name, appDefinition, user, null, Map.of(), List.of(), List.of(), List.of()); } - public SessionSpec(String name, String appDefinition, String user, String workspace, Map envVars) { - this(name, appDefinition, user, workspace, envVars, List.of(), List.of()); + public SessionSpec(String name, String appDefinition, String user, String workspace) { + this(name, appDefinition, user, workspace, Map.of(), List.of(), List.of(), List.of()); } public SessionSpec(String name, String appDefinition, String user, String workspace, Map envVars, - List envVarsFromConfigMaps) { - this(name, appDefinition, user, workspace, envVars, envVarsFromConfigMaps, List.of()); + List envVarsFromConfigMaps, List envVarsFromSecrets) { + this(name, appDefinition, user, workspace, envVars, envVarsFromConfigMaps, envVarsFromSecrets, List.of()); + } + + public SessionSpec(String name, String appDefinition, String user, String workspace, + List initOperations) { + this(name, appDefinition, user, workspace, Map.of(), List.of(), List.of(), initOperations); } public SessionSpec(String name, String appDefinition, String user, String workspace, Map envVars, - List envVarsFromConfigMaps, List envVarsFromSecrets) { + List envVarsFromConfigMaps, List envVarsFromSecrets, List initOperations) { this.name = name; this.appDefinition = appDefinition; this.user = user; @@ -93,6 +99,7 @@ public SessionSpec(String name, String appDefinition, String user, String worksp this.envVars = envVars; this.envVarsFromConfigMaps = envVarsFromConfigMaps; this.envVarsFromSecrets = envVarsFromSecrets; + this.initOperations = initOperations; } public String getName() { diff --git a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/util/TheiaCloudError.java b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/util/TheiaCloudError.java index 91ada640..23c3e8a2 100644 --- a/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/util/TheiaCloudError.java +++ b/java/common/org.eclipse.theia.cloud.common/src/main/java/org/eclipse/theia/cloud/common/util/TheiaCloudError.java @@ -23,6 +23,8 @@ public class TheiaCloudError { // client errors: 47x public static final TheiaCloudError INVALID_APP_ID = new TheiaCloudError(470, "Invalid application id."); public static final TheiaCloudError INVALID_WORKSPACE_NAME = new TheiaCloudError(471, "Invalid workspace name."); + public static final TheiaCloudError INVALID_GIT_INIT_CONFIGURATION = new TheiaCloudError(472, + "Invalid git init configuration"); public static final TheiaCloudError INVALID_APP_DEFINITION_NAME = new TheiaCloudError(473, "Invalid app definition name."); public static final TheiaCloudError INVALID_SESSION_NAME = new TheiaCloudError(474, "Invalid session name."); diff --git a/java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/impl/GitInitOperationHandler.java b/java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/impl/GitInitOperationHandler.java index f59c200e..86c96413 100644 --- a/java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/impl/GitInitOperationHandler.java +++ b/java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/impl/GitInitOperationHandler.java @@ -73,9 +73,9 @@ public String operationId() { public void addInitContainer(String correlationId, TheiaCloudClient client, Deployment deployment, AppDefinition appDefinition, Session session, List args) { - if (args.size() != 3) { + if (args.size() < 2 || args.size() > 3) { LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, MessageFormat.format( - "Git init expects three arguments (repository path, branch, secret-name). Passed arguments are: {0}", + "Git init expects 2-3 arguments (repository path, branch, (secret-name)). Passed arguments are: {0}", args.stream().collect(Collectors.joining(","))))); return; } @@ -112,27 +112,33 @@ public void addInitContainer(String correlationId, TheiaCloudClient client, Depl VolumeMount volumeMount = AddedHandlerUtil.createUserDataVolumeMount(appDefinition.getSpec()); gitInitContainer.getVolumeMounts().add(volumeMount); - String secretName = args.get(2); - Secret secret = client.kubernetes().secrets().withName(secretName).get(); - if (secret == null) { - LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, - MessageFormat.format("No secret with name {0} found.", secretName))); - return; - } + Optional secretName = args.size() == 3 ? Optional.of(args.get(2)) : Optional.empty(); + Optional secret; + if (secretName.isPresent()) { + Secret k8sSecret = client.kubernetes().secrets().withName(secretName.get()).get(); + if (k8sSecret == null) { + LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, + MessageFormat.format("No secret with name {0} found.", secretName))); + return; + } - String theiaCloudInit = secret.getMetadata().getLabels().get(THEIA_CLOUD_INIT_LABEL); - if (theiaCloudInit == null || !ID.equals(theiaCloudInit)) { - LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, MessageFormat - .format("Secret with name {0} is not configured to be used with Git init.", secretName))); - return; - } + String theiaCloudInit = k8sSecret.getMetadata().getLabels().get(THEIA_CLOUD_INIT_LABEL); + if (theiaCloudInit == null || !ID.equals(theiaCloudInit)) { + LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, MessageFormat + .format("Secret with name {0} is not configured to be used with Git init.", secretName))); + return; + } - String theiaCloudUser = secret.getMetadata().getAnnotations().get("theiaCloudUser"); - if (theiaCloudUser == null || !session.getSpec().getUser().equals(theiaCloudUser)) { - LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, - MessageFormat.format("Secret with name {0} is not configured to be used by user {1}.", secretName, - session.getSpec().getUser()))); - return; + String theiaCloudUser = k8sSecret.getMetadata().getAnnotations().get("theiaCloudUser"); + if (theiaCloudUser == null || !session.getSpec().getUser().equals(theiaCloudUser)) { + LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, + MessageFormat.format("Secret with name {0} is not configured to be used by user {1}.", + secretName, session.getSpec().getUser()))); + return; + } + secret = Optional.of(k8sSecret); + } else { + secret = Optional.empty(); } if (isHTTP(repository)) { @@ -147,99 +153,105 @@ public void addInitContainer(String correlationId, TheiaCloudClient client, Depl } - protected boolean injectHTTPRepoCredentials(String correlationId, Secret secret, String secretName, - String repository, Container gitInitContainer) { + protected boolean injectHTTPRepoCredentials(String correlationId, Optional secret, + Optional secretName, String repository, Container gitInitContainer) { /* get username/password from secret */ boolean injectUsername = false; boolean injectPassword = false; - if (!KUBERNETES_IO_BASIC_AUTH.equals(secret.getType())) { - LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, MessageFormat - .format("Secret with name {0} is not of type {1}.", secretName, KUBERNETES_IO_BASIC_AUTH))); - return false; - } + if (secret.isPresent() && secretName.isPresent()) { + if (!KUBERNETES_IO_BASIC_AUTH.equals(secret.get().getType())) { + LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, MessageFormat.format( + "Secret with name {0} is not of type {1}.", secretName.get(), KUBERNETES_IO_BASIC_AUTH))); + return false; + } - String[] split = repository.toLowerCase().split(Pattern.quote("://"), 2); - if (split.length != 2) { - LOGGER.error(LogMessageUtil.formatLogMessage(correlationId, MessageFormat - .format("Failed to check whether repository {0} contains any user information. ", repository))); - return false; - } - String repositoryWithoutProtocol = split[1]; - if (repositoryWithoutProtocol.contains("@")) { - if (repositoryWithoutProtocol.split(Pattern.quote("@"))[0].contains(":")) { - /* username and password part of URL */ + String[] split = repository.toLowerCase().split(Pattern.quote("://"), 2); + if (split.length != 2) { + LOGGER.error(LogMessageUtil.formatLogMessage(correlationId, MessageFormat + .format("Failed to check whether repository {0} contains any user information. ", repository))); + return false; + } + String repositoryWithoutProtocol = split[1]; + if (repositoryWithoutProtocol.contains("@")) { + if (repositoryWithoutProtocol.split(Pattern.quote("@"))[0].contains(":")) { + /* username and password part of URL */ + } else { + /* username part of url */ + injectPassword = true; + } } else { - /* username part of url */ + injectUsername = true; injectPassword = true; } - } else { - injectUsername = true; - injectPassword = true; } LOGGER.info(LogMessageUtil.formatLogMessage(correlationId, MessageFormat.format("Inject username: {0}; Inject password: {1}", injectUsername, injectPassword))); - String nextEnv = GIT_PROMPT1; - if (injectUsername) { - EnvVar envVar = new EnvVar(); - gitInitContainer.getEnv().add(envVar); - envVar.setName(nextEnv); - nextEnv = GIT_PROMPT2; - - EnvVarSource envVarSource = new EnvVarSource(); - envVar.setValueFrom(envVarSource); - envVarSource.setSecretKeyRef(new SecretKeySelector(USERNAME, secretName, false)); - } - if (injectPassword) { - EnvVar envVar = new EnvVar(); - gitInitContainer.getEnv().add(envVar); - envVar.setName(nextEnv); - - EnvVarSource envVarSource = new EnvVarSource(); - envVar.setValueFrom(envVarSource); - envVarSource.setSecretKeyRef(new SecretKeySelector(PASSWORD, secretName, false)); + if (secretName.isPresent()) { + String nextEnv = GIT_PROMPT1; + if (injectUsername) { + EnvVar envVar = new EnvVar(); + gitInitContainer.getEnv().add(envVar); + envVar.setName(nextEnv); + nextEnv = GIT_PROMPT2; + + EnvVarSource envVarSource = new EnvVarSource(); + envVar.setValueFrom(envVarSource); + envVarSource.setSecretKeyRef(new SecretKeySelector(USERNAME, secretName.get(), false)); + } + if (injectPassword) { + EnvVar envVar = new EnvVar(); + gitInitContainer.getEnv().add(envVar); + envVar.setName(nextEnv); + + EnvVarSource envVarSource = new EnvVarSource(); + envVar.setValueFrom(envVarSource); + envVarSource.setSecretKeyRef(new SecretKeySelector(PASSWORD, secretName.get(), false)); + } } return true; } - protected boolean injectSSHRepoCredentials(String correlationId, Secret secret, String secretName, - String repository, Container gitInitContainer, List volumes) { + protected boolean injectSSHRepoCredentials(String correlationId, Optional secret, + Optional secretName, String repository, Container gitInitContainer, List volumes) { - if (!KUBERNETES_IO_SSH_AUTH.equals(secret.getType())) { - LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, MessageFormat - .format("Secret with name {0} is not of type {1}.", secretName, KUBERNETES_IO_SSH_AUTH))); - return false; - } + if (secret.isPresent() && secretName.isPresent()) { + if (!KUBERNETES_IO_SSH_AUTH.equals(secret.get().getType())) { + LOGGER.warn(LogMessageUtil.formatLogMessage(correlationId, MessageFormat + .format("Secret with name {0} is not of type {1}.", secretName.get(), KUBERNETES_IO_SSH_AUTH))); + return false; + } - /* inject password */ - EnvVar envVar = new EnvVar(); - gitInitContainer.getEnv().add(envVar); - envVar.setName(GIT_PROMPT1); - - EnvVarSource envVarSource = new EnvVarSource(); - envVar.setValueFrom(envVarSource); - envVarSource.setSecretKeyRef(new SecretKeySelector(PASSWORD, secretName, false)); - - /* inject ssh key */ - Volume volume = new Volume(); - volumes.add(volume); - volume.setName(SSH_KEY); - SecretVolumeSource secretVolumeSource = new SecretVolumeSource(); - volume.setSecret(secretVolumeSource); - secretVolumeSource.setSecretName(secretName); - KeyToPath keyToPath = new KeyToPath(); - secretVolumeSource.getItems().add(keyToPath); - keyToPath.setKey(SSH_PRIVATEKEY); - keyToPath.setPath(ID_THEIACLOUD); - - VolumeMount volumeMount = new VolumeMount(); - gitInitContainer.getVolumeMounts().add(volumeMount); - volumeMount.setName(SSH_KEY); - volumeMount.setMountPath(ETC_THEIA_CLOUD_SSH); - volumeMount.setReadOnly(true); + /* inject password */ + EnvVar envVar = new EnvVar(); + gitInitContainer.getEnv().add(envVar); + envVar.setName(GIT_PROMPT1); + + EnvVarSource envVarSource = new EnvVarSource(); + envVar.setValueFrom(envVarSource); + envVarSource.setSecretKeyRef(new SecretKeySelector(PASSWORD, secretName.get(), false)); + + /* inject ssh key */ + Volume volume = new Volume(); + volumes.add(volume); + volume.setName(SSH_KEY); + SecretVolumeSource secretVolumeSource = new SecretVolumeSource(); + volume.setSecret(secretVolumeSource); + secretVolumeSource.setSecretName(secretName.get()); + KeyToPath keyToPath = new KeyToPath(); + secretVolumeSource.getItems().add(keyToPath); + keyToPath.setKey(SSH_PRIVATEKEY); + keyToPath.setPath(ID_THEIACLOUD); + + VolumeMount volumeMount = new VolumeMount(); + gitInitContainer.getVolumeMounts().add(volumeMount); + volumeMount.setName(SSH_KEY); + volumeMount.setMountPath(ETC_THEIA_CLOUD_SSH); + volumeMount.setReadOnly(true); + } return true; } diff --git a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/GitInit.java b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/GitInit.java new file mode 100644 index 00000000..8d182fb4 --- /dev/null +++ b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/GitInit.java @@ -0,0 +1,40 @@ +/******************************************************************************** + * Copyright (C) 2023 EclipseSource and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the Eclipse + * Public License v. 2.0 are satisfied: GNU General Public License, version 2 + * with the GNU Classpath Exception which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + ********************************************************************************/ +package org.eclipse.theia.cloud.service; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; + +@Schema(name = "GitInit", description = "Holds information used to initialize a Workspace with a clone of a Git repository.") +public class GitInit { + + public static final String ID = "git"; + + @Schema(description = "The Git repository URL.", required = true) + public String repository; + + @Schema(description = "The branch, commit-id, or tag name to checkout.", example = "main, bd402d6, tags/1.0.0", required = true) + public String checkout; + + @Schema(description = "Key for the required auth information, if the repository is not public.", required = false) + public String authInformation; + + @Override + public String toString() { + return "GitInit [repository=" + repository + ", checkout=" + checkout + ", authInformation=" + authInformation + + "]"; + } + +} diff --git a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/K8sUtil.java b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/K8sUtil.java index 34887890..86cea005 100644 --- a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/K8sUtil.java +++ b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/K8sUtil.java @@ -18,7 +18,9 @@ import static org.eclipse.theia.cloud.common.util.WorkspaceUtil.getSessionName; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -29,6 +31,7 @@ import org.eclipse.theia.cloud.common.k8s.client.TheiaCloudClient; import org.eclipse.theia.cloud.common.k8s.resource.Session; import org.eclipse.theia.cloud.common.k8s.resource.SessionSpec; +import org.eclipse.theia.cloud.common.k8s.resource.SessionSpec.InitOperation; import org.eclipse.theia.cloud.common.k8s.resource.Workspace; import org.eclipse.theia.cloud.common.k8s.resource.WorkspaceSpec; import org.eclipse.theia.cloud.common.util.CustomResourceUtil; @@ -79,20 +82,20 @@ public String launchEphemeralSession(String correlationId, String appDefinition, } public String launchWorkspaceSession(String correlationId, UserWorkspace workspace, int timeout, - EnvironmentVars env) { - SessionSpec sessionSpec = new SessionSpec(getSessionName(workspace.name), workspace.appDefinition, - workspace.user, workspace.name); - sessionSpec = sessionSpecWithEnv(sessionSpec, env); + Optional env, Optional gitInit) { + SessionSpec sessionSpec = new SessionSpec(// + getSessionName(workspace.name), // + workspace.appDefinition, // + workspace.user, // + workspace.name, // + env.isPresent() ? env.get().fromMap : Map.of(), // + env.isPresent() ? env.get().fromConfigMaps : List.of(), // + env.isPresent() ? env.get().fromSecrets : List.of(), // + getInitOperations(gitInit)); return launchSession(correlationId, sessionSpec, timeout); } - private String launchSession(String correlationId, SessionSpec sessionSpec, int timeout) { - SessionSpec spec = CLIENT.sessions().launch(correlationId, sessionSpec, timeout).getSpec(); - TheiaCloudWebException.throwIfErroneous(spec); - return spec.getUrl(); - } - private SessionSpec sessionSpecWithEnv(SessionSpec spec, EnvironmentVars env) { if (env == null) return spec; @@ -101,6 +104,26 @@ private SessionSpec sessionSpecWithEnv(SessionSpec spec, EnvironmentVars env) { env.fromMap, env.fromConfigMaps, env.fromSecrets); } + private List getInitOperations(Optional gitInit) { + List result = new ArrayList<>(); + if (gitInit.isPresent()) { + List args = new ArrayList<>(); + args.add(gitInit.get().repository); + args.add(gitInit.get().checkout); + if (gitInit.get().authInformation != null && !gitInit.get().authInformation.isBlank()) { + args.add(gitInit.get().authInformation); + } + result.add(new InitOperation(GitInit.ID, args)); + } + return result; + } + + private String launchSession(String correlationId, SessionSpec sessionSpec, int timeout) { + SessionSpec spec = CLIENT.sessions().launch(correlationId, sessionSpec, timeout).getSpec(); + TheiaCloudWebException.throwIfErroneous(spec); + return spec.getUrl(); + } + public boolean reportSessionActivity(String correlationId, String sessionName) { return CLIENT.sessions().reportActivity(correlationId, sessionName); } diff --git a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/LaunchRequest.java b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/LaunchRequest.java index b2f9dbc0..efb6dcb2 100644 --- a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/LaunchRequest.java +++ b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/LaunchRequest.java @@ -39,6 +39,9 @@ public class LaunchRequest extends UserScopedServiceRequest { @Schema(description = "Environment variables", required = false) public EnvironmentVars env = new EnvironmentVars(); + @Schema(description = "Git Init information", required = false) + public GitInit gitInit; + public LaunchRequest() { super(KIND); } @@ -61,8 +64,8 @@ public boolean isCreateWorkspace() { @Override public String toString() { return "LaunchRequest [user=" + user + ", appDefinition=" + appDefinition + ", workspaceName=" + workspaceName - + ", label=" + label + ", ephemeral=" + ephemeral + ", appId=" + appId + ", kind=" + kind + ", timeout=" - + timeout + ", " + env + "]"; + + ", label=" + label + ", ephemeral=" + ephemeral + ", timeout=" + timeout + ", env=" + env + + ", gitInit=" + gitInit + "]"; } } diff --git a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/RootResource.java b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/RootResource.java index 1208755b..865888fc 100644 --- a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/RootResource.java +++ b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/RootResource.java @@ -67,6 +67,18 @@ public String launch(LaunchRequest request) { throw new TheiaCloudWebException(TheiaCloudError.INVALID_APP_DEFINITION_NAME); } + if (request.gitInit != null) { + if (request.isEphemeral()) { + /* + * Git init is currently only possible with non ephemeral sessions because we + * are initialising the mounted volume + */ + error(correlationId, + "Failed to lauch session. Initialising a git repository with an ephemeral session is not supported at the moment."); + throw new TheiaCloudWebException(TheiaCloudError.INVALID_GIT_INIT_CONFIGURATION); + } + } + if (request.isEphemeral()) { info(correlationId, "Launching ephemeral session " + request); return k8sUtil.launchEphemeralSession(correlationId, request.appDefinition, user, request.timeout, @@ -87,7 +99,7 @@ public String launch(LaunchRequest request) { info(correlationId, "Launching existing workspace session " + request); return k8sUtil.launchWorkspaceSession(correlationId, new UserWorkspace(workspace.get().getSpec()), - request.timeout, request.env); + request.timeout, Optional.ofNullable(request.env), Optional.ofNullable(request.gitInit)); } } @@ -99,7 +111,7 @@ public String launch(LaunchRequest request) { info(correlationId, "Launch workspace session " + request); try { return k8sUtil.launchWorkspaceSession(correlationId, new UserWorkspace(workspace.getSpec()), - request.timeout, request.env); + request.timeout, Optional.ofNullable(request.env), Optional.ofNullable(request.gitInit)); } catch (Exception exception) { info(correlationId, "Delete workspace due to launch error " + request); k8sUtil.deleteWorkspace(correlationId, workspace.getSpec().getName()); diff --git a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/session/SessionResource.java b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/session/SessionResource.java index 7edbdce9..515bc120 100644 --- a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/session/SessionResource.java +++ b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/session/SessionResource.java @@ -74,6 +74,19 @@ public String start(SessionStartRequest request) { final String user = evaluatedRequest.getUser(); info(correlationId, "Launching session " + request); + + if (request.gitInit != null) { + if (request.isEphemeral()) { + /* + * Git init is currently only possible with non ephemeral sessions because we + * are initialising the mounted volume + */ + error(correlationId, + "Failed to lauch session. Initialising a git repository with an ephemeral session is not supported at the moment."); + throw new TheiaCloudWebException(TheiaCloudError.INVALID_GIT_INIT_CONFIGURATION); + } + } + if (request.isEphemeral()) { return k8sUtil.launchEphemeralSession(correlationId, request.appDefinition, user, request.timeout, request.env); @@ -92,7 +105,7 @@ public String start(SessionStartRequest request) { } info(correlationId, "Launch workspace session: " + request); return k8sUtil.launchWorkspaceSession(correlationId, new UserWorkspace(workspace.get().getSpec()), - request.timeout, request.env); + request.timeout, Optional.ofNullable(request.env), Optional.ofNullable(request.gitInit)); } @Operation(summary = "Stop session", description = "Stops a session.") @@ -126,6 +139,7 @@ public boolean stop(SessionStopRequest request) { @Operation(summary = "Report session activity", description = "Updates the last activity timestamp for a session to monitor activity.") @PATCH @PermitAll + @Deprecated public boolean activity(SessionActivityRequest request) { // TODO activity reporting will be removed from this service // There will be a dedicated service that will have direct communication with @@ -180,4 +194,5 @@ protected boolean isOwner(String user, SessionSpec session) { return session.getUser().equals(user); } + } diff --git a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/session/SessionStartRequest.java b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/session/SessionStartRequest.java index 1ab2419b..9473ef9c 100644 --- a/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/session/SessionStartRequest.java +++ b/java/service/org.eclipse.theia.cloud.service/src/main/java/org/eclipse/theia/cloud/service/session/SessionStartRequest.java @@ -18,6 +18,7 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.eclipse.theia.cloud.service.EnvironmentVars; +import org.eclipse.theia.cloud.service.GitInit; import org.eclipse.theia.cloud.service.UserScopedServiceRequest; @Schema(name = "SessionStartRequest", description = "A request to start a session") @@ -36,6 +37,9 @@ public class SessionStartRequest extends UserScopedServiceRequest { @Schema(description = "Environment variables", required = false) public EnvironmentVars env = new EnvironmentVars(); + @Schema(description = "Git Init information", required = false) + public GitInit gitInit; + public SessionStartRequest() { super(KIND); } @@ -69,7 +73,7 @@ public boolean isEphemeral() { @Override public String toString() { return "SessionStartRequest [user=" + user + ", appDefinition=" + appDefinition + ", workspaceName=" - + workspaceName + ", timeout=" + timeout + ", env=" + env + "]"; + + workspaceName + ", timeout=" + timeout + ", env=" + env + ", gitInit=" + gitInit + "]"; } } diff --git a/java/service/org.eclipse.theia.cloud.service/src/test/java/org/eclipse/theia/cloud/service/session/SessionResourceTests.java b/java/service/org.eclipse.theia.cloud.service/src/test/java/org/eclipse/theia/cloud/service/session/SessionResourceTests.java index 09cb8bd8..421cb93e 100644 --- a/java/service/org.eclipse.theia.cloud.service/src/test/java/org/eclipse/theia/cloud/service/session/SessionResourceTests.java +++ b/java/service/org.eclipse.theia.cloud.service/src/test/java/org/eclipse/theia/cloud/service/session/SessionResourceTests.java @@ -402,7 +402,7 @@ void start_noKeycloak_throwForbidden() { // Assert Mockito.verify(k8sUtil, never()).getWorkspace(anyString(), anyString()); - Mockito.verify(k8sUtil, never()).launchWorkspaceSession(anyString(), any(), anyInt(), any()); + Mockito.verify(k8sUtil, never()).launchWorkspaceSession(anyString(), any(), anyInt(), any(), any()); assertEquals(Status.FORBIDDEN.getStatusCode(), exception.getResponse().getStatus()); } @@ -425,7 +425,7 @@ void start_otherUser_throwForbidden() { // Assert Mockito.verify(k8sUtil, never()).getWorkspace(anyString(), anyString()); - Mockito.verify(k8sUtil, never()).launchWorkspaceSession(anyString(), any(), anyInt(), any()); + Mockito.verify(k8sUtil, never()).launchWorkspaceSession(anyString(), any(), anyInt(), any(), any()); assertEquals(Status.FORBIDDEN.getStatusCode(), exception.getResponse().getStatus()); } diff --git a/node/common/src/client/api.ts b/node/common/src/client/api.ts index fba8c198..cd8e58e8 100644 --- a/node/common/src/client/api.ts +++ b/node/common/src/client/api.ts @@ -4,7 +4,7 @@ * Theia.cloud API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: 0.8.0 + * The version of the OpenAPI document: 0.8.1 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -21,7 +21,7 @@ import globalAxios from 'axios'; import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; import type { RequestArgs } from './base'; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError } from './base'; +import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; /** * An object to hold all the ways environment variables can be passed. Not to be used by itself. @@ -48,6 +48,50 @@ export interface EnvironmentVars { */ 'fromSecrets'?: Array; } +/** + * Holds information used to initialize a Workspace with a clone of a Git repository. + * @export + * @interface GitInit + */ +export interface GitInit { + /** + * The Git repository URL. + * @type {string} + * @memberof GitInit + */ + 'repository': string; + /** + * The branch, commit-id, or tag name to checkout. + * @type {string} + * @memberof GitInit + */ + 'checkout': string; + /** + * Key for the required auth information, if the repository is not public. + * @type {string} + * @memberof GitInit + */ + 'authInformation'?: string; +} +/** + * + * @export + * @interface InitOperation + */ +export interface InitOperation { + /** + * + * @type {string} + * @memberof InitOperation + */ + 'id'?: string; + /** + * + * @type {Array} + * @memberof InitOperation + */ + 'arguments'?: Array; +} /** * A request to launch a new session. * @export @@ -102,6 +146,12 @@ export interface LaunchRequest { * @memberof LaunchRequest */ 'env'?: LaunchRequestEnv; + /** + * + * @type {LaunchRequestGitInit} + * @memberof LaunchRequest + */ + 'gitInit'?: LaunchRequestGitInit; } /** * @@ -128,6 +178,31 @@ export interface LaunchRequestEnv { */ 'fromSecrets'?: Array; } +/** + * + * @export + * @interface LaunchRequestGitInit + */ +export interface LaunchRequestGitInit { + /** + * The Git repository URL. + * @type {string} + * @memberof LaunchRequestGitInit + */ + 'repository': string; + /** + * The branch, commit-id, or tag name to checkout. + * @type {string} + * @memberof LaunchRequestGitInit + */ + 'checkout': string; + /** + * Key for the required auth information, if the repository is not public. + * @type {string} + * @memberof LaunchRequestGitInit + */ + 'authInformation'?: string; +} /** * Request to ping the availability of the service. * @export @@ -301,6 +376,12 @@ export interface SessionSpec { * @memberof SessionSpec */ 'envVarsFromSecrets'?: Array; + /** + * + * @type {Array} + * @memberof SessionSpec + */ + 'initOperations'?: Array; } /** * A request to start a session @@ -344,6 +425,12 @@ export interface SessionStartRequest { * @memberof SessionStartRequest */ 'env'?: LaunchRequestEnv; + /** + * + * @type {LaunchRequestGitInit} + * @memberof SessionStartRequest + */ + 'gitInit'?: LaunchRequestGitInit; } /** * A request to stop a session @@ -584,7 +671,9 @@ export const RootResourceApiFp = function(configuration?: Configuration) { */ async serviceAppIdGet(appId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceAppIdGet(appId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['RootResourceApi.serviceAppIdGet']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, /** * Launches a session and creates a workspace if required. Responds with the URL of the launched session. @@ -595,7 +684,9 @@ export const RootResourceApiFp = function(configuration?: Configuration) { */ async servicePost(launchRequest?: LaunchRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.servicePost(launchRequest, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['RootResourceApi.servicePost']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, } }; @@ -663,6 +754,7 @@ export class RootResourceApi extends BaseAPI { } + /** * SessionResourceApi - axios parameter creator * @export @@ -754,6 +846,7 @@ export const SessionResourceApiAxiosParamCreator = function (configuration?: Con * @summary Report session activity * @param {SessionActivityRequest} [sessionActivityRequest] * @param {*} [options] Override http request option. + * @deprecated * @throws {RequiredError} */ serviceSessionPatch: async (sessionActivityRequest?: SessionActivityRequest, options: AxiosRequestConfig = {}): Promise => { @@ -887,7 +980,9 @@ export const SessionResourceApiFp = function(configuration?: Configuration) { */ async serviceSessionAppIdUserGet(appId: string, user: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceSessionAppIdUserGet(appId, user, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['SessionResourceApi.serviceSessionAppIdUserGet']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, /** * Stops a session. @@ -898,18 +993,23 @@ export const SessionResourceApiFp = function(configuration?: Configuration) { */ async serviceSessionDelete(sessionStopRequest?: SessionStopRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceSessionDelete(sessionStopRequest, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['SessionResourceApi.serviceSessionDelete']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, /** * Updates the last activity timestamp for a session to monitor activity. * @summary Report session activity * @param {SessionActivityRequest} [sessionActivityRequest] * @param {*} [options] Override http request option. + * @deprecated * @throws {RequiredError} */ async serviceSessionPatch(sessionActivityRequest?: SessionActivityRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceSessionPatch(sessionActivityRequest, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['SessionResourceApi.serviceSessionPatch']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, /** * Returns the current CPU and memory usage of the session\'s pod. @@ -921,7 +1021,9 @@ export const SessionResourceApiFp = function(configuration?: Configuration) { */ async serviceSessionPerformanceAppIdSessionNameGet(appId: string, sessionName: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceSessionPerformanceAppIdSessionNameGet(appId, sessionName, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['SessionResourceApi.serviceSessionPerformanceAppIdSessionNameGet']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, /** * Starts a new session for an existing workspace and responds with the URL of the started session. @@ -932,7 +1034,9 @@ export const SessionResourceApiFp = function(configuration?: Configuration) { */ async serviceSessionPost(sessionStartRequest?: SessionStartRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceSessionPost(sessionStartRequest, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['SessionResourceApi.serviceSessionPost']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, } }; @@ -970,6 +1074,7 @@ export const SessionResourceApiFactory = function (configuration?: Configuration * @summary Report session activity * @param {SessionActivityRequest} [sessionActivityRequest] * @param {*} [options] Override http request option. + * @deprecated * @throws {RequiredError} */ serviceSessionPatch(sessionActivityRequest?: SessionActivityRequest, options?: any): AxiosPromise { @@ -1036,6 +1141,7 @@ export class SessionResourceApi extends BaseAPI { * @summary Report session activity * @param {SessionActivityRequest} [sessionActivityRequest] * @param {*} [options] Override http request option. + * @deprecated * @throws {RequiredError} * @memberof SessionResourceApi */ @@ -1070,6 +1176,7 @@ export class SessionResourceApi extends BaseAPI { } + /** * WorkspaceResourceApi - axios parameter creator * @export @@ -1214,7 +1321,9 @@ export const WorkspaceResourceApiFp = function(configuration?: Configuration) { */ async serviceWorkspaceAppIdUserGet(appId: string, user: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceWorkspaceAppIdUserGet(appId, user, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['WorkspaceResourceApi.serviceWorkspaceAppIdUserGet']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, /** * Deletes a workspace. @@ -1225,7 +1334,9 @@ export const WorkspaceResourceApiFp = function(configuration?: Configuration) { */ async serviceWorkspaceDelete(workspaceDeletionRequest?: WorkspaceDeletionRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceWorkspaceDelete(workspaceDeletionRequest, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['WorkspaceResourceApi.serviceWorkspaceDelete']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, /** * Creates a new workspace for a user. @@ -1236,7 +1347,9 @@ export const WorkspaceResourceApiFp = function(configuration?: Configuration) { */ async serviceWorkspacePost(workspaceCreationRequest?: WorkspaceCreationRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.serviceWorkspacePost(workspaceCreationRequest, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + const index = configuration?.serverIndex ?? 0; + const operationBasePath = operationServerMap['WorkspaceResourceApi.serviceWorkspacePost']?.[index]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); }, } }; @@ -1328,3 +1441,4 @@ export class WorkspaceResourceApi extends BaseAPI { } + diff --git a/node/common/src/client/base.ts b/node/common/src/client/base.ts index 021d1142..826facd7 100644 --- a/node/common/src/client/base.ts +++ b/node/common/src/client/base.ts @@ -4,7 +4,7 @@ * Theia.cloud API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: 0.8.0 + * The version of the OpenAPI document: 0.8.1 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -53,7 +53,7 @@ export class BaseAPI { constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { if (configuration) { this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; + this.basePath = configuration.basePath ?? basePath; } } }; @@ -70,3 +70,17 @@ export class RequiredError extends Error { this.name = "RequiredError" } } + +interface ServerMap { + [key: string]: { + url: string, + description: string, + }[]; +} + +/** + * + * @export + */ +export const operationServerMap: ServerMap = { +} diff --git a/node/common/src/client/common.ts b/node/common/src/client/common.ts index ec23c5ce..ce29e5f5 100644 --- a/node/common/src/client/common.ts +++ b/node/common/src/client/common.ts @@ -4,7 +4,7 @@ * Theia.cloud API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: 0.8.0 + * The version of the OpenAPI document: 0.8.1 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -144,7 +144,7 @@ export const toPathString = function (url: URL) { */ export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url}; + const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || axios.defaults.baseURL || basePath) + axiosArgs.url}; return axios.request(axiosRequestArgs); }; } diff --git a/node/common/src/client/configuration.ts b/node/common/src/client/configuration.ts index a93108b4..d26512cb 100644 --- a/node/common/src/client/configuration.ts +++ b/node/common/src/client/configuration.ts @@ -4,7 +4,7 @@ * Theia.cloud API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: 0.8.0 + * The version of the OpenAPI document: 0.8.1 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -19,6 +19,7 @@ export interface ConfigurationParameters { password?: string; accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); basePath?: string; + serverIndex?: number; baseOptions?: any; formDataCtor?: new () => any; } @@ -58,6 +59,13 @@ export class Configuration { * @memberof Configuration */ basePath?: string; + /** + * override server index + * + * @type {number} + * @memberof Configuration + */ + serverIndex?: number; /** * base options for axios calls * @@ -80,6 +88,7 @@ export class Configuration { this.password = param.password; this.accessToken = param.accessToken; this.basePath = param.basePath; + this.serverIndex = param.serverIndex; this.baseOptions = param.baseOptions; this.formDataCtor = param.formDataCtor; } diff --git a/node/common/src/client/index.ts b/node/common/src/client/index.ts index 94045ca3..12feaefd 100644 --- a/node/common/src/client/index.ts +++ b/node/common/src/client/index.ts @@ -4,7 +4,7 @@ * Theia.cloud API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: 0.8.0 + * The version of the OpenAPI document: 0.8.1 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/node/package-lock.json b/node/package-lock.json index eb68db3e..57a2ce72 100644 --- a/node/package-lock.json +++ b/node/package-lock.json @@ -38,7 +38,7 @@ }, "monitor": { "name": "theiacloud-monitor", - "version": "0.8.0", + "version": "0.8.1", "license": "EPL-2.0", "dependencies": { "express": "^4.18.1", @@ -68,7 +68,8 @@ } }, "monitor-theia": { - "version": "0.8.0", + "name": "@eclipse-theiacloud/monitor-theia", + "version": "0.8.1-alpha.2", "dependencies": { "@theia/core": "^1.34.0", "@theia/plugin-ext": "^1.34.0" @@ -2230,6 +2231,10 @@ "resolved": "common", "link": true }, + "node_modules/@eclipse-theiacloud/monitor-theia": { + "resolved": "monitor-theia", + "link": true + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -6056,8 +6061,6 @@ "version": "8.11.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", - "optional": true, - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -6072,9 +6075,7 @@ "node_modules/ajv-formats/node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "optional": true, - "peer": true + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/ajv-keywords": { "version": "3.5.2", @@ -13990,10 +13991,6 @@ "node": ">=10" } }, - "node_modules/monitor-theia": { - "resolved": "monitor-theia", - "link": true - }, "node_modules/mount-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mount-point/-/mount-point-3.0.0.tgz", @@ -22371,6 +22368,15 @@ "uuid": "^8.3.2" } }, + "@eclipse-theiacloud/monitor-theia": { + "version": "file:monitor-theia", + "requires": { + "@theia/core": "^1.34.0", + "@theia/plugin-ext": "^1.34.0", + "rimraf": "^3.0.2", + "typescript": "^4.6.3" + } + }, "@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -25405,13 +25411,14 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", - "requires": {}, + "requires": { + "ajv": "^8.0.0" + }, "dependencies": { "ajv": { - "version": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", - "optional": true, - "peer": true, "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -25422,9 +25429,7 @@ "json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "optional": true, - "peer": true + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" } } }, @@ -31307,15 +31312,6 @@ } } }, - "monitor-theia": { - "version": "file:monitor-theia", - "requires": { - "@theia/core": "^1.34.0", - "@theia/plugin-ext": "^1.34.0", - "rimraf": "^3.0.2", - "typescript": "^4.6.3" - } - }, "mount-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mount-point/-/mount-point-3.0.0.tgz", @@ -34570,6 +34566,7 @@ "normalize-path": "^3.0.0", "object-hash": "^3.0.0", "picocolors": "^1.0.0", + "postcss": "^8.4.12", "postcss-js": "^4.0.0", "postcss-load-config": "^3.1.4", "postcss-nested": "5.0.6",