Skip to content

Commit

Permalink
RW-9480 add workspaceId in v1 createApp API (#4020)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qi77Qi authored Dec 8, 2023
1 parent ddebdc0 commit 2782ecb
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ object LeonardoApiClient {
Map.empty,
None,
List.empty,
None,
None
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ final case class CreateAppRequest(kubernetesRuntimeConfig: Option[KubernetesRunt
customEnvironmentVariables: Map[String, String],
descriptorPath: Option[Uri],
extraArgs: List[String],
workspaceId: Option[WorkspaceId],
sourceWorkspaceId: Option[WorkspaceId]
)

Expand Down
3 changes: 3 additions & 0 deletions http/src/main/resources/swagger/api-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4028,6 +4028,9 @@ components:
items:
type: string
description: Extra arguments to pass to the application. Only used if appType is CUSTOM.
workspaceId:
type: string
description: Optional id of workspace. Every app must have a workspaceId, but this is not required for backwards-compatibility. Note, if you're using v2 APIs, this field is not used.
sourceWorkspaceId:
type: string
description: Optional id of source workspace if app is a clone.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ object AppV2Routes {
cv <- x.downField("customEnvironmentVariables").as[Option[LabelMap]]
dp <- x.downField("descriptorPath").as[Option[Uri]]
ea <- x.downField("extraArgs").as[Option[List[String]]]
wsi <- x.downField("workspaceId").as[Option[WorkspaceId]]
swi <- x.downField("sourceWorkspaceId").as[Option[WorkspaceId]]

optStr <- x.downField("appType").as[Option[String]]
Expand Down Expand Up @@ -202,6 +203,7 @@ object AppV2Routes {
cv.getOrElse(Map.empty),
dp,
ea.getOrElse(List.empty),
wsi,
swi
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ final class LeoAppServiceInterp[F[_]: Parallel](config: AppServiceConfig,
lastUsedApp,
petSA,
nodepool.id,
None,
req.workspaceId,
ctx
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ object KubernetesTestData {
Map.empty,
None,
List.empty,
None,
None
)

Expand Down Expand Up @@ -121,6 +122,7 @@ object KubernetesTestData {
customEnvironmentVariables = customEnvVars,
descriptorPath = None,
extraArgs = List.empty,
None,
None
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.broadinstitute.dsde.workbench.leonardo.http.api

import io.circe.parser.decode
import org.broadinstitute.dsde.workbench.google2.DiskName
import org.broadinstitute.dsde.workbench.leonardo.http.api.AppV2Routes.createAppDecoder
import org.broadinstitute.dsde.workbench.leonardo.http.{CreateAppRequest, PersistentDiskRequest}
import org.broadinstitute.dsde.workbench.leonardo.{AllowedChartName, AppType, LeonardoTestSuite, WorkspaceId}
import org.scalatest.flatspec.AnyFlatSpec

import java.util.UUID

class AppV2RouteSpec extends AnyFlatSpec with LeonardoTestSuite {
it should "decode createApp request properly" in {
val workspaceId = WorkspaceId(UUID.randomUUID())
val jsonString =
s"""
|{
| "diskConfig": {
| "name": "disk1"
| },
| "appType": "ALLOWED",
| "allowedChartName": "rstudio",
| "workspaceId": "${workspaceId.value.toString}"
|}
|""".stripMargin

val res = decode[CreateAppRequest](jsonString)

val expected = CreateAppRequest(
None,
AppType.Allowed,
Some(AllowedChartName.RStudio),
None,
Some(PersistentDiskRequest(DiskName("disk1"), None, None, Map.empty)),
Map.empty,
Map.empty,
None,
List.empty,
Some(workspaceId),
None
)
res shouldBe (Right(expected))
}
}

0 comments on commit 2782ecb

Please sign in to comment.