Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import io.seqera.tower.ApiException;
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions;
import io.seqera.tower.cli.exceptions.ComputeEnvNotFoundException;
import io.seqera.tower.cli.responses.Response;
import io.seqera.tower.cli.responses.computeenvs.ComputeEnvDeleted;
import io.seqera.tower.model.ComputeEnvResponseDto;
Expand Down Expand Up @@ -50,15 +49,7 @@ protected Response exec() throws ApiException {
id = computeEnv.getId();
}

try {
computeEnvsApi().deleteComputeEnv(id, wspId);
return new ComputeEnvDeleted(id, workspaceRef(wspId));
} catch (ApiException e) {
if (e.getCode() == 403) {
// Customize the forbidden message
throw new ComputeEnvNotFoundException(id, workspaceRef(wspId));
}
throw e;
}
computeEnvsApi().deleteComputeEnv(id, wspId);
return new ComputeEnvDeleted(id, workspaceRef(wspId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import io.seqera.tower.ApiException;
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions;
import io.seqera.tower.cli.exceptions.ComputeEnvNotFoundException;
import io.seqera.tower.cli.exceptions.InvalidResponseException;
import io.seqera.tower.cli.responses.Response;
import io.seqera.tower.cli.responses.computeenvs.ComputeEnvUpdated;
Expand Down Expand Up @@ -70,20 +69,7 @@ protected Response exec() throws ApiException, IOException {

}

private ComputeEnvResponseDto describeCE(ComputeEnvRefOptions computeEnvRefOptions, Long wspId) throws ComputeEnvNotFoundException, ApiException {
try {
return fetchComputeEnv(computeEnvRefOptions, wspId);

} catch (ApiException e) {
if (e.getCode() == 403) {
String ref = computeEnvRefOptions.computeEnv.computeEnvId != null
? computeEnvRefOptions.computeEnv.computeEnvId
: computeEnvRefOptions.computeEnv.computeEnvName;
// Customize the forbidden message
throw new ComputeEnvNotFoundException(ref, workspaceRef(wspId));
}

throw e;
}
private ComputeEnvResponseDto describeCE(ComputeEnvRefOptions computeEnvRefOptions, Long wspId) throws ApiException {
return fetchComputeEnv(computeEnvRefOptions, wspId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import io.seqera.tower.ApiException;
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions;
import io.seqera.tower.cli.exceptions.ComputeEnvNotFoundException;
import io.seqera.tower.cli.responses.Response;
import io.seqera.tower.cli.responses.computeenvs.ComputeEnvView;
import io.seqera.tower.model.ComputeEnvResponseDto;
Expand All @@ -42,19 +41,8 @@ public class ViewCmd extends AbstractComputeEnvCmd {
protected Response exec() throws ApiException {
Long wspId = workspaceId(workspace.workspace);

try {
ComputeEnvResponseDto computeEnv = fetchComputeEnv(computeEnvRefOptions, wspId);

return new ComputeEnvView(computeEnv.getId(), workspaceRef(wspId), computeEnv, baseWorkspaceUrl(wspId));
} catch (ApiException e) {
if (e.getCode() == 403) {
String ref = computeEnvRefOptions.computeEnv.computeEnvId != null ? computeEnvRefOptions.computeEnv.computeEnvId : computeEnvRefOptions.computeEnv.computeEnvName;

// Customize the forbidden message
throw new ComputeEnvNotFoundException(ref, workspaceRef(wspId));
}
throw e;
}
ComputeEnvResponseDto computeEnv = fetchComputeEnv(computeEnvRefOptions, wspId);
return new ComputeEnvView(computeEnv.getId(), workspaceRef(wspId), computeEnv, baseWorkspaceUrl(wspId));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import io.seqera.tower.ApiException;
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions;
import io.seqera.tower.cli.exceptions.CredentialsNotFoundException;
import io.seqera.tower.cli.responses.CredentialsDeleted;
import io.seqera.tower.cli.responses.Response;
import io.seqera.tower.model.Credentials;
Expand Down Expand Up @@ -50,15 +49,7 @@ protected Response exec() throws ApiException {
id = credentials.getId();
}

try {
deleteCredentialsById(id, wspId);
return new CredentialsDeleted(id, workspaceRef(wspId));
} catch (ApiException e) {
if (e.getCode() == 403) {
// Customize the forbidden message
throw new CredentialsNotFoundException(id, workspaceRef(wspId));
}
throw e;
}
deleteCredentialsById(id, wspId);
return new CredentialsDeleted(id, workspaceRef(wspId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.seqera.tower.cli.commands.credentials.CredentialsRefOptions;
import io.seqera.tower.cli.commands.credentials.providers.CredentialsProvider;
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions;
import io.seqera.tower.cli.exceptions.CredentialsNotFoundException;
import io.seqera.tower.cli.responses.CredentialsUpdated;
import io.seqera.tower.cli.responses.Response;
import io.seqera.tower.model.Credentials;
Expand All @@ -48,20 +47,8 @@ public AbstractUpdateCmd() {
protected Response exec() throws ApiException, IOException {
Long wspId = workspaceId(workspace.workspace);

// Check that exists
try {
// DescribeCredentialsResponse response = api().describeCredentials(credentials, wspId);
Credentials credentials = fetchCredentials(credentialsRefOptions, wspId);
return update(credentials, wspId);
} catch (ApiException e) {
if (e.getCode() == 403) {
String ref = credentialsRefOptions.credentialsRef.credentialsId != null ? credentialsRefOptions.credentialsRef.credentialsId : credentialsRefOptions.credentialsRef.credentialsName;

// Customize the forbidden message
throw new CredentialsNotFoundException(ref, workspaceRef(wspId));
}
throw e;
}
Credentials credentials = fetchCredentials(credentialsRefOptions, wspId);
return update(credentials, wspId);
}

protected Response update(Credentials creds, Long wspId) throws ApiException, IOException {
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/io/seqera/tower/cli/commands/runs/CancelCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import io.seqera.tower.ApiException;
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions;
import io.seqera.tower.cli.exceptions.RunNotFoundException;
import io.seqera.tower.cli.responses.Response;
import io.seqera.tower.cli.responses.runs.RunCanceled;
import picocli.CommandLine;
Expand All @@ -42,15 +41,7 @@ public class CancelCmd extends AbstractRunsCmd {
protected Response exec() throws ApiException, IOException {
Long wspId = workspaceId(workspace.workspace);

try {
workflowsApi().cancelWorkflow(id, wspId, null, null);

return new RunCanceled(id, workspaceRef(wspId));
} catch (ApiException e) {
if (e.getCode() == 403) {
throw new RunNotFoundException(id, workspaceRef(wspId));
}
throw e;
}
workflowsApi().cancelWorkflow(id, wspId, null, null);
return new RunCanceled(id, workspaceRef(wspId));
}
}
13 changes: 2 additions & 11 deletions src/main/java/io/seqera/tower/cli/commands/runs/DeleteCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import io.seqera.tower.ApiException;
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions;
import io.seqera.tower.cli.exceptions.RunNotFoundException;
import io.seqera.tower.cli.responses.Response;
import io.seqera.tower.cli.responses.runs.RunDeleted;
import picocli.CommandLine;
Expand All @@ -45,15 +44,7 @@ public class DeleteCmd extends AbstractRunsCmd {
protected Response exec() throws ApiException, IOException {
Long wspId = workspaceId(workspace.workspace);

try {
workflowsApi().deleteWorkflow(id, wspId, force);

return new RunDeleted(id, workspaceRef(wspId));
} catch (ApiException e) {
if (e.getCode() == 403) {
throw new RunNotFoundException(id, workspaceRef(wspId));
}
throw e;
}
workflowsApi().deleteWorkflow(id, wspId, force);
return new RunDeleted(id, workspaceRef(wspId));
}
}
Loading