Class ClusterRestController

java.lang.Object
com.netflix.genie.web.apis.rest.v3.controllers.ClusterRestController

@RestController @RequestMapping("/api/v3/clusters") public class ClusterRestController extends Object
REST end-point for supporting clusters.
Since:
3.0.0
  • Constructor Details

    • ClusterRestController

      @Autowired public ClusterRestController(DataServices dataServices, EntityModelAssemblers entityModelAssemblers)
      Constructor.
      Parameters:
      dataServices - The DataServices encapsulation instance to use.
      entityModelAssemblers - The encapsulation of all available V3 resource assemblers
  • Method Details

    • createCluster

      @PostMapping(consumes="application/json") @ResponseStatus(CREATED) public org.springframework.http.ResponseEntity<Void> createCluster(@RequestBody @Valid @Valid Cluster cluster) throws IdAlreadyExistsException
      Create cluster configuration.
      Parameters:
      cluster - contains the cluster information to create
      Returns:
      The created cluster
      Throws:
      IdAlreadyExistsException - If there is a conflict for the id
    • getCluster

      @GetMapping(value="/{id}", produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.EntityModel<Cluster> getCluster(@PathVariable("id") String id) throws NotFoundException
      Get cluster configuration from unique id.
      Parameters:
      id - id for the cluster
      Returns:
      the cluster
      Throws:
      NotFoundException - If no cluster with id exists
    • getClusters

      @GetMapping(produces="application/hal+json") @ResponseStatus(OK) public org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<Cluster>> getClusters(@RequestParam(value="name",required=false) @Nullable String name, @RequestParam(value="status",required=false) @Nullable Set<String> statuses, @RequestParam(value="tag",required=false) @Nullable Set<String> tags, @RequestParam(value="minUpdateTime",required=false) @Nullable Long minUpdateTime, @RequestParam(value="maxUpdateTime",required=false) @Nullable Long maxUpdateTime, @PageableDefault(size=64,sort="updated",direction=DESC) org.springframework.data.domain.Pageable page, org.springframework.data.web.PagedResourcesAssembler<Cluster> assembler) throws GenieException
      Get cluster config based on user params. If empty strings are passed for they are treated as nulls (not false).
      Parameters:
      name - cluster name (can be a pattern)
      statuses - valid types - Types.ClusterStatus
      tags - tags for the cluster
      minUpdateTime - min time when cluster configuration was updated
      maxUpdateTime - max time when cluster configuration was updated
      page - The page to get
      assembler - The paged resources assembler to use
      Returns:
      the Clusters found matching the criteria
      Throws:
      GenieException - For any error
    • updateCluster

      @PutMapping(value="/{id}", consumes="application/json") @ResponseStatus(NO_CONTENT) public void updateCluster(@PathVariable("id") String id, @RequestBody Cluster updateCluster) throws NotFoundException, PreconditionFailedException
      Update a cluster configuration.
      Parameters:
      id - unique if for cluster to update
      updateCluster - contains the cluster information to update
      Throws:
      NotFoundException - If no cluster with id exists
      PreconditionFailedException - If the ids don't match
    • patchCluster

      @PatchMapping(value="/{id}", consumes="application/json") @ResponseStatus(NO_CONTENT) public void patchCluster(@PathVariable("id") String id, @RequestBody com.github.fge.jsonpatch.JsonPatch patch) throws NotFoundException, PreconditionFailedException, GenieServerException
      Patch a cluster using JSON Patch.
      Parameters:
      id - The id of the cluster to patch
      patch - The JSON Patch instructions
      Throws:
      NotFoundException - If no cluster with id exists
      PreconditionFailedException - If the ids don't match
      GenieServerException - If the patch can't be applied
    • deleteCluster

      @DeleteMapping("/{id}") @ResponseStatus(NO_CONTENT) public void deleteCluster(@PathVariable("id") String id) throws PreconditionFailedException
      Delete a cluster configuration.
      Parameters:
      id - unique id for cluster to delete
      Throws:
      PreconditionFailedException - If the cluster can't be deleted due to constraints
    • deleteAllClusters

      @DeleteMapping @ResponseStatus(NO_CONTENT) public void deleteAllClusters() throws PreconditionFailedException
      Delete all clusters from database.
      Throws:
      PreconditionFailedException - If any cluster can't be deleted due to a constraint in the system
    • addConfigsForCluster

      @PostMapping(value="/{id}/configs", consumes="application/json") @ResponseStatus(NO_CONTENT) public void addConfigsForCluster(@PathVariable("id") String id, @RequestBody Set<String> configs) throws NotFoundException
      Add new configuration files to a given cluster.
      Parameters:
      id - The id of the cluster to add the configuration file to. Not null/empty/blank.
      configs - The configuration files to add. Not null/empty/blank.
      Throws:
      NotFoundException - If no cluster with id exists
    • getConfigsForCluster

      @GetMapping(value="/{id}/configs", produces="application/json") @ResponseStatus(OK) public Set<String> getConfigsForCluster(@PathVariable("id") String id) throws NotFoundException
      Get all the configuration files for a given cluster.
      Parameters:
      id - The id of the cluster to get the configuration files for. Not NULL/empty/blank.
      Returns:
      The active set of configuration files.
      Throws:
      NotFoundException - If no cluster with id exists
    • updateConfigsForCluster

      @PutMapping(value="/{id}/configs", consumes="application/json") @ResponseStatus(NO_CONTENT) public void updateConfigsForCluster(@PathVariable("id") String id, @RequestBody Set<String> configs) throws NotFoundException
      Update the configuration files for a given cluster.
      Parameters:
      id - The id of the cluster 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 - If no cluster with id exists
    • removeAllConfigsForCluster

      @DeleteMapping("/{id}/configs") @ResponseStatus(NO_CONTENT) public void removeAllConfigsForCluster(@PathVariable("id") String id) throws NotFoundException
      Delete the all configuration files from a given cluster.
      Parameters:
      id - The id of the cluster to delete the configuration files from. Not null/empty/blank.
      Throws:
      NotFoundException - If no cluster with id exists
    • addDependenciesForCluster

      @PostMapping(value="/{id}/dependencies", consumes="application/json") @ResponseStatus(NO_CONTENT) public void addDependenciesForCluster(@PathVariable("id") String id, @RequestBody Set<String> dependencies) throws NotFoundException
      Add new dependency files for a given cluster.
      Parameters:
      id - The id of the cluster to add the dependency file to. Not null/empty/blank.
      dependencies - The dependency files to add. Not null.
      Throws:
      NotFoundException - If no cluster with id exists
    • getDependenciesForCluster

      @GetMapping(value="/{id}/dependencies", produces="application/json") @ResponseStatus(OK) public Set<String> getDependenciesForCluster(@PathVariable("id") String id) throws NotFoundException
      Get all the dependency files for a given cluster.
      Parameters:
      id - The id of the cluster to get the dependency files for. Not NULL/empty/blank
      Returns:
      The set of dependency files
      Throws:
      NotFoundException - If no cluster with id exists
    • updateDependenciesForCluster

      @PutMapping(value="/{id}/dependencies", consumes="application/json") @ResponseStatus(NO_CONTENT) public void updateDependenciesForCluster(@PathVariable("id") String id, @RequestBody Set<String> dependencies) throws NotFoundException
      Update the dependency files for a given cluster.
      Parameters:
      id - The id of the cluster 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 - If no cluster with id exists
    • removeAllDependenciesForCluster

      @DeleteMapping("/{id}/dependencies") @ResponseStatus(NO_CONTENT) public void removeAllDependenciesForCluster(@PathVariable("id") String id) throws NotFoundException
      Delete the all dependency files from a given cluster.
      Parameters:
      id - The id of the cluster to delete the dependency files from. Not null/empty/blank.
      Throws:
      NotFoundException - If no cluster with id exists
    • addTagsForCluster

      @PostMapping(value="/{id}/tags", consumes="application/json") @ResponseStatus(NO_CONTENT) public void addTagsForCluster(@PathVariable("id") String id, @RequestBody Set<String> tags) throws NotFoundException
      Add new tags to a given cluster.
      Parameters:
      id - The id of the cluster to add the tags to. Not null/empty/blank.
      tags - The tags to add. Not null/empty/blank.
      Throws:
      NotFoundException - If no cluster with id exists
    • getTagsForCluster

      @GetMapping(value="/{id}/tags", produces="application/json") @ResponseStatus(OK) public Set<String> getTagsForCluster(@PathVariable("id") String id) throws NotFoundException
      Get all the tags for a given cluster.
      Parameters:
      id - The id of the cluster to get the tags for. Not NULL/empty/blank.
      Returns:
      The active set of tags.
      Throws:
      NotFoundException - If no cluster with id exists
    • updateTagsForCluster

      @PutMapping(value="/{id}/tags", consumes="application/json") @ResponseStatus(NO_CONTENT) public void updateTagsForCluster(@PathVariable("id") String id, @RequestBody Set<String> tags) throws NotFoundException
      Update the tags for a given cluster.
      Parameters:
      id - The id of the cluster to update the tags for. Not null/empty/blank.
      tags - The tags to replace existing configuration files with. Not null/empty/blank.
      Throws:
      NotFoundException - If no cluster with id exists
    • removeAllTagsForCluster

      @DeleteMapping("/{id}/tags") @ResponseStatus(NO_CONTENT) public void removeAllTagsForCluster(@PathVariable("id") String id) throws NotFoundException
      Delete the all tags from a given cluster.
      Parameters:
      id - The id of the cluster to delete the tags from. Not null/empty/blank.
      Throws:
      NotFoundException - If no cluster with id exists
    • removeTagForCluster

      @DeleteMapping("/{id}/tags/{tag}") @ResponseStatus(NO_CONTENT) public void removeTagForCluster(@PathVariable("id") String id, @PathVariable("tag") String tag) throws NotFoundException
      Remove an tag from a given cluster.
      Parameters:
      id - The id of the cluster to delete the tag from. Not null/empty/blank.
      tag - The tag to remove. Not null/empty/blank.
      Throws:
      NotFoundException - If no cluster with id exists
    • addCommandsForCluster

      @PostMapping(value="/{id}/commands", consumes="application/json") @ResponseStatus(NO_CONTENT) public void addCommandsForCluster(@PathVariable("id") String id, @RequestBody List<String> commandIds)
      Add new commandIds to the given cluster. This is a no-op as of 4.0.0.
      Parameters:
      id - The id of the cluster to add the commandIds to. Not null/empty/blank.
      commandIds - The ids of the commandIds to add. Not null.
    • getCommandsForCluster

      @GetMapping(value="/{id}/commands", produces="application/hal+json") @ResponseStatus(OK) public List<org.springframework.hateoas.EntityModel<Command>> getCommandsForCluster(@PathVariable("id") String id, @RequestParam(value="status",required=false) @Nullable Set<String> statuses) throws NotFoundException
      Get all the commands configured for a given cluster. This is a no-op as of 4.0.0.
      Parameters:
      id - The id of the cluster to get the command files for. Not NULL/empty/blank.
      statuses - The various statuses to return commandIds for.
      Returns:
      The active set of commandIds for the cluster.
      Throws:
      NotFoundException - If the cluster doesn't exist
    • setCommandsForCluster

      @PutMapping(value="/{id}/commands", consumes="application/json") @ResponseStatus(NO_CONTENT) public void setCommandsForCluster(@PathVariable("id") String id, @RequestBody List<String> commandIds)
      Set the commandIds for a given cluster. This is a no-op as of 4.0.0.
      Parameters:
      id - The id of the cluster to update the configuration files for. Not null/empty/blank.
      commandIds - The ids of the commands to replace existing commands with. Not null/empty/blank.
    • removeAllCommandsForCluster

      @DeleteMapping("/{id}/commands") @ResponseStatus(NO_CONTENT) public void removeAllCommandsForCluster(@PathVariable("id") String id)
      Remove the all commandIds from a given cluster. This is a no-op as of 4.0.0.
      Parameters:
      id - The id of the cluster to delete the commandIds from. Not null/empty/blank.
    • removeCommandForCluster

      @DeleteMapping("/{id}/commands/{commandId}") @ResponseStatus(NO_CONTENT) public void removeCommandForCluster(@PathVariable("id") String id, @PathVariable("commandId") String commandId)
      Remove a command from a given cluster. This is a no-op as of 4.0.0.
      Parameters:
      id - The id of the cluster to delete the command from. Not null/empty/blank.
      commandId - The id of the command to remove. Not null/empty/blank.