Skip to content

Commit

Permalink
Merge pull request #220 from ajordens/application-pipeline-strategy-h…
Browse files Browse the repository at this point in the history
…istory

Application pipeline strategy history
  • Loading branch information
ajordens committed May 15, 2016
2 parents bd6d60f + 1dbdc03 commit 75d42af
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,29 @@ class ApplicationController {
Environment environment

@RequestMapping(method = RequestMethod.GET)
List<Map> all() {
applicationService.all
List<Map> getAllApplications() {
applicationService.getAllApplications()
}

@RequestMapping(value = "/{application:.+}", method = RequestMethod.GET)
Map show(@PathVariable("application") String application) {
def result = applicationService.get(application)
Map getApplication(@PathVariable("application") String application) {
def result = applicationService.getApplication(application)
if (!result) {
log.warn("Application ${application} not found")
throw new ApplicationNotFoundException("Application ${application} not found")
} else if (!result.name) {
// applicationService.get() doesn't set the name unless clusters are found. Deck requires the name.
// applicationService.getApplication() doesn't set the name unless clusters are found. Deck requires the name.
result.name = application
}
result
}

@RequestMapping(value = "/{application}/history", method = RequestMethod.GET)
List<Map> getApplicationHistory(@PathVariable("application") String application,
@RequestParam(value = "limit", defaultValue = "20") int limit) {
return applicationService.getApplicationHistory(application, limit)
}

@RequestMapping(value = "/{application}/tasks", method = RequestMethod.GET)
List getTasks(@PathVariable("application") String application,
@RequestParam(value = "limit", required = false) Integer limit,
Expand All @@ -86,7 +92,7 @@ class ApplicationController {
}

/**
* @deprecated There is no reason to provide an app name, use PipelineController instead for pipeline operations.
* @deprecated There is no reason to provide an app name, use PipelineController instead for pipeline operations.
*/
@Deprecated
@RequestMapping(value = "/{application}/pipelines/{id}/cancel", method = RequestMethod.PUT)
Expand All @@ -95,33 +101,33 @@ class ApplicationController {
}

@RequestMapping(value = "/{application}/pipelineConfigs", method = RequestMethod.GET)
List getPipelineConfigs(@PathVariable("application") String application) {
applicationService.getPipelineConfigs(application)
List getPipelineConfigsForApplication(@PathVariable("application") String application) {
applicationService.getPipelineConfigsForApplication(application)
}

@RequestMapping(value = "/{application}/pipelineConfigs/{pipelineName:.+}", method = RequestMethod.GET)
Map getPipelineConfig(
@PathVariable("application") String application, @PathVariable("pipelineName") String pipelineName) {
applicationService.getPipelineConfigs(application).find {
@PathVariable("application") String application, @PathVariable("pipelineName") String pipelineName) {
applicationService.getPipelineConfigsForApplication(application).find {
it.name == pipelineName
}
}

@RequestMapping(value = "/{application}/strategyConfigs", method = RequestMethod.GET)
List getStrategyConfigs(@PathVariable("application") String application) {
applicationService.getStrategyConfigs(application)
List getStrategyConfigsForApplication(@PathVariable("application") String application) {
applicationService.getStrategyConfigsForApplication(application)
}

@RequestMapping(value = "/{application}/strategyConfigs/{strategyName:.+}", method = RequestMethod.GET)
Map getStrategyConfig(
@PathVariable("application") String application, @PathVariable("strategyName") String strategyName) {
applicationService.getStrategyConfigs(application).find {
@RequestMapping(value = "/{application}/strategyConfigs/{strategyName}", method = RequestMethod.GET)
Map getStrategyConfig(@PathVariable("application") String application,
@PathVariable("strategyName") String strategyName) {
applicationService.getStrategyConfigsForApplication(application).find {
it.name == strategyName
}
}

/**
* @deprecated Use PipelineController instead for pipeline operations.
* @deprecated Use PipelineController instead for pipeline operations.
*/
@Deprecated
@RequestMapping(value = "/{application}/pipelineConfigs/{pipelineName:.+}", method = RequestMethod.POST)
Expand All @@ -133,7 +139,7 @@ class ApplicationController {
}

/**
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
*/
@Deprecated
@RequestMapping(value = "/{application}/tasks/{id}", method = RequestMethod.GET)
Expand All @@ -142,7 +148,7 @@ class ApplicationController {
}

/**
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
*/
@Deprecated
@RequestMapping(value = "/{application}/tasks/{id}/cancel", method = RequestMethod.PUT)
Expand All @@ -151,7 +157,7 @@ class ApplicationController {
}

/**
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
*/
@Deprecated
@RequestMapping(value = "/{application}/tasks/{id}/details/{taskDetailsId}", method = RequestMethod.GET)
Expand All @@ -160,7 +166,7 @@ class ApplicationController {
}

/**
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
*/
@Deprecated
@RequestMapping(value = "/{application}/tasks", method = RequestMethod.POST)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2016 Netflix, 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.commands.HystrixFactory
import com.netflix.spinnaker.gate.services.internal.Front50Service
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@Slf4j
@CompileStatic
@RestController
@RequestMapping("/pipelineConfigs")
class PipelineConfigController {
private static final String HYSTRIX_GROUP = "pipelineConfigs";

@Autowired
Front50Service front50Service

@RequestMapping(method = RequestMethod.GET)
Collection<Map> getAllPipelineConfigs() {
return HystrixFactory.newListCommand(HYSTRIX_GROUP, "getAllPipelineConfigs") {
front50Service.getAllPipelineConfigs()
}.execute()
}

@RequestMapping(value = "/{pipelineConfigId}/history", method = RequestMethod.GET)
Collection<Map> getPipelineConfigHistory(@PathVariable("pipelineConfigId") String pipelineConfigId,
@RequestParam(value = "limit", defaultValue = "20") int limit) {
return HystrixFactory.newListCommand(HYSTRIX_GROUP, "getPipelineConfigHistory") {
front50Service.getPipelineConfigHistory(pipelineConfigId, limit)
}.execute()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2016 Netflix, 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.commands.HystrixFactory
import com.netflix.spinnaker.gate.services.internal.Front50Service
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@Slf4j
@CompileStatic
@RestController
@RequestMapping("/strategyConfigs")
class StrategyConfigController {
private static final String HYSTRIX_GROUP = "strategyConfigs";

@Autowired
Front50Service front50Service

@RequestMapping(method = RequestMethod.GET)
Collection<Map> getAllStrategyConfigs() {
return HystrixFactory.newListCommand(HYSTRIX_GROUP, "getAllStrategyConfigs") {
front50Service.getAllStrategyConfigs()
}.execute()
}

@RequestMapping(value = "/{strategyConfigId}/history", method = RequestMethod.GET)
Collection<Map> getPipelineConfigHistory(@PathVariable("strategyConfigId") String strategyConfigId,
@RequestParam(value = "limit", defaultValue = "20") int limit) {
return HystrixFactory.newListCommand(HYSTRIX_GROUP, "getStrategyConfigHistory") {
front50Service.getStrategyConfigHistory(strategyConfigId, limit)
}.execute()
}
}
Loading

0 comments on commit 75d42af

Please sign in to comment.