Class CommandRestController
java.lang.Object
com.netflix.genie.web.apis.rest.v3.controllers.CommandRestController
@RestController
@RequestMapping("/api/v3/commands")
public class CommandRestController
extends Object
REST end-point for supporting commands.
- Since:
- 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionCommandRestController
(DataServices dataServices, EntityModelAssemblers entityModelAssemblers) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addApplicationsForCommand
(String id, List<String> applicationIds) Add applications for the given command.void
addClusterCriterionForCommand
(String id, @Valid Criterion criterion) Add a newCriterion
as the lowest priority criterion for the given command.void
addConfigsForCommand
(String id, Set<String> configs) Add new configuration files to a given command.void
addDependenciesForCommand
(String id, Set<String> dependencies) Add new dependency files for a given command.void
addTagsForCommand
(String id, Set<String> tags) Add new tags to a given command.org.springframework.http.ResponseEntity<Void>
createCommand
(@Valid Command command) Create a Command configuration.void
Delete all applications from database.void
deleteCommand
(String id) Delete a command.List<org.springframework.hateoas.EntityModel<Application>>
Get the applications configured for a given command.Get all theCriterion
currently associated with the command in priority order.getClustersForCommand
(String id, Set<String> statuses) Get all the clusters this command is associated with.org.springframework.hateoas.EntityModel<Command>
getCommand
(String id) Get Command configuration for given id.org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<Command>>
getCommands
(String name, String user, Set<String> statuses, Set<String> tags, org.springframework.data.domain.Pageable page, org.springframework.data.web.PagedResourcesAssembler<Command> assembler) Get Command configuration based on user parameters.Get all the configuration files for a given command.Get all the dependency files for a given command.Get all the tags for a given command.void
insertClusterCriterionForCommand
(String id, @jakarta.validation.constraints.Min(0L) int priority, @Valid Criterion criterion) Insert a new cluster criterion for the given command at the supplied priority.void
patchCommand
(String id, com.github.fge.jsonpatch.JsonPatch patch) Patch a command using JSON Patch.void
Remove the applications from a given command.void
Remove all theCriterion
currently associated with the command.void
Delete the all configuration files from a given command.void
Delete the all dependency files from a given command.void
Delete the all tags from a given command.void
removeApplicationForCommand
(String id, String appId) Remove the application from a given command.void
removeClusterCriterionFromCommand
(String id, @jakarta.validation.constraints.Min(0L) int priority) Remove the criterion with the given priority from the given command.void
removeTagForCommand
(String id, String tag) Remove an tag from a given command.resolveClustersForCommandClusterCriteria
(String id, Boolean addDefaultStatus) void
setApplicationsForCommand
(String id, List<String> applicationIds) Set the applications for the given command.void
setClusterCriteriaForCommand
(String id, @Valid List<Criterion> clusterCriteria) Set all new cluster criteria for the given command.void
updateCommand
(String id, Command updateCommand) Update command configuration.void
updateConfigsForCommand
(String id, Set<String> configs) Update the configuration files for a given command.void
updateDependenciesForCommand
(String id, Set<String> dependencies) Update the dependency files for a given command.void
updateTagsForCommand
(String id, Set<String> tags) Update the tags for a given command.
-
Constructor Details
-
CommandRestController
@Autowired public CommandRestController(DataServices dataServices, EntityModelAssemblers entityModelAssemblers) Constructor.- Parameters:
dataServices
- TheDataServices
encapsulation instance to useentityModelAssemblers
- The encapsulation of all available V3 resource assemblers
-
-
Method Details
-
createCommand
@PostMapping(consumes="application/json") @ResponseStatus(CREATED) public org.springframework.http.ResponseEntity<Void> createCommand(@RequestBody @Valid @Valid Command command) throws IdAlreadyExistsException Create a Command configuration.- Parameters:
command
- The command configuration to create- Returns:
- The command created
- Throws:
IdAlreadyExistsException
- When the command id was already used
-
getCommand
@GetMapping(value="/{id}", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<Command> getCommand(@PathVariable("id") String id) throws NotFoundException Get Command configuration for given id.- Parameters:
id
- unique id for command configuration- Returns:
- The command configuration
- Throws:
NotFoundException
- When noCommand
with the given id exists
-
getCommands
@GetMapping(produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<Command>> getCommands(@RequestParam(value="name",required=false) @Nullable String name, @RequestParam(value="user",required=false) @Nullable String user, @RequestParam(value="status",required=false) @Nullable Set<String> statuses, @RequestParam(value="tag",required=false) @Nullable Set<String> tags, @PageableDefault(size=64,sort="updated",direction=DESC) org.springframework.data.domain.Pageable page, org.springframework.data.web.PagedResourcesAssembler<Command> assembler) throws GenieException Get Command configuration based on user parameters.- Parameters:
name
- Name for command (optional)user
- The user who created the configuration (optional)statuses
- The statuses of the commands to get (optional)tags
- The set of tags you want the command for.page
- The page to getassembler
- The paged resources assembler to use- Returns:
- All the Commands matching the criteria or all if no criteria
- Throws:
GenieException
- For any error
-
updateCommand
@PutMapping(value="/{id}", consumes="application/json") @ResponseStatus(NO_CONTENT) public void updateCommand(@PathVariable("id") String id, @RequestBody Command updateCommand) throws NotFoundException, PreconditionFailedException Update command configuration.- Parameters:
id
- unique id for the configuration to update.updateCommand
- the information to update the command with- Throws:
NotFoundException
- When noCommand
with the given id existsPreconditionFailedException
- When id and the updateCommand id don't match
-
patchCommand
@PatchMapping(value="/{id}", consumes="application/json") @ResponseStatus(NO_CONTENT) public void patchCommand(@PathVariable("id") String id, @RequestBody com.github.fge.jsonpatch.JsonPatch patch) throws NotFoundException, PreconditionFailedException, GenieServerException Patch a command using JSON Patch.- Parameters:
id
- The id of the command to patchpatch
- The JSON Patch instructions- Throws:
NotFoundException
- When noCommand
with the given id existsPreconditionFailedException
- When id and the updateCommand id don't matchGenieServerException
- When the patch can't be applied
-
deleteAllCommands
@DeleteMapping @ResponseStatus(NO_CONTENT) public void deleteAllCommands() throws PreconditionFailedExceptionDelete all applications from database.- Throws:
PreconditionFailedException
- When deleting one of the commands would violated a consistency issue
-
deleteCommand
@DeleteMapping("/{id}") @ResponseStatus(NO_CONTENT) public void deleteCommand(@PathVariable("id") String id) throws NotFoundException Delete a command.- Parameters:
id
- unique id for configuration to delete- Throws:
NotFoundException
- If noCommand
exists with the given id
-
addConfigsForCommand
@PostMapping(value="/{id}/configs", consumes="application/json") @ResponseStatus(NO_CONTENT) public void addConfigsForCommand(@PathVariable("id") String id, @RequestBody Set<String> configs) throws NotFoundException Add new configuration files to a given command.- Parameters:
id
- The id of the command to add the configuration file to. Not null/empty/blank.configs
- The configuration files to add. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
getConfigsForCommand
@GetMapping(value="/{id}/configs", produces="application/json") @ResponseStatus(OK) public Set<String> getConfigsForCommand(@PathVariable("id") String id) throws NotFoundException Get all the configuration files for a given command.- Parameters:
id
- The id of the command to get the configuration files for. Not NULL/empty/blank.- Returns:
- The active set of configuration files.
- Throws:
NotFoundException
- When noCommand
with the given id exists
-
updateConfigsForCommand
@PutMapping(value="/{id}/configs", consumes="application/json") @ResponseStatus(NO_CONTENT) public void updateConfigsForCommand(@PathVariable("id") String id, @RequestBody Set<String> configs) throws NotFoundException Update the configuration files for a given command.- Parameters:
id
- The id of the command to update the configuration files for. Not null/empty/blank.configs
- The configuration files to replace existing configuration files with. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
removeAllConfigsForCommand
@DeleteMapping("/{id}/configs") @ResponseStatus(NO_CONTENT) public void removeAllConfigsForCommand(@PathVariable("id") String id) throws NotFoundException Delete the all configuration files from a given command.- Parameters:
id
- The id of the command to delete the configuration files from. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
addDependenciesForCommand
@PostMapping(value="/{id}/dependencies", consumes="application/json") @ResponseStatus(NO_CONTENT) public void addDependenciesForCommand(@PathVariable("id") String id, @RequestBody Set<String> dependencies) throws NotFoundException Add new dependency files for a given command.- Parameters:
id
- The id of the command to add the dependency file to. Not null/empty/blank.dependencies
- The dependency files to add. Not null.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
getDependenciesForCommand
@GetMapping(value="/{id}/dependencies", produces="application/json") @ResponseStatus(OK) public Set<String> getDependenciesForCommand(@PathVariable("id") String id) throws NotFoundException Get all the dependency files for a given command.- Parameters:
id
- The id of the command to get the dependency files for. Not NULL/empty/blank.- Returns:
- The set of dependency files.
- Throws:
NotFoundException
- When noCommand
with the given id exists
-
updateDependenciesForCommand
@PutMapping(value="/{id}/dependencies", consumes="application/json") @ResponseStatus(NO_CONTENT) public void updateDependenciesForCommand(@PathVariable("id") String id, @RequestBody Set<String> dependencies) throws NotFoundException Update the dependency files for a given command.- Parameters:
id
- The id of the command to update the dependency files for. Not null/empty/blank.dependencies
- The dependency files to replace existing dependency files with. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
removeAllDependenciesForCommand
@DeleteMapping("/{id}/dependencies") @ResponseStatus(NO_CONTENT) public void removeAllDependenciesForCommand(@PathVariable("id") String id) throws NotFoundException Delete the all dependency files from a given command.- Parameters:
id
- The id of the command to delete the dependency files from. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
addTagsForCommand
@PostMapping(value="/{id}/tags", consumes="application/json") @ResponseStatus(NO_CONTENT) public void addTagsForCommand(@PathVariable("id") String id, @RequestBody Set<String> tags) throws NotFoundException Add new tags to a given command.- Parameters:
id
- The id of the command to add the tags to. Not null/empty/blank.tags
- The tags to add. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
getTagsForCommand
@GetMapping(value="/{id}/tags", produces="application/json") @ResponseStatus(OK) public Set<String> getTagsForCommand(@PathVariable("id") String id) throws NotFoundException Get all the tags for a given command.- Parameters:
id
- The id of the command to get the tags for. Not NULL/empty/blank.- Returns:
- The active set of tags.
- Throws:
NotFoundException
- When noCommand
with the given id exists
-
updateTagsForCommand
@PutMapping(value="/{id}/tags", consumes="application/json") @ResponseStatus(NO_CONTENT) public void updateTagsForCommand(@PathVariable("id") String id, @RequestBody Set<String> tags) throws NotFoundException Update the tags for a given command.- Parameters:
id
- The id of the command to update the tags for. Not null/empty/blank.tags
- The tags to replace existing tags with. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
removeAllTagsForCommand
@DeleteMapping("/{id}/tags") @ResponseStatus(NO_CONTENT) public void removeAllTagsForCommand(@PathVariable("id") String id) throws NotFoundException Delete the all tags from a given command.- Parameters:
id
- The id of the command to delete the tags from. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
removeTagForCommand
@DeleteMapping("/{id}/tags/{tag}") @ResponseStatus(NO_CONTENT) public void removeTagForCommand(@PathVariable("id") String id, @PathVariable("tag") String tag) throws NotFoundException Remove an tag from a given command.- Parameters:
id
- The id of the command to delete the tag from. Not null/empty/blank.tag
- The tag to remove. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists
-
addApplicationsForCommand
@PostMapping(value="/{id}/applications", consumes="application/json") @ResponseStatus(NO_CONTENT) public void addApplicationsForCommand(@PathVariable("id") String id, @RequestBody List<String> applicationIds) throws NotFoundException, PreconditionFailedException Add applications for the given command.- Parameters:
id
- The id of the command to add the applications to. Not null/empty/blank.applicationIds
- The ids of the applications to add. Not null. No duplicates- Throws:
NotFoundException
- When noCommand
with the given id existsPreconditionFailedException
- If there are any duplicate applications in the list or when combined with existing applications associated with the command
-
getApplicationsForCommand
@GetMapping(value="/{id}/applications", produces="application/hal+json") @ResponseStatus(OK) public List<org.springframework.hateoas.EntityModel<Application>> getApplicationsForCommand(@PathVariable("id") String id) throws NotFoundException Get the applications configured for a given command.- Parameters:
id
- The id of the command to get the application files for. Not NULL/empty/blank.- Returns:
- The active applications for the command.
- Throws:
NotFoundException
- When noCommand
with the given id exists
-
setApplicationsForCommand
@PutMapping(value="/{id}/applications", consumes="application/json") @ResponseStatus(NO_CONTENT) public void setApplicationsForCommand(@PathVariable("id") String id, @RequestBody List<String> applicationIds) throws NotFoundException, PreconditionFailedException Set the applications for the given command.- Parameters:
id
- The id of the command to add the applications to. Not null/empty/blank.applicationIds
- The ids of the applications to set in order. Not null.- Throws:
NotFoundException
- When noCommand
with the given id existsPreconditionFailedException
- If there are any duplicate applications in the list
-
removeAllApplicationsForCommand
@DeleteMapping("/{id}/applications") @ResponseStatus(NO_CONTENT) public void removeAllApplicationsForCommand(@PathVariable("id") String id) throws NotFoundException, PreconditionFailedException Remove the applications from a given command.- Parameters:
id
- The id of the command to delete the applications from. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id existsPreconditionFailedException
- If constraints block removal
-
removeApplicationForCommand
@DeleteMapping("/{id}/applications/{appId}") @ResponseStatus(NO_CONTENT) public void removeApplicationForCommand(@PathVariable("id") String id, @PathVariable("appId") String appId) throws NotFoundException Remove the application from a given command.- Parameters:
id
- The id of the command to delete the application from. Not null/empty/blank.appId
- The id of the application to remove from the command. Not null/empty/blank.- Throws:
NotFoundException
- When noCommand
with the given id exists or no application exists
-
getClustersForCommand
@GetMapping(value="/{id}/clusters", produces="application/hal+json") @ResponseStatus(OK) public Set<org.springframework.hateoas.EntityModel<Cluster>> getClustersForCommand(@PathVariable("id") String id, @RequestParam(value="status",required=false) @Nullable Set<String> statuses) throws NotFoundException, GeniePreconditionException Get all the clusters this command is associated with.- Parameters:
id
- The id of the command to get the clusters for. Not NULL/empty/blank.statuses
- The statuses of the clusters to get- Returns:
- The list of clusters
- Throws:
NotFoundException
- When noCommand
with the given id existsGeniePreconditionException
- If a supplied status is not valid
-
getClusterCriteriaForCommand
@GetMapping(value="/{id}/clusterCriteria", produces="application/json") @ResponseStatus(OK) public List<Criterion> getClusterCriteriaForCommand(@PathVariable("id") String id) throws NotFoundException Get all theCriterion
currently associated with the command in priority order.- Parameters:
id
- The id of the command to get the criteria for- Returns:
- The criteria
- Throws:
NotFoundException
- When noCommand
with the given id exists
-
removeAllClusterCriteriaFromCommand
@DeleteMapping("/{id}/clusterCriteria") @ResponseStatus(OK) public void removeAllClusterCriteriaFromCommand(@PathVariable("id") String id) throws NotFoundException Remove all theCriterion
currently associated with the command.- Parameters:
id
- The id of the command to remove the criteria for- Throws:
NotFoundException
- When noCommand
with the given id exists
-
addClusterCriterionForCommand
@PostMapping(value="/{id}/clusterCriteria", consumes="application/json") @ResponseStatus(OK) public void addClusterCriterionForCommand(@PathVariable("id") String id, @RequestBody @Valid @Valid Criterion criterion) throws NotFoundException Add a newCriterion
as the lowest priority criterion for the given command.- Parameters:
id
- The id of the command to add the new criterion tocriterion
- TheCriterion
to add- Throws:
NotFoundException
- When noCommand
with the given id exists
-
setClusterCriteriaForCommand
@PutMapping(value="/{id}/clusterCriteria", consumes="application/json") @ResponseStatus(OK) public void setClusterCriteriaForCommand(@PathVariable("id") String id, @RequestBody @Valid @Valid List<Criterion> clusterCriteria) throws NotFoundException Set all new cluster criteria for the given command.- Parameters:
id
- The id of the command to add the new criteria toclusterCriteria
- The list ofCriterion
in priority order to set for the given command- Throws:
NotFoundException
- When noCommand
with the given id exists
-
insertClusterCriterionForCommand
@PutMapping(value="/{id}/clusterCriteria/{priority}", consumes="application/json") @ResponseStatus(OK) public void insertClusterCriterionForCommand(@PathVariable("id") String id, @PathVariable("priority") @Min(0L) @jakarta.validation.constraints.Min(0L) int priority, @RequestBody @Valid @Valid Criterion criterion) throws NotFoundException Insert a new cluster criterion for the given command at the supplied priority.- Parameters:
id
- The id of the command to add the new criterion forpriority
- The priority (min 0) to insert the criterion at in the listcriterion
- TheCriterion
to add- Throws:
NotFoundException
- When noCommand
with the given id exists
-
removeClusterCriterionFromCommand
@DeleteMapping("/{id}/clusterCriteria/{priority}") @ResponseStatus(OK) public void removeClusterCriterionFromCommand(@PathVariable("id") String id, @PathVariable("priority") @Min(0L) @jakarta.validation.constraints.Min(0L) int priority) throws NotFoundException Remove the criterion with the given priority from the given command.- Parameters:
id
- The id of the command to remove the criterion frompriority
- The priority (min 0, max number of existing criteria minus one) of the criterion to remove- Throws:
NotFoundException
- When noCommand
with the given id exists
-
resolveClustersForCommandClusterCriteria
@GetMapping(value="/{id}/resolvedClusters", produces="application/json") @ResponseStatus(OK) public List<ResolvedResources<Cluster>> resolveClustersForCommandClusterCriteria(@PathVariable("id") String id, @RequestParam(value="addDefaultStatus",defaultValue="true") Boolean addDefaultStatus) throws NotFoundException For a givenCommand
retrieve theCriterion
and attempt to resolve all theCluster
's the criteria would currently match within the database.- Parameters:
id
- The id of the command to get the criterion fromaddDefaultStatus
- Whether the system should add the defaultClusterStatus
to theCriterion
if no status currently is within theCriterion
. The default value is true which will currently add the statusClusterStatus.UP
- Returns:
- A list
ResolvedResources
of each criterion to theCluster
's it resolved to - Throws:
NotFoundException
- When noCommand
with the given id exists
-