-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLAT-1243 - Add ability to pass in datalinks to be mounted to data st…
…udio by name, resourceRef or id
- Loading branch information
1 parent
7d31056
commit da2a534
Showing
10 changed files
with
394 additions
and
55 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/main/java/io/seqera/tower/cli/commands/data/links/AbstractDataLinkCmd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2021-2023, Seqera. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package io.seqera.tower.cli.commands.data.links; | ||
|
||
import io.seqera.tower.ApiException; | ||
import io.seqera.tower.cli.commands.AbstractApiCmd; | ||
import io.seqera.tower.cli.commands.enums.OutputType; | ||
import io.seqera.tower.cli.utils.ResponseHelper; | ||
|
||
public class AbstractDataLinkCmd extends AbstractApiCmd { | ||
|
||
public boolean checkIfResultIncomplete(Long wspId, String credId, boolean wait) { | ||
DataLinksFetchStatus status = checkDataLinksFetchStatus(wspId, credId); | ||
if (wait && status == DataLinksFetchStatus.FETCHING) { | ||
waitForDoneStatus(wspId, credId); | ||
} | ||
|
||
return !wait && status == DataLinksFetchStatus.FETCHING; | ||
} | ||
|
||
void waitForDoneStatus(Long wspId, String credId) { | ||
try { | ||
ResponseHelper.waitStatus( | ||
app().getOut(), | ||
app().output != OutputType.json, | ||
DataLinksFetchStatus.DONE, | ||
DataLinksFetchStatus.values(), | ||
() -> checkDataLinksFetchStatus(wspId, credId), | ||
DataLinksFetchStatus.DONE, DataLinksFetchStatus.ERROR | ||
); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
DataLinksFetchStatus checkDataLinksFetchStatus(Long wspId, String credentialsId) { | ||
int status; | ||
try { | ||
status = api().listDataLinksWithHttpInfo(wspId, credentialsId, null, 1, 0, null).getStatusCode(); | ||
} catch (ApiException e) { | ||
return DataLinksFetchStatus.ERROR; | ||
} | ||
switch (status) { | ||
case 200: | ||
return DataLinksFetchStatus.DONE; | ||
case 202: | ||
return DataLinksFetchStatus.FETCHING; | ||
default: | ||
return DataLinksFetchStatus.ERROR; | ||
} | ||
} | ||
|
||
public enum DataLinksFetchStatus { | ||
FETCHING, DONE, ERROR | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/io/seqera/tower/cli/commands/datastudios/DataLinkRefOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2021-2023, Seqera. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package io.seqera.tower.cli.commands.datastudios; | ||
|
||
import java.util.List; | ||
|
||
import picocli.CommandLine; | ||
|
||
public class DataLinkRefOptions { | ||
|
||
@CommandLine.ArgGroup | ||
public DataLinkRef dataLinkRef; | ||
|
||
public static class DataLinkRef { | ||
@CommandLine.Option(names = {"--mount-data"}, description = "Optional configuration override for 'mountData' setting (comma separate list of data-link names)", split = ",") | ||
public List<String> mountDataNames; | ||
|
||
@CommandLine.Option(names = {"--mount-data-ids"}, description = "Optional configuration override for 'mountData' setting (comma separate list of data-link Ids)", split = ",") | ||
public List<String> mountDataIds; | ||
|
||
@CommandLine.Option(names = {"--mount-data-resource-refs"}, description = "Optional configuration override for 'mountData' setting (comma separate list of data-link resource refs)", split = ",") | ||
public List<String> mountDataResourceRefs; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/io/seqera/tower/cli/exceptions/DataLinkNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2021-2023, Seqera. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package io.seqera.tower.cli.exceptions; | ||
|
||
public class DataLinkNotFoundException extends TowerRuntimeException { | ||
|
||
public DataLinkNotFoundException(String dataLinkIdentifier, Long workspaceId) { | ||
super(String.format("DataLink '%s' not found at workspace '%s'", dataLinkIdentifier, workspaceId)); | ||
} | ||
|
||
} |
Oops, something went wrong.