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 Details

    • CommandRestController

      @Autowired public CommandRestController(DataServices dataServices, EntityModelAssemblers entityModelAssemblers)
      Constructor.
      Parameters:
      dataServices - The DataServices encapsulation instance to use
      entityModelAssemblers - 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 no Command 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 get
      assembler - 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 no Command with the given id exists
      PreconditionFailedException - 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 patch
      patch - The JSON Patch instructions
      Throws:
      NotFoundException - When no Command with the given id exists
      PreconditionFailedException - When id and the updateCommand id don't match
      GenieServerException - When the patch can't be applied
    • deleteAllCommands

      @DeleteMapping @ResponseStatus(NO_CONTENT) public void deleteAllCommands() throws PreconditionFailedException
      Delete 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command 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 no Command with the given id exists
      PreconditionFailedException - 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 no Command 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 no Command with the given id exists
      PreconditionFailedException - 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 no Command with the given id exists
      PreconditionFailedException - 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 no Command 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 no Command with the given id exists
      GeniePreconditionException - 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 the Criterion 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 no Command with the given id exists
    • removeAllClusterCriteriaFromCommand

      @DeleteMapping("/{id}/clusterCriteria") @ResponseStatus(OK) public void removeAllClusterCriteriaFromCommand(@PathVariable("id") String id) throws NotFoundException
      Remove all the Criterion currently associated with the command.
      Parameters:
      id - The id of the command to remove the criteria for
      Throws:
      NotFoundException - When no Command 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 new Criterion as the lowest priority criterion for the given command.
      Parameters:
      id - The id of the command to add the new criterion to
      criterion - The Criterion to add
      Throws:
      NotFoundException - When no Command 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 to
      clusterCriteria - The list of Criterion in priority order to set for the given command
      Throws:
      NotFoundException - When no Command 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 for
      priority - The priority (min 0) to insert the criterion at in the list
      criterion - The Criterion to add
      Throws:
      NotFoundException - When no Command 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 from
      priority - The priority (min 0, max number of existing criteria minus one) of the criterion to remove
      Throws:
      NotFoundException - When no Command 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 given Command retrieve the Criterion and attempt to resolve all the Cluster's the criteria would currently match within the database.
      Parameters:
      id - The id of the command to get the criterion from
      addDefaultStatus - Whether the system should add the default ClusterStatus to the Criterion if no status currently is within the Criterion. The default value is true which will currently add the status ClusterStatus.UP
      Returns:
      A list ResolvedResources of each criterion to the Cluster's it resolved to
      Throws:
      NotFoundException - When no Command with the given id exists