Class CommitsController

java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.CommitsController

@RequestMapping("/api/commits") @RestController public class CommitsController extends ApiController
This is a REST controller for Commits
  • Constructor Details

    • CommitsController

      public CommitsController()
  • Method Details

    • allCommits

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<Commit> allCommits()
      List all Commits
      Returns:
      an iterable of Commits
    • postCommit

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public Commit postCommit(@RequestParam String message, @RequestParam String url, @RequestParam String authorLogin, @RequestParam("commitTime") @DateTimeFormat(iso=DATE_TIME) ZonedDateTime commitTime) throws com.fasterxml.jackson.core.JsonProcessingException
      Create a new commit
      Parameters:
      message - the commit message
      url - the commit url
      authorLogin - the github login id of the user that authored the commit
      commitTime - the timestamp on the commit, with time zone information
      Returns:
      the saved commit
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public Commit getById(@RequestParam Long id)
      Get a single commit by id
      Parameters:
      id - the id of the commit
      Returns:
      a Commit
    • updateCommit

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public Commit updateCommit(@RequestParam Long id, @RequestBody @Valid @Valid Commit incoming)
      Update a single commit
      Parameters:
      id - id of the commit to update
      incoming - the new commit
      Returns:
      the updated commit object
    • deleteUCSBDate

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteUCSBDate(@RequestParam Long id)
      Delete a Commit
      Parameters:
      id - the id of the commit to delete
      Returns:
      a message indicating the commit was deleted