Skip to content

Commit

Permalink
core: Job Details endpoint (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander authored and Travis Tomsu committed May 4, 2016
1 parent 23970b8 commit cbdd298
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ interface ClouddriverService {
@GET("/applications/{name}/jobs")
List getJobs(@Path("name") String name, @Query("expand") String expand)

@Headers("Accept: application/json")
@GET("/applications/{name}/jobs/{account}/{region}/{jobName}")
Map getJobDetails(@Path("name") String name,
@Path("account") String account,
@Path("region") String region,
@Path("jobName") String jobName)

@Headers("Accept: application/json")
@GET("/applications/{name}/serverGroups/{account}/{region}/{serverGroupName}")
Map getServerGroupDetails(@Path("name") String appName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.springframework.stereotype.Component
@ConfigurationProperties("insights")
class InsightConfiguration {
List<Link> serverGroup = []
List<Link> job = []
List<Link> instance = []

static class Link {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ class JobController {
List getJobs(@PathVariable String applicationName, @RequestParam(required = false, value = 'expand', defaultValue = 'false') String expand) {
jobService.getForApplication(applicationName, expand)
}

@RequestMapping(value = "/applications/{applicationName}/jobs/{account}/{region}/{name}", method = RequestMethod.GET)
Map getJob(@PathVariable String applicationName, @PathVariable String account,
@PathVariable String region,
@PathVariable String name,
@RequestParam(required = false, value = 'expand', defaultValue = 'false') String expand) {
jobService.getForApplicationAndAccountAndRegion(applicationName, account, region, name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.netflix.spinnaker.gate.services.internal.ClouddriverService
import groovy.transform.CompileStatic
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import retrofit.RetrofitError

@CompileStatic
@Component
Expand All @@ -40,5 +41,25 @@ class JobService {
clouddriverService.getJobs(applicationName, expand)
} execute()
}

Map getForApplicationAndAccountAndRegion(String applicationName, String account, String region, String name) {
HystrixFactory.newMapCommand(GROUP, "getJobsForApplicationAccountAndRegion", {
try {
def context = getContext(applicationName, account, region, name)
return clouddriverService.getJobDetails(applicationName, account, region, name) + [
"insightActions": insightConfiguration.job.collect { it.applyContext(context) }
]
} catch (RetrofitError e) {
if (e.response?.status == 404) {
return [:]
}
throw e
}
}) execute()
}

static Map<String, String> getContext(String application, String account, String region, String jobName) {
return ["application": application, "account": account, "region": region, "jobName": jobName]
}
}

0 comments on commit cbdd298

Please sign in to comment.