Skip to content

Commit

Permalink
Merge pull request #193 from lwander/run-job
Browse files Browse the repository at this point in the history
core: Handle job requests
  • Loading branch information
lwander committed Apr 25, 2016
2 parents cac1d08 + 3a7e2c1 commit acb3e58
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ interface ClouddriverService {
@GET("/applications/{name}/serverGroups")
List getServerGroups(@Path("name") String name, @Query("expand") String expand)

@Headers("Accept: application/json")
@GET("/applications/{name}/jobs")
List getJobs(@Path("name") String name, @Query("expand") String expand)

@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
@@ -0,0 +1,37 @@
/*
* Copyright 2016 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


package com.netflix.spinnaker.gate.controllers

import com.netflix.spinnaker.gate.services.JobService
import groovy.transform.CompileStatic
import groovy.transform.InheritConstructors
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.*

@CompileStatic
@RestController
class JobController {
@Autowired
JobService jobService

@RequestMapping(value = "/applications/{applicationName}/jobs", method = RequestMethod.GET)
List getJobs(@PathVariable String applicationName, @RequestParam(required = false, value = 'expand', defaultValue = 'false') String expand) {
jobService.getForApplication(applicationName, expand)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2016 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.gate.services

import com.netflix.spinnaker.gate.config.InsightConfiguration
import com.netflix.spinnaker.gate.services.commands.HystrixFactory
import com.netflix.spinnaker.gate.services.internal.ClouddriverService
import groovy.transform.CompileStatic
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@CompileStatic
@Component
class JobService {
private static final String GROUP = "jobs"

@Autowired
ClouddriverService clouddriverService

@Autowired
InsightConfiguration insightConfiguration

List getForApplication(String applicationName, String expand) {
String commandKey = Boolean.valueOf(expand) ? "getExpandedJobsForApplication" : "getJobsForApplication"
HystrixFactory.newListCommand(GROUP, commandKey) {
clouddriverService.getJobs(applicationName, expand)
} execute()
}
}

0 comments on commit acb3e58

Please sign in to comment.