-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Vidarr retry failed provision-out command
Allows the new `/api/retry-provision-out` endpoint to be accessed via action command.
- Loading branch information
Showing
9 changed files
with
186 additions
and
64 deletions.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
* Add Vidarr _retry failed provision-out_ command |
98 changes: 98 additions & 0 deletions
98
plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/AvailableCommands.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,98 @@ | ||
package ca.on.oicr.gsi.shesmu.vidarr; | ||
|
||
import ca.on.oicr.gsi.shesmu.plugin.FrontEndIcon; | ||
import ca.on.oicr.gsi.shesmu.plugin.action.ActionCommand; | ||
import ca.on.oicr.gsi.shesmu.plugin.action.ActionCommand.Preference; | ||
import java.util.Optional; | ||
import java.util.stream.Stream; | ||
|
||
public enum AvailableCommands { | ||
RESET_ONLY(false) { | ||
@Override | ||
public Stream<ActionCommand<?>> commands() { | ||
return Stream.of(RESET); | ||
} | ||
}, | ||
CAN_RETRY(true) { | ||
@Override | ||
public Stream<ActionCommand<?>> commands() { | ||
return Stream.of(DELETE, RETRY_PROVISION_OUT, RESET); | ||
} | ||
}, | ||
CAN_REATTEMPT(true) { | ||
@Override | ||
public Stream<ActionCommand<?>> commands() { | ||
return Stream.of(DELETE, REATTEMPT, RESET); | ||
} | ||
}; | ||
static final ActionCommand<SubmitAction> DELETE = | ||
new ActionCommand<>( | ||
SubmitAction.class, | ||
"VIDARR-DELETE", | ||
FrontEndIcon.PLUG, | ||
"Delete and Purge", | ||
Preference.ALLOW_BULK, | ||
Preference.PROMPT, | ||
Preference.ANNOY_USER) { | ||
@Override | ||
protected Response execute(SubmitAction action, Optional<String> user) { | ||
return action.owner.get().url().map(action.state::delete).orElse(false) | ||
? Response.PURGE | ||
: Response.IGNORED; | ||
} | ||
}; | ||
static final ActionCommand<SubmitAction> REATTEMPT = | ||
new ActionCommand<>( | ||
SubmitAction.class, | ||
"VIDARR-REATTEMPT", | ||
FrontEndIcon.ARROW_REPEAT, | ||
"Reattempt Failed Workflow", | ||
Preference.PROMPT, | ||
Preference.ALLOW_BULK) { | ||
@Override | ||
protected Response execute(SubmitAction action, Optional<String> user) { | ||
final var result = action.state.reattempt(); | ||
result.ifPresent(s -> action.state = s); | ||
return result.isPresent() ? Response.RESET : Response.IGNORED; | ||
} | ||
}; | ||
static final ActionCommand<SubmitAction> RESET = | ||
new ActionCommand<>( | ||
SubmitAction.class, | ||
"VIDARR-RESET", | ||
FrontEndIcon.PLUG, | ||
"Search Vidarr Again", | ||
Preference.ALLOW_BULK) { | ||
@Override | ||
protected Response execute(SubmitAction action, Optional<String> user) { | ||
action.state = new RunStateAttemptSubmit(); | ||
return Response.RESET; | ||
} | ||
}; | ||
static final ActionCommand<SubmitAction> RETRY_PROVISION_OUT = | ||
new ActionCommand<>( | ||
SubmitAction.class, | ||
"VIDARR-RETRY-PROVISION-OUT", | ||
FrontEndIcon.ARROW_RIGHT_SQUARE_FILL, | ||
"Retry Provision Out", | ||
Preference.ALLOW_BULK, | ||
Preference.PROMPT) { | ||
@Override | ||
protected Response execute(SubmitAction action, Optional<String> user) { | ||
return action.owner.get().url().map(action.state::retry).orElse(false) | ||
? Response.ACCEPTED | ||
: Response.IGNORED; | ||
} | ||
}; | ||
private final boolean canRetry; | ||
|
||
AvailableCommands(boolean canRetry) { | ||
this.canRetry = canRetry; | ||
} | ||
|
||
public boolean canRetry() { | ||
return canRetry; | ||
} | ||
|
||
public abstract Stream<ActionCommand<?>> commands(); | ||
} |
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
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
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
Oops, something went wrong.