Skip to content

Commit

Permalink
Merge pull request #167 from anotherchrisberry/project-clusters
Browse files Browse the repository at this point in the history
add project clusters endpoint
  • Loading branch information
anotherchrisberry committed Dec 17, 2015
2 parents 18b63f5 + cd39e85 commit 90851f0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ interface ClouddriverService {
@Path("region") String region,
@Path("imageId") String imageId)

@Headers("Accept: application/json")
@GET("/projects/{project}/clusters")
List<Map> getProjectClusters(@Path("project") String project)

@Headers("Accept: application/json")
@GET("/reports/reservation")
List<Map> getReservationReports()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ class ProjectController {
result
}

@RequestMapping(value = "/{id}/clusters", method = RequestMethod.GET)
List<Map> getClusters(@PathVariable("id") String projectId) {
def result = projectService.getClusters(projectId)
if (!result) {
log.warn("Project not found (projectId: ${projectId}")
throw new ProjectNotFoundException("Project not found (projectId: ${projectId})")
}
result
}

@RequestMapping(value = "/{id:.+}/pipelines", method = RequestMethod.GET)
List<Map> allPipelinesForProject(@PathVariable("id") String projectId,
@RequestParam(value = "limit", defaultValue = "5") int limit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.netflix.spinnaker.gate.services

import com.netflix.spinnaker.gate.services.commands.HystrixFactory
import com.netflix.spinnaker.gate.services.internal.ClouddriverService
import com.netflix.spinnaker.gate.services.internal.Front50Service
import com.netflix.spinnaker.gate.services.internal.OrcaService
import groovy.transform.CompileStatic
Expand All @@ -37,6 +38,9 @@ class ProjectService {
@Autowired
OrcaService orcaService

@Autowired
ClouddriverService clouddriverService

List<Map> getAll() {
HystrixFactory.newListCommand(GROUP, "getAll") {
return front50Service.getAllProjects().embedded.projects ?: []
Expand All @@ -54,4 +58,10 @@ class ProjectService {
return orcaService.getPipelinesForProject(projectId, limit, statuses)
} execute()
}

List getClusters(String projectId) {
HystrixFactory.newListCommand(GROUP, "getClusters") {
return clouddriverService.getProjectClusters(projectId)
} execute()
}
}

0 comments on commit 90851f0

Please sign in to comment.