diff --git a/gate-core/src/main/groovy/com/netflix/spinnaker/gate/services/internal/ClouddriverService.groovy b/gate-core/src/main/groovy/com/netflix/spinnaker/gate/services/internal/ClouddriverService.groovy index ee0326faf4..9de344f5cc 100644 --- a/gate-core/src/main/groovy/com/netflix/spinnaker/gate/services/internal/ClouddriverService.groovy +++ b/gate-core/src/main/groovy/com/netflix/spinnaker/gate/services/internal/ClouddriverService.groovy @@ -383,4 +383,12 @@ interface ClouddriverService { @Query(value = "region") String region, @Query(value = "serviceInstanceName") String serviceInstanceName) + @GET(value = "/functions") + List getFunctions(@Query(value = "functionName") String functionName, + @Query(value = "region") String region, + @Query(value = "account") String account) + + @GET("/applications/{name}/functions") + List getApplicationFunctions(@Path("name") String appName) + } diff --git a/gate-web/config/gate.yml b/gate-web/config/gate.yml index e39c805685..e9408ff98b 100644 --- a/gate-web/config/gate.yml +++ b/gate-web/config/gate.yml @@ -91,6 +91,7 @@ swagger: - .*version.* - .*pubsub.* - .*projects.* + - .*functions.* integrations: gremlin: diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/aws/AmazonInfrastructureController.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/aws/AmazonInfrastructureController.groovy index 33289ef478..4f264f856b 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/aws/AmazonInfrastructureController.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/aws/AmazonInfrastructureController.groovy @@ -19,8 +19,10 @@ package com.netflix.spinnaker.gate.controllers.aws import com.netflix.spinnaker.gate.services.aws.InfrastructureService import io.swagger.annotations.ApiOperation 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 @RestController @@ -53,4 +55,18 @@ class AmazonInfrastructureController { List vpcs() { infrastructureService.vpcs } + + @ApiOperation(value = "Get functions", response = List.class) + @RequestMapping(value = "/functions", method = RequestMethod.GET) + List functions(@RequestParam(value = "functionName", required = false) String functionName, + @RequestParam(value = "region", required = false) String region, + @RequestParam(value = "account", required = false) String account) { + infrastructureService.getFunctions(functionName, region, account) + } + + @ApiOperation(value = "Get application functions", response = List.class) + @RequestMapping(value = "/applications/{application}/functions", method = RequestMethod.GET) + List applicationFunctions(@PathVariable String application) { + infrastructureService.getApplicationFunctions(application) + } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy index 84c239fd99..f7dabc1d4f 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy @@ -63,4 +63,16 @@ class InfrastructureService { clouddriverServiceSelector.select(selectorKey).getNetworks('aws') } execute() } + + List getFunctions(String selectorKey = null, String functionName, String region, String account) { + command("functions") { + clouddriverServiceSelector.select(selectorKey).getFunctions(functionName,region, account) + } execute() + } + + List getApplicationFunctions(String selectorKey = null, String application) { + command("functions") { + clouddriverServiceSelector.select(selectorKey).getApplicationFunctions(application) + } execute() + } }