feat(pagination): support the 'page' qs param in orca's tasks endpoint
MODIFY
gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ApplicationController.groovy
gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ApplicationController.groovy
@@ -104,9 +104,10 @@ class ApplicationController {
@ApiOperation(value = "Retrieve a list of an application's tasks", response = List.class)
@RequestMapping(value = "/{application}/tasks", method = RequestMethod.GET)
List getTasks(@PathVariable("application") String application,
+ @RequestParam(value = "page", required = false) Integer page,
@RequestParam(value = "limit", required = false) Integer limit,
@RequestParam(value = "statuses", required = false) String statuses) {
- executionHistoryService.getTasks(application, limit, statuses)
+ executionHistoryService.getTasks(application, page, limit, statuses)
}
@ApiOperation(value = "Retrieve a list of an application's pipeline executions", response = List.class)

MODIFY
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ExecutionHistoryService.groovy
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ExecutionHistoryService.groovy
@@ -33,12 +33,12 @@ class ExecutionHistoryService {
@Autowired
OrcaServiceSelector orcaServiceSelector
- List getTasks(String app, Integer limit, String statuses) {
+ List getTasks(String app, Integer page, Integer limit, String statuses) {
Preconditions.checkNotNull(app)
RequestContext requestContext = RequestContext.get()
def command = HystrixFactory.newListCommand("taskExecutionHistory", "getTasksForApp") {
- orcaServiceSelector.withContext(requestContext).getTasks(app, limit, statuses)
+ orcaServiceSelector.withContext(requestContext).getTasks(app, page, limit, statuses)
}
return command.execute()
}

MODIFY
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/OrcaService.groovy
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/OrcaService.groovy
@@ -35,7 +35,7 @@ interface OrcaService {
@Headers("Accept: application/json")
@GET("/applications/{application}/tasks")
- List getTasks(@Path("application") String app, @Query("limit") Integer limit, @Query("statuses") String statuses)
+ List getTasks(@Path("application") String app, @Query("page") Integer page, @Query("limit") Integer limit, @Query("statuses") String statuses)
@Headers("Accept: application/json")
@GET("/v2/applications/{application}/pipelines")

MODIFY
gate-web/src/test/groovy/com/netflix/spinnaker/gate/Api.groovy
gate-web/src/test/groovy/com/netflix/spinnaker/gate/Api.groovy
@@ -27,7 +27,7 @@ interface Api {
Map getApplication(@Path("name") String name)
@GET("/applications/{name}/tasks")
- List getTasks(@Path("name") String name, @Query("limit") Integer limit, @Query("statuses") String statuses)
+ List getTasks(@Path("name") String name, @Query("page") Integer page, @Query("limit") Integer limit, @Query("statuses") String statuses)
@POST("/applications/{name}/tasks")
Map createTask(@Path("name") String name, @Body Map body)

MODIFY
gate-web/src/test/groovy/com/netflix/spinnaker/gate/FunctionalSpec.groovy
gate-web/src/test/groovy/com/netflix/spinnaker/gate/FunctionalSpec.groovy
@@ -191,11 +191,11 @@ class FunctionalSpec extends Specification {
void "should call ApplicationService for an application's tasks"() {
when:
- api.getTasks(name, null, "RUNNING,TERMINAL")
+ api.getTasks(name, null, null, "RUNNING,TERMINAL")
then:
1 * orcaServiceSelector.withContext(_) >> { orcaService }
- 1 * orcaService.getTasks(name, null, "RUNNING,TERMINAL") >> []
+ 1 * orcaService.getTasks(name, null, null, "RUNNING,TERMINAL") >> []
where:
name = "foo"
@@ -215,19 +215,19 @@ class FunctionalSpec extends Specification {
void "should throw ServerErrorException(500) on a random thrown exception"() {
when:
- def tasks = executionHistoryService.getTasks("app", 5, null)
+ def tasks = executionHistoryService.getTasks("app", null, 5, null)
then:
1 * orcaServiceSelector.withContext(_) >> { orcaService }
- 1 * orcaService.getTasks("app", 5, null) >> { return ["1"] }
+ 1 * orcaService.getTasks("app", null, 5, null) >> { return ["1"] }
tasks == ["1"]
when:
- executionHistoryService.getTasks("app", 10, "RUNNING")
+ executionHistoryService.getTasks("app", null, 10, "RUNNING")
then:
1 * orcaServiceSelector.withContext(_) >> { orcaService }
- 1 * orcaService.getTasks("app", 10, "RUNNING") >> { throw new IllegalStateException() }
+ 1 * orcaService.getTasks("app", null, 10, "RUNNING") >> { throw new IllegalStateException() }
thrown(ServerErrorException)
when:

feat(pagination): support the 'page' qs param in orca's tasks endpoint