Skip to content

Commit

Permalink
fix(firewalls): enable retrieval of all firewalls in an account+region (
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry committed May 15, 2019
1 parent 271bfab commit c25fd51
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit c25fd51

Please sign in to comment.