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 dcc08751b7..ee0326faf4 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 @@ -257,7 +257,10 @@ interface ClouddriverService { Map getSecurityGroups() @GET('/securityGroups/{account}/{type}') - Map getSecurityGroups(@Path("account") String account, @Path("type") String type, @Query("region") String region) + Map getSecurityGroups(@Path("account") String account, @Path("type") String type) + + @GET('/securityGroups/{account}/{type}') + List getSecurityGroupsForRegion(@Path("account") String account, @Path("type") String type, @Query("region") String region) @GET('/securityGroups/{account}/{type}/{region}/{name}') Map getSecurityGroup(@Path("account") String account, @Path("type") String type, @Path("name") String name, diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/FirewallController.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/FirewallController.groovy index 6f9b5bb13c..317b98dd0e 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/FirewallController.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/FirewallController.groovy @@ -48,10 +48,19 @@ class FirewallController { @ApiOperation(value = "Retrieve a list of firewalls for a given account, grouped by region") @RequestMapping(value = "/{account}", method = RequestMethod.GET) Map allByAccount( - @PathVariable String account, - @RequestParam(value = "provider", defaultValue = "aws", required = false) String provider, - @RequestParam(value = "region", required = false) String region, - @RequestHeader(value = "X-RateLimit-App", required = false) String sourceApp) { + @PathVariable String account, + @RequestParam(value = "provider", defaultValue = "aws", required = false) String provider, + @RequestHeader(value = "X-RateLimit-App", required = false) String sourceApp) { + securityGroupService.getForAccountAndProvider(account, provider, sourceApp) + } + + @ApiOperation(value = "Retrieve a list of firewalls for a given account and region") + @RequestMapping(value = "/{account}/{region}", method = RequestMethod.GET) + List allByAccountAndRegion( + @PathVariable String account, + @PathVariable String region, + @RequestParam(value = "provider", defaultValue = "aws", required = false) String provider, + @RequestHeader(value = "X-RateLimit-App", required = false) String sourceApp) { securityGroupService.getForAccountAndProviderAndRegion(account, provider, region, sourceApp) } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SecurityGroupController.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SecurityGroupController.groovy index be4203caaa..9a7802b497 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SecurityGroupController.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SecurityGroupController.groovy @@ -51,9 +51,8 @@ class SecurityGroupController { Map allByAccount( @PathVariable String account, @RequestParam(value = "provider", defaultValue = "aws", required = false) String provider, - @RequestParam(value = "region", required = false) String region, @RequestHeader(value = "X-RateLimit-App", required = false) String sourceApp) { - securityGroupService.getForAccountAndProviderAndRegion(account, provider, region, sourceApp) + securityGroupService.getForAccountAndProvider(account, provider, sourceApp) } @ApiOperation(value = "Retrieve a security group's details") diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SecurityGroupService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SecurityGroupService.groovy index 7a2c2ec14e..77e4604faf 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SecurityGroupService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SecurityGroupService.groovy @@ -72,9 +72,15 @@ class SecurityGroupService { * @param provider provider name (aws, gce, docker) * @param region optional. nullable */ - Map getForAccountAndProviderAndRegion(String account, String provider, String region, String selectorKey) { + Map getForAccountAndProvider(String account, String provider, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getSecurityGroupsForAccountAndProvider-$provider") { - clouddriverServiceSelector.select(selectorKey).getSecurityGroups(account, provider, region) + clouddriverServiceSelector.select(selectorKey).getSecurityGroups(account, provider) + } execute() + } + + List getForAccountAndProviderAndRegion(String account, String provider, String region, String selectorKey) { + HystrixFactory.newListCommand(GROUP, "getSecurityGroupsForAccountAndProvider-$provider") { + clouddriverServiceSelector.select(selectorKey).getSecurityGroupsForRegion(account, provider, region) } execute() }