diff --git a/automation/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/LeonardoApiClient.scala b/automation/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/LeonardoApiClient.scala index e50497324ae..c689291c5ed 100644 --- a/automation/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/LeonardoApiClient.scala +++ b/automation/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/LeonardoApiClient.scala @@ -125,6 +125,7 @@ object LeonardoApiClient { Map.empty, None, List.empty, + None, None ) diff --git a/core/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/appRoutesModels.scala b/core/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/appRoutesModels.scala index 5bbf5f10884..6a6163ff3f7 100644 --- a/core/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/appRoutesModels.scala +++ b/core/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/appRoutesModels.scala @@ -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] ) diff --git a/http/src/main/resources/swagger/api-docs.yaml b/http/src/main/resources/swagger/api-docs.yaml index 51da960de92..ba619f997db 100644 --- a/http/src/main/resources/swagger/api-docs.yaml +++ b/http/src/main/resources/swagger/api-docs.yaml @@ -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. diff --git a/http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/AppV2Routes.scala b/http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/AppV2Routes.scala index bd695018587..20b2ab9b950 100644 --- a/http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/AppV2Routes.scala +++ b/http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/AppV2Routes.scala @@ -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]] @@ -202,6 +203,7 @@ object AppV2Routes { cv.getOrElse(Map.empty), dp, ea.getOrElse(List.empty), + wsi, swi ) } diff --git a/http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/service/LeoAppServiceInterp.scala b/http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/service/LeoAppServiceInterp.scala index e1a26591505..99f839d2a56 100644 --- a/http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/service/LeoAppServiceInterp.scala +++ b/http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/service/LeoAppServiceInterp.scala @@ -250,7 +250,7 @@ final class LeoAppServiceInterp[F[_]: Parallel](config: AppServiceConfig, lastUsedApp, petSA, nodepool.id, - None, + req.workspaceId, ctx ) ) diff --git a/http/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/KubernetesTestData.scala b/http/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/KubernetesTestData.scala index 902449214bb..f9ae8890855 100644 --- a/http/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/KubernetesTestData.scala +++ b/http/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/KubernetesTestData.scala @@ -80,6 +80,7 @@ object KubernetesTestData { Map.empty, None, List.empty, + None, None ) @@ -121,6 +122,7 @@ object KubernetesTestData { customEnvironmentVariables = customEnvVars, descriptorPath = None, extraArgs = List.empty, + None, None ) diff --git a/http/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/AppV2RouteSpec.scala b/http/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/AppV2RouteSpec.scala new file mode 100644 index 00000000000..dafd75ef872 --- /dev/null +++ b/http/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/AppV2RouteSpec.scala @@ -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)) + } +}