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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all CommitsdeleteUCSBDate
(Long id) Delete a CommitGet a single commit by idpostCommit
(String message, String url, String authorLogin, ZonedDateTime commitTime) Create a new commitupdateCommit
(Long id, @Valid Commit incoming) Update a single commitMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
CommitsController
public CommitsController()
-
-
Method Details
-
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 messageurl
- the commit urlauthorLogin
- the github login id of the user that authored the commitcommitTime
- 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 updateincoming
- 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
-