-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: PLAT-1152 / add data studios 'list' command #475
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f32cbbc
feat: adding data studios view command
endre-seqera f767ef7
fix: adding some missing reflection metadata
endre-seqera 775b1e1
fix: adding some more reflection metadata
endre-seqera 807bb04
fix: yet more reflection metadata
endre-seqera 05af32d
fix: missing reflection metadata
endre-seqera 25877af
fix: update sdk and extend studios view command
endre-seqera 53d94d3
fix: missing reflection metadata
endre-seqera cbc0a51
fix: missing reflection metadata again
endre-seqera bfbd17f
fix: newline formatting
endre-seqera 9a2da6a
fix: removing conda env from test
endre-seqera 161abf2
remove duplicated reflection metadata
endre-seqera ef47376
PLAT-1152 - Add Data studios CLI list command
georgi-seqera 58e335a
PLAT-1152 - Update reflect-config.json for new data studio List command
georgi-seqera d5cb9e6
PLAT-1152 - Update reflect-config.json for new data studio List command
georgi-seqera 94306df
PLAT-1152 - Add more fine grain API error handling for data studios
georgi-seqera 3954bad
PLAT-1152 - minor cleanup tweaks
georgi-seqera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -7,4 +7,7 @@ build | |
**/build-info.properties | ||
|
||
# Location for unshared files | ||
.user/ | ||
.user/ | ||
|
||
|
||
*.iml |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
33 changes: 33 additions & 0 deletions
33
src/main/java/io/seqera/tower/cli/commands/DataStudiosCmd.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,33 @@ | ||
/* | ||
* 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; | ||
|
||
import io.seqera.tower.cli.commands.datastudios.ListCmd; | ||
import io.seqera.tower.cli.commands.datastudios.ViewCmd; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command( | ||
name = "studios", // alternative "data-studio" | ||
description = "Manage data studios.", | ||
subcommands = { | ||
ViewCmd.class, | ||
ListCmd.class, | ||
} | ||
) | ||
public class DataStudiosCmd extends AbstractRootCmd { | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/io/seqera/tower/cli/commands/datastudios/AbstractStudiosCmd.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,29 @@ | ||
/* | ||
* 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 io.seqera.tower.ApiException; | ||
import io.seqera.tower.cli.commands.AbstractApiCmd; | ||
import io.seqera.tower.model.DataStudioDto; | ||
|
||
public class AbstractStudiosCmd extends AbstractApiCmd { | ||
|
||
protected DataStudioDto fetchDataStudio(DataStudioRefOptions dataStudioRefOptions, Long wspId) throws ApiException { | ||
return api().describeDataStudio(dataStudioRefOptions.dataStudio.sessionId, wspId); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/seqera/tower/cli/commands/datastudios/DataStudioRefOptions.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,31 @@ | ||
/* | ||
* 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 picocli.CommandLine; | ||
|
||
public class DataStudioRefOptions { | ||
|
||
@CommandLine.ArgGroup(multiplicity = "1") | ||
public DataStudioRef dataStudio; | ||
|
||
public static class DataStudioRef { | ||
@CommandLine.Option(names = {"-i", "--id"}, description = "DataStudio session ID.") | ||
public String sessionId; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
src/main/java/io/seqera/tower/cli/commands/datastudios/ListCmd.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,74 @@ | ||
/* | ||
* 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 io.seqera.tower.ApiException; | ||
import io.seqera.tower.cli.commands.global.PaginationOptions; | ||
import io.seqera.tower.cli.commands.global.ShowLabelsOption; | ||
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions; | ||
import io.seqera.tower.cli.commands.pipelines.AbstractPipelinesCmd; | ||
import io.seqera.tower.cli.commands.pipelines.PipelineVisibility; | ||
import io.seqera.tower.cli.exceptions.WorkspaceNotFoundException; | ||
import io.seqera.tower.cli.responses.Response; | ||
import io.seqera.tower.cli.responses.datastudios.DataStudiosList; | ||
import io.seqera.tower.cli.responses.pipelines.PipelinesList; | ||
import io.seqera.tower.cli.utils.PaginationInfo; | ||
import io.seqera.tower.model.DataStudioListResponse; | ||
import io.seqera.tower.model.ListPipelinesResponse; | ||
import io.seqera.tower.model.PipelineQueryAttribute; | ||
import picocli.CommandLine; | ||
import picocli.CommandLine.Command; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
@Command( | ||
name = "list", | ||
description = "List workspace data studios." | ||
) | ||
public class ListCmd extends AbstractStudiosCmd { | ||
|
||
@CommandLine.Mixin | ||
public WorkspaceOptionalOptions workspace; | ||
|
||
@CommandLine.Option(names = {"-f", "--filter"}, description = "Optional filter criteria, allowing free text search on name and templateUrl " + | ||
"and keywords: `userName`, `computeEnvName` and `status`. Example keyword usage: -f status:RUNNING") | ||
public String filter; | ||
|
||
@CommandLine.Mixin | ||
PaginationOptions paginationOptions; | ||
|
||
@Override | ||
protected Response exec() throws ApiException, IOException { | ||
Long wspId = workspaceId(workspace.workspace); | ||
Integer max = PaginationOptions.getMax(paginationOptions); | ||
Integer offset = PaginationOptions.getOffset(paginationOptions, max); | ||
|
||
DataStudioListResponse response = new DataStudioListResponse(); | ||
|
||
try { | ||
response = api().listDataStudios(wspId, filter, max, offset); | ||
} catch (ApiException apiException) { | ||
if (apiException.getCode() == 404){ | ||
throw new WorkspaceNotFoundException(wspId); | ||
} | ||
} | ||
|
||
return new DataStudiosList(workspaceRef(wspId), response.getStudios(), PaginationInfo.from(paginationOptions, response.getTotalSize())); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/io/seqera/tower/cli/commands/datastudios/ViewCmd.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,56 @@ | ||
/* | ||
* 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 io.seqera.tower.ApiException; | ||
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions; | ||
import io.seqera.tower.cli.exceptions.TowerException; | ||
import io.seqera.tower.cli.responses.Response; | ||
import io.seqera.tower.cli.responses.datastudios.DataStudiosView; | ||
import io.seqera.tower.model.DataStudioDto; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command( | ||
name = "view", | ||
description = "View data studio." | ||
) | ||
public class ViewCmd extends AbstractStudiosCmd { | ||
|
||
@CommandLine.Mixin | ||
public WorkspaceOptionalOptions workspace; | ||
|
||
@CommandLine.Mixin | ||
public DataStudioRefOptions dataStudioRefOptions; | ||
|
||
@Override | ||
protected Response exec() throws ApiException { | ||
Long wspId = workspaceId(workspace.workspace); | ||
|
||
try { | ||
DataStudioDto dataStudioDto = fetchDataStudio(dataStudioRefOptions, wspId); | ||
|
||
return new DataStudiosView(dataStudioDto, workspaceRef(wspId)); | ||
} catch (ApiException e) { | ||
if (e.getCode() == 403) { | ||
endre-seqera marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throw new TowerException(String.format("DataStudio '%s' not found at %s workspace", dataStudioRefOptions.dataStudio.sessionId, wspId)); | ||
} | ||
throw e; | ||
} | ||
} | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/io/seqera/tower/cli/responses/datastudios/DataStudiosList.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,88 @@ | ||
/* | ||
* 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.responses.datastudios; | ||
|
||
import java.io.PrintWriter; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.annotation.Nullable; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import io.seqera.tower.cli.responses.Response; | ||
import io.seqera.tower.cli.utils.PaginationInfo; | ||
import io.seqera.tower.cli.utils.TableList; | ||
import io.seqera.tower.model.DataStudioDto; | ||
import io.seqera.tower.model.DataStudioStatusInfo; | ||
import io.seqera.tower.model.StudioUser; | ||
|
||
import static io.seqera.tower.cli.utils.FormatHelper.formatDataStudioStatus; | ||
import static io.seqera.tower.cli.utils.FormatHelper.formatPipelineId; | ||
|
||
public class DataStudiosList extends Response { | ||
|
||
public final String workspaceRef; | ||
public final List<DataStudioDto> studios; | ||
|
||
@JsonIgnore | ||
@Nullable | ||
private final PaginationInfo paginationInfo; | ||
|
||
public DataStudiosList(String workspaceRef, List<DataStudioDto> studios, @Nullable PaginationInfo paginationInfo) { | ||
this.workspaceRef = workspaceRef; | ||
this.studios = studios; | ||
this.paginationInfo = paginationInfo; | ||
} | ||
|
||
@Override | ||
public void toString(PrintWriter out) { | ||
|
||
out.println(ansi(String.format("%n @|bold Data Studios at %s workspace:|@%n", workspaceRef))); | ||
|
||
if (studios.isEmpty()) { | ||
out.println(ansi(" @|yellow No data studios found|@")); | ||
return; | ||
} | ||
|
||
List<String> descriptions = new ArrayList<>(List.of("ID", "Name", "Description", "User", "Status")); | ||
|
||
TableList table = new TableList(out, descriptions.size(), descriptions.toArray(new String[descriptions.size()])).sortBy(0); | ||
table.setPrefix(" "); | ||
|
||
studios.forEach(studio -> { | ||
|
||
DataStudioStatusInfo statusInfo = studio.getStatusInfo(); | ||
StudioUser user = studio.getUser(); | ||
List<String> rows = new ArrayList<>(List.of( | ||
studio.getSessionId() == null ? "" : studio.getSessionId(), | ||
studio.getName() == null ? "" : studio.getName(), | ||
studio.getDescription() == null ? "" : studio.getDescription(), | ||
user == null ? "" : user.getUserName(), | ||
formatDataStudioStatus(statusInfo == null ? null : statusInfo.getStatus()) | ||
)); | ||
|
||
table.addRow(rows.toArray(new String[rows.size()])); | ||
}); | ||
|
||
table.print(); | ||
|
||
PaginationInfo.addFooter(out, paginationInfo); | ||
|
||
out.println(""); | ||
} | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule is to follow the API, as we use studios in API this is correct, no need for data-studios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw. you can remove that comment then if everyone agrees