List of usage examples for org.springframework.hateoas MediaTypes HAL_JSON_VALUE
String HAL_JSON_VALUE
To view the source code for org.springframework.hateoas MediaTypes HAL_JSON_VALUE.
Click Source Link
From source file:com.netflix.genie.web.controllers.RootRestController.java
/** * Get a simple HAL+JSON object which represents the various links available in Genie REST API as an entry point. * * @return the root resource containing various links to the real APIs *//* w ww . j a va 2 s.co m*/ @GetMapping(produces = MediaTypes.HAL_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public RootResource getRoot() { final JsonNodeFactory factory = JsonNodeFactory.instance; final JsonNode node = factory.objectNode().set("description", factory.textNode("Genie V3 API")); return this.rootResourceAssembler.toResource(node); }
From source file:com.netflix.genie.web.controllers.ClusterRestController.java
/** * Get cluster configuration from unique id. * * @param id id for the cluster// w w w . ja v a 2 s . c o m * @return the cluster * @throws GenieException For any error */ @GetMapping(value = "/{id}", produces = MediaTypes.HAL_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public ClusterResource getCluster(@PathVariable("id") final String id) throws GenieException { log.debug("Called with id: {}", id); return this.clusterResourceAssembler.toResource(this.clusterService.getCluster(id)); }
From source file:com.netflix.genie.web.controllers.CommandRestController.java
/** * Get Command configuration for given id. * * @param id unique id for command configuration * @return The command configuration/*from w w w . j a va 2s.c o m*/ * @throws GenieException For any error */ @GetMapping(value = "/{id}", produces = MediaTypes.HAL_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public CommandResource getCommand(@PathVariable("id") final String id) throws GenieException { log.debug("Called to get command with id {}", id); return this.commandResourceAssembler.toResource(this.commandService.getCommand(id)); }
From source file:com.netflix.genie.web.controllers.ApplicationRestController.java
/** * Get Applications based on user parameters. * * @param name name for configuration (optional) * @param user The user who created the application (optional) * @param statuses The statuses of the applications (optional) * @param tags The set of tags you want the application for. (optional) * @param type The type of applications to get (optional) * @param page The page to get/*from w ww . jav a2 s . c om*/ * @param assembler The paged resources assembler to use * @return All applications matching the criteria * @throws GenieException For any error */ @GetMapping(produces = MediaTypes.HAL_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public PagedResources<ApplicationResource> getApplications( @RequestParam(value = "name", required = false) final String name, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "status", required = false) final Set<String> statuses, @RequestParam(value = "tag", required = false) final Set<String> tags, @RequestParam(value = "type", required = false) final String type, @PageableDefault(sort = { "updated" }, direction = Sort.Direction.DESC) final Pageable page, final PagedResourcesAssembler<Application> assembler) throws GenieException { log.debug("Called [name | user | status | tags | type | pageable]"); log.debug("{} | {} | {} | {} | | {} | {}", name, user, statuses, tags, type, page); Set<ApplicationStatus> enumStatuses = null; if (statuses != null) { enumStatuses = EnumSet.noneOf(ApplicationStatus.class); for (final String status : statuses) { enumStatuses.add(ApplicationStatus.parse(status)); } } final Link self = ControllerLinkBuilder .linkTo(ControllerLinkBuilder.methodOn(ApplicationRestController.class).getApplications(name, user, statuses, tags, type, page, assembler)) .withSelfRel(); return assembler.toResource( this.applicationService.getApplications(name, user, enumStatuses, tags, type, page), this.applicationResourceAssembler, self); }
From source file:com.netflix.genie.web.controllers.ClusterRestController.java
/** * Get cluster config based on user params. If empty strings are passed for * they are treated as nulls (not false). * * @param name cluster name (can be a pattern) * @param statuses valid types - Types.ClusterStatus * @param tags tags for the cluster * @param minUpdateTime min time when cluster configuration was updated * @param maxUpdateTime max time when cluster configuration was updated * @param page The page to get/*from w w w. j a v a 2 s .c o m*/ * @param assembler The paged resources assembler to use * @return the Clusters found matching the criteria * @throws GenieException For any error */ @GetMapping(produces = MediaTypes.HAL_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public PagedResources<ClusterResource> getClusters( @RequestParam(value = "name", required = false) final String name, @RequestParam(value = "status", required = false) final Set<String> statuses, @RequestParam(value = "tag", required = false) final Set<String> tags, @RequestParam(value = "minUpdateTime", required = false) final Long minUpdateTime, @RequestParam(value = "maxUpdateTime", required = false) final Long maxUpdateTime, @PageableDefault(size = 64, sort = { "updated" }, direction = Sort.Direction.DESC) final Pageable page, final PagedResourcesAssembler<Cluster> assembler) throws GenieException { log.debug("Called [name | statuses | tags | minUpdateTime | maxUpdateTime | page]"); log.debug("{} | {} | {} | {} | {} | {}", name, statuses, tags, minUpdateTime, maxUpdateTime, page); //Create this conversion internal in case someone uses lower case by accident? Set<ClusterStatus> enumStatuses = null; if (statuses != null) { enumStatuses = EnumSet.noneOf(ClusterStatus.class); for (final String status : statuses) { enumStatuses.add(ClusterStatus.parse(status)); } } // Build the self link which will be used for the next, previous, etc links final Link self = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(ClusterRestController.class) .getClusters(name, statuses, tags, minUpdateTime, maxUpdateTime, page, assembler)).withSelfRel(); return assembler.toResource( this.clusterService.getClusters(name, enumStatuses, tags, minUpdateTime == null ? null : new Date(minUpdateTime), maxUpdateTime == null ? null : new Date(maxUpdateTime), page), this.clusterResourceAssembler, self); }
From source file:com.netflix.genie.web.controllers.CommandRestController.java
/** * Get Command configuration based on user parameters. * * @param name Name for command (optional) * @param user The user who created the configuration (optional) * @param statuses The statuses of the commands to get (optional) * @param tags The set of tags you want the command for. * @param page The page to get//from ww w . ja va2s . c o m * @param assembler The paged resources assembler to use * @return All the Commands matching the criteria or all if no criteria * @throws GenieException For any error */ @GetMapping(produces = MediaTypes.HAL_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public PagedResources<CommandResource> getCommands( @RequestParam(value = "name", required = false) final String name, @RequestParam(value = "user", required = false) final String user, @RequestParam(value = "status", required = false) final Set<String> statuses, @RequestParam(value = "tag", required = false) final Set<String> tags, @PageableDefault(size = 64, sort = { "updated" }, direction = Sort.Direction.DESC) final Pageable page, final PagedResourcesAssembler<Command> assembler) throws GenieException { log.debug("Called [name | user | status | tags | page]"); log.debug("{} | {} | {} | {} | {}", name, user, statuses, tags, page); Set<CommandStatus> enumStatuses = null; if (statuses != null) { enumStatuses = EnumSet.noneOf(CommandStatus.class); for (final String status : statuses) { enumStatuses.add(CommandStatus.parse(status)); } } // Build the self link which will be used for the next, previous, etc links final Link self = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(CommandRestController.class) .getCommands(name, user, statuses, tags, page, assembler)).withSelfRel(); return assembler.toResource(this.commandService.getCommands(name, user, enumStatuses, tags, page), this.commandResourceAssembler, self); }
From source file:com.netflix.genie.web.controllers.ApplicationRestController.java
/** * Get Application for given id.//from w w w . j a v a2s .c o m * * @param id unique id for application configuration * @return The application configuration * @throws GenieException For any error */ @GetMapping(value = "/{id}", produces = MediaTypes.HAL_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public ApplicationResource getApplication(@PathVariable("id") final String id) throws GenieException { log.debug("Called to get Application for id {}", id); return this.applicationResourceAssembler.toResource(this.applicationService.getApplication(id)); }
From source file:com.netflix.genie.web.controllers.ApplicationRestController.java
/** * Get all the commands this application is associated with. * * @param id The id of the application to get the commands for. Not * NULL/empty/blank./*from ww w. jav a 2 s. co m*/ * @param statuses The various statuses of the commands to retrieve * @return The set of commands. * @throws GenieException For any error */ @GetMapping(value = "/{id}/commands", produces = MediaTypes.HAL_JSON_VALUE) public Set<CommandResource> getCommandsForApplication(@PathVariable("id") final String id, @RequestParam(value = "status", required = false) final Set<String> statuses) throws GenieException { log.debug("Called with id {}", id); Set<CommandStatus> enumStatuses = null; if (statuses != null) { enumStatuses = EnumSet.noneOf(CommandStatus.class); for (final String status : statuses) { enumStatuses.add(CommandStatus.parse(status)); } } return this.applicationService.getCommandsForApplication(id, enumStatuses).stream() .map(this.commandResourceAssembler::toResource).collect(Collectors.toSet()); }