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 Summary
ConstructorDescriptionClusterRestController
(DataServices dataServices, EntityModelAssemblers entityModelAssemblers) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCommandsForCluster
(String id, List<String> commandIds) Add new commandIds to the given cluster.void
addConfigsForCluster
(String id, Set<String> configs) Add new configuration files to a given cluster.void
addDependenciesForCluster
(String id, Set<String> dependencies) Add new dependency files for a given cluster.void
addTagsForCluster
(String id, Set<String> tags) Add new tags to a given cluster.org.springframework.http.ResponseEntity<Void>
createCluster
(@Valid Cluster cluster) Create cluster configuration.void
Delete all clusters from database.void
deleteCluster
(String id) Delete a cluster configuration.org.springframework.hateoas.EntityModel<Cluster>
getCluster
(String id) Get cluster configuration from unique id.org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<Cluster>>
getClusters
(String name, Set<String> statuses, Set<String> tags, Long minUpdateTime, Long maxUpdateTime, org.springframework.data.domain.Pageable page, org.springframework.data.web.PagedResourcesAssembler<Cluster> assembler) Get cluster config based on user params.getCommandsForCluster
(String id, Set<String> statuses) Get all the commands configured for a given cluster.Get all the configuration files for a given cluster.Get all the dependency files for a given cluster.Get all the tags for a given cluster.void
patchCluster
(String id, com.github.fge.jsonpatch.JsonPatch patch) Patch a cluster using JSON Patch.void
Remove the all commandIds from a given cluster.void
Delete the all configuration files from a given cluster.void
Delete the all dependency files from a given cluster.void
Delete the all tags from a given cluster.void
removeCommandForCluster
(String id, String commandId) Remove a command from a given cluster.void
removeTagForCluster
(String id, String tag) Remove an tag from a given cluster.void
setCommandsForCluster
(String id, List<String> commandIds) Set the commandIds for a given cluster.void
updateCluster
(String id, Cluster updateCluster) Update a cluster configuration.void
updateConfigsForCluster
(String id, Set<String> configs) Update the configuration files for a given cluster.void
updateDependenciesForCluster
(String id, Set<String> dependencies) Update the dependency files for a given cluster.void
updateTagsForCluster
(String id, Set<String> tags) Update the tags for a given cluster.
-
Constructor Details
-
ClusterRestController
@Autowired public ClusterRestController(DataServices dataServices, EntityModelAssemblers entityModelAssemblers) Constructor.- Parameters:
dataServices
- TheDataServices
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.ClusterStatustags
- tags for the clusterminUpdateTime
- min time when cluster configuration was updatedmaxUpdateTime
- max time when cluster configuration was updatedpage
- The page to getassembler
- 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 updateupdateCluster
- contains the cluster information to update- Throws:
NotFoundException
- If no cluster with id existsPreconditionFailedException
- 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 patchpatch
- The JSON Patch instructions- Throws:
NotFoundException
- If no cluster with id existsPreconditionFailedException
- If the ids don't matchGenieServerException
- 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 PreconditionFailedExceptionDelete 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.
-