From ffd405d1b3d8c1109ca2be352789203bc424e083 Mon Sep 17 00:00:00 2001 From: Joel Thibault Date: Fri, 25 Oct 2024 11:15:09 -0400 Subject: [PATCH 1/4] manageleoruntimes bad bump leo client to latest --- api/build.gradle | 4 +- .../tools/ManageLeonardoRuntimes.java | 77 +++++++++++++------ 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/api/build.gradle b/api/build.gradle index 4de6268372b..98451c1b785 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -541,9 +541,9 @@ dependencies { exclude group: 'org.apache.oltu.oauth2', module: 'org.apache.oltu.oauth2.common' } - // updated 2 Oct 2024 to most recent develop + // updated 21 Oct 2024 to most recent develop // see https://github.com/DataBiosphere/leonardo/actions/workflows/publish_java_client.yml - implementation("org.broadinstitute.dsde.workbench:leonardo-client_2.13:1.3.6-3fbffee") + implementation("org.broadinstitute.dsde.workbench:leonardo-client_2.13:1.3.6-880147e") implementation group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '4.0.5' diff --git a/api/tools/src/main/java/org/pmiops/workbench/tools/ManageLeonardoRuntimes.java b/api/tools/src/main/java/org/pmiops/workbench/tools/ManageLeonardoRuntimes.java index c3c4944d9c5..93008b09f4e 100644 --- a/api/tools/src/main/java/org/pmiops/workbench/tools/ManageLeonardoRuntimes.java +++ b/api/tools/src/main/java/org/pmiops/workbench/tools/ManageLeonardoRuntimes.java @@ -23,15 +23,14 @@ import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; -import okhttp3.Call; +import org.broadinstitute.dsde.workbench.client.leonardo.ApiClient; +import org.broadinstitute.dsde.workbench.client.leonardo.ApiException; +import org.broadinstitute.dsde.workbench.client.leonardo.ApiResponse; +import org.broadinstitute.dsde.workbench.client.leonardo.api.RuntimesApi; +import org.broadinstitute.dsde.workbench.client.leonardo.model.ClusterStatus; +import org.broadinstitute.dsde.workbench.client.leonardo.model.GetRuntimeResponse; +import org.broadinstitute.dsde.workbench.client.leonardo.model.ListRuntimeResponse; import org.pmiops.workbench.auth.ServiceAccounts; -import org.pmiops.workbench.legacy_leonardo_client.ApiClient; -import org.pmiops.workbench.legacy_leonardo_client.ApiException; -import org.pmiops.workbench.legacy_leonardo_client.ApiResponse; -import org.pmiops.workbench.legacy_leonardo_client.api.RuntimesApi; -import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoGetRuntimeResponse; -import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoListRuntimeResponse; -import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoRuntimeStatus; import org.pmiops.workbench.utils.mappers.LeonardoMapper; import org.pmiops.workbench.utils.mappers.LeonardoMapperImpl; import org.springframework.boot.CommandLineRunner; @@ -89,7 +88,7 @@ private static RuntimesApi newApiClient(String apiUrl) throws IOException { return api; } - private String runtimeId(LeonardoListRuntimeResponse r) { + private String runtimeId(ListRuntimeResponse r) { return leonardoMapper.toGoogleProject(r.getCloudContext()) + "/" + r.getRuntimeName(); } @@ -113,14 +112,14 @@ private static String toWholeSeconds(@Nullable String dateTimeString) { } } - private String formatTabular(LeonardoListRuntimeResponse r) { + private String formatTabular(ListRuntimeResponse r) { Gson gson = new Gson(); JsonObject labels = gson.toJsonTree(r.getLabels()).getAsJsonObject(); String creator = "unknown"; if (labels.has("created-by")) { creator = labels.get("created-by").getAsString(); } - LeonardoRuntimeStatus status = LeonardoRuntimeStatus.UNKNOWN; + ClusterStatus status = ClusterStatus.UNKNOWN; if (r.getStatus() != null) { status = r.getStatus(); } @@ -134,10 +133,10 @@ private String formatTabular(LeonardoListRuntimeResponse r) { toWholeSeconds(r.getAuditInfo().getDestroyedDate())); } - private void printFormatted(List runtimes, OutputFormat fmt) { - Function toGoogle = + private void printFormatted(List runtimes, OutputFormat fmt) { + Function toGoogle = r -> leonardoMapper.toGoogleProject(r.getCloudContext()); - Stream stream = + Stream stream = runtimes.stream() .sorted( Comparator.comparing(toGoogle) @@ -165,10 +164,25 @@ private void listRuntimes( throws IOException, ApiException { RuntimesApi api = newApiClient(apiUrl); - List runtimes; + List runtimes; if (googleProjectId.isPresent()) { runtimes = api.listRuntimesByProject(googleProjectId.get(), null, includeDeleted); } else { + /* + I see an error for + ./project.rb list-runtimes --project all-of-us-workbench-test fails with + + com.google.gson.JsonSyntaxException: java.io.IOException: The JSON string is invalid for + OneOfRuntimeConfigInResponse with oneOf schemas: AzureConfig, DataprocConfig, + GceWithPdConfigInResponse. 2 class(es) match the result, expected 1. Detailed failure message + for oneOf schemas: [Deserialization for DataprocConfig failed with + `The required field `numberOfWorkers` is not found in the JSON string: + {"machineType":"n1-standard-4","persistentDiskId":23905,"cloudService":"GCE", + "bootDiskSize":250,"zone":"us-central1-c","gpuConfig":null,"configType":"GceWithPdConfig"}`.]. + JSON: {"machineType":"n1-standard-4","persistentDiskId":23905,"cloudService":"GCE", + "bootDiskSize":250,"zone":"us-central1-c","gpuConfig":null,"configType":"GceWithPdConfig"} + */ + runtimes = api.listRuntimes(null, includeDeleted); } printFormatted(runtimes, fmt); @@ -188,22 +202,35 @@ private static void describeRuntime( String googleProject = parts[0]; String runtimeName = parts[1]; + /* + what I want to do is: + GetRuntimeResponse runtime = client.getRuntime(googleProject, runtimeName); + + but I see an error for: + ./project.rb describe-runtime --project all-of-us-workbench-test --id aou-rw-test-154a8b2d/all-of-us-3979 + + Caused by: java.io.IOException: The JSON string is invalid for OneOfRuntimeConfigInResponse + with oneOf schemas: AzureConfig, DataprocConfig, GceWithPdConfigInResponse. 2 class(es) match + the result, expected 1. Detailed failure message for + oneOf schemas: [Deserialization for DataprocConfig failed with `The required field + `numberOfWorkers` is not found in the JSON string: + {"machineType":"n1-standard-4","persistentDiskId":2526,"cloudService":"GCE", + "bootDiskSize":70,"zone":"us-central1-b","gpuConfig":null,"configType":"GceWithPdConfig"}`.]. + JSON: {"machineType":"n1-standard-4","persistentDiskId":2526,"cloudService":"GCE", + "bootDiskSize":70,"zone":"us-central1-b","gpuConfig":null,"configType":"GceWithPdConfig"} + */ + // Leo's getRuntime API swagger tends to be outdated; issue a raw getRuntime request to ensure // we get all available information for debugging. RuntimesApi client = newApiClient(apiUrl); - Call call = - client.getRuntimeCall( - googleProject, - runtimeName, - /* progressListener */ null, - /* progressRequestListener */ null); + okhttp3.Call call = client.getRuntimeCall(googleProject, runtimeName, /* _callback */ null); ApiResponse resp = client.getApiClient().execute(call, Object.class); - // Parse the response as well so we can log specific structured fields. - LeonardoGetRuntimeResponse runtime = - PRETTY_GSON.fromJson(PRETTY_GSON.toJson(resp.getData()), LeonardoGetRuntimeResponse.class); + GetRuntimeResponse runtime = + PRETTY_GSON.fromJson(PRETTY_GSON.toJson(resp.getData()), GetRuntimeResponse.class); System.out.println(PRETTY_GSON.toJson(resp.getData())); + System.out.printf("\n\nTo inspect logs in cloud storage, run the following:\n\n"); System.out.printf( @@ -222,7 +249,7 @@ private void deleteRuntimes( AtomicInteger deleted = new AtomicInteger(); RuntimesApi api = newApiClient(apiUrl); api.listRuntimes(null, false).stream() - .sorted(Comparator.comparing(LeonardoListRuntimeResponse::getRuntimeName)) + .sorted(Comparator.comparing(ListRuntimeResponse::getRuntimeName)) .filter( (r) -> { Instant createdDate = Instant.parse(r.getAuditInfo().getCreatedDate()); From 89b9bb1c5e92f82fc6eca6ace236768e2fe468b0 Mon Sep 17 00:00:00 2001 From: Joel Thibault Date: Tue, 29 Oct 2024 13:31:36 -0400 Subject: [PATCH 2/4] comments --- .../org/pmiops/workbench/api/OfflineRuntimeController.java | 3 +++ .../org/pmiops/workbench/utils/mappers/LeonardoMapper.java | 2 ++ .../java/org/pmiops/workbench/api/RuntimeControllerTest.java | 2 ++ 3 files changed, 7 insertions(+) diff --git a/api/src/main/java/org/pmiops/workbench/api/OfflineRuntimeController.java b/api/src/main/java/org/pmiops/workbench/api/OfflineRuntimeController.java index 34104673909..42e370a906c 100644 --- a/api/src/main/java/org/pmiops/workbench/api/OfflineRuntimeController.java +++ b/api/src/main/java/org/pmiops/workbench/api/OfflineRuntimeController.java @@ -338,6 +338,9 @@ public boolean isDiskAttached(ListPersistentDiskResponse diskResponse, String go return leonardoApiClient.listRuntimesByProjectAsService(googleProject).stream() // this filter/map follows the discriminator logic in the source Leonardo Swagger // for OneOfRuntimeConfigInResponse + + // TODO: does all this go away for the new client? + .filter( resp -> { var runtimeConfig = diff --git a/api/src/main/java/org/pmiops/workbench/utils/mappers/LeonardoMapper.java b/api/src/main/java/org/pmiops/workbench/utils/mappers/LeonardoMapper.java index 3045a2bc904..a3870496c79 100644 --- a/api/src/main/java/org/pmiops/workbench/utils/mappers/LeonardoMapper.java +++ b/api/src/main/java/org/pmiops/workbench/utils/mappers/LeonardoMapper.java @@ -273,6 +273,8 @@ default void mapRuntimeConfig( return; } + // TODO: does all this go away for the new client? + Gson gson = new Gson(); String runtimeConfigJson = gson.toJson(runtimeConfigObj); LeonardoRuntimeConfig runtimeConfig = diff --git a/api/src/test/java/org/pmiops/workbench/api/RuntimeControllerTest.java b/api/src/test/java/org/pmiops/workbench/api/RuntimeControllerTest.java index c3a43f951cd..e40ab453bb3 100644 --- a/api/src/test/java/org/pmiops/workbench/api/RuntimeControllerTest.java +++ b/api/src/test/java/org/pmiops/workbench/api/RuntimeControllerTest.java @@ -875,6 +875,8 @@ public void testCreateRuntime_dataproc() throws ApiException { LeonardoCreateRuntimeRequest createRuntimeRequest = createRuntimeRequestCaptor.getValue(); + // TODO: does all this go away for the new client? + Gson gson = new Gson(); LeonardoMachineConfig createLeonardoMachineConfig = gson.fromJson( From 22b9156923b0e59ab98f3d88ccab06a182625b49 Mon Sep 17 00:00:00 2001 From: Joel Thibault Date: Tue, 29 Oct 2024 16:49:04 -0400 Subject: [PATCH 3/4] rename --- .../org/pmiops/workbench/api/WorkspaceAdminControllerTest.java | 2 +- .../test/java/org/pmiops/workbench/utils/TestMockFactory.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/test/java/org/pmiops/workbench/api/WorkspaceAdminControllerTest.java b/api/src/test/java/org/pmiops/workbench/api/WorkspaceAdminControllerTest.java index 87fc516cb50..80b25154d65 100644 --- a/api/src/test/java/org/pmiops/workbench/api/WorkspaceAdminControllerTest.java +++ b/api/src/test/java/org/pmiops/workbench/api/WorkspaceAdminControllerTest.java @@ -127,7 +127,7 @@ public void setUp() { .thenReturn(cloudStorageCounts); LeonardoListRuntimeResponse leonardoListRuntimeResponse = - TestMockFactory.createLeonardoListRuntimesResponse(); + TestMockFactory.createListRuntimeResponse(); List runtimes = List.of(leonardoListRuntimeResponse); when(mockLeonardoNotebooksClient.listRuntimesByProjectAsService(WORKSPACE_NAMESPACE)) .thenReturn(runtimes); diff --git a/api/src/test/java/org/pmiops/workbench/utils/TestMockFactory.java b/api/src/test/java/org/pmiops/workbench/utils/TestMockFactory.java index 08cdb42326e..ff3ea9684c0 100644 --- a/api/src/test/java/org/pmiops/workbench/utils/TestMockFactory.java +++ b/api/src/test/java/org/pmiops/workbench/utils/TestMockFactory.java @@ -172,7 +172,7 @@ public static RawlsWorkspaceDetails createTerraWorkspace( .googleProject(DEFAULT_GOOGLE_PROJECT); } - public static LeonardoListRuntimeResponse createLeonardoListRuntimesResponse() { + public static LeonardoListRuntimeResponse createListRuntimeResponse() { return new LeonardoListRuntimeResponse() .runtimeName("runtime") .cloudContext( From 7f4725bea742695529749adb5f667bed530e9f39 Mon Sep 17 00:00:00 2001 From: Joel Thibault Date: Tue, 29 Oct 2024 17:26:07 -0400 Subject: [PATCH 4/4] migrate getRuntime --- .../workbench/api/RuntimeController.java | 12 +++++------ .../workbench/leonardo/LeonardoApiClient.java | 4 ++-- .../leonardo/LeonardoApiClientImpl.java | 20 +++++++++++++------ .../workbench/leonardo/LeonardoConfig.java | 15 ++++++++++++-- .../utils/mappers/LeonardoMapper.java | 11 +++++----- 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/api/src/main/java/org/pmiops/workbench/api/RuntimeController.java b/api/src/main/java/org/pmiops/workbench/api/RuntimeController.java index 89bf97a893c..c10b025cf64 100644 --- a/api/src/main/java/org/pmiops/workbench/api/RuntimeController.java +++ b/api/src/main/java/org/pmiops/workbench/api/RuntimeController.java @@ -17,16 +17,16 @@ import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.broadinstitute.dsde.workbench.client.leonardo.model.ClusterError; +import org.broadinstitute.dsde.workbench.client.leonardo.model.ClusterStatus; +import org.broadinstitute.dsde.workbench.client.leonardo.model.GetRuntimeResponse; import org.pmiops.workbench.config.WorkbenchConfig; import org.pmiops.workbench.db.model.DbUser; import org.pmiops.workbench.db.model.DbWorkspace; import org.pmiops.workbench.exceptions.BadRequestException; import org.pmiops.workbench.exceptions.NotFoundException; import org.pmiops.workbench.interactiveanalysis.InteractiveAnalysisService; -import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoClusterError; -import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoGetRuntimeResponse; import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoListRuntimeResponse; -import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoRuntimeStatus; import org.pmiops.workbench.leonardo.LeonardoApiClient; import org.pmiops.workbench.leonardo.LeonardoApiHelper; import org.pmiops.workbench.leonardo.PersistentDiskUtils; @@ -92,9 +92,9 @@ public ResponseEntity getRuntime(String workspaceNamespace) { DbWorkspace dbWorkspace = workspaceService.lookupWorkspaceByNamespace(workspaceNamespace); String googleProject = dbWorkspace.getGoogleProject(); try { - LeonardoGetRuntimeResponse leoRuntimeResponse = + GetRuntimeResponse leoRuntimeResponse = leonardoNotebooksClient.getRuntime(googleProject, user.getRuntimeName()); - if (LeonardoRuntimeStatus.ERROR.equals(leoRuntimeResponse.getStatus())) { + if (ClusterStatus.ERROR.equals(leoRuntimeResponse.getStatus())) { log.warning( String.format( "Observed Leonardo runtime with unexpected error status:\n%s", @@ -106,7 +106,7 @@ public ResponseEntity getRuntime(String workspaceNamespace) { } } - private String formatRuntimeErrors(@Nullable List errors) { + private String formatRuntimeErrors(@Nullable List errors) { if (errors == null || errors.isEmpty()) { return "no error messages"; } diff --git a/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoApiClient.java b/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoApiClient.java index a7996dc22fc..fa694d8b0e4 100644 --- a/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoApiClient.java +++ b/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoApiClient.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.Map; +import org.broadinstitute.dsde.workbench.client.leonardo.model.GetRuntimeResponse; import org.broadinstitute.dsde.workbench.client.leonardo.model.ListPersistentDiskResponse; import org.pmiops.workbench.db.model.DbWorkspace; import org.pmiops.workbench.exceptions.WorkbenchException; @@ -59,8 +60,7 @@ LeonardoGetRuntimeResponse getRuntimeAsService(String googleProject, String runt int stopAllUserRuntimesAsService(String userEmail) throws WorkbenchException; /** Gets information about a notebook runtime */ - LeonardoGetRuntimeResponse getRuntime(String googleProject, String runtimeName) - throws WorkbenchException; + GetRuntimeResponse getRuntime(String googleProject, String runtimeName) throws WorkbenchException; /** Send files over to notebook runtime */ void localizeForRuntime(String googleProject, String runtimeName, Map fileList) diff --git a/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoApiClientImpl.java b/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoApiClientImpl.java index 6ea53ae9dbc..01f493f47dc 100644 --- a/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoApiClientImpl.java +++ b/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoApiClientImpl.java @@ -32,6 +32,7 @@ import org.broadinstitute.dsde.workbench.client.leonardo.api.AppsApi; import org.broadinstitute.dsde.workbench.client.leonardo.api.DisksApi; import org.broadinstitute.dsde.workbench.client.leonardo.model.AppStatus; +import org.broadinstitute.dsde.workbench.client.leonardo.model.GetRuntimeResponse; import org.broadinstitute.dsde.workbench.client.leonardo.model.ListAppResponse; import org.broadinstitute.dsde.workbench.client.leonardo.model.ListPersistentDiskResponse; import org.broadinstitute.dsde.workbench.client.leonardo.model.UpdateDiskRequest; @@ -98,6 +99,8 @@ public class LeonardoApiClientImpl implements LeonardoApiClient { private final LeonardoApiClientFactory leonardoApiClientFactory; private final Provider runtimesApiProvider; + private final Provider + newRuntimesApiProvider; private final Provider serviceRuntimesApiProvider; private final Provider resourcesApiProvider; @@ -119,7 +122,10 @@ public class LeonardoApiClientImpl implements LeonardoApiClient { @Autowired public LeonardoApiClientImpl( LeonardoApiClientFactory leonardoApiClientFactory, - @Qualifier(LeonardoConfig.USER_RUNTIMES_API) Provider runtimesApiProvider, + @Qualifier(LeonardoConfig.LEGACY_USER_RUNTIMES_API) Provider runtimesApiProvider, + @Qualifier(LeonardoConfig.USER_RUNTIMES_API) + Provider + newRuntimesApiProvider, @Qualifier(LeonardoConfig.SERVICE_RUNTIMES_API) Provider serviceRuntimesApiProvider, @Qualifier(LeonardoConfig.SERVICE_RESOURCE_API) Provider resourcesApiProvider, @@ -139,6 +145,7 @@ public LeonardoApiClientImpl( WorkspaceDao workspaceDao) { this.leonardoApiClientFactory = leonardoApiClientFactory; this.runtimesApiProvider = runtimesApiProvider; + this.newRuntimesApiProvider = newRuntimesApiProvider; this.serviceRuntimesApiProvider = serviceRuntimesApiProvider; this.resourcesApiProvider = resourcesApiProvider; this.proxyApiProvider = proxyApiProvider; @@ -349,13 +356,14 @@ public void deleteRuntime(String googleProject, String runtimeName, Boolean dele } @Override - public LeonardoGetRuntimeResponse getRuntime(String googleProject, String runtimeName) { - RuntimesApi runtimesApi = runtimesApiProvider.get(); + public GetRuntimeResponse getRuntime(String googleProject, String runtimeName) { + org.broadinstitute.dsde.workbench.client.leonardo.api.RuntimesApi runtimesApi = + newRuntimesApiProvider.get(); try { - return legacyLeonardoRetryHandler.runAndThrowChecked( + return leonardoRetryHandler.runAndThrowChecked( (context) -> runtimesApi.getRuntime(googleProject, runtimeName)); - } catch (org.pmiops.workbench.legacy_leonardo_client.ApiException e) { - throw ExceptionUtils.convertLegacyLeonardoException(e); + } catch (ApiException e) { + throw ExceptionUtils.convertLeonardoException(e); } } diff --git a/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoConfig.java b/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoConfig.java index cf065b3b090..cc1de9ae3d5 100644 --- a/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoConfig.java +++ b/api/src/main/java/org/pmiops/workbench/leonardo/LeonardoConfig.java @@ -24,6 +24,7 @@ @org.springframework.context.annotation.Configuration public class LeonardoConfig { + public static final String LEGACY_USER_RUNTIMES_API = "legacyUserRuntimesApi"; public static final String USER_RUNTIMES_API = "userRuntimesApi"; public static final String SERVICE_RUNTIMES_API = "svcRuntimesApi"; @@ -130,9 +131,9 @@ public org.pmiops.workbench.notebooks.ApiClient workbenchServiceAccountClient( return apiClient; } - @Bean(name = USER_RUNTIMES_API) + @Bean(name = LEGACY_USER_RUNTIMES_API) @RequestScope(proxyMode = ScopedProxyMode.DEFAULT) - public RuntimesApi runtimesApi( + public RuntimesApi legacyRuntimesApi( @Qualifier(LEGACY_USER_LEONARDO_CLIENT) org.pmiops.workbench.legacy_leonardo_client.ApiClient apiClient) { RuntimesApi api = new RuntimesApi(); @@ -140,6 +141,16 @@ public RuntimesApi runtimesApi( return api; } + @Bean(name = USER_RUNTIMES_API) + @RequestScope(proxyMode = ScopedProxyMode.DEFAULT) + public org.broadinstitute.dsde.workbench.client.leonardo.api.RuntimesApi runtimesApi( + @Qualifier(USER_LEONARDO_CLIENT) ApiClient apiClient) { + org.broadinstitute.dsde.workbench.client.leonardo.api.RuntimesApi api = + new org.broadinstitute.dsde.workbench.client.leonardo.api.RuntimesApi(); + api.setApiClient(apiClient); + return api; + } + @Bean(name = USER_DISKS_API) @RequestScope(proxyMode = ScopedProxyMode.DEFAULT) public DisksApi disksApi(@Qualifier(USER_LEONARDO_CLIENT) ApiClient apiClient) { diff --git a/api/src/main/java/org/pmiops/workbench/utils/mappers/LeonardoMapper.java b/api/src/main/java/org/pmiops/workbench/utils/mappers/LeonardoMapper.java index a3870496c79..0fc436689bc 100644 --- a/api/src/main/java/org/pmiops/workbench/utils/mappers/LeonardoMapper.java +++ b/api/src/main/java/org/pmiops/workbench/utils/mappers/LeonardoMapper.java @@ -10,8 +10,10 @@ import org.broadinstitute.dsde.workbench.client.leonardo.model.AllowedChartName; import org.broadinstitute.dsde.workbench.client.leonardo.model.CloudContext; import org.broadinstitute.dsde.workbench.client.leonardo.model.CloudProvider; +import org.broadinstitute.dsde.workbench.client.leonardo.model.GetRuntimeResponse; import org.broadinstitute.dsde.workbench.client.leonardo.model.ListAppResponse; import org.broadinstitute.dsde.workbench.client.leonardo.model.ListPersistentDiskResponse; +import org.broadinstitute.dsde.workbench.client.leonardo.model.RuntimeImage; import org.mapstruct.AfterMapping; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -31,7 +33,6 @@ import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoMachineConfig; import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoRuntimeConfig; import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoRuntimeConfig.CloudServiceEnum; -import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoRuntimeImage; import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoRuntimeStatus; import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoUpdateDataprocConfig; import org.pmiops.workbench.legacy_leonardo_client.model.LeonardoUpdateGceConfig; @@ -159,7 +160,7 @@ default String toGoogleProject(@Nullable CloudContext lcc) { @Mapping( target = "googleProject", source = "cloudContext", - qualifiedByName = "legacy_cloudContextToGoogleProject") + qualifiedByName = "cloudContextToGoogleProject") @Mapping( target = "configurationType", source = "labels", @@ -168,7 +169,7 @@ default String toGoogleProject(@Nullable CloudContext lcc) { @Mapping(target = "gceConfig", ignore = true) @Mapping(target = "gceWithPdConfig", ignore = true) @Mapping(target = "dataprocConfig", ignore = true) - Runtime toApiRuntime(LeonardoGetRuntimeResponse runtime); + Runtime toApiRuntime(GetRuntimeResponse runtime); @Mapping(target = "createdDate", source = "auditInfo.createdDate") @Mapping( @@ -316,11 +317,11 @@ default DiskStatus toApiDiskStatus( } @Nullable - default String getJupyterImage(@Nullable List images) { + default String getJupyterImage(@Nullable List images) { return Optional.ofNullable(images) .flatMap( i -> i.stream().filter(image -> "Jupyter".equals(image.getImageType())).findFirst()) - .map(LeonardoRuntimeImage::getImageUrl) + .map(RuntimeImage::getImageUrl) .orElse(null); } }